Hi
I would like to draw some lines using the MS Windows version of PolyML.
I have looked at the documentation for the Windows programming interface,
but I am unsure as to how to handle WM_PAINT, BeginPaint and EndPaint in
PolyML.
What I have in mind is something like the C code below.
Thanks
Pat Browne
#include <windows.h>
HWND g_hwndMain;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
int wmId, wmEvent;
RECT rect;
HDC hDC;
PAINTSTRUCT Ps;
HPEN hPen;
HFONT hFont;
switch (message)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &Ps);
hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
SelectObject(hDC, hPen);
MoveToEx(hDC, 0, 25, NULL);
LineTo(hDC, 240, 25);
EndPaint(hWnd, &Ps);
break;
case WM_KEYDOWN:
if( wParam == VK_ESCAPE )
{
DestroyWindow(hWnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = szWindowClass;
return RegisterClass(&wc);
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
TCHAR szWindowClass[MAX_PATH]; // The window class name
wcscpy(szWindowClass, TEXT("TITLE"));
MyRegisterClass(hInstance, szWindowClass);
g_hwndMain = CreateWindow(szWindowClass, TEXT("TITLE"), WS_EX_TOPMOST,
0, 0, 500, 500, NULL, NULL, hInstance, NULL);
ShowWindow(g_hwndMain , nCmdShow);
UpdateWindow(g_hwndMain);
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPTSTR
lpCmdLine,int nCmdShow)
{
MSG msg;
HACCEL hAccelTable;
ZeroMemory(&msg, sizeof(MSG));
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
// Main message loop:
while(msg.message != WM_QUIT)
{
PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}