--- mstools/samples/deb/toolbar.c 2018/08/09 18:20:39 1.1.1.1 +++ mstools/samples/deb/toolbar.c 2018/08/09 18:23:35 1.1.1.3 @@ -1,43 +1,60 @@ + +/******************************************************************************\ +* 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. +\******************************************************************************/ + // ************************************************************************ -// PROGRAM : ToolBar.C -// PURPOSE : A Win32 DLL containing various ToolBar controls +// MODULE : ToolBar.C +// PURPOSE : A Win32 DLL containing a simple text ToolBar // FUNCTIONS : -// LibMain() - Dll entry point +// DllMain() - Dll entry point (via _DLLMainCRTStartup) // TextButtonBar() - generate a text button ToolBar // TextButtonBarProc - processes messages for the TextButtonBarWClass // COMMENTS : +// // ************************************************************************ -#define NOMINMAX // eliminate the duplicate min, max defs -#include // required for all Windows applications -#include // strlen(), strchr(), strcpy(), strcat() -#include // ltoa() +#define STRICT // enable strict typing +#include // required for all Windows applications -#include "ToolBar.H" // specific to this program +#include "ToolBar.H" // specific to this program //-- internal data -HWND hWndToolBarOwner; // window handle of Toolbar owner - // where all WM_COMMAND messages are sent +HWND hWndToolBarOwner; // window handle of Toolbar owner + // where all WM_COMMAND messages are sent + +//-- internal prototypes +LRESULT CALLBACK TextButtonBarProc( HWND, UINT, WPARAM, LPARAM ); + // ************************************************************************ -// FUNCTION : LibMain( HANDLE, DWORD, LPVOID ) -// PURPOSE : LibMain is called by Windows when -// the DLL is initialized, Thread Attached, and other times. -// No initialization is needed here. +// FUNCTION : DllMain( HINSTANCE, DWORD, LPVOID ) +// PURPOSE : DLLMain is called by the C run-time library from the +// _DLLMainCRTStartup entry point. The DLL entry point gets +// called (entered) on the following events: "Process Attach", +// "Thread Attach", "Thread Detach" or "Process Detach". +// COMMENTS : No initialization is needed here so this entry point simply +// returns TRUE. // ************************************************************************ -BOOL -LibMain( HANDLE hInst, DWORD dwReason, LPVOID lpReserved ) +BOOL WINAPI +DllMain( HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved ) { - UNREFERENCED_PARAMETER( hInst ); - UNREFERENCED_PARAMETER( dwReason ); - UNREFERENCED_PARAMETER( lpReserved ); + UNREFERENCED_PARAMETER( hInstDLL ); + UNREFERENCED_PARAMETER( fdwReason ); + UNREFERENCED_PARAMETER( lpvReserved ); return( TRUE ); } // ************************************************************************ -// FUNCTION : TextButtonBar( HANDLE, HWND, LPTEXTBUTTON, LPINT ) -// PURPOSE : Generate a text button ToolBar +// FUNCTION : TextButtonBar( HWND, LPTEXTBUTTON, LPINT ) +// PURPOSE : Generate a simple text button ToolBar // COMMENTS : lpTextButton points to an array of TEXTBUTTON // structures. The last structure must set the // member lpButtonText to NULL. lpHeight contains the @@ -64,24 +81,23 @@ TextButtonBar( HWND hWndParent, LPTEXTBU SIZE ButtonTextSize; RECT rect; - //-- store owner of Toolbar hWndToolBarOwner = hWndParent; //-- register the TestButtonBar window class - wndclass.style = NULL; + wndclass.style = (UINT) NULL; wndclass.lpfnWndProc = (WNDPROC) TextButtonBarProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = NULL; wndclass.hIcon = NULL; wndclass.hCursor = NULL; - wndclass.hbrBackground = GetStockObject(LTGRAY_BRUSH); + wndclass.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = "TextButtonBarWClass"; + wndclass.lpszClassName = TEXT( "TextButtonBarWClass" ); if( !RegisterClass( &wndclass ) ) - return( NULL ); + return( FALSE ); hDC = GetDC( hWndParent ); GetTextMetrics( hDC, &tm ); @@ -90,7 +106,7 @@ TextButtonBar( HWND hWndParent, LPTEXTBU GetWindowRect( GetDesktopWindow(), &rect ); hWndTextButtonBar = CreateWindow( - "TextButtonBarWClass", "Toolbar", + TEXT( "TextButtonBarWClass" ), TEXT( "Toolbar" ), WS_CHILD | WS_CLIPSIBLINGS, 0, 0, rect.right - rect.left, *lpHeight, hWndToolBarOwner, @@ -106,22 +122,23 @@ TextButtonBar( HWND hWndParent, LPTEXTBU //-- Create all the button windows for( lpTempTextButton = lpTextButton; - !(lpTempTextButton->lpButtonText == '\0' && lpTempTextButton->idButton == NULL); + !( (lpTempTextButton->lpButtonText) == '\0' + && (lpTempTextButton->idButton) == (UINT) NULL); lpTempTextButton++ ) { - //-- if TB_SPACE the adjust new xPos and continue + //-- if TB_SPACE then adjust new xPos and continue if( lpTempTextButton->idButton == TB_SPACE ) { xPosButton += ButtonSpace; continue; } lpButtonString = lpTempTextButton->lpButtonText; - GetTextExtentPoint( hDC, lpButtonString, strlen(lpButtonString), &ButtonTextSize ); + GetTextExtentPoint( hDC, lpButtonString, lstrlen(lpButtonString), &ButtonTextSize ); ButtonWidth = (4 * BUTTON_BORDER) + (LONG) ButtonTextSize.cx; (lpTempTextButton->hWndButton) = CreateWindow( - "BUTTON", lpButtonString, - WS_VISIBLE | BS_PUSHBUTTON /* | WS_CLIPSIBLINGS */ | WS_CHILD, + TEXT( "BUTTON" ), lpButtonString, + WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD, xPosButton, BUTTONBAR_BORDER, ButtonWidth, ButtonHeight, hWndTextButtonBar, (HMENU) lpTempTextButton->idButton, @@ -139,8 +156,8 @@ TextButtonBar( HWND hWndParent, LPTEXTBU // FUNCTION : TextButtonBarProc( HWND, UINT, WPARAM, LPARAM ) // PURPOSE : Processes messages for the TextButtonBarWClass // MESSAGES : -// WM_COMMAND - forwarded onto the owner -// WM_PAINT - draw a 3D background +// WM_COMMAND - forwarded to the owner window +// WM_PAINT - draws a 3D background // COMMENTS : // ************************************************************************ LRESULT CALLBACK @@ -154,7 +171,7 @@ TextButtonBarProc( HWND hWnd, UINT uMsg, case WM_COMMAND: SendMessage( hWndToolBarOwner, uMsg, wParam, lParam ); - return( NULL ); + return( FALSE ); case WM_PAINT: hDC = BeginPaint( hWnd, &ps ); @@ -175,7 +192,7 @@ TextButtonBarProc( HWND hWnd, UINT uMsg, DeleteObject( SelectObject( hDC, GetStockObject(BLACK_PEN) ) ); EndPaint( hWnd, &ps ); - return( NULL ); + return( FALSE ); default: return( DefWindowProc(hWnd, uMsg, wParam, lParam) );