GDI求助(为什么显示不了图形)

#include<windows.h>HDChDC;PAINTSTRUCTPs;HBRUSHNewBrush;HWNDhWnd;voidDrawContent(){hDC... #include <windows.h>

HDC hDC;
PAINTSTRUCT Ps;
HBRUSH NewBrush;
HWND hWnd;
void DrawContent()
{ hDC = BeginPaint(hWnd, &Ps);
POINT Pt[3];
NewBrush = CreateSolidBrush(RGB(0, 125, 5));
Pt[0].x = 125; Pt[0].y = 10;
Pt[1].x = 95; Pt[1].y = 70;
Pt[2].x = 155; Pt[2].y = 70;
SelectObject(hDC, NewBrush);
Polygon(hDC, Pt, 3);
DeleteObject(NewBrush);
EndPaint(hWnd, &Ps);}
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WndCls;
MSG Msg;
WndCls.cbSize = sizeof(WndCls);
WndCls.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
WndCls.lpfnWndProc = WindProcedure;
WndCls.cbClsExtra = 0;
WndCls.cbWndExtra = 0;
WndCls.hInstance = hInstance;
WndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndCls.hCursor = LoadCursor(NULL, IDC_ARROW);
WndCls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndCls.lpszMenuName = NULL;
WndCls.lpszClassName = TEXT("MAIN");
WndCls.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
RegisterClassEx(&WndCls);
CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,TEXT("MAIN"),TEXT( "GDI Brushes Fundamentals"),WS_OVERLAPPEDWINDOW | WS_VISIBLE,CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, NULL, NULL, hInstance, NULL);
while( GetMessage(&Msg, NULL, 0, 0) )
{TranslateMessage(&Msg);
DispatchMessage( &Msg);}
return static_cast<int>(Msg.wParam);}
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam)
{switch(Msg)
{
case WM_PAINT:
DrawContent();
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}return 0;}
为什么显示的总是白的没有内容的呢???
展开
 我来答
百度网友5c69cfc
2013-10-08 · TA获得超过238个赞
知道小有建树答主
回答量:325
采纳率:100%
帮助的人:227万
展开全部
全局变量 hWnd 没有设置

CreateWindowEx 前面加 hWnd=
hWnd=CreateWindowEx
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式