class cwnd //窗口类的封装
{
public:
bool createex(
DWORD dwExStyle,
LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU nIDorHMenu,
LPVOID lpParam);
bool showwindow(int ncndshow);
bool updatewindow();
public:
HWND m_hwnd;
};
bool cwnd::createex(
DWORD dwExStyle,
LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU nIDorHMenu,
LPVOID lpParam)
{
m_hwnd=createwindowex(dwexstyle,lpszclassname,lpszwindowname,
dwstyle,x,y,nwidth,nheight,hwndparent,
nidorhmenu,lpparam);
if(m_hwnd!=HULL)
return true;
else
return false;
}
bool cwnd::showwindow(int ncmdshow)
{
return ::showwindow(m_hwnd,ncndshow);
}
bool cwnd::updatewindow() //更新窗口
{
return ::updatewindow(m_hwnd);
}
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd
)
{
wndclass wndcls; //设置窗口类
wndcls.cbclsextra=0;
wndcls.cbwndextra=0;
......
registerclass(&wndcls);
cwnd wnd;
wnd.createex(....);
wnd.showwindow(sw_shownormal);
wnd.updatewindow();
.........
}