Created
May 4, 2024 22:32
-
-
Save EncodeTheCode/391385e3c46395cc542e68e9aa621119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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