/* * Initialize module */ BOOL WINAPI MwInitializeDialogs(HINSTANCE hInstance) { #ifdef WNDCLASSEX WNDCLASSEX wcl; #else WNDCLASS wcl; #endif MwRegisterStaticControl(hInstance); MwRegisterButtonControl(hInstance); MwRegisterEditControl(hInstance); MwRegisterListboxControl(hInstance); MwRegisterProgressBarControl(hInstance); MwRegisterComboboxControl(hInstance); memset(&wcl, 0, sizeof(wcl)); #ifdef WNDCLASSEX wcl.cbSize = sizeof(wcl); #endif wcl.style = CS_BYTEALIGNCLIENT | CS_DBLCLKS; wcl.cbWndExtra = DWL_DLGDATA + 4; wcl.lpfnWndProc = (WNDPROC) mwDialogProc; wcl.hInstance = hInstance; wcl.lpszClassName = "GDLGCLASS"; wcl.hbrBackground = GetStockObject(LTGRAY_BRUSH); #ifdef WNDCLASSEX return (RegisterClassEx(&wcl) != 0); #else return (RegisterClass(&wcl) != 0); #endif }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static char szAppName[]="HolaWin"; HWND hwnd; MSG msg; WNDCLASS wndclass; int width, height; RECT r; HWND hlist,hedit; GetWindowRect(GetDesktopWindow(), &r); width = height = r.right / 2; MwRegisterButtonControl(NULL); MwRegisterEditControl(NULL); MwRegisterListboxControl(NULL); MwRegisterProgressBarControl(NULL); MwRegisterStaticControl(NULL); MwRegisterComboboxControl(NULL); MwRegisterScrollbarControl(NULL); wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = (WNDPROC)wproc; wndclass.cbClsExtra =0; wndclass.cbWndExtra =0; wndclass.hInstance =0; wndclass.hIcon =0; wndclass.hCursor =0; wndclass.hbrBackground =(HBRUSH)GetStockObject(LTGRAY_BRUSH); wndclass.lpszMenuName =NULL; wndclass.lpszClassName = szAppName; RegisterClass(&wndclass); hwnd=CreateWindowEx(0L, szAppName, "Hola", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, width,//80, height,//80, NULL, NULL, NULL, NULL); #if !ELKS hedit=CreateWindowEx(0L, "EDIT", "OK", WS_BORDER|WS_CHILD | WS_VISIBLE, width * 5 / 8, 10, 100, 18, hwnd, (HMENU)5, NULL, NULL); CreateWindowEx(0L, "PROGBAR", "OK", WS_BORDER|WS_CHILD | WS_VISIBLE, width * 5 / 8, 32, 100, 18, hwnd, (HMENU)6, NULL, NULL); hlist = CreateWindowEx(0L, "LISTBOX", "OK", WS_VSCROLL| /*WS_HSCROLL|*/ WS_BORDER|WS_CHILD | WS_VISIBLE, width * 5 / 8, 54, 100, 54, hwnd, (HMENU)7, NULL, NULL); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Cherry"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Apple"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Orange"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Banana"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Smooth"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"00000"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"11111"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"22222"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"33333"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"44444"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"55555"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"66666"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"77777"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"88888"); SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"99999"); CreateWindowEx(0L, "BUTTON", "Cancel", WS_CHILD | WS_VISIBLE, width * 5 / 8 + 50, 106+16+6, 50, 14, hwnd, (HMENU)8, NULL, NULL); CreateWindowEx(0L, "STATIC", "Static", WS_CHILD | WS_VISIBLE, width * 5 / 8, 106+34+6, 100, 18, hwnd, (HMENU)9, NULL, NULL); #if 0 { HWND hcombo; hcombo = CreateWindowEx(0L, "COMBOBOX", "Combobox", #if 0 CBS_SIMPLE | //edit+list #else #if 0 CBS_DROPDOWNLIST | //static+pop #else CBS_DROPDOWN | //edit+pop #endif #endif #if 1 WS_VSCROLL| #endif WS_CHILD | WS_VISIBLE, width * 5 / 8, 106+14+4+18+4, 100, (18*5), hwnd, (HMENU)10, NULL, NULL); SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Cherry"); SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Apple"); SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Orange"); SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Banana"); } #endif #if 1 CreateWindowEx(0L, "SCROLLBAR", "OK", SBS_VERT | WS_CHILD | WS_VISIBLE , width * 5 / 8 -(18*2), 106+68, 18, 128, hwnd, (HMENU)11, NULL, NULL); CreateWindowEx(0L, "SCROLLBAR", "OK", SBS_HORZ | WS_CHILD | WS_VISIBLE , width * 5 / 8 -18 , 106+68, 128, 18, hwnd, (HMENU)12, NULL, NULL); #endif #endif ShowWindow(hwnd,iCmdShow); UpdateWindow(hwnd); while (GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }