|
-
Feb 21st, 2002, 09:30 AM
#1
Thread Starter
Frenzied Member
Setting combo box style at runtime?
If I want to change the style of a button control at runtime I can do this by sending it the BM_SETSTYLE message and refreshing it...
Is there a way of doing this for a combo box that has already been created? Specifically how do I set CBS_UPPERCASE or CBS_LOWERCASE?
Thanks in advance,
Duncan
-
Feb 21st, 2002, 11:26 AM
#2
Unfortunately, not all styles can be change at run time.
The only way to achieve this is to setup a system hook for the entire application and watch for WM_CREATE message.
-
Feb 24th, 2002, 02:50 PM
#3
Frenzied Member
A hack around it. This will convert all characters to lowercase.
VB Code:
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
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 GetWindow Lib "user32" ( _
ByVal hwnd As Long, _
ByVal wCmd As Long) As Long
Private Const GW_CHILD As Long = 5
Private Const GWL_STYLE As Long = (-16)
Private Const ES_LOWERCASE As Long = &H10&
Private Sub Form_Load()
Dim lngStyle As Long, lngHWND As Long
lngHWND = GetWindow(Combo1.hwnd, GW_CHILD)
lngStyle = GetWindowLong(lngHWND, GWL_STYLE)
lngStyle = lngStyle Or ES_LOWERCASE
Call SetWindowLong(lngHWND, GWL_STYLE, lngStyle)
End Sub
-
Feb 25th, 2002, 09:21 AM
#4
This will work only for the "Edit" part of the comboxbox. All items in the list will still be the same.
-
Feb 25th, 2002, 09:44 AM
#5
Fanatic Member
You might want to check out the code here http://www.thescarms.com/vbasic/OwnerDrawn.asp also.
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
|