|
-
Mar 14th, 2002, 06:27 PM
#1
Thread Starter
Addicted Member
Subclass Combobox
I need to use a combo box without it being 3D. I just need it to be flat and with or without a border, b/c I change the border style at run-time. What API would I use to subclass the combo box?? Thanks
-
Mar 14th, 2002, 06:34 PM
#2
Unfortunately there is no way to make a normal combobox flat, not using DrawEdge, Or any Style Combination I just spent a day searching for the same thing so I finally made my own. You can have it if you want, although it's not done completely, It doesn't have any databound props (cause I never use them anyway) but I did add autocomplete and sorting (changable at runtime) and you can add Items at designtime. Let me know if you want me to post it.
-
Mar 14th, 2002, 07:05 PM
#3
I wouldn't mind taking a look Edneeis (when its done).
-
Mar 15th, 2002, 03:35 AM
#4
Sure I'm almost done, making the dropdown list hang past the edge of the form and the like created a few problems, but I think I've found a way around most of them. I think I'll declare it 'Good enough' when I fix the scroll problem. Since I have to capture the mouse during dropdown to see if the user clicks outside of the control it made it so you can't scroll on the list. So I gotta fix that, but I added a SetTabs method and ListHeight, oh and a TransferList method so you can transfer the list to a list or combo box.
-
Mar 15th, 2002, 04:34 AM
#5
-
Mar 15th, 2002, 05:43 AM
#6
Well the vbAccelerator control is probably the best solution but here is what I got so far. Everything should work fine as long as the control is on the form itself and not on any containers (frames or tabs). I'm working on fixing that.
-
Mar 15th, 2002, 05:47 AM
#7
I use:
VB Code:
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cY As Long, ByVal wFlags As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CLIENTEDGE = &H200
Private Const WS_EX_STATICEDGE = &H20000
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOOWNERZORDER = &H200
Private Const SWP_NOREDRAW = &H8
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_SHOWWINDOW = &H40
Public Function ThinBorder(ByVal lhWnd As Long, ByVal bState As Boolean)
Dim lS As Long
lS = GetWindowLong(lhWnd, GWL_EXSTYLE)
If Not (bState) Then
lS = lS Or WS_EX_CLIENTEDGE And Not WS_EX_STATICEDGE
Else
lS = lS Or WS_EX_STATICEDGE And Not WS_EX_CLIENTEDGE
End If
SetWindowLong lhWnd, GWL_EXSTYLE, lS
SetWindowPos lhWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOOWNERZORDER Or SWP_NOZORDER Or SWP_FRAMECHANGED
End Function
If you try to give a command button a thin border you end up with a really cool button I think so anyways...
To use the above the controls border has to be set to None 1st then give a thin border using the above...which you can't do for a combo box text boxes, picture boxes etc look cool, try it on a command button
-
Mar 15th, 2002, 05:58 AM
#8
-
Mar 15th, 2002, 06:00 AM
#9
-
Mar 15th, 2002, 11:14 AM
#10
Hey its all good. Hmm that is strange I'm using a the same OS and VB version as you. And this is only my second control so I don't feel bad I'm still learning, although it worked good for me. I'll check it out, on Autocomplete were you using Partial or Exact?
Hey thanks for the bug report.
-
Mar 15th, 2002, 11:22 AM
#11
-
Mar 15th, 2002, 11:45 AM
#12
Well the crash when going to the properties at designtime was my bad I didn't post the latest code here is the repleacement. As for the Autocomplete I couldn't reproduce the problem, if its on partial then it works liek you'd think if its on Exact then it just selects what you typed in the list, although nothing looks different since you already typed the whole word(s) until you dropdown the list and then it shows that item selected already.
And now I fixed the problems for when it is not directly on the form.
Opps I guess I should read before I post I missed your last post.
Last edited by Edneeis; Mar 15th, 2002 at 12:30 PM.
-
Mar 18th, 2002, 03:45 AM
#13
-
Mar 18th, 2002, 03:55 AM
#14
No I can't do that, I'm not that cool yet. Although I am looking in to it.
-
Mar 18th, 2002, 04:00 AM
#15
No I can't do that, I'm not that cool yet. Although I am looking in to it.
Here is the most recent version (of the combo).
-
Mar 18th, 2002, 04:00 AM
#16
-
Mar 18th, 2002, 04:10 AM
#17
-
Mar 18th, 2002, 04:21 AM
#18
It's a sunny day, so why is there a dead rat in my microwave?!
Now you have no excuse for not rewriting the code using API
-
Mar 18th, 2002, 04:28 AM
#19
Well I guess I better get on it then :> !
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
|