Hi,
How can I create a Slider control without having to use the common controls ocx-files?
Printable View
Hi,
How can I create a Slider control without having to use the common controls ocx-files?
A whole lot more code than would/could be posted here. Whats wrong with the common controls ocx?
it's too big!!
Use CreateWindowEx to create the control, and specify msctls_trackbar as the classname.
Also make sure that you load the common control library with the LoadLibrary function.
Here's an example I just wrote up.
VB Code:
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long Private Const TRACKBAR_CLASS = "msctls_trackbar" Private Const WS_CHILD = &H40000000 Private Const WS_VISIBLE = &H10000000 Private hModule As Long Private Sub Form_Load() hModule = LoadLibrary("comctl32.dll") If hModule <> 0 Then Dim hProg As Long hProg = CreateWindowEx(0, TRACKBAR_CLASS, "", WS_CHILD Or WS_VISIBLE, 20, 20, 100, 20, Me.hWnd, 0, App.hInstance, 0) Else MsgBox "Cannot load comctl32.dll", vbOKOnly + vbExclamation, "Error" Unload Me End If End Sub Private Sub Form_Unload(Cancel As Integer) If hModule <> 0 Then FreeLibrary (hModule) End Sub
Thanks.