ComboBox on Toolbar
No attachments for this post
This subroutine shows how to Really put a ComboBox (or any control with a hWnd) onto a ToolBar
(or any other control/window with a hWnd).
Original Author: Andrew Mitchell Barfield
There are no input paramaters
Add a ComboBox, CheckBox and Toolbar to Form1.
Keep the default names of the above mentioned controls.
Don't worry about control placement or size.
Click the form after you run the app.
There are no function returns
No side effects, completely safe.
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Sub Form_Load()
'Set Toolbar1 as Combo1's parent, then move Combo1 where we want it.
SetParent Combo1.hwnd, Toolbar1.hwnd
MoveWindow Combo1.hwnd, 100, 1, 50, 50, True 'Note: units are pixels
'Set Toolbar1 as Check1's parent, then move Check1 where we want it.
SetParent Check1.hwnd, Toolbar1.hwnd
MoveWindow Check1.hwnd, 175, 5, 150, 15, True
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Demonstrate that Combo1 and Check1 are really "on" Toolbar1 by moving Toolbar1 when
'the form is clicked.
Toolbar1.Move X, Y
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.