--- mstools/samples/memory/memory.c 2018/08/09 18:20:01 1.1.1.1 +++ mstools/samples/memory/memory.c 2018/08/09 18:21:21 1.1.1.3 @@ -6,7 +6,7 @@ * * * History: -* 09-17-91 PetrusW Created. +* 09-17-91 Petrus Wong Created. * \***************************************************************************/ @@ -52,23 +52,24 @@ typedef struct _node { * Forward declarations. */ BOOL InitializeApp (void); -LONG MainWndProc (HWND, UINT, DWORD, LONG); -LONG ServerWndProc (HWND, UINT, DWORD, LONG); -LONG ClientWndProc (HWND, UINT, DWORD, LONG); -LONG About (HWND, UINT, DWORD, LONG); +LONG APIENTRY MainWndProc (HWND, UINT, DWORD, LONG); +LONG APIENTRY ServerWndProc (HWND, UINT, DWORD, LONG); +LONG APIENTRY ClientWndProc (HWND, UINT, DWORD, LONG); +LONG APIENTRY About (HWND, UINT, DWORD, LONG); LONG FileType (HWND, UINT, DWORD, LONG); LONG MapFileName (HWND, UINT, DWORD, LONG); -LONG TextWndProc (HWND, UINT, DWORD, LONG); +LONG APIENTRY TextWndProc (HWND, UINT, DWORD, LONG); +extern int FAR PASCAL ShellAbout(HWND, LPCSTR, LPCSTR, HICON); /***************************************************************************\ * main * * * History: -* 04-17-91 ScottLu Created. +* 04-17-91 ???? Created. \***************************************************************************/ -int WinMain( +int WINAPI WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, @@ -115,7 +116,7 @@ int WinMain( * InitializeApp * * History: -* 09-09-91 PetrusW Created. +* 09-09-91 Petrus Wong Created. \***************************************************************************/ BOOL InitializeApp(void) @@ -123,7 +124,7 @@ BOOL InitializeApp(void) WNDCLASS wc; wc.style = CS_OWNDC; - wc.lpfnWndProc = MainWndProc; + wc.lpfnWndProc = (WNDPROC)MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof(LONG); wc.hInstance = ghModule; @@ -137,7 +138,7 @@ BOOL InitializeApp(void) return FALSE; wc.style = CS_OWNDC; - wc.lpfnWndProc = ServerWndProc; + wc.lpfnWndProc = (WNDPROC)ServerWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; // LATER sizeof(LONG); wc.hInstance = ghModule; @@ -151,7 +152,7 @@ BOOL InitializeApp(void) return FALSE; wc.style = CS_OWNDC; - wc.lpfnWndProc = ClientWndProc; + wc.lpfnWndProc = (WNDPROC)ClientWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; // LATER sizeof(LONG); wc.hInstance = ghModule; @@ -165,7 +166,7 @@ BOOL InitializeApp(void) return FALSE; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = TextWndProc; + wc.lpfnWndProc = (WNDPROC)TextWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = ghModule; @@ -199,7 +200,7 @@ BOOL InitializeApp(void) SetWindowLong(ghwndMain, GWL_USERDATA, 0L); - SetFocus(ghwndMain); /* set initial focus */ + //SetFocus(ghwndMain); /* set initial focus */ return TRUE; } @@ -209,10 +210,10 @@ BOOL InitializeApp(void) * MainWndProc * * History: -* 09-09-91 PetrusW Created. +* 09-09-91 Petrus Wong Created. \***************************************************************************/ -long MainWndProc( +long APIENTRY MainWndProc( HWND hwnd, UINT message, DWORD wParam, @@ -220,7 +221,6 @@ long MainWndProc( { static int iSvrCount=1; static int iCltCount=1; - static HWND hwndClient; CLIENTCREATESTRUCT clientcreate; HWND hwndChildWindow; @@ -233,7 +233,7 @@ long MainWndProc( clientcreate.hWindowMenu = hMenuWindow; clientcreate.idFirstChild = 1; - hwndClient = CreateWindow("MDICLIENT", NULL, + ghwndClient = CreateWindow("MDICLIENT", NULL, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, 0,0,0,0, hwnd, NULL, ghModule, (LPVOID)&clientcreate); @@ -248,13 +248,13 @@ long MainWndProc( switch (LOWORD(wParam)) { case IDM_TILE: - SendMessage(hwndClient, WM_MDITILE, 0L, 0L); + SendMessage(ghwndClient, WM_MDITILE, 0L, 0L); return 0L; case IDM_CASCADE: - SendMessage(hwndClient, WM_MDICASCADE, 0L, 0L); + SendMessage(ghwndClient, WM_MDICASCADE, 0L, 0L); return 0L; case IDM_ARRANGE: - SendMessage(hwndClient, WM_MDIICONARRANGE, 0L, 0L); + SendMessage(ghwndClient, WM_MDIICONARRANGE, 0L, 0L); return 0L; case MM_SERVER: { @@ -282,7 +282,7 @@ long MainWndProc( /*Create Child Window*/ hwndChildWindow = - (HANDLE) SendMessage(hwndClient, WM_MDICREATE, + (HANDLE) SendMessage(ghwndClient, WM_MDICREATE, 0L, (LONG)(LPMDICREATESTRUCT)&mdicreate); @@ -291,7 +291,7 @@ long MainWndProc( return 0L; } - pNode->ChildWnd.hParent = hwndClient; + pNode->ChildWnd.hParent = ghwndClient; pNode->ChildWnd.hThisWnd = hwndChildWindow; hHead = (HANDLE)GetWindowLong(hwnd, 0); pNode->hNext = hHead; @@ -332,7 +332,7 @@ long MainWndProc( /*Create Child Window*/ hwndChildWindow = - (HANDLE) SendMessage(hwndClient, WM_MDICREATE, + (HANDLE) SendMessage(ghwndClient, WM_MDICREATE, 0L, (LONG)(LPMDICREATESTRUCT)&mdicreate); @@ -341,7 +341,7 @@ long MainWndProc( return 0L; } - pNode->ChildWnd.hParent = hwndClient; + pNode->ChildWnd.hParent = ghwndClient; pNode->ChildWnd.hThisWnd = hwndChildWindow; hHead = (HANDLE)GetWindowLong(hwnd, 0); pNode->hNext = hHead; @@ -358,8 +358,10 @@ long MainWndProc( } case MM_ABOUT: - if (DialogBox(ghModule, "AboutBox", ghwndMain, About) == -1) - MessageBox(ghwndMain, "DEMO: About Dialog Creation Error!", "Error", MB_OK); + ShellAbout(ghwndMain, "Memory", "Microsoft Developer Support", NULL); + + //if (DialogBox(ghModule, "AboutBox", ghwndMain, (DLGPROC)About) == -1) + // MessageBox(ghwndMain, "DEMO: About Dialog Creation Error!", "Error", MB_OK); return 0L; case MM_OPT_1: @@ -372,19 +374,19 @@ long MainWndProc( case MM_OPT_8: { HWND hActiveChild; - hActiveChild = (HANDLE) SendMessage(hwndClient, WM_MDIGETACTIVE, 0L, 0L); + hActiveChild = (HANDLE) SendMessage(ghwndClient, WM_MDIGETACTIVE, 0L, 0L); if (hActiveChild) SendMessage(hActiveChild, WM_COMMAND, wParam, lParam); return 0L; } default: - return DefFrameProc(hwnd, hwndClient, message, wParam, lParam); + return DefFrameProc(hwnd, ghwndClient, message, wParam, lParam); } default: - return DefFrameProc(hwnd, hwndClient, message, wParam, lParam); + return DefFrameProc(hwnd, ghwndClient, message, wParam, lParam); } } @@ -392,11 +394,11 @@ long MainWndProc( * ServerWndProc * * History: -* 04-17-91 ScottLu Created. -* 09-09-91 PetrusW Rewrote. +* 04-17-91 ???? Created. +* 09-09-91 Petrus Wong Rewrote. \***************************************************************************/ -long ServerWndProc( +long APIENTRY ServerWndProc( HWND hwnd, UINT message, DWORD wParam, @@ -416,7 +418,7 @@ long ServerWndProc( case MM_OPT_1: { //Create File SetWindowText(hTextWnd, "Creating Map File"); - switch (DialogBox(ghModule, "FileType", hwnd, FileType)) { + switch (DialogBox(ghModule, "FileType", hwnd, (DLGPROC)FileType)) { case -1: MessageBox(ghwndMain, "Server: File dialog box creation failed!", "Error", MB_OK); SetWindowText(hTextWnd, "File dialog box creation failed"); @@ -441,7 +443,7 @@ long ServerWndProc( SetWindowText(hTextWnd, "Creating File Mapping"); if (MapFileHandle != NULL ) { - switch (DialogBox(ghModule, "MapName", hwnd, MapFileName)) { + switch (DialogBox(ghModule, "MapName", hwnd, (DLGPROC)MapFileName)) { case -1: MessageBox(ghwndMain, "Server: Map dialog box creation failed!", "Error", MB_OK); SetWindowText(hTextWnd, "Map dialog box creation failed"); @@ -546,8 +548,8 @@ long ServerWndProc( return 0L; case WM_SETFOCUS: - if (hEdit) - SetFocus(hEdit); + //if (hEdit) + //SetFocus(hEdit); return DefMDIChildProc(hwnd, message, wParam, lParam); case WM_MDIACTIVATE: @@ -556,7 +558,7 @@ long ServerWndProc( (DWORD) hServerMenu, (LONG) hServerMenuWindow) ; DrawMenuBar(GetParent(GetParent(hwnd))) ; - SetFocus(hEdit); + //SetFocus(hEdit); } return 0; @@ -697,11 +699,11 @@ Wnd_Out1: * ClientWndProc * * History: -* 04-17-91 ScottLu Created. -* 09-09-91 PetrusW Rewrote. +* 04-17-91 ???? Created. +* 09-09-91 Petrus Wong Rewrote. \***************************************************************************/ -long ClientWndProc( +long APIENTRY ClientWndProc( HWND hwnd, UINT message, DWORD wParam, @@ -718,7 +720,7 @@ long ClientWndProc( switch (LOWORD(wParam)) { case MM_OPT_5: { //Open File Mapping SetWindowText(hTextWnd, "Opening Mapping File"); - switch (DialogBox(ghModule, "MapName", hwnd, MapFileName)) { + switch (DialogBox(ghModule, "MapName", hwnd, (DLGPROC)MapFileName)) { case -1: MessageBox(ghwndMain, "Client: Map dialog box creation failed!", "Error", MB_OK); break; @@ -767,7 +769,7 @@ long ClientWndProc( rcl.bottom-rcl.top-GetWindowLong(hTextWnd, GWL_USERDATA), hwnd, (HMENU) 1, ghModule, NULL); if (hEdit) { - SetFocus(hEdit); + //SetFocus(hEdit); SendMessage(hEdit, WM_SETTEXT, 0L, (LONG)pShrMem1); SetTimer(hwnd, 2, 10000, NULL); EnableMenuItem(hClientMenu, MM_OPT_8, MF_ENABLED); @@ -787,14 +789,14 @@ long ClientWndProc( hActive = (HANDLE) SendMessage(GetParent(hwnd), WM_MDIGETACTIVE, 0L, 0L); SendMessage(hEdit, WM_SETTEXT, 0L, (LONG)pShrMem1); - SetFocus(hActive); + //SetFocus(hActive); return 0L; } } } case WM_SETFOCUS: - if (hEdit) - SetFocus(hEdit); + //if (hEdit) + //SetFocus(hEdit); return DefMDIChildProc(hwnd, message, wParam, lParam); case WM_TIMER: { @@ -803,7 +805,7 @@ long ClientWndProc( if (hEdit) { hActive = (HANDLE) SendMessage(GetParent(hwnd), WM_MDIGETACTIVE, 0L, 0L); SendMessage(hEdit, WM_SETTEXT, 0L, (LONG)pShrMem1); - SetFocus(hActive); + //SetFocus(hActive); } return 0L; } @@ -814,7 +816,7 @@ long ClientWndProc( (DWORD) hClientMenu, (LONG) hClientMenuWindow) ; DrawMenuBar(GetParent(GetParent(hwnd))) ; - SetFocus(hEdit); + //SetFocus(hEdit); } return 0; @@ -953,11 +955,11 @@ Wnd_Out1: * About dialog proc. * * History: -* 04-13-91 ScottLu Created. -* 09-09-91 PetrusW Rewrote. +* 04-13-91 ???? Created. +* 09-09-91 Petrus Wong Rewrote. \***************************************************************************/ -long About( +long APIENTRY About( HWND hDlg, UINT message, DWORD wParam, @@ -985,7 +987,7 @@ long About( * MapFileName dialog proc. * * History: -* 09-09-91 PetrusW Created. +* 09-09-91 Petrus Wong Created. \***************************************************************************/ long MapFileName( @@ -1027,7 +1029,7 @@ long MapFileName( * FileType dialog proc. * * History: -* 09-09-91 PetrusW Created. +* 09-09-91 Petrus Wong Created. \***************************************************************************/ long FileType( @@ -1074,11 +1076,11 @@ long FileType( * Text Window proc. * * History: -* 10-07-91 PetrusW Created. +* 10-07-91 Petrus Wong Created. * \***************************************************************************/ -LONG TextWndProc (HWND hwnd, UINT message, DWORD wParam, LONG lParam) +LONG APIENTRY TextWndProc (HWND hwnd, UINT message, DWORD wParam, LONG lParam) { static HFONT hFont = (HFONT) NULL; @@ -1093,7 +1095,7 @@ LONG TextWndProc (HWND hwnd, UINT messag RECT rect; LONG lHeight; - SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), (LONG) &lf, FALSE); + SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, FALSE); hDC = GetDC(hwnd); // this is the height for 8 point size font in pixels