#define STRICT
#define VC_EXTRALEAN
#include <atlbase.h>
#include <atlwin.h>
class CMyWindow : public CWindowImpl<CMyWindow,CWindow,CFrameWinTraits>
{
public:
 DECLARE_WND_CLASS(_T("My Window Class"))
 BEGIN_MSG_MAP(CMyWindow)
  MESSAGE_HANDLER(WM_CLOSE,  OnClose)
  MESSAGE_HANDLER(WM_DESTROY,OnDestroy)
 END_MSG_MAP()
    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
  DestroyWindow();
  return 0;
 }
    LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
  PostQuitMessage(0);
  return 0;
 }
};
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPTSTR szCmdLine, int nCmdShow)
{
 CMyWindow WndMain;
 MSG msg;
 if (NULL == WndMain.Create(NULL,CWindow::rcDefault,_T("Hello")))
 {
  return 1;
 }
 WndMain.ShowWindow(nCmdShow);
 WndMain.UpdateWindow();
 while(GetMessage(&msg,NULL,0,0) > 0)
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
 return msg.wParam;
}
可以用在 Win32 和 Win32_CE 上。
沒有留言:
張貼留言