First, there is virtually no documentation (which I will ever find) explaining how to use WTL. It seems to be a library of experts, for experts.
Now your options: use the MFC application wizard to create an application or navigate the Win32 API path. The Win32 API itself is the C API, MFC is the C ++ wrapper around the C Win32 API with the addition of an application model for viewing documents.
However, instead of creating your controls from code: the closest analogue of the native Windows API to "WinForm" is a dialog box. Dialogs are placed in resource files that are embedded during binding in the EXE or DLL that you are developing. The dialog resource accepts a font parameter, which is automatically applied to all controls in the dialog box, and dialogs are laid out in terms of dialog blocks, not pixels, which allows them to automatically scale relative to the font face and dpi settings in the user system.
If you create a dialog resource and add it to a simple application, it does not need to get complicated to get the dialogue on the screen and close it in response to the click of the OK button.
#include <windows.h> #include "resource.h" BOOL CALLBACK MyDialogProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch(uMsg){ case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch(LOWORD(wParam){ case IDOK: EndDialog(hwnd,wParam); } return TRUE; } return FALSE; } int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hNull,LPCTSTR strCmdLine,int nCmdShow) { return DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,&DialogProc,0l); }
Chris becke
source share