Results 1 to 6 of 6

Thread: ***Resolved***:How can I create a Slider with API?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Location
    Binghamton
    Posts
    10

    Question ***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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    A whole lot more code than would/could be posted here. Whats wrong with the common controls ocx?

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Location
    Binghamton
    Posts
    10
    it's too big!!

  4. #4
    Megatron
    Guest
    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.

  5. #5
    Megatron
    Guest
    Here's an example I just wrote up.
    VB Code:
    1. Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
    2. Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
    3. 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
    4. Private Const TRACKBAR_CLASS = "msctls_trackbar"
    5. Private Const WS_CHILD = &H40000000
    6. Private Const WS_VISIBLE = &H10000000
    7. Private hModule As Long
    8.  
    9. Private Sub Form_Load()
    10.     hModule = LoadLibrary("comctl32.dll")
    11.     If hModule <> 0 Then
    12.         Dim hProg As Long
    13.         hProg = CreateWindowEx(0, TRACKBAR_CLASS, "", WS_CHILD Or WS_VISIBLE, 20, 20, 100, 20, Me.hWnd, 0, App.hInstance, 0)
    14.     Else
    15.         MsgBox "Cannot load comctl32.dll", vbOKOnly + vbExclamation, "Error"
    16.         Unload Me
    17.     End If
    18. End Sub
    19.  
    20. Private Sub Form_Unload(Cancel As Integer)
    21.     If hModule <> 0 Then FreeLibrary (hModule)
    22. End Sub

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Location
    Binghamton
    Posts
    10
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width