Skip to content

Instantly share code, notes, and snippets.

@EncodeTheCode
Created May 4, 2024 22:32
Show Gist options
  • Save EncodeTheCode/a4e2cadef2f627709ffdceb7f5761dd5 to your computer and use it in GitHub Desktop.
Save EncodeTheCode/a4e2cadef2f627709ffdceb7f5761dd5 to your computer and use it in GitHub Desktop.
#include <atlbase.h>
#include <atlapp.h>
#include <atlwin.h>
#include <atlimage.h>
#define IDB_TOP_LEFT_CORNER 101
#define IDB_TOP_RIGHT_CORNER 102
#define IDB_TOP_EDGE 103
#define IDB_BOTTOM_LEFT_CORNER 104
#define IDB_BOTTOM_RIGHT_CORNER 105
#define IDB_BOTTOM_EDGE 106
#define IDB_CENTER 107
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.LoadFromResource(_AtlBaseModule.GetResourceInstance(), IDB_TOP_LEFT_CORNER);
imageTopRightCorner.LoadFromResource(_AtlBaseModule.GetResourceInstance(), IDB_TOP_RIGHT_CORNER);
imageTopEdge.LoadFromResource(_AtlBaseModule.GetResourceInstance(), IDB_TOP_EDGE);
imageBottomLeftCorner.LoadFromResource(_AtlBaseModule.GetResourceInstance(), IDB_BOTTOM_LEFT_CORNER);
imageBottomRightCorner.LoadFromResource(_AtlBaseModule.GetResourceInstance(), IDB_BOTTOM_RIGHT_CORNER);
imageBottomEdge.LoadFromResource(_AtlBaseModule.GetResourceInstance(), IDB_BOTTOM_EDGE);
imageCenter.LoadFromResource(_AtlBaseModule.GetResourceInstance(), IDB_CENTER);
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