通常,要绘制一条线,我们在WM_PAINT中绘制它
LRESULT CALLBACK Display::DisplayWindowProc(HWND hWnd,UINT msg,WPARAM wParamm,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(msg)
{
case WM_PAINT:
hdc = BeginPaint(hWnd,&ps);
MoveToEx(hdc,0,0,0);
LineTo(hdc,100,100);
EndPaint(hWnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc( hWnd, msg, wParamm, lParam);
}
但是,我想随时画线,简单的例子:
int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR cmdLine,
int showCmd
)
{
//Do Other Things
Display dislpay;
display.DrawLine();
//Do Other Things
}
我的程序是面向对象的,我在 Display 类中显示东西,我想知道我是否可以在 Display 类中的 DrawLine() 之类的函数中画线。