When using VC to write Windows programs, I do not like to use MFC, here I will be the API way of the VC program used in various ways to record down.
VC using the API
First, the main structure
1. Create a new Windows Forms project in VS2008 and select "Empty Project";
2. Create a new "main.cpp" file in the project, the code is at the end of the text;
3. Create a new dialog form resource in the project and set its ID to "Idd_main";
4. Compile and run.
#include"resource.h"#include<windows.h>#include<stdio.h>///////////////////////////////////////////////////////////////////////////intCALLBACK Dlgproc (HWND hdlg, UINT umsg, WPARAM WPARAM, LPARAM LPARAM);///////////////////////////////////////////////////////////////////////////intapientry WinMain (hinstance hinstance, hinstance hprevinstance, LPSTR lpcmdl INE,intnShowCmd) {DialogBox (hinstance, Makeintresource (Idd_main), NULL, Dlgproc); return 0;}////////////////////////////////////////////////////////////////////////////intCALLBACK Dlgproc (HWND hdlg, UINT umsg, WPARAM WPARAM, LPARAM LPARAM) {Switch(umsg) { Casewm_command: {Switch(LoWord (WParam)) { CaseIDOK: {MessageBox (0,"Hello world!","This is the title",0); } Break; } } Break; Casewm_initdialog: {} Break; Casewm_close: {enddialog (hdlg,0); } Break; } return 0;}
Using the API's vc-main architecture