1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
LRESULT CALLBACK DialogProcedure(HWND hWnd,UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg)
{
// Sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function.
case WM_CREATE:
AddDialogBox(hWnd);
break;
// Sent as a signal that a window or an application should terminate.
case WM_CLOSE:
DestroyWindow(hWnd);
break;
default:
return DefWindowProcW(hWnd, msg, wp, lp);
} // end switch
} // end LRESULT CALLBACK DialogProcedure
void RegisterDialogClass(HINSTANCE hInst)
{
WNDCLASSW dialog = {0} ;
dialog.hbrBackground = (HBRUSH)COLOR_WINDOW ; // A handle to the class background brush
dialog.hCursor = LoadCursor(NULL, IDC_HAND); // A handle to the class cursor. This member must be a handle to a cursor resource.
dialog.hInstance = hInst; // A handle to the instance that contains the window procedure for the class.
dialog.lpszClassName = L"SimpleDialog"; // A pointer to a null-terminated string or is an atom
dialog.lpfnWndProc = DialogProcedure ; // A pointer to the window procedure
RegisterClassW(&dialog);
} // end RegisterDialogClass
void displayDialog(HWND hWnd)
{
CreateWindowW(L"SimpleDialog", L"DialogBox", WS_VISIBLE | WS_OVERLAPPEDWINDOW , 400,200,500,300,hWnd,NULL,NULL,NULL);
} // end displayDialog
void AddDialogBox(HWND hWnd)
{
CreateWindowW(L"static", L"User Name: Lee D. Daniel\n\nProgram Name: JimmyDaLou\n\nProgram Description: Simple GUI with Menu and DialogBox\n\nProgram Version Number: 1.0", WS_VISIBLE | WS_BORDER | WS_CHILD ,5,5,450,150,hWnd,NULL,NULL,NULL);
}
void addControls(HWND hWnd)
{
CreateWindowW(L"Button", L"Fill", WS_VISIBLE | WS_CHILD, 40, 40, 100, 50, hWnd, (HMENU)ID_FILL_TANK, NULL, NULL);
CreateWindowW(L"Button", L"Empty", WS_VISIBLE | WS_CHILD, 210, 40, 100, 50, hWnd, (HMENU)ID_EMPTY_TANK, NULL, NULL);
CreateWindowW(L"Button", L"Half", WS_VISIBLE | WS_CHILD, 380, 40, 100, 50, hWnd, (HMENU)ID_HALF_FILL_TANK, NULL, NULL);
CreateWindowW(L"Button", L"AutoBot", WS_VISIBLE | WS_CHILD, 550, 40, 100, 50, hWnd, (HMENU)ID_AUTO_RUN, NULL, NULL);
TextBox = CreateWindowW(L"Edit", L"", WS_VISIBLE | WS_CHILD | ES_MULTILINE| WS_BORDER | WS_VSCROLL, 12, 200, 650, 300, hWnd, NULL, NULL, NULL);
}
| |