用VisualC++6.0的Win32 Application创建了一个空白工程目的是创建一个窗口,编译组建都通过,却不能执行
这是代码,有什么问题吗?跪求大神解决#defineWIN32_LEAN_AND_MEAN//justsaynotoMFC#include<windows.h>//incl...
这是代码,有什么问题吗?跪求大神解决
#define WIN32_LEAN_AND_MEAN //just say no to MFC
#include<windows.h> //include all the windows headers
#include<windowsx.h> //include useful macros
#include<stdio.h>
#include<math.h>
#define WINDOW_CLASS_NAME "WINCLASS1"
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{return(0);
} break;
case WM_PAINT:
{hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;
case WM_DESTROY:
{PostQuitMessage(0);
return(0);
} break;
default:break;
}
return (DefWindowProc(hwnd,msg,wparam,lparam));
}
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow)
{WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszClassName=WINDOW_CLASS_NAME;
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&winclass))
return(0);
if(!(hwnd=CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"My Basic Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE
0,0,
400,400,
NULL,
NULL,
hinstance,
NULL)))
return(0);
while(GetMessage(&msg,NULL,0,0))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return((int)msg.wParam);
} 展开
#define WIN32_LEAN_AND_MEAN //just say no to MFC
#include<windows.h> //include all the windows headers
#include<windowsx.h> //include useful macros
#include<stdio.h>
#include<math.h>
#define WINDOW_CLASS_NAME "WINCLASS1"
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{return(0);
} break;
case WM_PAINT:
{hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;
case WM_DESTROY:
{PostQuitMessage(0);
return(0);
} break;
default:break;
}
return (DefWindowProc(hwnd,msg,wparam,lparam));
}
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow)
{WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszClassName=WINDOW_CLASS_NAME;
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&winclass))
return(0);
if(!(hwnd=CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"My Basic Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE
0,0,
400,400,
NULL,
NULL,
hinstance,
NULL)))
return(0);
while(GetMessage(&msg,NULL,0,0))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return((int)msg.wParam);
} 展开
1个回答
展开全部
填写winclass结构没完成,还差个winclass.lpszMenuName=NULL;
完整代码如下:
#define WIN32_LEAN_AND_MEAN //just say no to MFC
#include<windows.h> //include all the windows headers
#include<windowsx.h> //include useful macros
#include<stdio.h>
#include<math.h>
#define WINDOW_CLASS_NAME "WINCLASS1"
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{return(0);
} break;
case WM_PAINT:
{hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;
case WM_DESTROY:
{PostQuitMessage(0);
return(0);
} break;
default:break;
}
return (DefWindowProc(hwnd,msg,wparam,lparam));
}
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszClassName=WINDOW_CLASS_NAME;
winclass.lpszMenuName=NULL;
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&winclass))
return(0);
if(!(hwnd=CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"My Basic Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
400,400,
NULL,
NULL,
hinstance,
NULL)))
return(0);
while(GetMessage(&msg,NULL,0,0))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return((int)msg.wParam);
}
完整代码如下:
#define WIN32_LEAN_AND_MEAN //just say no to MFC
#include<windows.h> //include all the windows headers
#include<windowsx.h> //include useful macros
#include<stdio.h>
#include<math.h>
#define WINDOW_CLASS_NAME "WINCLASS1"
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{return(0);
} break;
case WM_PAINT:
{hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;
case WM_DESTROY:
{PostQuitMessage(0);
return(0);
} break;
default:break;
}
return (DefWindowProc(hwnd,msg,wparam,lparam));
}
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszClassName=WINDOW_CLASS_NAME;
winclass.lpszMenuName=NULL;
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&winclass))
return(0);
if(!(hwnd=CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"My Basic Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
400,400,
NULL,
NULL,
hinstance,
NULL)))
return(0);
while(GetMessage(&msg,NULL,0,0))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return((int)msg.wParam);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询