|
|
1.1.1.4 ! root 1: ! 2: /******************************************************************************\ ! 3: * This is a part of the Microsoft Source Code Samples. ! 4: * Copyright (C) 1993 Microsoft Corporation. ! 5: * All rights reserved. ! 6: * This source code is only intended as a supplement to ! 7: * Microsoft Development Tools and/or WinHelp documentation. ! 8: * See these sources for detailed information regarding the ! 9: * Microsoft samples programs. ! 10: \******************************************************************************/ ! 11: 1.1 root 12: /****************************** Module Header ******************************\ 13: * Module Name: memory.c 14: \***************************************************************************/ 15: 16: #include <stdlib.h> 17: 18: #include "memory.h" 19: #include <stdarg.h> 20: 21: extern CreateMapFile(); 22: extern CreateMap(); 23: extern MapView(); 24: extern OpenMap(); 25: 26: 27: HANDLE ghModule; 28: HWND ghwndMain = NULL; 29: 1.1.1.4 ! root 30: HMENU hMenu, hMenuWindow; 1.1 root 31: HMENU hServerMenu, hServerMenuWindow; 32: HMENU hClientMenu, hClientMenuWindow; 33: 34: CHAR gszFile[20]; 35: CHAR gszMapName[20]; 36: 37: 38: typedef struct _PerWndInfo { 39: // HWND hMainFrame; 40: HWND hParent; 1.1.1.4 ! root 41: HWND hThisWnd; // CR! used in locating the node ! 42: // LPVOID pShrMem1; // LATER! create more clients/servers 1.1 root 43: RECT rcClient; 44: char CaptionBarText[SIZEOFCAPTIONTEXT]; 45: } PERWNDINFO, *PPERWNDINFO; 46: 47: 48: typedef struct _node { 1.1.1.4 ! root 49: PERWNDINFO ChildWnd; ! 50: HANDLE hNext; 1.1 root 51: } NODE, *PNODE; 52: 53: 54: /* 55: * Forward declarations. 56: */ 57: BOOL InitializeApp (void); 1.1.1.3 root 58: LONG APIENTRY MainWndProc (HWND, UINT, DWORD, LONG); 59: LONG APIENTRY ServerWndProc (HWND, UINT, DWORD, LONG); 60: LONG APIENTRY ClientWndProc (HWND, UINT, DWORD, LONG); 1.1.1.4 ! root 61: BOOL CALLBACK About (HWND, UINT, DWORD, LONG); ! 62: BOOL CALLBACK FileType (HWND, UINT, DWORD, LONG); ! 63: BOOL CALLBACK MapFileName (HWND, UINT, DWORD, LONG); 1.1.1.3 root 64: LONG APIENTRY TextWndProc (HWND, UINT, DWORD, LONG); 1.1 root 65: 66: /***************************************************************************\ 67: * main 68: * 69: * 70: * History: 1.1.1.3 root 71: * 04-17-91 ???? Created. 1.1 root 72: \***************************************************************************/ 73: 1.1.1.3 root 74: int WINAPI WinMain( 1.1 root 75: HANDLE hInstance, 76: HANDLE hPrevInstance, 77: LPSTR lpCmdLine, 78: int nShowCmd) 79: { 80: MSG msg; 81: 82: // this will change to something more reasonable 83: 84: ghModule = GetModuleHandle(NULL); 85: if (!InitializeApp()) { 1.1.1.4 ! root 86: MessageBox(ghwndMain, "memory: InitializeApp failure!", "Error", MB_OK); 1.1 root 87: return 0; 88: } 89: 90: while (GetMessage(&msg, NULL, 0, 0)) { 91: TranslateMessage(&msg); 92: DispatchMessage(&msg); 93: } 94: 95: if (hMenuWindow && IsWindow(hMenuWindow)) 1.1.1.4 ! root 96: DestroyMenu(hMenuWindow); 1.1 root 97: if (hClientMenuWindow && IsWindow(hClientMenuWindow)) 1.1.1.4 ! root 98: DestroyMenu(hClientMenuWindow); 1.1 root 99: if (hServerMenuWindow && IsWindow(hServerMenuWindow)) 1.1.1.4 ! root 100: DestroyMenu(hServerMenuWindow); 1.1 root 101: if (hMenu && IsWindow(hMenu)) 1.1.1.4 ! root 102: DestroyMenu(hMenu); 1.1 root 103: if (hClientMenu && IsWindow(hClientMenu)) 1.1.1.4 ! root 104: DestroyMenu(hClientMenu); 1.1 root 105: if (hServerMenu && IsWindow(hServerMenu)) 1.1.1.4 ! root 106: DestroyMenu(hServerMenu); 1.1 root 107: 108: return 1; 109: 110: UNREFERENCED_PARAMETER(lpCmdLine); 111: UNREFERENCED_PARAMETER(nShowCmd); 112: UNREFERENCED_PARAMETER(hInstance); 113: UNREFERENCED_PARAMETER(hPrevInstance); 114: } 115: 116: 117: /***************************************************************************\ 118: * InitializeApp 119: * 120: * History: 1.1.1.4 ! root 121: * 09-09-91 Petrus Wong Created. 1.1 root 122: \***************************************************************************/ 123: 124: BOOL InitializeApp(void) 125: { 126: WNDCLASS wc; 127: 128: wc.style = CS_OWNDC; 1.1.1.4 ! root 129: wc.lpfnWndProc = (WNDPROC)MainWndProc; 1.1 root 130: wc.cbClsExtra = 0; 1.1.1.4 ! root 131: wc.cbWndExtra = sizeof(LONG); 1.1 root 132: wc.hInstance = ghModule; 133: wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 134: wc.hCursor = LoadCursor(NULL, IDC_ARROW); 1.1.1.4 ! root 135: wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE); 1.1 root 136: wc.lpszMenuName = "MainMenu"; 1.1.1.4 ! root 137: wc.lpszClassName = "MemoryClass"; 1.1 root 138: 139: if (!RegisterClass(&wc)) 1.1.1.4 ! root 140: return FALSE; 1.1 root 141: 1.1.1.4 ! root 142: wc.style = CS_OWNDC; ! 143: wc.lpfnWndProc = (WNDPROC)ServerWndProc; 1.1 root 144: wc.cbClsExtra = 0; 1.1.1.4 ! root 145: wc.cbWndExtra = 0; // LATER sizeof(LONG); 1.1 root 146: wc.hInstance = ghModule; 147: wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 148: wc.hCursor = LoadCursor(NULL, IDC_ARROW); 1.1.1.4 ! root 149: wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE); ! 150: wc.lpszMenuName = NULL; ! 151: wc.lpszClassName = "ServerClass"; 1.1 root 152: 153: if (!RegisterClass(&wc)) 154: return FALSE; 155: 1.1.1.4 ! root 156: wc.style = CS_OWNDC; ! 157: wc.lpfnWndProc = (WNDPROC)ClientWndProc; 1.1 root 158: wc.cbClsExtra = 0; 1.1.1.4 ! root 159: wc.cbWndExtra = 0; // LATER sizeof(LONG); 1.1 root 160: wc.hInstance = ghModule; 161: wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 162: wc.hCursor = LoadCursor(NULL, IDC_ARROW); 1.1.1.4 ! root 163: wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE); ! 164: wc.lpszMenuName = NULL; ! 165: wc.lpszClassName = "ClientClass"; 1.1 root 166: 167: if (!RegisterClass(&wc)) 1.1.1.4 ! root 168: return FALSE; 1.1 root 169: 1.1.1.4 ! root 170: wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; ! 171: wc.lpfnWndProc = (WNDPROC)TextWndProc; ! 172: wc.cbClsExtra = 0; ! 173: wc.cbWndExtra = 0; 1.1 root 174: wc.hInstance = ghModule; 1.1.1.4 ! root 175: wc.hIcon = NULL; 1.1 root 176: wc.hCursor = LoadCursor(NULL, IDC_ARROW); 1.1.1.4 ! root 177: wc.hbrBackground = (HBRUSH)(COLOR_BTNSHADOW); ! 178: wc.lpszMenuName = NULL; ! 179: wc.lpszClassName = "Text"; 1.1 root 180: 181: if (!RegisterClass(&wc)) 182: return FALSE; 183: 184: 185: 1.1.1.4 ! root 186: hMenu = LoadMenu(ghModule, "MainMenu"); 1.1 root 187: hServerMenu = LoadMenu(ghModule, "ServerMenu"); 188: hClientMenu = LoadMenu(ghModule, "ClientMenu"); 189: hMenuWindow = GetSubMenu(hMenu, 1); 190: hServerMenuWindow = GetSubMenu(hServerMenu, 2); 191: hClientMenuWindow = GetSubMenu(hClientMenu, 2); 192: 193: ghwndMain = CreateWindowEx(0L, "MemoryClass", "Memory", 1.1.1.4 ! root 194: WS_OVERLAPPED | WS_CAPTION | WS_BORDER | ! 195: WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | ! 196: WS_CLIPCHILDREN | WS_VISIBLE | WS_SYSMENU, 1.1 root 197: 80, 70, 400, 300, 1.1.1.4 ! root 198: NULL, hMenu, ghModule, NULL); 1.1 root 199: 200: if (ghwndMain == NULL) 1.1.1.4 ! root 201: return FALSE; 1.1 root 202: 203: SetWindowLong(ghwndMain, GWL_USERDATA, 0L); 204: 1.1.1.3 root 205: //SetFocus(ghwndMain); /* set initial focus */ 1.1 root 206: 207: return TRUE; 208: } 209: 210: 211: /***************************************************************************\ 212: * MainWndProc 213: * 214: * History: 1.1.1.4 ! root 215: * 09-09-91 Petrus Wong Created. 1.1 root 216: \***************************************************************************/ 217: 1.1.1.3 root 218: long APIENTRY MainWndProc( 1.1 root 219: HWND hwnd, 220: UINT message, 221: DWORD wParam, 222: LONG lParam) 223: { 1.1.1.4 ! root 224: static int iSvrCount=1; ! 225: static int iCltCount=1; 1.1 root 226: CLIENTCREATESTRUCT clientcreate; 227: HWND hwndChildWindow; 228: 229: 230: switch (message) { 231: 232: case WM_CREATE: 1.1.1.4 ! root 233: SetWindowLong(hwnd, 0, (LONG)NULL); 1.1 root 234: 1.1.1.4 ! root 235: clientcreate.hWindowMenu = hMenuWindow; ! 236: clientcreate.idFirstChild = 1; 1.1 root 237: 1.1.1.4 ! root 238: ghwndClient = CreateWindow("MDICLIENT", NULL, ! 239: WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, ! 240: 0,0,0,0, ! 241: hwnd, NULL, ghModule, (LPVOID)&clientcreate); ! 242: return 0L; 1.1 root 243: 244: case WM_DESTROY: { 1.1.1.4 ! root 245: PostQuitMessage(0); ! 246: return 0L; 1.1 root 247: } 248: 249: case WM_COMMAND: 250: 1.1.1.4 ! root 251: switch (LOWORD(wParam)) { ! 252: case IDM_TILE: ! 253: SendMessage(ghwndClient, WM_MDITILE, 0L, 0L); ! 254: return 0L; ! 255: case IDM_CASCADE: ! 256: SendMessage(ghwndClient, WM_MDICASCADE, 0L, 0L); ! 257: return 0L; ! 258: case IDM_ARRANGE: ! 259: SendMessage(ghwndClient, WM_MDIICONARRANGE, 0L, 0L); ! 260: return 0L; ! 261: ! 262: case MM_SERVER: { ! 263: HANDLE hNode, hHead; ! 264: PNODE pNode; 1.1 root 265: MDICREATESTRUCT mdicreate; 266: 1.1.1.4 ! root 267: hNode = LocalAlloc(LHND, (WORD) sizeof(NODE)); ! 268: if (hNode) { ! 269: if ((pNode = (PNODE)LocalLock(hNode)) == NULL) ! 270: MessageBox(ghwndMain, "Failed in LocalLock, hNode", "Error", MB_OK); ! 271: ! 272: wsprintf((LPSTR) &(pNode->ChildWnd.CaptionBarText), ! 273: "Server %d", iSvrCount); ! 274: ! 275: mdicreate.szClass = "ServerClass"; ! 276: mdicreate.szTitle = (LPTSTR)&(pNode->ChildWnd.CaptionBarText); ! 277: mdicreate.hOwner = ghModule; ! 278: mdicreate.x = ! 279: mdicreate.y = ! 280: mdicreate.cx = ! 281: mdicreate.cy = CW_USEDEFAULT; ! 282: mdicreate.style = 0l; ! 283: mdicreate.lParam = 0L; ! 284: ! 285: /*Create Child Window*/ ! 286: hwndChildWindow = ! 287: (HANDLE) SendMessage(ghwndClient, WM_MDICREATE, ! 288: 0L, ! 289: (LONG)(LPMDICREATESTRUCT)&mdicreate); ! 290: ! 291: if (hwndChildWindow == NULL) { ! 292: MessageBox(ghwndMain, "Failed in Creating Child Window", "Error", MB_OK); ! 293: return 0L; ! 294: } ! 295: ! 296: pNode->ChildWnd.hParent = ghwndClient; ! 297: pNode->ChildWnd.hThisWnd = hwndChildWindow; ! 298: hHead = (HANDLE)GetWindowLong(hwnd, 0); ! 299: pNode->hNext = hHead; ! 300: SetWindowLong(hwnd, 0, (LONG) hNode); ! 301: ! 302: iSvrCount++; ! 303: ! 304: ! 305: LocalUnlock(hNode); ! 306: } else { ! 307: MessageBox(ghwndMain, "Failed to Allocate Node!", "Error", MB_OK); ! 308: } ! 309: return 0L; ! 310: } ! 311: ! 312: case MM_CLIENT: { ! 313: HANDLE hNode, hHead; ! 314: PNODE pNode; 1.1 root 315: MDICREATESTRUCT mdicreate; 316: 1.1.1.4 ! root 317: hNode = LocalAlloc(LHND, (WORD) sizeof(NODE)); ! 318: if (hNode) { ! 319: if ((pNode = (PNODE)LocalLock(hNode))==NULL) ! 320: MessageBox(ghwndMain, "Failed in LocalLock, hNode!", "Error", MB_OK); ! 321: ! 322: wsprintf((LPSTR) &(pNode->ChildWnd.CaptionBarText), ! 323: "Client %d", iCltCount); ! 324: ! 325: mdicreate.szClass = "ClientClass"; ! 326: mdicreate.szTitle = (LPSTR) &(pNode->ChildWnd.CaptionBarText); ! 327: mdicreate.hOwner = ghModule; ! 328: mdicreate.x = ! 329: mdicreate.y = ! 330: mdicreate.cx = ! 331: mdicreate.cy = CW_USEDEFAULT; ! 332: mdicreate.style = 0l; ! 333: mdicreate.lParam = 0L; ! 334: ! 335: /*Create Child Window*/ ! 336: hwndChildWindow = ! 337: (HANDLE) SendMessage(ghwndClient, WM_MDICREATE, ! 338: 0L, ! 339: (LONG)(LPMDICREATESTRUCT)&mdicreate); ! 340: ! 341: if (hwndChildWindow == NULL) { ! 342: MessageBox(ghwndMain, "Failed in Creating Child Window!", "Error", MB_OK); ! 343: return 0L; ! 344: } ! 345: ! 346: pNode->ChildWnd.hParent = ghwndClient; ! 347: pNode->ChildWnd.hThisWnd = hwndChildWindow; ! 348: hHead = (HANDLE)GetWindowLong(hwnd, 0); ! 349: pNode->hNext = hHead; ! 350: SetWindowLong(hwnd, 0, (LONG) hNode); ! 351: ! 352: iCltCount++; ! 353: ! 354: LocalUnlock(hNode); ! 355: ! 356: } else { ! 357: MessageBox(ghwndMain, "Failed to Allocate Node!", "Error", MB_OK); ! 358: } ! 359: return 0L; ! 360: } ! 361: ! 362: case MM_ABOUT: ! 363: if (DialogBox(ghModule, "AboutBox", ghwndMain, (DLGPROC)About) == -1) ! 364: MessageBox(ghwndMain, "DEMO: About Dialog Creation Error!", "Error", MB_OK); ! 365: return 0L; ! 366: ! 367: case MM_OPT_1: ! 368: case MM_OPT_2: ! 369: case MM_OPT_3: ! 370: case MM_OPT_4: ! 371: case MM_OPT_5: ! 372: case MM_OPT_6: ! 373: case MM_OPT_7: ! 374: case MM_OPT_8: { ! 375: HWND hActiveChild; ! 376: ! 377: hActiveChild = (HANDLE) SendMessage(ghwndClient, WM_MDIGETACTIVE, 0L, 0L); ! 378: if (hActiveChild) ! 379: SendMessage(hActiveChild, WM_COMMAND, wParam, lParam); ! 380: return 0L; ! 381: } 1.1 root 382: 1.1.1.4 ! root 383: default: ! 384: return DefFrameProc(hwnd, ghwndClient, message, wParam, lParam); 1.1 root 385: } 386: 387: default: 388: 1.1.1.4 ! root 389: return DefFrameProc(hwnd, ghwndClient, message, wParam, lParam); 1.1 root 390: } 391: } 392: 393: /********************************************************************\ 394: * ServerWndProc 395: * 396: * History: 1.1.1.3 root 397: * 04-17-91 ???? Created. 1.1.1.4 ! root 398: * 09-09-91 Petrus Wong Rewrote. 1.1 root 399: \***************************************************************************/ 400: 1.1.1.3 root 401: long APIENTRY ServerWndProc( 1.1 root 402: HWND hwnd, 403: UINT message, 404: DWORD wParam, 405: LONG lParam) 406: { 407: static HANDLE MapFileHandle = NULL; 1.1.1.4 ! root 408: static HANDLE hMem1 = NULL; ! 409: static LPVOID pShrMem1 = NULL; 1.1 root 410: static HANDLE hEdit; 1.1.1.4 ! root 411: static BOOL bDirty = FALSE; ! 412: static HWND hTextWnd; 1.1 root 413: 414: switch (message) { 1.1.1.4 ! root 415: case WM_COMMAND: { ! 416: ! 417: switch (LOWORD(wParam)) { ! 418: case MM_OPT_1: { //Create File 1.1 root 419: 1.1.1.4 ! root 420: SetWindowText(hTextWnd, "Creating Map File"); ! 421: switch (DialogBox(ghModule, "FileType", hwnd, (DLGPROC)FileType)) { ! 422: case -1: ! 423: MessageBox(ghwndMain, "Server: File dialog box creation failed!", "Error", MB_OK); ! 424: SetWindowText(hTextWnd, "File dialog box creation failed"); ! 425: break; ! 426: case IDBTN_MAP: ! 427: if ((MapFileHandle = (HANDLE) CreateMapFile(gszFile)) == (HANDLE)NULL) { ! 428: MessageBox(ghwndMain, "Server: CreateMapFile() failed!", "Error", MB_OK); ! 429: SetWindowText(hTextWnd, "Map File creation failed"); ! 430: } ! 431: else { ! 432: SetWindowText(hTextWnd, "Select 'Create File Mapping...'"); ! 433: } ! 434: break; ! 435: default: ! 436: MapFileHandle = (HANDLE) 0xFFFFFFFF; ! 437: EnableMenuItem(hServerMenu, MM_OPT_2, MF_ENABLED); ! 438: break; ! 439: } ! 440: return 0L; ! 441: } ! 442: case MM_OPT_2: { //Create File Mapping ! 443: ! 444: SetWindowText(hTextWnd, "Creating File Mapping"); ! 445: if (MapFileHandle != NULL ) { ! 446: switch (DialogBox(ghModule, "MapName", hwnd, (DLGPROC)MapFileName)) { ! 447: case -1: ! 448: MessageBox(ghwndMain, "Server: Map dialog box creation failed!", "Error", MB_OK); ! 449: SetWindowText(hTextWnd, "Map dialog box creation failed"); ! 450: break; ! 451: case IDBTN_OK: ! 452: if ((hMem1 = (HANDLE) CreateMap((HANDLE *) &MapFileHandle, gszMapName) ) == (HANDLE)NULL) { ! 453: MessageBox(ghwndMain, "Server: CreateMap() failed!", "Error", MB_OK); ! 454: SetWindowText(hTextWnd, "File Mapping creation failed"); ! 455: } ! 456: else { ! 457: EnableMenuItem(hServerMenu, MM_OPT_3, MF_ENABLED); ! 458: SetWindowText(hTextWnd, "Select 'Map View of File'"); ! 459: } ! 460: break; ! 461: default: ! 462: break; ! 463: } ! 464: } else { ! 465: MessageBox(ghwndMain, "Server: MapFileHandle is NULL!", "Error", MB_OK); ! 466: SetWindowText(hTextWnd, "Advice: Create server file first"); ! 467: } ! 468: return 0L; ! 469: } ! 470: case MM_OPT_3: { //Map View of File ! 471: SetWindowText(hTextWnd, "Mapping view of File"); ! 472: if (hMem1) { ! 473: if ((pShrMem1 = (LPVOID)MapView(&hMem1)) == (LPVOID)NULL) { ! 474: MessageBox(ghwndMain, "Server: MapView() failed!", "Error", MB_OK); ! 475: SetWindowText(hTextWnd, "Map view of File failed"); ! 476: } ! 477: else { ! 478: EnableMenuItem(hServerMenu, MM_OPT_4, MF_ENABLED); ! 479: SetWindowText(hTextWnd, "Select 'Access' to enter text"); ! 480: } ! 481: } else { ! 482: MessageBox(ghwndMain, "Server: Mapping view of File Failed!", "Error", MB_OK); ! 483: SetWindowText(hTextWnd, "Advice: Create File Mapping First"); ! 484: } ! 485: return 0L; ! 486: } ! 487: case MM_OPT_4: { //Access ! 488: RECT rcl; ! 489: ! 490: SetWindowText(hTextWnd, "Accessing Server for writing"); ! 491: ! 492: if (pShrMem1) { ! 493: GetClientRect(hwnd, &rcl); ! 494: hEdit = CreateWindow("edit", (LPSTR) NULL, ! 495: WS_CHILD | WS_VISIBLE | WS_HSCROLL | ! 496: WS_VSCROLL | WS_BORDER | ES_LEFT | ! 497: ES_MULTILINE | ES_AUTOHSCROLL | ! 498: ES_AUTOVSCROLL, ! 499: 0,0, rcl.right-rcl.left, ! 500: rcl.bottom-rcl.top-GetWindowLong(hTextWnd, GWL_USERDATA), ! 501: hwnd, (HMENU)1, ghModule, (LPVOID)NULL); ! 502: if (hEdit) { ! 503: SetFocus(hEdit); ! 504: } else { ! 505: MessageBox(ghwndMain, "Server: Create MLE failed!", "Error", MB_OK); ! 506: SetWindowText(hTextWnd, "Failed to create MLE"); ! 507: } ! 508: } else { ! 509: MessageBox(ghwndMain, "Server: Accessing for writing Failed!", "Error", MB_OK); ! 510: SetWindowText(hTextWnd, "Advice: Map view of File First"); ! 511: } ! 512: ! 513: return 0L; ! 514: } ! 515: ! 516: } ! 517: ! 518: switch (HIWORD(wParam)) { ! 519: case EN_UPDATE: { ! 520: if ((hEdit != NULL) && (hEdit == (HANDLE)lParam) ) { ! 521: bDirty = TRUE; ! 522: } ! 523: return 0L; ! 524: } ! 525: } ! 526: ! 527: } ! 528: case WM_TIMER: ! 529: if (bDirty && hEdit) { ! 530: ! 531: // ! 532: // EM_GETHANDLE doesn't work for Win32s ! 533: // ! 534: #if 0 ! 535: HANDLE hBuf; ! 536: BYTE * pBuf; ! 537: ! 538: hBuf = (HANDLE) SendMessage(hEdit, EM_GETHANDLE, 0L, 0L); ! 539: if (hBuf) { ! 540: if ((pBuf = (BYTE *)LocalLock(hBuf)) == NULL) { ! 541: MessageBox(ghwndMain, "Can't get at Edit Control's data!", "Error", MB_OK); ! 542: } else { ! 543: strncpy(pShrMem1, pBuf, strlen(pBuf)+1); ! 544: bDirty = FALSE; ! 545: } ! 546: LocalUnlock(hBuf); ! 547: } else { ! 548: MessageBox(ghwndMain, "Failed in SendMessage EM_GETHANDLE!", "Error", MB_OK); ! 549: } ! 550: #endif ! 551: ! 552: // so use WM_GETTEXT instead... ! 553: ! 554: int iCnt; ! 555: ! 556: if (iCnt) { ! 557: iCnt = SendMessage(hEdit, WM_GETTEXT, (WPARAM)4000, (LPARAM)pShrMem1); ! 558: bDirty = FALSE; ! 559: } ! 560: ! 561: } ! 562: return 0L; 1.1 root 563: 1.1.1.4 ! root 564: case WM_SETFOCUS: ! 565: //if (hEdit) ! 566: //SetFocus(hEdit); ! 567: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 568: ! 569: case WM_MDIACTIVATE: ! 570: if ((HWND) lParam == hwnd) { ! 571: SendMessage(GetParent(hwnd), WM_MDISETMENU, ! 572: (DWORD) hServerMenu, ! 573: (LONG) hServerMenuWindow) ; ! 574: DrawMenuBar(GetParent(GetParent(hwnd))) ; ! 575: //SetFocus(hEdit); ! 576: } ! 577: return 0; ! 578: ! 579: case WM_SIZE: ! 580: if (hEdit) ! 581: MoveWindow(hEdit, 0, 0, ! 582: LOWORD(lParam), ! 583: HIWORD(lParam)-GetWindowLong(hTextWnd, GWL_USERDATA), ! 584: TRUE); ! 585: MoveWindow(hTextWnd, ! 586: 0, ! 587: HIWORD(lParam) - GetWindowLong(hTextWnd, GWL_USERDATA), ! 588: LOWORD(lParam), ! 589: HIWORD(lParam), TRUE); ! 590: ! 591: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 592: ! 593: case WM_CREATE: { ! 594: PPERWNDINFO pWndInfo; ! 595: PNODE pHead; ! 596: HANDLE hHead, hTmp; ! 597: RECT rect; ! 598: ! 599: GetClientRect(hwnd, &rect); ! 600: hTextWnd = CreateWindow("Text", NULL, ! 601: WS_BORDER | SS_LEFT | WS_CHILD | WS_VISIBLE, ! 602: 0, 0, 0, 0, ! 603: hwnd, ! 604: (HMENU) 2, ! 605: ghModule, ! 606: NULL); ! 607: ! 608: SetWindowText(hTextWnd, "Select 'Create File...'"); ! 609: ! 610: // now find match ! 611: hHead = (HANDLE) GetWindowLong(ghwndMain, 0); ! 612: if (hHead) { ! 613: if ((pHead = (PNODE)LocalLock(hHead))==NULL) ! 614: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK); ! 615: ! 616: while ((pHead->ChildWnd.hThisWnd != hwnd) && ! 617: (pHead->hNext != NULL)) { ! 618: hTmp = hHead; ! 619: hHead = pHead->hNext; ! 620: LocalUnlock(hTmp); ! 621: if ((pHead = (PNODE) LocalLock(hHead))==NULL) ! 622: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK); ! 623: } ! 624: if (pHead->ChildWnd.hThisWnd == hwnd) { ! 625: pWndInfo = &pHead->ChildWnd; ! 626: goto Wnd_Found; ! 627: } else { ! 628: //MessageBox(ghwndMain, "Trouble - Can't find the node!", "Error", MB_OK); ! 629: goto Wnd_Out; ! 630: } 1.1 root 631: 632: Wnd_Found: 1.1.1.4 ! root 633: if (!GetClientRect(pWndInfo->hThisWnd, ! 634: &pWndInfo->rcClient)) ! 635: MessageBox(ghwndMain, "Failed in GetClientRect!", "Error", MB_OK); 1.1 root 636: Wnd_Out: 1.1.1.4 ! root 637: LocalUnlock(hHead); ! 638: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 639: } else { ! 640: //MessageBox(ghwndMain, "Can't GetWindowLong(ghwndMain,0)!", "Error", MB_OK); ! 641: } return DefMDIChildProc(hwnd, message, wParam, lParam); ! 642: ! 643: } ! 644: ! 645: case WM_CLOSE: { ! 646: PPERWNDINFO pWndInfo; ! 647: PNODE pHead, pTrail; ! 648: HANDLE hHead, hTmp; ! 649: ! 650: SendMessage(GetParent(hwnd), WM_MDISETMENU, ! 651: (DWORD) hMenu, ! 652: (LONG) hMenuWindow) ; ! 653: DrawMenuBar(GetParent(GetParent(hwnd))) ; ! 654: ! 655: ! 656: // now find match ! 657: hHead = (HANDLE) GetWindowLong(ghwndMain, 0); ! 658: if (hHead) { ! 659: if ((pHead = (PNODE)LocalLock(hHead))==NULL) ! 660: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK); ! 661: ! 662: pTrail = pHead; ! 663: while ((pHead->ChildWnd.hThisWnd != hwnd) && ! 664: (pHead->hNext != NULL)) { ! 665: hTmp = hHead; ! 666: pTrail = pHead; ! 667: hHead = pHead->hNext; ! 668: LocalUnlock(hTmp); ! 669: if ((pHead = (PNODE) LocalLock(hHead))==NULL) ! 670: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK); ! 671: } ! 672: if (pHead->ChildWnd.hThisWnd == hwnd) { ! 673: pWndInfo = &pHead->ChildWnd; ! 674: goto Wnd_Found1; ! 675: } else { ! 676: //MessageBox(ghwndMain, "Trouble - Can't find the thread node!", "Error", MB_OK); ! 677: goto Wnd_Out1; ! 678: } ! 679: ! 680: Wnd_Found1: if (pTrail == pHead) ! 681: SetWindowLong(ghwndMain, 0, (LONG) pHead->hNext); ! 682: else ! 683: pTrail->hNext = pHead->hNext; ! 684: ! 685: //if (!LocalUnlock(hHead)) { ! 686: LocalFree(hHead); ! 687: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 688: //} 1.1 root 689: Wnd_Out1: 1.1.1.4 ! root 690: LocalUnlock(hHead); ! 691: } else { ! 692: //MessageBox(ghwndMain, "Can't GetWindowLong(ghwndMain,0) !", "Error", MB_OK); ! 693: } ! 694: return DefMDIChildProc(hwnd, message, wParam, lParam); 1.1 root 695: 1.1.1.4 ! root 696: } ! 697: ! 698: case WM_DESTROY: ! 699: KillTimer(hwnd, 1); ! 700: return 0L; 1.1 root 701: 1.1.1.4 ! root 702: case WM_PAINT: ! 703: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 704: ! 705: default: ! 706: return DefMDIChildProc(hwnd, message, wParam, lParam); 1.1 root 707: } 708: 709: } 710: 711: /********************************************************************\ 712: * ClientWndProc 713: * 714: * History: 1.1.1.3 root 715: * 04-17-91 ???? Created. 1.1.1.4 ! root 716: * 09-09-91 Petrus Wong Rewrote. 1.1 root 717: \***************************************************************************/ 718: 1.1.1.3 root 719: long APIENTRY ClientWndProc( 1.1 root 720: HWND hwnd, 721: UINT message, 722: DWORD wParam, 723: LONG lParam) 724: { 725: static HANDLE hMem1 = NULL; 726: static LPVOID pShrMem1 = NULL; 727: static HANDLE hEdit; 728: static HANDLE hTextWnd; 729: 730: switch (message) { 1.1.1.4 ! root 731: case WM_COMMAND: { ! 732: ! 733: switch (LOWORD(wParam)) { ! 734: case MM_OPT_5: { //Open File Mapping ! 735: SetWindowText(hTextWnd, "Opening Mapping File"); ! 736: switch (DialogBox(ghModule, "MapName", hwnd, (DLGPROC)MapFileName)) { ! 737: case -1: ! 738: MessageBox(ghwndMain, "Client: Map dialog box creation failed!", "Error", MB_OK); ! 739: break; ! 740: case IDBTN_OK: ! 741: if ((hMem1 = (HANDLE) OpenMap(gszMapName)) == (HANDLE)NULL) { ! 742: MessageBox(ghwndMain, "Client: Open File Mapping failed!", "Error", MB_OK); ! 743: SetWindowText(hTextWnd, "Advice: Make sure Map file is created on Server"); ! 744: } else { ! 745: EnableMenuItem(hClientMenu, MM_OPT_6, MF_ENABLED); ! 746: SetWindowText(hTextWnd, "Select 'Map View of File'"); ! 747: } ! 748: break; ! 749: default: ! 750: break; ! 751: } ! 752: return 0L; ! 753: } ! 754: case MM_OPT_6: { //Map View of File ! 755: SetWindowText(hTextWnd, "Mapping view of File"); ! 756: if (hMem1) { ! 757: if ((pShrMem1 = (LPVOID) MapView(&hMem1)) == (LPVOID)NULL) ! 758: MessageBox(ghwndMain, "Client: MapView() failed!", "Error", MB_OK); ! 759: else { ! 760: EnableMenuItem(hClientMenu, MM_OPT_7, MF_ENABLED); ! 761: SetWindowText(hTextWnd, "Select 'Access' for reading Server "); ! 762: } ! 763: } else { ! 764: MessageBox(ghwndMain, "Client: Mapping view of File Failed!", "Error", MB_OK); ! 765: SetWindowText(hTextWnd, "Advice: Open File Mapping first"); ! 766: } ! 767: return 0L; ! 768: } ! 769: case MM_OPT_7: { //Access ! 770: RECT rcl; ! 771: ! 772: SetWindowText(hTextWnd, "Accessing Server for reading"); ! 773: if (pShrMem1) { ! 774: GetClientRect(hwnd, &rcl); ! 775: ! 776: hEdit = CreateWindow("edit", NULL, ! 777: WS_CHILD | WS_VISIBLE | WS_HSCROLL | ! 778: WS_VSCROLL | WS_BORDER | ES_LEFT | ! 779: ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | ! 780: ES_AUTOVSCROLL, ! 781: 0,0, rcl.right-rcl.left, ! 782: rcl.bottom-rcl.top-GetWindowLong(hTextWnd, GWL_USERDATA), ! 783: hwnd, (HMENU) 1, ghModule, NULL); ! 784: if (hEdit) { ! 785: //SetFocus(hEdit); ! 786: SendMessage(hEdit, WM_SETTEXT, 0L, (LONG)pShrMem1); ! 787: SetTimer(hwnd, 2, 10000, NULL); ! 788: EnableMenuItem(hClientMenu, MM_OPT_8, MF_ENABLED); ! 789: } else { ! 790: MessageBox(ghwndMain, "Client: Create MLE failed!", "Error", MB_OK); ! 791: } ! 792: } else { ! 793: MessageBox(ghwndMain, "Client: Accessing for reading Failed!", "Error", MB_OK); ! 794: SetWindowText(hTextWnd, "Advice: Map View of File first"); ! 795: } ! 796: ! 797: return 0L; ! 798: } ! 799: ! 800: case MM_OPT_8: { // refresh now ! 801: HANDLE hActive; ! 802: ! 803: hActive = (HANDLE) SendMessage(GetParent(hwnd), WM_MDIGETACTIVE, 0L, 0L); ! 804: SendMessage(hEdit, WM_SETTEXT, 0L, (LONG)pShrMem1); ! 805: //SetFocus(hActive); ! 806: return 0L; ! 807: } ! 808: } ! 809: } ! 810: case WM_SETFOCUS: ! 811: //if (hEdit) ! 812: //SetFocus(hEdit); ! 813: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 814: ! 815: case WM_TIMER: { ! 816: HANDLE hActive; ! 817: ! 818: if (hEdit) { ! 819: hActive = (HANDLE) SendMessage(GetParent(hwnd), WM_MDIGETACTIVE, 0L, 0L); ! 820: SendMessage(hEdit, WM_SETTEXT, 0L, (LONG)pShrMem1); ! 821: //SetFocus(hActive); ! 822: } ! 823: return 0L; ! 824: } 1.1 root 825: 1.1.1.4 ! root 826: case WM_MDIACTIVATE: ! 827: if ((HWND) lParam == hwnd) { ! 828: SendMessage(GetParent(hwnd), WM_MDISETMENU, ! 829: (DWORD) hClientMenu, ! 830: (LONG) hClientMenuWindow) ; ! 831: DrawMenuBar(GetParent(GetParent(hwnd))) ; ! 832: //SetFocus(hEdit); ! 833: } ! 834: return 0; ! 835: ! 836: case WM_SIZE: ! 837: if (hEdit) ! 838: MoveWindow(hEdit, 0, 0, ! 839: LOWORD(lParam), ! 840: HIWORD(lParam)-GetWindowLong(hTextWnd, GWL_USERDATA), ! 841: TRUE); ! 842: MoveWindow(hTextWnd, ! 843: 0, ! 844: HIWORD(lParam) - GetWindowLong(hTextWnd, GWL_USERDATA), ! 845: LOWORD(lParam), ! 846: HIWORD(lParam), TRUE); ! 847: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 848: ! 849: case WM_CREATE: { ! 850: PPERWNDINFO pWndInfo; ! 851: PNODE pHead; ! 852: HANDLE hHead, hTmp; ! 853: RECT rect; ! 854: ! 855: GetClientRect(hwnd, &rect); ! 856: hTextWnd = CreateWindow("Text", NULL, ! 857: WS_BORDER | SS_LEFT | WS_CHILD | WS_VISIBLE, ! 858: 0, 0, 0, 0, ! 859: hwnd, ! 860: (HMENU) 2, ! 861: ghModule, ! 862: NULL); ! 863: ! 864: SetWindowText(hTextWnd, "Select 'Open File...'"); ! 865: ! 866: // now find match ! 867: hHead = (HANDLE) GetWindowLong(ghwndMain, 0); ! 868: if (hHead) { ! 869: if ((pHead = (PNODE)LocalLock(hHead))==NULL) ! 870: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK); ! 871: ! 872: while ((pHead->ChildWnd.hThisWnd != hwnd) && ! 873: (pHead->hNext != NULL)) { ! 874: hTmp = hHead; ! 875: hHead = pHead->hNext; ! 876: LocalUnlock(hTmp); ! 877: if ((pHead = (PNODE) LocalLock(hHead))==NULL) ! 878: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK); ! 879: } ! 880: if (pHead->ChildWnd.hThisWnd == hwnd) { ! 881: pWndInfo = &pHead->ChildWnd; ! 882: goto Wnd_Found; ! 883: } else { ! 884: //MessageBox(ghwndMain, "Trouble - Can't find the node!", "Error", MB_OK); ! 885: goto Wnd_Out; ! 886: } 1.1 root 887: 888: Wnd_Found: 1.1.1.4 ! root 889: if (!GetClientRect(pWndInfo->hThisWnd, ! 890: &pWndInfo->rcClient)) ! 891: MessageBox(ghwndMain, "Failed in GetClientRect!", "Error", MB_OK); 1.1 root 892: Wnd_Out: 1.1.1.4 ! root 893: LocalUnlock(hHead); ! 894: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 895: } else { ! 896: //MessageBox(ghwndMain, "Can't GetWindowLong(ghwndMain,0) !", "Error", MB_OK); ! 897: } return DefMDIChildProc(hwnd, message, wParam, lParam); ! 898: ! 899: } ! 900: ! 901: case WM_CLOSE: { ! 902: PPERWNDINFO pWndInfo; ! 903: PNODE pHead, pTrail; ! 904: HANDLE hHead, hTmp; ! 905: ! 906: SendMessage(GetParent(hwnd), WM_MDISETMENU, ! 907: (DWORD) hMenu, ! 908: (LONG) hMenuWindow) ; ! 909: DrawMenuBar(GetParent(GetParent(hwnd))) ; ! 910: ! 911: ! 912: // now find match ! 913: hHead = (HANDLE) GetWindowLong(ghwndMain, 0); ! 914: if (hHead) { ! 915: if ((pHead = (PNODE)LocalLock(hHead))==NULL) ! 916: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK); ! 917: ! 918: pTrail = pHead; ! 919: while ((pHead->ChildWnd.hThisWnd != hwnd) && ! 920: (pHead->hNext != NULL)) { ! 921: hTmp = hHead; ! 922: pTrail = pHead; ! 923: hHead = pHead->hNext; ! 924: LocalUnlock(hTmp); ! 925: if ((pHead = (PNODE) LocalLock(hHead))==NULL) ! 926: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK); ! 927: } ! 928: if (pHead->ChildWnd.hThisWnd == hwnd) { ! 929: pWndInfo = &pHead->ChildWnd; ! 930: goto Wnd_Found1; ! 931: } else { ! 932: //MessageBox(ghwndMain, "Trouble - Can't find the thread node!", "Error", MB_OK); ! 933: goto Wnd_Out1; ! 934: } ! 935: ! 936: Wnd_Found1: if (pTrail == pHead) ! 937: SetWindowLong(ghwndMain, 0, (LONG) pHead->hNext); ! 938: else ! 939: pTrail->hNext = pHead->hNext; ! 940: ! 941: //if (!LocalUnlock(hHead)) { ! 942: LocalFree(hHead); ! 943: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 944: //} 1.1 root 945: Wnd_Out1: 1.1.1.4 ! root 946: LocalUnlock(hHead); ! 947: } else { ! 948: //MessageBox(ghwndMain, "Can't GetWindowLong(ghwndMain,0)!", "Error", MB_OK); ! 949: } ! 950: return DefMDIChildProc(hwnd, message, wParam, lParam); ! 951: ! 952: } 1.1 root 953: 1.1.1.4 ! root 954: case WM_DESTROY: ! 955: KillTimer(hwnd, 2); ! 956: return 0l; ! 957: ! 958: default: ! 959: return DefMDIChildProc(hwnd, message, wParam, lParam); 1.1 root 960: } 961: 962: } 963: 964: /***************************************************************************\ 965: * About 966: * 967: * About dialog proc. 968: * 969: * History: 1.1.1.3 root 970: * 04-13-91 ???? Created. 1.1.1.4 ! root 971: * 09-09-91 Petrus Wong Rewrote. 1.1 root 972: \***************************************************************************/ 973: 1.1.1.4 ! root 974: BOOL CALLBACK APIENTRY About( 1.1 root 975: HWND hDlg, 976: UINT message, 977: DWORD wParam, 978: LONG lParam) 979: { 980: switch (message) { 981: case WM_INITDIALOG: 982: return TRUE; 983: 984: case WM_COMMAND: 985: if (wParam == IDOK) 986: EndDialog(hDlg, wParam); 987: break; 988: } 989: 990: return FALSE; 991: 992: UNREFERENCED_PARAMETER(lParam); 993: UNREFERENCED_PARAMETER(hDlg); 994: } 995: 996: /***************************************************************************\ 997: * MapFileName 998: * 999: * MapFileName dialog proc. 1000: * 1001: * History: 1.1.1.4 ! root 1002: * 09-09-91 Petrus Wong Created. 1.1 root 1003: \***************************************************************************/ 1004: 1.1.1.4 ! root 1005: BOOL CALLBACK MapFileName( 1.1 root 1006: HWND hDlg, 1007: UINT message, 1008: DWORD wParam, 1009: LONG lParam) 1010: { 1011: 1012: switch (message) { 1013: case WM_INITDIALOG: 1014: return TRUE; 1015: 1016: case WM_COMMAND: 1.1.1.4 ! root 1017: switch (wParam) { ! 1018: case IDBTN_OK: { 1.1 root 1019: 1.1.1.4 ! root 1020: if ((GetDlgItemText(hDlg, IDEDIT_MAPNAME, gszMapName, 20)) == 0) { ! 1021: MessageBox(ghwndMain, "MapFileName: Can't get edit text!", "Error", MB_OK); ! 1022: strncpy(gszMapName, "MapName1", 10); // default name ! 1023: } ! 1024: EndDialog(hDlg, IDBTN_OK); ! 1025: break; ! 1026: } 1.1 root 1027: 1.1.1.4 ! root 1028: } 1.1 root 1029: 1030: } 1031: 1032: return FALSE; 1033: 1034: UNREFERENCED_PARAMETER(lParam); 1035: UNREFERENCED_PARAMETER(hDlg); 1036: } 1037: 1038: /***************************************************************************\ 1039: * FileType 1040: * 1041: * FileType dialog proc. 1042: * 1043: * History: 1.1.1.4 ! root 1044: * 09-09-91 Petrus Wong Created. 1.1 root 1045: \***************************************************************************/ 1046: 1.1.1.4 ! root 1047: BOOL CALLBACK FileType( 1.1 root 1048: HWND hDlg, 1049: UINT message, 1050: DWORD wParam, 1051: LONG lParam) 1052: { 1053: 1054: switch (message) { 1055: case WM_INITDIALOG: 1056: return TRUE; 1057: 1058: case WM_COMMAND: 1.1.1.4 ! root 1059: switch (wParam) { ! 1060: case IDBTN_PAGE: { ! 1061: EndDialog(hDlg, IDBTN_PAGE); ! 1062: break; ! 1063: } ! 1064: ! 1065: case IDBTN_MAP: { ! 1066: if ((GetDlgItemText(hDlg, IDEDIT_MAPFILE, gszFile, 20)) == 0) ! 1067: EndDialog(hDlg, IDBTN_PAGE); // default to use PAGE file ! 1068: else ! 1069: EndDialog(hDlg, IDBTN_MAP); ! 1070: ! 1071: break; ! 1072: } ! 1073: } 1.1 root 1074: 1075: } 1076: 1077: return FALSE; 1078: 1079: UNREFERENCED_PARAMETER(lParam); 1080: UNREFERENCED_PARAMETER(hDlg); 1081: } 1082: 1083: 1084: /************************************************************************* 1085: * 1086: * TextWndProc 1087: * 1088: * Text Window proc. 1089: * 1090: * History: 1.1.1.4 ! root 1091: * 10-07-91 Petrus Wong Created. 1.1 root 1092: * 1093: \***************************************************************************/ 1094: 1.1.1.3 root 1095: LONG APIENTRY TextWndProc (HWND hwnd, UINT message, DWORD wParam, LONG lParam) 1.1 root 1096: { 1097: static HFONT hFont = (HFONT) NULL; 1098: 1099: switch (message) 1100: { 1101: case WM_CREATE: 1102: { 1.1.1.4 ! root 1103: LOGFONT lf; ! 1104: HDC hDC; ! 1105: HFONT hOldFont; 1.1 root 1106: TEXTMETRIC tm; 1.1.1.4 ! root 1107: RECT rect; ! 1108: LONG lHeight; 1.1 root 1109: 1.1.1.4 ! root 1110: SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, FALSE); 1.1 root 1111: 1.1.1.4 ! root 1112: hDC = GetDC(hwnd); ! 1113: // this is the height for 8 point size font in pixels ! 1114: lf.lfHeight = 8 * GetDeviceCaps(hDC, LOGPIXELSY) / 72; ! 1115: ! 1116: hFont = CreateFontIndirect(&lf); ! 1117: hOldFont = SelectObject(hDC, hFont); ! 1118: GetTextMetrics(hDC, &tm); ! 1119: GetClientRect(GetParent(hwnd), &rect); ! 1120: ! 1121: // base the height of the window on size of text ! 1122: lHeight = tm.tmHeight+6*GetSystemMetrics(SM_CYBORDER)+2; ! 1123: // saved the height for later reference ! 1124: SetWindowLong(hwnd, GWL_USERDATA, lHeight); ! 1125: SetWindowPos(hwnd, NULL, ! 1126: 0, ! 1127: rect.bottom-lHeight, ! 1128: rect.right-rect.left, ! 1129: lHeight, ! 1130: SWP_NOZORDER | SWP_NOMOVE); 1.1 root 1131: 1132: ReleaseDC(hwnd, hDC); 1133: break; 1134: } 1135: 1136: case WM_DESTROY: 1.1.1.4 ! root 1137: if (hFont) ! 1138: DeleteObject(hFont); ! 1139: break; 1.1 root 1140: 1141: case WM_SETTEXT: 1142: DefWindowProc(hwnd, message, wParam, lParam); 1143: InvalidateRect(hwnd,NULL,FALSE); 1144: UpdateWindow(hwnd); 1145: return 0L; 1146: 1147: case WM_PAINT: 1148: { 1149: PAINTSTRUCT ps; 1150: RECT rc; 1151: char ach[128]; 1152: int len, nxBorder, nyBorder; 1153: HFONT hOldFont = NULL; 1154: 1155: BeginPaint(hwnd, &ps); 1156: 1157: GetClientRect(hwnd,&rc); 1158: 1159: nxBorder = GetSystemMetrics(SM_CXBORDER); 1.1.1.4 ! root 1160: rc.left += 9*nxBorder; 1.1 root 1161: rc.right -= 9*nxBorder; 1162: 1163: nyBorder = GetSystemMetrics(SM_CYBORDER); 1.1.1.4 ! root 1164: rc.top += 3*nyBorder; ! 1165: rc.bottom -= 3*nyBorder; 1.1 root 1166: 1.1.1.4 ! root 1167: // 3D Text 1.1 root 1168: len = GetWindowText(hwnd, ach, sizeof(ach)); 1.1.1.4 ! root 1169: SetBkColor(ps.hdc, GetSysColor(COLOR_BTNFACE)); 1.1 root 1170: 1.1.1.4 ! root 1171: SetBkMode(ps.hdc, TRANSPARENT); ! 1172: SetTextColor(ps.hdc, RGB(64,96,96)); ! 1173: if (hFont) ! 1174: hOldFont = SelectObject(ps.hdc, hFont); ! 1175: ExtTextOut(ps.hdc, rc.left+2*nxBorder+2, rc.top+2, ETO_OPAQUE | ETO_CLIPPED, ! 1176: &rc, ach, len, NULL); ! 1177: ! 1178: SetTextColor(ps.hdc, RGB(128,128,128)); ! 1179: if (hFont) ! 1180: hOldFont = SelectObject(ps.hdc, hFont); ! 1181: ExtTextOut(ps.hdc, rc.left+2*nxBorder+1, rc.top+1, ETO_CLIPPED, ! 1182: &rc, ach, len, NULL); ! 1183: ! 1184: SetTextColor(ps.hdc, RGB(255,255,255)); ! 1185: if (hFont) ! 1186: hOldFont = SelectObject(ps.hdc, hFont); ! 1187: ExtTextOut(ps.hdc, rc.left+2*nxBorder, rc.top, ETO_CLIPPED, ! 1188: &rc, ach, len, NULL); 1.1 root 1189: 1.1.1.4 ! root 1190: SetBkMode(ps.hdc, OPAQUE); 1.1 root 1191: 1.1.1.4 ! root 1192: if (hOldFont) ! 1193: SelectObject(ps.hdc, hOldFont); 1.1 root 1194: 1195: EndPaint(hwnd, &ps); 1196: return 0L; 1197: } 1198: } 1199: return DefWindowProc(hwnd, message, wParam, lParam); 1200: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.