![]() |
CMPT 212
Spring 1998
|
cout << "Hello";will not work. It does not specify:
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int X; int Y; char str[80]; switch (message) { ... case WM_LBUTTONDOWN : hdc = GetDC(hwnd); strcpy(str, "Here"); X = LOWORD(lParam); Y = HIWORD(lParam); TextOut(hdc, X, Y, str, strlen(str)); ReleaseDC(hwnd, hdc); break; ... } return 0; }
char buffer[10]; HDC hdc; TEXTMETRIC tm; int x = 1; int y = 1; hdc = GetDC(hwnd); GetTextMetrics(hdc, &tm); for (int i=0; i<=10; i++) { sprintf(buffer, "%d", i); TextOut(hdc, x, y, buffer, strlen(buffer)); y = y + tm.tmHeight + tm.tmExternalLeading; } ReleaseDC(hwnd, hdc);
HDC hdc; PAINTSTRUCT paintstruct; ... switch (message) { ... case WM_PAINT: hdc = BeginPaint(hwnd, &paintstruct); TextOut(hdc, 1, 1, str, strlen(str)); EndPaint(hwnd, &paintstruct); break; ... }
![]() Return to lecture notes index |
|
This page is maintained by simpson@cs.sfu.ca. | Last updated on 16 Mar 1998. |