少了cw.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
就失败
那么哪些是必须要加的项目(WNDCLASSEX cw中的) 不要告诉我全部都要加哦
// sdk_1.cpp : Defines the entry point for the application.
//#include "stdafx.h"
LRESULT CALLBACK WinProc(HWND ,UINT,WPARAM,LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
HWND hwnd;
WNDCLASSEX cw;
MSG msg; cw.hInstance=hInstance;
cw.lpszClassName="Window";
cw.lpfnWndProc=WinProc;
cw.style=0; cw.cbSize=sizeof(WNDCLASSEX); cw.hIcon=LoadIcon(NULL,IDI_APPLICATION);
cw.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
cw.hCursor=LoadCursor(NULL,IDC_ARROW); cw.lpszMenuName=NULL;
cw.cbClsExtra=0;
cw.cbWndExtra=0;
cw.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); if(!RegisterClassEx(&cw)) { MessageBox(NULL,"Sdf","Sdf",MB_OK);return 0;}
hwnd=CreateWindow(
cw.lpszClassName,
"First",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
HWND_DESKTOP,
NULL,
cw.hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return msg.wParam;
}LRESULT CALLBACK WinProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lparam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lparam);
}
return 0;
}
就失败
那么哪些是必须要加的项目(WNDCLASSEX cw中的) 不要告诉我全部都要加哦
// sdk_1.cpp : Defines the entry point for the application.
//#include "stdafx.h"
LRESULT CALLBACK WinProc(HWND ,UINT,WPARAM,LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
HWND hwnd;
WNDCLASSEX cw;
MSG msg; cw.hInstance=hInstance;
cw.lpszClassName="Window";
cw.lpfnWndProc=WinProc;
cw.style=0; cw.cbSize=sizeof(WNDCLASSEX); cw.hIcon=LoadIcon(NULL,IDI_APPLICATION);
cw.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
cw.hCursor=LoadCursor(NULL,IDC_ARROW); cw.lpszMenuName=NULL;
cw.cbClsExtra=0;
cw.cbWndExtra=0;
cw.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); if(!RegisterClassEx(&cw)) { MessageBox(NULL,"Sdf","Sdf",MB_OK);return 0;}
hwnd=CreateWindow(
cw.lpszClassName,
"First",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
HWND_DESKTOP,
NULL,
cw.hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return msg.wParam;
}LRESULT CALLBACK WinProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lparam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lparam);
}
return 0;
}
反正我写SDK程序时不会少一个!
少一个好像都不对!
没辙!
memset(&cw,0,sizeof(cw));
void *memset( void *dest, int c, size_t count );???Sets buffers to a specified character.
这么做的作用是什么?
省去了填写的麻烦。
然后 你只需填cbSize,lpfnWndProc,lpszClassName
就可以注册成功。
但是这个也许并不是你需要的,所以你要根据自己的需要填写其他项目。