百度首页 | 百度空间
 
查看文章
 
孙鑫VC++第3课(函数封装的例子)
2008年01月19日 星期六 17:42

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();
.........
}


类别:我的vc++ | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu