|
-
Oct 23rd, 2001, 08:08 AM
#1
Thread Starter
New Member
***Resolved***:How can I create a Slider with API?
Hi,
How can I create a Slider control without having to use the common controls ocx-files?
Last edited by ulysses; Oct 25th, 2001 at 10:38 AM.
-
Oct 23rd, 2001, 08:17 AM
#2
A whole lot more code than would/could be posted here. Whats wrong with the common controls ocx?
-
Oct 23rd, 2001, 09:35 AM
#3
Thread Starter
New Member
-
Oct 23rd, 2001, 03:15 PM
#4
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.
-
Oct 23rd, 2001, 03:20 PM
#5
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
-
Oct 25th, 2001, 10:37 AM
#6
Thread Starter
New Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|