Windows编程高手进来看下
答案:2 悬赏:50 手机版
解决时间 2021-07-30 17:03
- 提问者网友:几叶到寒
- 2021-07-30 05:31
程序可以正常运行,为什么就是不显示窗口呢,
#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;
}
最佳答案
- 五星知识达人网友:痴妹与他
- 2021-07-30 06:00
#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);
}
全部回答
- 1楼网友:动情书生
- 2021-07-30 07:08
窗口过程里的默认项你没写
帮你写上了 也有注释
#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,"
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯