We've been thinking about writing Win32 applications before:
1, Design window class. 2, register the window class. 3, create the window. ......
However, when we touch the control, we find a problem, we put the control on the window is really difficult, and the Resource dialog box has a graphics editor, it is relatively convenient to operate.
So, there's an idea: Use the dialog box as the main window, so we can make it easier to layout the controls.
In fact, this idea has been done on the Internet, but the people are compiled with Win32, of course, to make it into C + + is easier.
First, introduce the first way to create a dialog box directly by using the desktop as the parent window.
1, create a dialog box resources, the interface to play your design talent.
2, create an icon resource, both as an icon for the application (vs compile will choose the first to add to the resource icon as an EXE icon), also as a dialog box icon.
3. Create and display a dialog box in your code.
#include <Windows.h> #include "resource.h"//Open Visualization #pragma comment (linker, "\"/manifestdependency: Type= ' Win32 '/name= ' microsoft.windows.common-controls ' version= ' 6.0.0.0 ' processorarchitecture= ' * ' PublicKeyToken = ' 6595B64144CCF1DF ' language= ' * ' "") int_ptr CALLBACK Dlgproc (HWND hdlg, UINT msg, WPARAM WPARAM, LPARAM LP
Aram);
HINSTANCE Hginst;
int WINAPI WinMain (hinstance Hthisapp, hinstance Hprevapp, LPSTR lpcmd, int nshow) {hginst = Hthisapp;
HWND Hdlg = createdialog (Hthisapp, Makeintresource (idd_my), GetDesktopWindow (), (Dlgproc) dlgproc);
if (!HDLG) {return 0;
} ShowWindow (Hdlg,sw_show);
MSG msg;
while (GetMessage (&msg,null,0,0)) {translatemessage (&msg);
DispatchMessage (&MSG);
return 0; INT_PTR CALLBACK Dlgproc (HWND hdlg, UINT msg, WPARAM WPARAM,LPARAM LPARAM) {switch (msg) {case WM_INITDIALOG://Setup dialog box icon S
Endmessage (Hdlg, Wm_seticon, Icon_small, (LPARAM) LoadIcon (Hginst, Makeintresource (Idi_app)));
return 0;
Case Wm_syscommand:if (WParam = = sc_close) {postquitmessage (0);/exit
return 0;
Return (INT_PTR) FALSE; }