01:文件头说明 - hd
/* ----------------------------------------------------------------------------- Author: Wu Hai Filename: $FILE_BASE$.$FILE_EXT$ Description: $Description$ ----------------------------------------------------------------------------- */
2.Header Guard - ifd
#ifndef $FILE_BASE$_h__ #ifndef $FILE_BASE$_h__ #define $FILE_BASE$_h__ class $Class_name$ { public: // $Class_name$(); // ~$Class_name$(); protected: $end$ private: $end$ }; $selected$ #endif // $FILE_BASE$_h__
3.函数分隔符 ff
//---------------------------------------------------------------------
4.WinMain WM
#include <windows.h> #include <iostream> LRESULT CALLBACK WinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow ) { WNDCLASS wc; wc.cbClsExtra=0; wc.cbWndExtra=0; wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); wc.hCursor=LoadCursor(0,IDC_ARROW); wc.hIcon=LoadIcon(0,IDI_ERROR); wc.hInstance=hInstance; wc.lpfnWndProc=WinProc; wc.lpszClassName="class"; wc.lpszMenuName=0; wc.style=CS_HREDRAW|CS_VREDRAW; RegisterClass(&wc); HWND hwnd; hwnd=CreateWindow("class","win",WS_OVERLAPPEDWINDOW,100,50,800,600, NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWNORMAL); UpdateWindow(hwnd); MSG msg; while (GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WinProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) { case WM_PAINT: HDC hdc; PAINTSTRUCT ps; hdc=BeginPaint(hwnd,&ps); TextOut(hdc,0,0,"hello",strlen("hello")); EndPaint(hwnd,&ps); return 0; case WM_CLOSE: DestroyWindow(hwnd); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; case WM_LBUTTONDOWN: ::MessageBox(hwnd,"Click",0,0); return 0; case WM_CHAR: char ch[20]; sprintf(ch,"char is %c",wParam); MessageBox(0,ch,0,0); return 0; default: return DefWindowProc(hwnd,uMsg,wParam,lParam); } return 0; }