Simple way to generate Win32 dialog program with VC6

xiaoxiao2021-03-06  113

Select Win32 Application in Project, then select Automatically generate a "Hello, World" program, you can go to a normal window dialog box and bring an About dialog. Subsequently, most of the code in the WinMain delete, add CreateDialog a function call, as follows: int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {MSG msg; // Create the main dialog, created with the CreateDialog It is the non-modal dialog, while DialogBox is a modal dialog, with your reference msdnhwnd hmain = null; hmain = create, (lpctstr) (Idd_aboutbox), NULL, (DLGPROC) About); :: setWindowPos (Hmain, hwnd_top , 250, 200, 0, 0, swp_nosize | swp_showwindow; // showwindow (hmain, sw_show) // With a top, this is not :: UpdateWindow (hmain);

IF (NULL == Hmain) {:: MeasureBox (Null, "CreateWindow Error", "Error", MB_OK; Return-1;} // main message loop: While (GetMessage (& MSG, NULL, 0, 0)))) {IF (!, & Msg)) {TranslateMessage (& MSG); DispatchMessage (& MSG);}}

Return Msg.wParam;} This can be seen when running, but there is a problem, when you click Close the dialog, the dialog is not really turned off, but you need to modify a small place, in the message processing In the callback function, you need to add this: LRESULT CALLBACK ABOUT (HWND HDLG, UINT MESSAGE, WPARAM WPARAM, LPARAM LPARAM) {Switch (Message) {Case WM_INITDIALOG: RETURN TRUE

转载请注明原文地址:https://www.9cbs.com/read-100849.html

New Post(0)