--- mstools/samples/fontview/fontview.c 2018/08/09 18:20:51 1.1.1.2 +++ mstools/samples/fontview/fontview.c 2018/08/09 18:24:04 1.1.1.4 @@ -1,3 +1,14 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + #define NOMINMAX #include @@ -12,6 +23,7 @@ #define APIENTRY FAR PASCAL typedef unsigned int UINT; #define WNDPROC FARPROC +#define DLGPROC FARPROC #endif @@ -76,7 +88,7 @@ HWND AddStatusField (HANDLE, int, int, i int StatusBarHeight (HWND); -int APIENTRY WinMain(HANDLE hInst, HANDLE hPrevInst, LPSTR lpCmdLine, int nCmdShow) +int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { MSG msg; @@ -141,7 +153,7 @@ int APIENTRY WinMain(HANDLE hInst, HANDL } /* Get handles to the various menus. Some of these we will use later */ /* to display menu descriptions in the status bar */ - hSysMenuMain = GetSystemMenu(hwndMain,FALSE); + hSysMenuMain = GetSystemMenu(hwndMain,FALSE); hMenu = GetMenu(hwndMain); if (hMenu) { hFileMenu = GetSubMenu(hMenu,0); @@ -192,7 +204,7 @@ int APIENTRY WinMain(HANDLE hInst, HANDL } ShowWindow (hwndMain, nCmdShow); - //UpdateWindow (hwndMain); + InvalidateRect (hwndZoom, NULL, TRUE); hAccelTable = LoadAccelerators (hInst, szAppName); @@ -263,7 +275,7 @@ BOOL FillInValue (HWND hwnd, int param) ATOM atom; HDC hdc; FARPROC lpEnumFonts; - HANDLE hInst; + HINSTANCE hInst; SendMessage (hwnd, CB_RESETCONTENT, 0, 0); focus = -1; @@ -568,20 +580,20 @@ BOOL FillInValue (HWND hwnd, int param) hdc = GetDC (hwnd); #if defined (WIN32) - hInst = (HANDLE)GetWindowLong (hwnd, GWL_HINSTANCE); + hInst = (HINSTANCE)GetWindowLong (hwnd, GWL_HINSTANCE); #else - hInst = GetWindowWord (hwnd, GWW_HINSTANCE); + hInst = (HINSTANCE)GetWindowWord (hwnd, GWW_HINSTANCE); #endif lpEnumFonts = MakeProcInstance ((FARPROC)EnumFontNames, hInst); - EnumFonts (hdc, NULL, lpEnumFonts, (LONG)&hwnd); + EnumFonts (hdc, NULL, (FONTENUMPROC)lpEnumFonts, (LPARAM)&hwnd); FreeProcInstance (lpEnumFonts); ReleaseDC (hwnd, hdc); atom = GlobalFindAtom ((LPSTR)lf.lfFaceName); - if (atom == NULL && (lstrlen (lf.lfFaceName)>0)) { - index = (int)SendMessage (hwnd, CB_ADDSTRING, 0, (LONG)(LPSTR)lf.lfFaceName); + if (atom == (ATOM)0 && (lstrlen (lf.lfFaceName)>0)) { + index = (int)SendMessage (hwnd, CB_ADDSTRING, 0, (LONG)(LPSTR)lf.lfFaceName); focus = index; } else if (lstrlen(lf.lfFaceName)==0) { - index = (int)SendMessage (hwnd, CB_FINDSTRING, (UINT)-1, (LONG)(LPSTR)"(none)"); + index = (int)SendMessage (hwnd, CB_FINDSTRING, (UINT)-1, (LONG)(LPSTR)"(none)"); focus = index; } else { index = (int)SendMessage (hwnd, CB_GETCOUNT, 0, 0); @@ -619,11 +631,11 @@ int FAR PASCAL EnumFontNames (LPLOGFONT hwndCombo = (HWND)*lpData; atom = GlobalFindAtom ((LPSTR)lpLogFont->lfFaceName); - if (atom == NULL) { + if (atom == (ATOM)0) { atom = GlobalAddAtom (lpLogFont->lfFaceName); } if (index = SendMessage(hwndCombo, CB_FINDSTRING, (UINT)-1, (LONG)(LPSTR)lpLogFont->lfFaceName) == CB_ERR) { - index = (int)SendMessage (hwndCombo, CB_ADDSTRING, 0, (LONG)(LPSTR)lpLogFont->lfFaceName); + index = (int)SendMessage (hwndCombo, CB_ADDSTRING, 0, (LONG)(LPSTR)lpLogFont->lfFaceName); SendMessage (hwndCombo, CB_SETITEMDATA, index, atom); } @@ -678,7 +690,7 @@ BOOL CenterWindow (HWND hwndChild, HWND LONG APIENTRY WndProc (HWND hwnd, UINT msg, UINT wParam, LONG lParam) { - HANDLE hInst; + HINSTANCE hInst; HDC hdc; PAINTSTRUCT ps; FARPROC lpDlgFunc; @@ -702,13 +714,13 @@ static int idMenuSelect; int wmMenuCmd, wmFlags; HMENU wmhMenu; - if (hwnd) { + if (hwnd) { #if defined (WIN32) - hInst = (HANDLE)GetWindowLong (hwnd, GWL_HINSTANCE); + hInst = (HINSTANCE)GetWindowLong (hwnd, GWL_HINSTANCE); #else - hInst = (HANDLE)GetWindowWord (hwnd, GWW_HINSTANCE); + hInst = (HINSTANCE)GetWindowWord (hwnd, GWW_HINSTANCE); #endif - } + } switch (msg) { case WM_CREATE: @@ -754,13 +766,13 @@ static int idMenuSelect; wmhWnd = WindowFromPoint(point); if (wmhWnd) { #if defined (WIN32) - wmId = GetWindowLong (wmhWnd, GWL_ID); + wmId = GetWindowLong (wmhWnd, GWL_ID); #else - wmId = GetWindowWord (wmhWnd, GWW_ID); + wmId = GetWindowWord (wmhWnd, GWW_ID); #endif - } else { - break; - } + } else { + break; + } switch (wmEvent) { case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: @@ -985,13 +997,13 @@ static int idMenuSelect; break; - case ID_ZOOM: - if (bZoomed) { - SetWindowLong (hwndClient, GWL_WNDPROC, (LONG)fpCharSetProc); - bZoomed = FALSE; + case ID_ZOOM: + if (bZoomed) { + SetWindowLong (hwndClient, GWL_WNDPROC, (LONG)fpCharSetProc); + bZoomed = FALSE; } else { - SetWindowLong (hwndClient, GWL_WNDPROC, (LONG)fpGlyphProc); - bZoomed = TRUE; + SetWindowLong (hwndClient, GWL_WNDPROC, (LONG)fpGlyphProc); + bZoomed = TRUE; } InvalidateRect (hwndClient, NULL, TRUE); break; @@ -1020,11 +1032,7 @@ static int idMenuSelect; case IDM_CREATEFONT: lpDlgFunc = MakeProcInstance((FARPROC) CreateDlgProc, hInst); -#if defined (WIN32) - DialogBoxParam(hInst, "CreateFont", hwnd, lpDlgFunc, (DWORD)(LPLOGFONT)&lf); -#else - DialogBoxParam(hInst, "CreateFont", hwnd, (FARPROC)lpDlgFunc, (DWORD)(LPLOGFONT)&lf); -#endif + DialogBoxParam(hInst, "CreateFont", hwnd, (DLGPROC)lpDlgFunc, (DWORD)(LPLOGFONT)&lf); FreeProcInstance(lpDlgFunc); index = (int)SendMessage (hwndCreateParam, CB_GETCURSEL, 0, 0); if (index != CB_ERR) { @@ -1038,11 +1046,7 @@ static int idMenuSelect; case IDM_TEXTMETRIC: lpDlgFunc = MakeProcInstance((FARPROC) MetricsDlgProc, hInst); -#if defined (WIN32) - DialogBoxParam(hInst, "TextMetric", hwnd, lpDlgFunc, (DWORD)(LPLOGFONT)&lf); -#else - DialogBoxParam(hInst, "TextMetric", hwnd, (FARPROC)lpDlgFunc, (DWORD)(LPLOGFONT)&lf); -#endif + DialogBoxParam(hInst, "TextMetric", hwnd, (DLGPROC)lpDlgFunc, (DWORD)(LPLOGFONT)&lf); FreeProcInstance(lpDlgFunc); index = (int)SendMessage (hwndCreateParam, CB_GETCURSEL, 0, 0); if (index != CB_ERR) { @@ -1055,11 +1059,7 @@ static int idMenuSelect; case IDM_ENUMFONTS: lpDlgFunc = MakeProcInstance((FARPROC) EnumDlgProc, hInst); -#if defined (WIN32) - DialogBoxParam(hInst, "EnumFonts", hwnd, lpDlgFunc, (DWORD)(LPLOGFONT)&lf); -#else - DialogBoxParam(hInst, "EnumFonts", hwnd, (FARPROC)lpDlgFunc, (DWORD)(LPLOGFONT)&lf); -#endif + DialogBoxParam(hInst, "EnumFonts", hwnd, (DLGPROC)lpDlgFunc, (DWORD)(LPLOGFONT)&lf); FreeProcInstance(lpDlgFunc); index = (int)SendMessage (hwndCreateParam, CB_GETCURSEL, 0, 0); if (index != CB_ERR) { @@ -1098,17 +1098,10 @@ static int idMenuSelect; case IDM_ABOUT: lpDlgFunc = MakeProcInstance((FARPROC) SimpleDlgProc, hInst); -#if defined (WIN32) - DialogBox(hInst, - (wmId==IDM_ABOUT)?"FONTVIEW":"UsageBox", - hwnd, - lpDlgFunc); -#else DialogBox(hInst, (wmId==IDM_ABOUT)?"FONTVIEW":"UsageBox", hwnd, - (FARPROC)lpDlgFunc); -#endif + (DLGPROC)lpDlgFunc); FreeProcInstance(lpDlgFunc); break; @@ -1196,7 +1189,7 @@ LONG APIENTRY ClientProc (HWND hwnd, UIN LONG APIENTRY ClientCharSetProc (HWND hwnd, UINT msg, UINT wParam, LONG lParam) { - HANDLE hInst; + HINSTANCE hInst; PAINTSTRUCT ps; HFONT hfont, hfontPrev; RECT rect; @@ -1204,13 +1197,13 @@ LONG APIENTRY ClientCharSetProc (HWND hw int x, y; BYTE glyph; - if (hwnd) { + if (hwnd) { #if defined (WIN32) - hInst = (HANDLE)GetWindowLong (hwnd, GWL_HINSTANCE); + hInst = (HINSTANCE)GetWindowLong (hwnd, GWL_HINSTANCE); #else - hInst = (HANDLE)GetWindowWord (hwnd, GWW_HINSTANCE); + hInst = (HINSTANCE)GetWindowWord (hwnd, GWW_HINSTANCE); #endif - } + } switch (msg) { case WM_PAINT: hdc = BeginPaint (hwnd, &ps); @@ -1254,7 +1247,7 @@ LONG APIENTRY ClientCharSetProc (HWND hw LONG APIENTRY ClientGlyphProc (HWND hwnd, UINT msg, UINT wParam, LONG lParam) { - HANDLE hInst; + HINSTANCE hInst; PAINTSTRUCT ps; HFONT hfont, hfontPrev; RECT rect; @@ -1262,13 +1255,13 @@ LONG APIENTRY ClientGlyphProc (HWND hwnd TEXTMETRIC tm; static BYTE glyph = 'A'; - if (hwnd) { + if (hwnd) { #if defined (WIN32) - hInst = (HANDLE)GetWindowLong (hwnd, GWL_HINSTANCE); + hInst = (HINSTANCE)GetWindowLong (hwnd, GWL_HINSTANCE); #else - hInst = (HANDLE)GetWindowWord (hwnd, GWW_HINSTANCE); + hInst = (HINSTANCE)GetWindowWord (hwnd, GWW_HINSTANCE); #endif - } + } switch (msg) { case WM_LBUTTONDBLCLK: