--- mstools/samples/deb/toolbar.c 2018/08/09 18:21:32 1.1.1.2 +++ mstools/samples/deb/toolbar.c 2018/08/09 18:23:35 1.1.1.3 @@ -1,40 +1,48 @@ -// ************************************************************************ -// -// Microsoft Developer Support -// Copyright (c) 1992 Microsoft Corporation -// + +/******************************************************************************\ +* 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. +\******************************************************************************/ + // ************************************************************************ // MODULE : ToolBar.C -// PURPOSE : A Win32 DLL containing various ToolBar controls +// 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 // 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 : DllEntryPoint( HINSTANCE, DWORD, LPVOID ) -// PURPOSE : DllEntryPoint is called by Windows when -// the DLL is initialized, Thread Attached, and other times. -// COMMENTS : 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 WINAPI -DllEntryPoint( HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved ) +DllMain( HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved ) { UNREFERENCED_PARAMETER( hInstDLL ); UNREFERENCED_PARAMETER( fdwReason ); @@ -46,7 +54,7 @@ DllEntryPoint( HINSTANCE hInstDLL, DWORD // ************************************************************************ // FUNCTION : TextButtonBar( HWND, LPTEXTBUTTON, LPINT ) -// PURPOSE : Generate a text button ToolBar +// 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 @@ -73,21 +81,20 @@ 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( FALSE ); @@ -99,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, @@ -115,10 +122,11 @@ 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; @@ -129,8 +137,8 @@ TextButtonBar( HWND hWndParent, LPTEXTBU 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, @@ -148,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