Data Access Worldwide Knowledge Base

Article ID 2210
Article Title HOWTO: Add a comboform to a cToolBar object
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2210
KBase Category VDF11
Date Created 01/24/2006
Last Edit Date 02/01/2006


Article Text
QUESTION:
Is it possible to add a comboform (or a form) to a cToolbar?

ANSWER:
As we can read at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/toolbar/toolbar_using.asp it is possible to embed non-button controls in a Toolbar. This is how I suggest you do it:

1. The best place is at the left side. This because the Toolbar has an IndentSize property to make space for your comboform. The suggestion in the article works too, but they use separator buttons and if you use that you will get vertical bars in the toolbar. You need to cover them completely to make the toolbar appearance acceptable. So Adding a second non-button control somewhere else in the toolbar requires a more creative solution. You might wonder why they suggest to use a separator and, if you look well at the picture, you'll see that their toolbar buttons are not flat toolbar buttons but pre-IE5 toolbar buttons.
2. You will need to alter the method add_focus to manually activate the comboform.
3. The method container_handle will need to be added to the toolbar because the toolbar needs to operate as a container for the comboform.

The above means the following code in your cToolBar object:

//******************************************************************
// Description
//  This method will be augmented to return the windowhandle.
//  Normally, this function would implicitly reside in containers,
//  but we're overriding it to force the children to become Windows'
//  children. If the function override was not there, the toolbar
//  would appear somewhere else on the screen.
//*****************************************************************
Function Container_Handle Returns Handle
     Handle hWnd

     Get Window_Handle To hWnd

     Function_Return hWnd
End_Function // Container_Handle

Object oComboForm Is A ComboForm
     Set Size To 100 150
     Set Location To 4 4

     Procedure Combo_Fill_List
         Send Combo_Add_Item "Value 1"
         Send Combo_Add_Item "Value 2"
         Send Combo_Add_Item "Value 3"
         Send Combo_Add_Item "Value 4"
     End_Procedure
End_Object

Object oSeparator is a cToolbarButton
     Set peStyle To bsSeparator
End_Object

Procedure Add_Focus Handle hoRoot Returns Integer
     Integer iRetval iGuiSize iGuiLocation

     Forward Get Msg_Add_Focus hoRoot To iRetval

     If (iRetval = 0) Begin
         Send Activate Of oComboForm
         Get GuiSize Of oComboForm To iGuiSize
         Get GuiLocation Of oComboForm To iGuiLocation
         Set piIndent To (5 + Low (iGuiSize) + Low (iGuiLocation))
     End
End_Procedure // Add_Focus



Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu

Web Links Related to this Article
Using Toolbar in MSDN
URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/toolbar/toolbar_using.asp


Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.