📄 zwin.cpp
字号:
#include "../stdafx.h"
#include "zWin.h"
#include "assert.h"
//##ModelId=3FFA19990363
zWin::zWin()
{
m_hWnd = NULL;
}
//##ModelId=3FFA19990377
zWin::~zWin()
{
}
//##ModelId=3FFA2A310249
LRESULT CALLBACK zWin::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
zWin * pWindow;
pWindow = (zWin *)GetWindowLong(hWnd,GWL_USERDATA);
if(pWindow)
{
return pWindow->WndProc(hWnd,uMsg,wParam,lParam);
}else
{
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
}
//##ModelId=3FFA2A3300EE
void zWin::OnDraw(HDC hDC)
{
}
//##ModelId=3FFA2A3503AD
LRESULT zWin::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(m_hWnd,&ps);
OnDraw(ps.hdc);
EndPaint(m_hWnd,&ps);
}
return 0;
case WM_DESTROY:
OnDestory();
return 0;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
//##ModelId=3FFA2A370143
void zWin::GetWndClassEx(WNDCLASS &wc)
{
memset(&wc,0,sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = NULL;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName= NULL;
}
//##ModelId=3FFA2A3802A3
bool zWin::CreateEx(DWORD dwExStyle, LPCTSTR lpszClass, LPCTSTR lpszName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hParent, HMENU hMenu, HINSTANCE hInst)
{
m_hInst = hInst;
if (!RegisterClass(lpszClass,hInst))
return false;
m_hWnd = CreateWindowEx(dwExStyle,lpszClass,lpszName,dwStyle,x,y,nWidth,nHeight,hParent,hMenu,hInst,this);
if (m_hWnd!=NULL)
{
::SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this);
OnCreate();
}
return m_hWnd != NULL;
}
bool zWin::CreateWin(HINSTANCE hInstance, int TemplateId, HWND hWndParent)
{
m_hInst = hInstance;
m_hWnd = ::CreateDialog(hInstance,MAKEINTRESOURCE(TemplateId),hWndParent,(DLGPROC)WindowProc);
if (m_hWnd)
{
::SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this);
OnCreate();
}
return m_hWnd!=NULL;
}
//##ModelId=3FFA2A3A004D
BOOL zWin::RegisterClass(LPCTSTR lpszClass, HINSTANCE hInst)
{
WNDCLASS wc;
if (!GetClassInfo(hInst,lpszClass,&wc))
{
GetWndClassEx(wc);
wc.hInstance = hInst;
wc.lpszClassName = lpszClass;
if (!::RegisterClass(&wc))
return FALSE;
}
return TRUE;
}
//##ModelId=3FFA2A3B015D
WPARAM zWin::MessageLoop()
{
MSG msg;
while(::GetMessage(&msg,NULL,0,0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
return msg.wParam;
}
//##ModelId=3FFA2A3C035D
BOOL zWin::ShowWindow(int nCmdShow)
{
return ::ShowWindow(m_hWnd,nCmdShow);
}
//##ModelId=3FFA2A3E0298
BOOL zWin::UpdateWindow()
{
return ::UpdateWindow(m_hWnd);
}
void zWin::OnCreate()
{
}
void zWin::OnDestory()
{
PostQuitMessage(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -