--- mstools/samples/ntfonts/toolbar.c 2018/08/09 18:20:59 1.1 +++ mstools/samples/ntfonts/toolbar.c 2018/08/09 18:22:13 1.1.1.2 @@ -2,24 +2,29 @@ * toolbar.c -- module for the "toolbar" on top of the main window. * Includes the window procedure and an initialization routine. * +* Steve Firebaugh +* Microsoft Developer Support +* Copyright (c) 1992 Microsoft Corporation +* \**************************************************************************/ +#define UNICODE #include #include "ntfonts.h" /* for the initial positioning of the buttons within the toolbar. */ -#define SPACEBUTTON 5 +#define SPACEBUTTON 8 #define CXBUTTON ((GetSystemMetrics (SM_CXFULLSCREEN)) /5 -2*SPACEBUTTON) #define BUTTONTOP TOOLBARHEIGHT/8 #define BUTTONHEIGHT TOOLBARHEIGHT*3/4 #define BUTTONLEFT(x) ((2*x+1)*SPACEBUTTON + x*CXBUTTON) -#define BORDER 4 +#define BORDER 2 -int initTB (HWND hwndMain) +int initTB (HWND hwndParent) { WNDCLASS wc; @@ -32,18 +37,18 @@ WNDCLASS wc; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = GetStockObject(LTGRAY_BRUSH); wc.lpszMenuName = NULL; - wc.lpszClassName = "ToolBar"; + wc.lpszClassName = TEXT("ToolBar"); if (!RegisterClass(&wc)) return (FALSE); hwndTB = CreateWindow( - "ToolBar", + TEXT("ToolBar"), NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 0,0, GetSystemMetrics (SM_CXFULLSCREEN), TOOLBARHEIGHT, - hwndMain, NULL, hInst, NULL); + hwndParent, NULL, hInst, NULL); if (!hwndTB) return (FALSE); @@ -64,7 +69,7 @@ WNDCLASS wc; * buttons send WM_COMMAND messages later, send the messages back to hwndMain. * \**************************************************************************/ -LRESULT ToolBarWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK ToolBarWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndButton; switch (message) { @@ -78,64 +83,40 @@ static HWND hwndButton; \**********************************************************************/ case WM_CREATE: { hwndButton = CreateWindow( - "BUTTON","&EnumFonts()", + TEXT("BUTTON"),TEXT("EnumFonts"), WS_CHILD | WS_VISIBLE, BUTTONLEFT(0),BUTTONTOP, CXBUTTON, BUTTONHEIGHT, hwnd, NULL, hInst, NULL); SetWindowLong (hwndButton, GWL_ID, TBID_ENUM); hwndButton = CreateWindow( - "BUTTON","&CreateFont()", + TEXT("BUTTON"),TEXT("CreateFont"), WS_CHILD | WS_VISIBLE, BUTTONLEFT(1),BUTTONTOP, CXBUTTON, BUTTONHEIGHT, hwnd, NULL, hInst, NULL); SetWindowLong (hwndButton, GWL_ID, TBID_CREATE); hwndButton = CreateWindow( - "BUTTON","Get&TextMetric()", + TEXT("BUTTON"),TEXT("GetMetrics"), WS_CHILD | WS_VISIBLE , BUTTONLEFT(2),BUTTONTOP, CXBUTTON, BUTTONHEIGHT, hwnd, NULL, hInst, NULL); SetWindowLong (hwndButton, GWL_ID, TBID_GETTM); - - /* create the two check boxes */ - hwndButton = CreateWindow( - "BUTTON","SetMapperFlags(1)", - WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, - BUTTONLEFT(3),BUTTONTOP, CXBUTTON, BUTTONHEIGHT/2, - hwnd, NULL, hInst, NULL); - SetWindowLong (hwndButton, GWL_ID, TBID_CHKMAPPERFLAGS); - hwndButton = CreateWindow( - "BUTTON","ShowAllGlyphs", - WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, - BUTTONLEFT(3),BUTTONTOP + BUTTONHEIGHT/2, CXBUTTON, BUTTONHEIGHT/2, + TEXT("BUTTON"),TEXT("GetFontData"), + WS_CHILD | WS_VISIBLE , + BUTTONLEFT(3),BUTTONTOP, CXBUTTON, BUTTONHEIGHT, hwnd, NULL, hInst, NULL); - SetWindowLong (hwndButton, GWL_ID, TBID_CHKALLGLYPHS); + SetWindowLong (hwndButton, GWL_ID, TBID_GETFONTDATA); - - /* put the printer fonts button near the RIGHT edge. */ hwndButton = CreateWindow( - "BUTTON","&Printer fonts", + TEXT("BUTTON"),TEXT("Enum(Printer)"), WS_CHILD | WS_VISIBLE, BUTTONLEFT(4),BUTTONTOP, CXBUTTON, BUTTONHEIGHT, hwnd, NULL, hInst, NULL); SetWindowLong (hwndButton, GWL_ID, TBID_PRINT); - } break; - - /**********************************************************************\ - * WM_CTLCOLORBTN - * - * Try to set the background of the check boxes to match the toolbar. - \**********************************************************************/ - case WM_CTLCOLORBTN: { - HDC hdc; - hdc = (HDC)wParam; - SetBkMode (hdc, TRANSPARENT); - - return (LONG) GetStockObject (LTGRAY_BRUSH); } break; @@ -161,11 +142,16 @@ static HWND hwndButton; hdc = BeginPaint(hwnd, &ps); GetClientRect (hwnd, &rect); - rect.bottom = rect.top+BORDER; - FillRect (hdc, &rect, GetStockObject (WHITE_BRUSH)); - GetClientRect (hwnd, &rect); - rect.top = rect.bottom-BORDER; - FillRect (hdc, &rect, GetStockObject (GRAY_BRUSH)); + rect.right --; + rect.bottom --; + + SelectObject (hdc, GetStockObject (BLACK_PEN)); + MoveToEx (hdc, rect.right, rect.top, NULL); + LineTo (hdc, rect.right, rect.bottom); + LineTo (hdc, rect.left, rect.bottom); + SelectObject (hdc, GetStockObject (WHITE_PEN)); + LineTo (hdc, rect.left, rect.top); + LineTo (hdc, rect.right, rect.top); EndPaint (hwnd, &ps); } break;