1.10 int CALLBACK ModelessDlgProc(HWND hwnd, UINT message, |
2.10 WPARAM wParam, LPARAM lParam) |
3.10 static HDC hDC; |
4.10 PAINTSTRUCT ps; |
5.10 static HBRUSH g_hbrBackground; |
6.10 static int xChar, xCaps, yChar, xClient, yClient, xClientMax; |
7.10 static int xPos = 1, xMin = 1, xMax = 500, yPos, yMax; |
8.10 int x, y, iPaintBeg, iPaintEnd, yInc, temp, xPosOld; |
9.10 static const int NUMLINES = 2000; |
10.10 TEXTMETRIC tm; |
11.10 static char buf1000; |
12.10 static HFONT font; |
13.10 static LOGFONT lf; |
14.10 strcpy_s(lf.lfFaceName, "MS Sans Serif"); |
15.10 lf.lfHeight = 14; |
16.10 lf.lfWeight = FW_SEMIBOLD; |
17.10 switch(message) |
18.10 case WM_INITDIALOG: |
19.10 hModelessDlg = hwnd; |
20.10 g_hbrBackground = CreateSolidBrush(RGB(255, 255, 255)); |
21.10 hDC = GetDC(hwnd); |
22.10 GetTextMetrics(hDC, &tm); |
23.10 xChar = tm.tmAveCharWidth; |
24.10 xCaps =(tm.tmPitchAndFamily & 1 ? 3: 2) * xChar/2; |
25.10 yChar = tm.tmHeight + tm.tmExternalLeading; |
26.10 ReleaseDC(hwnd, hDC); |
27.10 break; |
28.10 case WM_CLOSE: |
29.10 DestroyWindow(hwnd); |
30.10 hModelessDlg = 0; |
31.10 break; |
32.10 case WM_CTLCOLORDLG: |
33.10 return (LONG)g_hbrBackground; |
34.10 case WM_SIZE: |
35.10 yClient = HIWORD(lParam); //retrieving the dimensions of |
36.10 xClient = LOWORD (lParam); // the client area |
37.10 yMax = max(0, NUMLINES + 2 - yClient/yChar); |
38.10 yPos = min(yPos, yMax); |
39.10 SetScrollRange(hwnd, SB_VERT, 0, NUMLINES, FALSE); |
40.10 SetScrollPos (hwnd, SB_VERT, yPos, TRUE); |
41.10 xPos= min(xPos, xMax); |
42.10 SetScrollRange(hwnd, SB_HORZ, xMin, xMax, TRUE); |
43.10 SetScrollPos(hwnd, SB_HORZ, xPos, TRUE); |
44.10 break; |