我想创建一个主窗口及其子窗口,我这样写了代码,为什么不行 啊?谢谢#include<windows.h>
#include<stdio.h>
LRESULT CALLBACK WinProc(HWND h1,UINT msg,WPARAM wParam,LPARAM lParam);int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS w;
w.cbClsExtra=0;
w.cbWndExtra=0;
w.hbrBackground=(HBRUSH)::GetStockObject(DKGRAY_BRUSH);
w.hCursor=::LoadCursor(NULL,IDC_UPARROW);
w.hIcon=::LoadIcon(NULL,IDI_EXCLAMATION);
w.hInstance=hInstance;
w.lpfnWndProc=WinProc;
w.lpszClassName="窗口";
w.lpszMenuName=NULL;
w.style=CS_HREDRAW|CS_VREDRAW;
::RegisterClass(&w); HWND h1,h2;
h1=::CreateWindow("窗口","1",WS_OVERLAPPEDWINDOW,0,0,400,400,NULL,NULL,hInstance,NULL);
h2=::CreateWindow("窗口","2",WS_CHILD,400,400,600,600,NULL,NULL,hInstance,NULL); ShowWindow(h1,nCmdShow);
UpdateWindow(h1);
ShowWindow(h2,nCmdShow);
UpdateWindow(h2);
MSG msg;
while(::GetMessage(&msg,NULL,0,0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
} return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND h1,UINT msg,WPARAM wParam,LPARAM lParam){
switch(msg)
{
case WM_CLOSE:
::DestroyWindow(h1);
break; case WM_DESTROY:
::PostQuitMessage(0);
break; default:
return DefWindowProc(h1,msg,wParam,lParam);
}
return 0;
}
#include<stdio.h>
LRESULT CALLBACK WinProc(HWND h1,UINT msg,WPARAM wParam,LPARAM lParam);int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS w;
w.cbClsExtra=0;
w.cbWndExtra=0;
w.hbrBackground=(HBRUSH)::GetStockObject(DKGRAY_BRUSH);
w.hCursor=::LoadCursor(NULL,IDC_UPARROW);
w.hIcon=::LoadIcon(NULL,IDI_EXCLAMATION);
w.hInstance=hInstance;
w.lpfnWndProc=WinProc;
w.lpszClassName="窗口";
w.lpszMenuName=NULL;
w.style=CS_HREDRAW|CS_VREDRAW;
::RegisterClass(&w); HWND h1,h2;
h1=::CreateWindow("窗口","1",WS_OVERLAPPEDWINDOW,0,0,400,400,NULL,NULL,hInstance,NULL);
h2=::CreateWindow("窗口","2",WS_CHILD,400,400,600,600,NULL,NULL,hInstance,NULL); ShowWindow(h1,nCmdShow);
UpdateWindow(h1);
ShowWindow(h2,nCmdShow);
UpdateWindow(h2);
MSG msg;
while(::GetMessage(&msg,NULL,0,0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
} return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND h1,UINT msg,WPARAM wParam,LPARAM lParam){
switch(msg)
{
case WM_CLOSE:
::DestroyWindow(h1);
break; case WM_DESTROY:
::PostQuitMessage(0);
break; default:
return DefWindowProc(h1,msg,wParam,lParam);
}
return 0;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货