前回に続き、Hello Worldすら表示しない空のウィンドウを表示するプログラム、今度はWTLを使ったものです。

#define WINVER 0x0400
#define _WIN32_WINNT 0x0403
#define _WIN32_WINDOWS 0
#define _WIN32_IE 0x0300
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _WTL_NO_AUTOMATIC_NAMESPACE
 
#include <windows.h>
 
#include <atlbase.h>
#include <atlwin.h>
 
#include <atlapp.h>
#include <atlcrack.h>
 
class TestWindow : public ATL::CWindowImpl<TestWindow>
{
public:
  DECLARE_WND_CLASS(TEXT("Test Window Class"));
 
private:
  BEGIN_MSG_MAP(TestWindow)
    MSG_WM_DESTROY(OnDestroy)
  END_MSG_MAP()
 
  void OnDestroy()
  {
    PostQuitMessage(0);
  }
};
 
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int cmdShow)
{
  TestWindow wnd;
  if (!wnd.Create(nullptr, ATL::CWindow::rcDefault,
    TEXT("Hello, world"), WS_OVERLAPPEDWINDOW))
  {
    return -1;
  }
 
  wnd.ShowWindow(cmdShow);
  wnd.UpdateWindow();
 
  WTL::CMessageLoop msgLoop;
  return msgLoop.Run();
}

スポンサード リンク

この記事のカテゴリ

  • ⇒ 空のウィンドウを表示するだけのWindowsアプリケーション (WTL)
  • ⇒ 空のウィンドウを表示するだけのWindowsアプリケーション (WTL)