高手进WINDOWSapi建立简单窗口失败

来源:百度知道 编辑:UC知道 时间:2024/06/01 08:43:18
#include "stdio.h"
#include "windows.h"

LRESULT CALLBACK wndproc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
HINSTANCE hInstance;

class win
{
public:
BOOL W_class();
BOOL create();
BOOL ms();
};

BOOL win::W_class()
{
WNDCLASS wdnclass;//设计窗口
wdnclass.style=CS_HREDRAW|CS_VREDRAW;;//窗口
wdnclass.lpfnWndProc=wndproc;//窗口指针很重要
wdnclass.cbClsExtra=0;//通常为0
wdnclass.cbWndExtra=0;//通常为0
wdnclass.hInstance=hInstance;//句柄
wdnclass.hIcon=LoadIcon(NULL,IDI_ERROR);//图标句柄
wdnclass.hCursor=LoadCursor(NULL,IDC_CROSS);//光标句柄
wdnclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);//背色句柄
wdnclass.lpszMenuName=NULL;
wdnclass.lpszClassName="zhuzi";//类的名字

return (RegisterClass(&wdnclass));//注册窗口
}

BOOL win::create()
{ <

winapi函数缺少结尾括号和返回值。

int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
win window;
if(!window.W_class())
return 0;
if(!window.create())
return 0;
window.ms();
return 0;
}

这样就没有问题了...

不错 支持楼上的
//过程函数
LRESULT CALLBACK wndproc(
前面加
return 0;
}