HOWTO: Change the BackColor of a ToolBar When it is Docked

ID: Q139291


The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0


SUMMARY

In Visual FoxPro, the BackColor of a custom toolbar is set to grey by default. This article describes how to use the Windows API to ensure that your toolbar BackColor is the same as the color of the docking area of your application window.


MORE INFORMATION

The background color of the docking area is controlled by the Button Face color in Windows 3.1 and by the 3D Objects color in Windows 95. To ensure that your toolbar BackColor matches the background color of the docking area of your application window, use the Windows API to get the current color of the docking area, and then set the BackColor of your toolbar to the color returned.

To get the 3D Objects color in Windows 95 or the Button Face color in Windows 3.1, add the following code to the AfterDock event in your ToolBar or ToolBar class:


DECLARE INTEGER GetSysColor in User32.dll Integer
   This.BackColor = GetSysColor(15) 
The GetSysColor() API function can use the following list of color constants. These constants were obtained from the Winuser.h header file that is shipped with Microsoft Visual C++. This list can be placed in a header file and used with the formset that is associated with the toolbar. Using the actual Winuser.h header file as an include file with a form might cause Visual FoxPro to stop responding.

Here is the list of color constants:

   #define CTLCOLOR_MSGBOX             0
   #define CTLCOLOR_EDIT               1
   #define CTLCOLOR_LISTBOX            2
   #define CTLCOLOR_BTN                3
   #define CTLCOLOR_DLG                4
   #define CTLCOLOR_SCROLLBAR          5
   #define CTLCOLOR_STATIC             6
   #define CTLCOLOR_MAX                7
   #define COLOR_SCROLLBAR             0
   #define COLOR_BACKGROUND            1
   #define COLOR_ACTIVECAPTION         2
   #define COLOR_INACTIVECAPTION       3
   #define COLOR_MENU                  4
   #define COLOR_WINDOW                5
   #define COLOR_WINDOWFRAME           6
   #define COLOR_MENUTEXT              7
   #define COLOR_WINDOWTEXT            8
   #define COLOR_CAPTIONTEXT           9
   #define COLOR_ACTIVEBORDER         10
   #define COLOR_INACTIVEBORDER       11
   #define COLOR_APPWORKSPACE         12
   #define COLOR_HIGHLIGHT            13
   #define COLOR_HIGHLIGHTTEXT        14
   #define COLOR_BTNFACE              15
   #define COLOR_BTNSHADOW            16
   #define COLOR_GRAYTEXT             17
   #define COLOR_BTNTEXT              18
   #define COLOR_INACTIVECAPTIONTEXT  19
   #define COLOR_BTNHIGHLIGHT         20
   #if("4" $ OS())
   #define COLOR_3DDKSHADOW           21
   #define COLOR_3DLIGHT              22
   #define COLOR_INFOTEXT             23
   #define COLOR_INFOBK               24
   #define COLOR_DESKTOP           COLOR_BACKGROUND
   #define COLOR_3DFACE            COLOR_BTNFACE
   #define COLOR_3DSHADOW          COLOR_BTNSHADOW
   #define COLOR_3DHIGHLIGHT       COLOR_BTNHIGHLIGHT
   #define COLOR_3DHILIGHT         COLOR_BTNHIGHLIGHT
   #define COLOR_BTNHILIGHT        COLOR_BTNHIGHLIGHT
   #endif 
To create a header file out of the constants listed above:
  1. Either copy and paste the code or type the code into a new text file in Visual FoxPro.


  2. Save the text file as Colors.h or any other valid file name with a .h extension.


  3. Open a form in the Visual FoxPro Form Designer and select the Include file command from the Form menu. Click the name of the header file created in step 2.


  4. Use the constant names in the GetSysColor() API function.


Additional query words: API GetSysColor

Keywords : kbToolbar kbVFp kbVFp300
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: October 6, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.