Skip to content

Instantly share code, notes, and snippets.

@EncodeTheCode
Created May 4, 2024 22:32
Show Gist options
  • Save EncodeTheCode/92775999040e166e965803a7ef8ef578 to your computer and use it in GitHub Desktop.
Save EncodeTheCode/92775999040e166e965803a7ef8ef578 to your computer and use it in GitHub Desktop.
#include <atlbase.h>
#include <atlapp.h>
#include <atlwin.h>
#include <atlimage.h>
class CustomWindow : public CWindowImpl<CustomWindow> {
public:
DECLARE_WND_CLASS_EX(_T("CustomWindowClass"), CS_HREDRAW | CS_VREDRAW, COLOR_WINDOW)
BEGIN_MSG_MAP(CustomWindow)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
END_MSG_MAP()
LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
CPaintDC dc(m_hWnd);
CImage imageTopLeftCorner, imageTopRightCorner, imageTopEdge,
imageBottomLeftCorner, imageBottomRightCorner, imageBottomEdge, imageCenter;
imageTopLeftCorner.Load(_T("top_left_corner.png"));
imageTopRightCorner.Load(_T("top_right_corner.png"));
imageTopEdge.Load(_T("top_edge.png"));
imageBottomLeftCorner.Load(_T("bottom_left_corner.png"));
imageBottomRightCorner.Load(_T("bottom_right_corner.png"));
imageBottomEdge.Load(_T("bottom_edge.png"));
imageCenter.Load(_T("center.png"));
imageTopLeftCorner.Draw(dc, 0, 0);
imageTopRightCorner.Draw(dc, 750, 0);
imageTopEdge.Draw(dc, 50, 0);
// Draw other parts of the frame similarly...
return 0;
}
LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
PostQuitMessage(0);
return 0;
}
};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
CMessageLoop theLoop;
_Module.AddMessageLoop(&theLoop);
CustomWindow mainWindow;
mainWindow.Create(NULL, CWindow::rcDefault, _T("Custom Window"), WS_OVERLAPPEDWINDOW);
mainWindow.ShowWindow(nCmdShow);
int nRet = theLoop.Run();
_Module.RemoveMessageLoop();
return nRet;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment