Skip to content

Instantly share code, notes, and snippets.

@RadAd
Last active February 28, 2022 22:55
Show Gist options
  • Save RadAd/26ad7846e4e57aee57af74494fbd500b to your computer and use it in GitHub Desktop.
Save RadAd/26ad7846e4e57aee57af74494fbd500b to your computer and use it in GitHub Desktop.
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
#include <atlwin.h>
class CMainWnd :
public CWindowImpl<CMainWnd, CWindow, CFrameWinTraits>
{
public:
static LPCTSTR GetWndCaption()
{
return _T("Hello World");
}
BEGIN_MSG_MAP(CMainWnd)
END_MSG_MAP()
void OnFinalMessage(_In_ HWND /*hWnd*/) override
{
PostQuitMessage(0);
}
};
class CModule : public ATL::CAtlExeModuleT< CModule >
{
public:
HRESULT PreMessageLoop(_In_ int nShowCmd) throw()
{
//AtlInitCommonControls(0xFFFF);
CMainWnd* mainwnd = new CMainWnd();
if (!mainwnd->Create(NULL))
return AtlHresultFromWin32(GetLastError());
mainwnd->ShowWindow(nShowCmd);
HRESULT hr = __super::PreMessageLoop(nShowCmd);
if (FAILED(hr))
return hr;
return S_OK;
}
};
CModule _AtlModule;
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nShowCmd)
{
return _AtlModule.WinMain(nShowCmd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment