Putting a ListBox in the Toolbar


horizontal rule

Back Home Next

Author Aart Onkenhout
Date 28-09-2000


It's possible to put controls in your toolbar. To do so you must know the handle of the toolbar. To get it you can use the FindWindowExA API. When you have the handle you can use it to change the parent of objects you create using OpenUserObject.

Declare the following Local External Functions:

Function uLong FindWindowExA( long hParent, long hChildAfter, String lpszClass, String lpszWindow ) Library "user32.dll"
Function uLong SetParent( uLong hChild, uLong hWnd ) Library "user32.dll"

In your MDI-frame Open-script:


String        ls_ClassName, ls_Null

uLong        lul_Toolbar, lul_Null, lul_ListBox

ListBox      llb_1


SetNull( ls_Null )
SetNull( lul_Null )
ls_ClassName = 'FNFIXEDBAR60'
// Find handle of toolbar (for PB 7 use FNFIXEDBAR70)
lul_Toolbar = FindWindowExA( Handle( this ), lul_Null, ls_Classname, ls_Null )

// Create a listbox.
OpenUserObject( llb_1, 'Listbox', 0, 0 )
// Get handle of the listbox
lul_ListBox = Handle( llb_1 )
// Set toolbar to be the parent
SetParent( lul_ListBox, lul_Toolbar )

// Change some properties of listbox
llb_1.Y = 12
llb_1.X = 1000
llb_1.Width = 200
llb_1.Height = 61