永发信息网

Windows编程高手进来看下

答案:2  悬赏:50  手机版
解决时间 2021-07-30 17:03

程序可以正常运行,为什么就是不显示窗口呢,

#include<windows.h>
#include<stdio.h>

LRESULT CALLBACK winSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);


int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmline,
int nShowCmd
)
{

WNDCLASS wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor = LoadCursor(NULL,IDC_CROSS);
wc.hIcon = LoadIcon(NULL,IDI_ERROR);
wc.hInstance = hInstance;
wc.lpfnWndProc = winSunProc;
wc.lpszClassName = "SUNXIN";
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wc);

HWND hwnd;
hwnd =CreateWindow("SUNXIN","WANGWENQUAN",
WS_OVERLAPPED,0,0,800,600,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);

MSG msg;
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK winSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
char szchar[20];
sprintf(szchar,"char code is%d",wParam);
MessageBox(hwnd,szchar, "char",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"111111","22222222",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,10,10,"laji",5);
case WM_PAINT:
HDC Hdc;
PAINTSTRUCT ps;
Hdc =BeginPaint(hwnd ,&ps);

TextOut(Hdc,40,40,"wangwen",strlen("wangwen"));
EndPaint(hwnd,&ps);
break;
}
return 0;
}

最佳答案
#include<windows.h>
#include<stdio.h>

LRESULT CALLBACK winSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);


int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmline,
int nShowCmd
)
{

WNDCLASS wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor = LoadCursor(NULL,IDC_CROSS);
wc.hIcon = LoadIcon(NULL,IDI_ERROR);
wc.hInstance = hInstance;
wc.lpfnWndProc = winSunProc;
wc.lpszClassName = "SUNXIN";
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wc);

HWND hwnd;
hwnd =CreateWindow("SUNXIN","WANGWENQUAN",
WS_OVERLAPPED,0,0,800,600,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);

MSG msg;
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK winSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
char szchar[20];
sprintf(szchar,"char code is%d",wParam);
MessageBox(hwnd,szchar, "char",0);
return 0;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"111111","22222222",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,10,10,"laji",5);
return 0;
case WM_PAINT:
HDC Hdc;
PAINTSTRUCT ps;
Hdc =BeginPaint(hwnd ,&ps);

TextOut(Hdc,40,40,"wangwen",strlen("wangwen"));
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

全部回答
窗口过程里的默认项你没写 帮你写上了 也有注释 #include<windows.h> #include<stdio.h> LRESULT CALLBACK winSunProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmline, int nShowCmd ) { WNDCLASS wc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hCursor = LoadCursor(NULL,IDC_CROSS); wc.hIcon = LoadIcon(NULL,IDI_ERROR); wc.hInstance = hInstance; wc.lpfnWndProc = winSunProc; wc.lpszClassName = "SUNXIN"; wc.lpszMenuName = NULL; wc.style = CS_HREDRAW|CS_VREDRAW; RegisterClass(&wc); HWND hwnd; hwnd =CreateWindow("SUNXIN","WANGWENQUAN", WS_OVERLAPPED,0,0,800,600,NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWNORMAL); UpdateWindow(hwnd); MSG msg; while(GetMessage(&msg,hwnd,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK winSunProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) { case WM_CHAR: char szchar[20]; sprintf(szchar,"char code is%d",wParam); MessageBox(hwnd,szchar, "char",0); break; case WM_LBUTTONDOWN: MessageBox(hwnd,"
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
为什么没有一个值得喜欢的人呢?
Zhang Li the dog eat dog shit这句中文是什
罗田县黄冈安化黑茶(罗田体验馆)这个地址在什
热舞派对更新时抽奖几率是不是更大些?
睡觉老出汗是什么原因呢
最近有什么新电影要上映?国内 国外的都要
QQ号多久不用就自动消失
像螳螂捕蝉这样的寓言故事有很多,如()、(
谁能告诉我QQ宠物企鹅里藏宝图里小锄头指的是
什么是玉老?
最便宜的无线上网卡是哪个品牌,价格过少?
渑池县三门峡发之语(仰韶大街)我想知道这个在
投篮后,球落到地板上再抓,还算篮板吗?有人
谁有韩服跑跑卡丁车网通的号码?
DNF街霸刷图技巧
推荐资讯
关于转换DPG格式电影
吃了紧急避孕药后为什么一连四天内裤都脏脏的
道里区哈尔滨阿萨迪地址在什么地方,想今天过
请问;那个网名叫"天天开心"的人怎么又来偷菜
我该怎么追稿酬?
海纳百川,有容乃大;壁立千仞,无欲则刚。通
现在魔兽世界游戏时间收费么
郧西县十堰王力唯欧木门地址在哪,我要去那里
地下城与勇士安全
通许县开封风味小吃怎么去啊,谁知道地址啊
绿茶可以加冰糖吗?
我要mariah carey 海豚音的演唱会所有专集名
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?