窗口为什么不能显示??

来源:百度知道 编辑:UC知道 时间:2024/06/07 16:38:59
// PROJECT1.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "windows.h"

LRESULT CALLBACK huidiao(HWND hwnd,UINT uMsg,WPARAM wparam,LPARAM lparam)
{
while(1);
}
void reg_window_and_make(HINSTANCE hInstance)
{
WNDCLASSEX wc;
memset(&wc,0,sizeof(wc));
wc.cbSize=sizeof wc;
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.cbWndExtra=0;
wc.cbClsExtra=0;
wc.lpfnWndProc = huidiao;// huidiao;//回调函数,对窗口内的消息进行处理
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION );
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hInstance = hInstance;//这是一个实例?
wc.hbrBackground=NULL;
wc.lpszMenuName=NULL;
wc.lpszClassName="mine";

RegisterClassEx(&wc);

HWND hwnd;
hwnd = CreateWindowEx(0,"mine","FUck you",WS_POPUP,600,400,600,400,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,SW_SHOWMAXIMI

应在UpdateWindow(hwnd);后加上这几句:
while(GetMessage(&msg,NULL,0,0)
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wparam;
并声明MSG msg;如果不这么做,回调函数就没有意义了,窗口只执行了未能看见的一次就自动退出了。

我感觉是回调函数的问题~
可能程序一闪就过去了~
看下进程里有没有~