ComboBox on Toolbar
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).
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
Option Explicit 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 End Sub 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 End Sub Upload
Original Comments (3)
Recovered from Wayback Machine