rofl :lol: :D
Printable View
rofl :lol: :D
Very nice work with the recent mods CVMichael and baja_yu. I will do the SelectedItem property as well as the XP styles then.
OMG ! :D :D :D
Now that is really funny.... none of us thought of it ! hehehe
I have changed the attachment again, I have changed the ColapseList back to Public as it is needed by the subclassing. Doh :(
Can you upload it again baja? When I try to download it it gives me the message "Invalid attachment".
Here it is here...
By the way, we should also make the usual events like Click, DblClick, Changed, KeyPress, KeyDown, KeyUp, MouseDown, MouseMove, MouseUp, GetFocus, SetFocus...
Ow, and I also want a sub so that the user can call the "Drop" window (in case you want to have the drop window open as default when you open the form for example). I sometimes wanted to do that with a regular DropDown.
I can do that, it's very easy, but... now I guess I have to wait for penagate to make his modifications :) (and of course I have to wait till I get off work)
If anyone can think of this kind of little features to add ?
Make it a "Friend", then it should be visible only in the drop down project...Quote:
Originally Posted by baja_yu
You can use SendMessage, I think it is CB_SHOWDROPDOWN or something like that ;)Quote:
Originally Posted by CVMichael
Now I will shut up and get back to coding :p
Let's leave it as Public then, so we have it along with the Drop procedure.
Could one of you tell me how the control's height is determined? I've been looking through the code but can't find it. Its' fixed size is too tall.
Controls size is determined by the font size that you select. Choose a smaller font size and the control will shrink too.
In the cmdDrop_Click() event:
[edit]VB Code:
If lstListData.ListItems.Count < lngMaxRows Then ColsHeight = lstListData.ListItems.Count Else ColsHeight = lngMaxRows End If lstListData.Move ControlPos.Left + 2, ControlPos.Bottom, UserControl.ScaleWidth - 4, [b](oFont.TextHeight("W") + 1) * ColsHeight + 2[/b]
I just realized I named the variable wrong, it should not be ColsHeight , it should be RowsHeight
And, it's handled in the Resize event:
VB Code:
Private Sub UserControl_Resize() Dim FntSize As Single FntSize = oFont.TextHeight("A") * Screen.TwipsPerPixelY If lstListData.Visible = False Then If UserControl.Height > FntSize + 120 Then UserControl.Height = FntSize + 120 End If lstChoice.Height = UserControl.ScaleHeight lngChoiceH = lstChoice.Height cmdDrop.Height = UserControl.ScaleHeight - 90 End If lstChoice.Move 0, 0, UserControl.ScaleWidth, lngChoiceH lstListData.Move 0, 0, UserControl.ScaleWidth cmdDrop.Move UserControl.ScaleWidth - cmdDrop.Width - 45, 45 End Sub
Wait a minute, are you talking about the height of the DropDown list, or height of the control (when the list is NOT droped down)?
Thanks, got it. Now is there a way of setting both listviews' row heights? With size 8 Tahoma the control size is perfect, but the the listview rows are too short vertically.
I was talking about the height of the control, not the drop down. Sorry for the confusion.Quote:
Originally Posted by baja_yu
I'm not sure if it was mentioned yet but TrueDBCombo (made by APEX I believe) works just like you would want it to: dropdown supports multiple columns with the headers.
Is it free?Quote:
Originally Posted by RhinoBull
I can't see this, or I dont understand what you are reffering to.Quote:
Originally Posted by penagate
When you set the font size, both lists (the 'control' list which shows the selected item, and the dropdown list) change their row height based on the font size.
Yes, but that height is too short. You'll see ;)
Attached the latest version with the XP styled edge and button. It uses the vbAccelerator UxTheme class, and I'm not sure how it will behave on pre-XP systems.
Can't wait to try it out. I've been following the progress closely. :thumb:
Nooooooooooooooooooooooooo ;) :pQuote:
Originally Posted by baja_yu
Here is a small correction, plus I added the DropList procedure (ColapseList is also available).
I am not sure what we can do about the height, as it is set automatically.
Maybe we can replace lstChoice with something else. Or can it be subclassed to change the row height?
Gee... I kept refreshing the second page, and I see now we are on the 3'rd page :D
This is the longest thread I've even been subscribed to :)
There is one more 'bug':
If nothing is selected, and you try to use the SelectedItem property, and error is raised.
Penagate, are you working on implementing the events? (MouseDown, MouseUp, Click etc..)
DropList works nicely :thumb: What was the small correction you made?Quote:
Originally Posted by baja_yu
FYI, apart from adding the styling, I also changed the double DoEvents call in the slideout routine to more efficient GetMessage/TranslateMessage/DispatchMessage calls. This makes the sliding a lot smoother and quicker.
Ammm.... is it supposed to look like this ?
I think there was none. Only the DropList. I am fidling around with the row height thing.
D'oh, your not using XP are you. That means we will have to add an OS check, and if the OS is not XP then we will have to draw the button and edge normally.
Guess XP styles dont work on non XP systems. How 'bout we incorporate windows version detection. That way we can turn on the XP style if the system is XP.Quote:
Originally Posted by CVMichael
Fixed :)Quote:
Originally Posted by baja_yu
I have done ShowDropDown, HideDropDown, MouseDown, MouseMove, MouseUp. What others should we have?Quote:
Originally Posted by baja_yu
Actually I'm using Windows XP Home edition, but the Display Settings are the "Classic Style"
We'll have to incorporate a check for that too :)Quote:
Originally Posted by CVMichael
We could also have KeyPress, KeyDown, KeyUp, LostFocus events.
LostFocus and GotFocus are auto added by VB. I will code the other ones though, and also keyboard support (Alt+Down to drop list, arrow keys to select, etc.)
Great. I'm going to poke around to find a way to detect if XP styles are turned on or off...
I don't have time to look now and see how you do the XP styles, but theoretically, when you call the API functions to do the XP style thing, doesn't it return an error ? That way you know if the XP Syles are enabled or not ?
OK here is my latest version. Now supports keyboard selection and Alt+Down and Alt+Up to drop and collapse the listview.
I'm hitting the sack, so the code is back to you guys ;)
How about ColumnClick and DblClick?Quote:
Originally Posted by penagate
There was a small bug, keyboard selection does not work if you drop down the list using the mouse. The list did not get the focus.
Here is the correction.
I'm still trying to figure out the XP style problem, and the row height problem...
The row height problem can be fixed in the UserControl_Resize()
But then it won't look right on non-xp style (wich I'm using by the way)VB Code:
If UserControl.Height > FntSize + 60 Then UserControl.Height = FntSize + 60 End If
I'm not using the xp stype because I don't really like it, and also I want to same some CPU by not drowing fancy stuff on the screen.
I'm looking for a way to determin if the XP styles are turned on or not so we can draw the controls accordingally.
What if we just make it as a property ? Something like "DrawXPStyle = True" ?
Then if the user want XP Syle, he can have it... (make it default False)
That's not a bad idea. It would be much easier then to mess around with detecting windows version, then the XP style etc.
That does fix the height, but it cuts of a part of the button (in XP style at least). I've been searching around to find a way to increase the height of the row, but I'm begining to think it is not possible without changing the font...Quote:
Originally Posted by CVMichael
Just make the picDrop height smaller, I have it set to: Height = 225, Width = 255Quote:
Originally Posted by baja_yu
I am not sure that the size of the picDrop can be changed. I think it is set by Windows. Looks like we'll have to wait for Penagate to check it out. He knows that code best.
Well, I changed it, and it works...
Just tried out the latest in XP with Classic style.
It doesn't work
Maybe we could use this function to test for themesVB Code:
Option Explicit Private Declare Function GetCurrentThemeName Lib "UxTheme.dll" ( _ ByVal pszThemeFileName As String, _ ByVal dwMaxNameChars As Long, _ ByVal pszColorBuff As String, _ ByVal cchMaxColorChars As Long, _ ByVal pszSizeBuff As String, _ ByVal cchMaxSizeChars As Long _ ) As Long Const S_OK = 0 Function isThemePresent() As Boolean Dim BufferLen As Long BufferLen = 256 Dim lResult As Long Dim ThemeName As String Dim ColorBuffer As String Dim SizeBuffer As String ThemeName = String(BufferLen, 0) ColorBuffer = String(BufferLen, 0) SizeBuffer = String(BufferLen, 0) isThemePresent = False On Error GoTo NotXP lResult = GetCurrentThemeName( _ ThemeName, BufferLen, _ ColorBuffer, BufferLen, _ SizeBuffer, BufferLen _ ) On Error GoTo 0 If lResult = S_OK Then isThemePresent = True NotXP: End Function
I get error code (&H80070490): Element not found: since I don't have a theme
Can someone try it with a theme?
Very nice moeur, it works !
I tried it with XP Style, and It returned True, then I changed my settings to Classic Style, and it returned False
I guess now we have to wait for penagate to incorporate it in the control...
It gives True on my PC.
This might be a little simpler
It returns 0 if no style is applied to a window, otherwise it returns the handle to the style.VB Code:
Private Declare Function GetWindowTheme Lib "UxTheme.dll" ( _ hwnd As Long _ ) As Long
I think I got it. It now tests for Themes and adjusts looks accordingally.
Anyone want to test? :)
EDIT: New attachment. A small cosmetical correction.
Yup, It works fine on both styles XP & Classical...
By the way, why do you always indent all the code ? It's so anoying, I always have to indent back on all the modules when I download code from you...
:) I dont know, I dont like when it is close to the left border. I aways make one tab from the left...
So, what do we do now? Wait for Penagate to make the ComlumnClick and DblClick events?
I dont think that they are usefull, at least not double click, as it will always drop or colapse the list on first click.
Any other (un)known bugs to fix? Ideas to implement?
I added an About box, check attachment
For credits I wrote:
I'm not good at making nice looking About boxes, and also not good with credits stuff...Code:DropDownListView credits to:
CVMichael - had the idea, and started the project
baja_yu - contributed with fixes, and completed it
penagate - contributed with XP Style and events
Joacim Andersson - CTextSize class for TextWidth & TextHeight
moeur - isThemePresent code snipet.
If I missed something please tell tell me what to add (or do it yourself and attach back the project updated)
That's fine. We dont need anything fancy. Maybe we should create an icon for it (and use it in the About dialog too). Anyone have any good icons handy?
So, is this the final version then?
Nooo.... :DQuote:
Originally Posted by baja_yu
We need to fix it so it changes style properly when the Windows style is changed. Also, the sizing under Classic mode seems to be a bit off. Will fix ;)