Did you check out the latest version? It's in post #117 poste by Michael.
Printable View
Did you check out the latest version? It's in post #117 poste by Michael.
One more thing that would be nice, Change and Click events for the control...
Isn't Click the same as either MouseUp or ItemSelect?
Your right. We dont need them then. What's the resizing problem you mentioned? I dont see it.
It's too short, and in Classic mode the button is a pixel or two too tall. I had it the same height as a normal combo box, but then we have the problem with the listview row height. That could be solved by turning off the gridlines from lstChoice, but then we wouldn't see the column separators. I guess if that isn't an issue we could do that, what do you think?
I cant see that. Can you send a screenshot?
Also, check this version out. I made some modification in the usercontrol's Resize event. There was a problem that the user could manualy resize the control to have shorter height then needed. The corrections are commented.
I have checked it both in classic mode and in XP Style mode. Works good in both. The only difference (not a problem) is that in classic mode, the dropdown button resizes along with the control, but in XP mode the picDrop is always the same height.
I can't now either, it seems to have fixed itself :DQuote:
Originally Posted by baja_yu
I tried that and it wouldn't let me :confused:Quote:
Also, check this version out. I made some modification in the usercontrol's Resize event. There was a problem that the user could manualy resize the control to have shorter height then needed. The corrections are commented.
Fixed :)Quote:
I have checked it both in classic mode and in XP Style mode. Works good in both. The only difference (not a problem) is that in classic mode, the dropdown button resizes along with the control, but in XP mode the picDrop is always the same height.
The resizing now is not allowed by user. The control automatically takes the exact height that is needed by selected font size.
I have added an InitTheme procedure to the control that takes care of choosing between XP style and Classic style. The procedure is called from _Initialize and also for all controls when the system colours change (WM_SYSCOLORCHANGE, from the WndProc), so the appearance always matches the users theme.
Also, the graphic used for cmdDrop has a grey background which shows up if the user's button face colour is not the same. Can you think of a way around this? I tried Wingdings but none of the arrow symbols are the same as the Windows one.
There is a character in Webdings that looks like it. I think it is on number six.
OK, I found the symbol, but I can't get it the right size. It is either too small (6 or 7) or too big (8 or 9 pt). Anyway, that doesn't matter too much.
I can't get the drop-down button to be the right height, it keeps making itself too tall for some reason, like it has a minimum height :confused:
Also, should we support combo box window message? (CB_*)?
You know what we need ? A ListIndex property... or a way to change the selection through code, and when we DO change the selection through code, the Changed event should fire also...
Hey guys. I've been away from my PC for a few days. Where are we at with the project? What's left to be done?
Post the project as you have it, i think I'll be able to fix that...Quote:
Originally Posted by penagate
I don't think so, then we whould have to subclass the control, that would be too much I think.Quote:
Originally Posted by penagate
The only thing I think we are left to do is what I said in my previous post about the ListIndex property.Quote:
Originally Posted by baja_yu
Also... I want to make a List property (same as a regular drop down) where you put your data in, but since we have more than one column, then it should have a character separator like comma, so then every comma the data will be in the next column. That way if you have constant data, you can preset it at design time.
[edit]
PS, I know how to make the ListIndex thing, but I don't know how to make the List property to have multiline input... I tried with String() but that did not work...
http://70.85.169.212/3524/183/emo/bananarock.gif
Here is the latest I have:
Nar, I don't know, also that reminds me, the Font choice box is very ugly... Do you know how to make it use the standard Font box like other controls?Quote:
Originally Posted by CVMichael
I fixed the problem, it was because the button's Font was set to webdings, as soon as you change to "MS Sans Serif" the button's size resizes properly...Quote:
Originally Posted by penagate
I'm gonna try to see if I can get the List property to work...
Yes, that was so that the arrow symbol would show up properly ;) Otherwise, if you use an image, you get the background colour around the arrow, and it doesn't look to great if the user has custom colours.Quote:
Originally Posted by CVMichael
There must be a way to fix that with a picture...
By the way, you did not make it show the arrow with webdings... in the button caption you have to type "6", and remove the picture, then it will show the down arrow from webdings. But I tried it and first of all you have the problem with the height, and second the arrow is too low, it's not in the center of the button, and it looks so bad because of that.
I changed it back to the picture...
I'm gonna change the button color in my windows so I can see the picture's background, that way I can troubleshoot the problem and find a way to make it transparent...
Regarding the List property, maybe it would be better to use the pipe character as the separator, it is less likely that thse user will need that character.
Another idea, cant we make the List property accept an array. Then simply have the control got through the array and read the first 'colimn number' items from it?
I did :confused: Maybe I didn't save it. And yes it looks terrible.Quote:
Originally Posted by CVMichael
I searched the web on Google, and the vbforums, and I could not find anything helpfull for the List property.
I tried like this:
and many other things, and NONE of them made the List property show up in the Properties ListVB Code:
Public Property Get List(Index As Integer) As String End Property Public Property Let List(Index As Integer, ByVal vNewValue As String) End Property ' and like this: Public Property Get List() As String() End Property Public Property Let List(ByRef vNewValue() As String) End Property
For the drop down button you should use the DrawFrameControl API function. Since that is what Windows is doing it should be drawn with the correct style on XP as well. To try it out just start a new standard EXE project. Add a PictureBox to the Form and set the BorderStyle to 0-None. Then copy and paste the following code:VB Code:
Private Declare Function DrawFrameControl Lib "user32.dll" ( _ ByVal hDC As Long, _ ByRef lpRect As RECT, _ ByVal uType As Long, _ ByVal uState As Long) As Long Private Declare Function SetCapture Lib "user32.dll" ( _ ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32.dll" () As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Const DFC_SCROLL As Long = 3 Private Const DFCS_SCROLLDOWN As Long = &H1 Private Const DFCS_PUSHED As Long = &H200 Private Enum eBtnState eButtonUp eButtonDown = DFCS_PUSHED End Enum Private blnHasCapture As Boolean Private nfBtnState As eBtnState Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then nfBtnState = eButtonDown Picture1.Refresh End If End Sub Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If blnHasCapture = False Then SetCapture Picture1.hwnd blnHasCapture = True End If If (X < 0 Or X > Picture1.ScaleWidth) Or (Y < 0 Or Y > Picture1.ScaleHeight) Then If Button = 0 Then ReleaseCapture blnHasCapture = False End If nfBtnState = eButtonUp ElseIf (Button And vbLeftButton) = vbLeftButton Then nfBtnState = eButtonDown End If Picture1.Refresh End Sub Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) SetCapture Picture1.hwnd nfBtnState = eButtonUp blnHasCapture = True Picture1.Refresh End Sub Private Sub Picture1_Paint() Dim r As RECT r.Bottom = Picture1.ScaleHeight \ Screen.TwipsPerPixelY r.Right = Picture1.ScaleWidth \ Screen.TwipsPerPixelX Call DrawFrameControl(Picture1.hDC, r, DFC_SCROLL, DFCS_SCROLLDOWN Or nfBtnState) End Sub
Thanks Joacim, very nice :) Unfortunately it doesn't work with XP styles, but that's not an issue, it can be used to draw the non-styled version of the button.
Just made a slight edit to the Picture1_MouseMove event so it redraw itself if you've pressed down the button (without releasing it) and moved the mouse away from the picture box and then entered it again.
That's probably because Windows doesn't recognise the picturebox as the push button used in a combo box. But I know for a fact that this is the way Windows draw drop-down buttons and scrollbar buttons.Quote:
Originally Posted by penagate
Joacim's code looks very promissing. Maybe there is a way to adapt it for XP styles as well...
Can anyone figure out how to do the List property ? (cuz i'm really tired of trying things)
Why do you want to use a simple List property for? Why not use ListItems since you're using a ListView anyway.
Here are some small corrections to the latest code.
1. I added some text and links in the about box.
2. There was a problem with SetFocus for the list. When you drop it down once using the cmdDrop, the focus is set and you can scroll using the arrow keys. But after that if you drop it again (without setting the focust to another control on the form) the keys are not functional (the focus is not set). The problem did not occur if you droped the list by clicking on the lstChoice.
I'll see what I can do about the List (ListItems) property.
Regarding the button and XP styles, wouldn't using the manifest file work for our control too? Because all the controls we used for making it support XP styles when using the manifest file.
Regarding the List property, we would have to either:
1. have it access the data in lstChoice, but then we would need to modify it to have an extra column which would hold the info which item (index number) in the lstListData is selected
2. have it access the selected item of lstListData (if the selected property is retained after making the selection). But then we would need to make it so the selection (data in lstChoice) changes too after making a change in lstListData.
What do you guys think?
Here is a change for classic users
VB Code:
Private Sub UserControl_Resize() Dim FntSize As Single FntSize = oFont.TextHeight("A") * Screen.TwipsPerPixelY If isThemePresent = False Then If UserControl.Height > FntSize + 120 Then UserControl.Height = FntSize + 120 ElseIf UserControl.Height < FntSize Then UserControl.Height = FntSize + 120 End If 'add this line - these numbers look good on my machine cmdDrop.Move UserControl.ScaleWidth - cmdDrop.Width - 25, _ 30, 255, UserControl.ScaleHeight - 60 Else If UserControl.Height > FntSize + 60 Then UserControl.Height = FntSize + 60 ElseIf UserControl.Height < FntSize Then UserControl.Height = FntSize + 60 End If 'move this line up here picDrop.Move UserControl.ScaleWidth - picDrop.Width - 15, _ 15, 255, UserControl.ScaleHeight - 30 End If 'rest of code ....
I don't think you can have a property array show up in the properties window.Quote:
I searched the web on Google, and the vbforums, and I could not find anything helpfull for the List property.
I tried like this:
What is it you want to do with this property? read/set one row of data or the entire table?
If you want to set data through the list property, I would suggest making the property a delimited string. You could even add a property page to the list property if you want the user to be able to just type the info in.
I want this type of list:
So would that access the entire table of data? If so then the list has to have columns.
In either case, you'll have to make a property page for the List property. On that property page you can put whatever controls you want. I don't know what type of control can show columns and at the same time allow the user to edit all the cells.
I guess we could fake it by popping up a textbox over the cell when it's clicked.
I could come up with an example if you let me know what you want it to look like.
To get set the correct width of the drop-down button you should use the GetSystemMetric API function with the SM_CXHSCROLL value.
With a property page, I would've been done by now... I wanted to imitate the regular List property of DropDown.
I our case the columns would be separated by comma or |, or we could make another property to set the separator...
Then you would have to input something like (for 3 columns) (for example):
1,a,aa
2,b,ab
3,c,ac
4,d,ad
But I looked everywhere, and LOTS of people asked for the same question, and no one had an anser.
So I guess i'll be making a property page after all...
So, the List property should just be a string of delimited values such as
"1|a|aa|2|b|ab|3|c|ac|4|d|ad"
and since the control knows how many coulmns it has it knows where to make the row breaks.
moeur, please look how the List property is for the DropDown... the list has multiline input....
The way I typed it in the post, THAT'S EXACTLY the way will be typed in the List Property
1,a,aa
2,b,ab
3,c,ac
4,d,ad
NOT
1|a|aa|2|b|ab|3|c|ac|4|d|ad
Just put a DropDown of a form, click on List property in the Properties list, and type something, to go to the next line you have to exit the List property, and then go back. Then you will have the cursor under the text you previously typed....
... or you could just press Ctrl+Enter...Quote:
Originally Posted by CVMichael