UserControl, MarkupLabel and KeyDown Event |
Post Reply |
Author | |
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
Posted: 29 June 2009 at 6:15am |
Hi all!
I am using a MarkupLabel inside a UserControl and I need to trap some keyboard events from the MarkupLabel, or even from the UserControl (since there is only the MarkupLabel inside of it). But I have encoutered problems: 1. The MarkupLabel does not have keyboard events. 2. The MarkupLabel does not expose a hWnd, then we cannot subclass it. 3. The MarkupLabel consumes the keyboard arrows keys events, even if we use the KeyPreview=True for the usercontrol. Then the usercontrol don't receives these events (I don't know why) :( Note: the event is fired for the other keys, but not for the arrows keys. I tried to subclass the usercontrol but did not work. Anyone knows how we can to capture the keyboard events of the MarkupLabel or usercontrol for the arrows keys (vbKeyDown, vbKeyUp, vbKeyLeft and vbKeyRight) ? I am thinking about to use a timer with the GetKeyState function. But this is not a good way to implement this. The codejock team is planning to implement the keyboard events in the MarkupLabel? I think it is important. And it don't need to be per element (and I suspect that it cannot to be), it can be for the entire control. The project files are bellow for testing: 20090629_061525_TestControlProj.zip |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
The Markup label is great, but unfortunately there are still a number
of features missing that would make it a really versatile powerhouse
for VB6. Key events are one of those missing features. I had started a
list of requests as a support ticket, but unfortunately other work was
prioritized over the Markup label. I'd be happy to start a list here
and get feedback from you about additions. Maybe CJ will be more
interested in the Markup control if they see more customers interested
in using it and having the features extended.
Here are my ideas (I'll add yours below, starting at number 10):
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Hi Jason! Thank you for the reply.
I think we can discuss the items to see what we can to implement by ourselves. I have here some notes to the items you wrote: 1. I don't know if it is so important, because we can use a usercontrol to implement it. 2. The drag and drop events can to retrieve the X and Y coordinates related to the MarkupLabel and with the item 6 we could to retrieve what elements are bellow it. 3. What would be the use of MinValue and MaxValue? I did not understand because the ScrollViewer element does scroll its content automatically. It is not only a ScrollBar. Unless we would to use it not as a container but as a ScrollBar (we can?). 5. I think that the addition of the TextBox element is important and this feature was requested by other users already. The ListBox and ComboBox elements would to be nice too. But if the codejock team does not have too much time, simple adding the TextBox is a good start. 6. Good idea! 7. This item we could to implement ourselves if we had the Left and Top properties for each element (see item 13 bellow). New items to the wish list: 13 A. To have Left and Top (read-only) properties for each element. These properties could to be related to the parent element. Example of use: to retrieve the Top position of a TextBlock inside a StackPanel, being this TextBlock not the first one in the StackPanel. Maybe we can implement it by ourselves using the elements Height and Width properties, plus the Margin and Padding. But it should to be better that it could to be inside of the control itself. So all of us will have access to it, until the ones that cannot to realize how to implement it. And while it is not done yet by the codejock team, we could to use the subforum to share these stuffs. 13 B. We could have another XLeft and XTop properties that are relative to the control. Can we calculate it for all the elements? I will test it. Finally: I think it is a good idea to have a subforum for the MarkupLabel. And the posts related to it can be moved to there. This control is powerfull and we are not using all of its power. We need to promote it. (Or we would to move to the XAML Snippets section?) I am doing a control that uses the MarkupLabel to show some great things we can make with it. Once I end it I will post it here or in the XAML Snippets. Thanks to jbpro, Aaron and others that shared its codes. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Some new items: 13 C. The Height and Width properties of the elements does not return the actual values that are being used for them. They return the values that was set by the application or by the XAML string. Then it would to be a valuable thing another 2 properties (the name can be ActualHeight and ActualWidth or something else) that return the actual Height and Width that are being used for the element at the time the call is made. The same could to be applied to the Margin, Padding and BorderThickness properties. I suspect that these values are already stored inside of each element at run-time, then exposing them in a read-only mode may not to be an hard work. Well, without the ActualHeight and ActualWidth properties we cannot to calculate the actual Top and Left positions of each element at run-time, as we expected (item 13 A). The Margin, Padding and BorderThickness are also needed for our calculations. 14. Scroll event for the ScrollViewer element. 15. To add support to add and/or change the Style property of the elements at runtime. Example: Set Border = MarkupLabel1.MarkupContext.CreateObject("Border") ' This does not work: Border.Style = "{StaticResource br}" ' This does not work too: Set Border = MarkupLabel1.MarkupContext.Parse("<Border Style='{StaticResource br}'/>") Set TextBlock = MarkupLabel1.MarkupContext.Parse("<TextBlock Style='{StaticResource tr}' />") Anyone knows how to do it at runtime? |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Hi Krog, looks like you've been busy :)
1. Originally I wanted it to be a container control so that I could implement my own OLEDragDrop support by putting a transparent standard label over the MarkupLabel (I do this with another control that lacks OLEDragDrop but it is a container control, so it supports this workaround). Using the UserControl method, the Label never appears above the MarkupLabel in the ZOrder because it is windowless. I've since found a way to implement OLEDragDrop at the form level, which suits my purposes, so this isn't a critical feature request by any stretch. 2. Yes, as long as we have the drag & drop events ;) 3. The min value and max value (along with Large/Small change values) would allow use to make a "stepped" scrollbar instead of a "smooth" one. For example, I have a 150px wide scrollviewer with 10 of 150 px wide images. If I could set the Min to 0, Max=1500 and Large/SmallChange values to 150, then clicking the scroll bar would advance one image at a time like a slideshow. Now that I think of it, maybe Min and Max aren't necessary as long as we have Large/SmallChange properties. Of course, if we had a Slider control then we could use that instead of a scrollbar. 5. TextBox/ListBox/ComboBox are all needed, but that's not what I meant in my #5. Right now, every markup object has a Tag property that you can assign another markup object too. Other CJ controls (e.g. the ReportControl records) have tag properties that accept ANY VB6 class or object. This is really useful because you can create a class with a bunch of properties to track all sorts of item specific data and then assign it to an item. Since other CJ controls have true Variant Tag properties, I think the Markup control objects should have it too. 7 & 13 & 14. You are right, RelativeLeft, RelativeTop (both relative to Parent), ClientLeft, ClientTop (both relative to MarkupControl) and ActualWidth and Actual Height properties would make a lot of things possible. 16. Excellent Idea. 17. I've only just started experimenting with styles, and I agree that some way to create, modify and apply styles on the fly is required. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Krog, I merged 13, 14 & 15 into a single item in the big list since I figured they were all related. I've also thought of three new proposed items:
16. Slider control would be great, especially if #5 is not implementable. 17. ProgressBar would be great. I know we can implement our own, but having a system/skin style bar would be nice 18. Speaking of implementing our own progress bar, we still can't implement an auto width progress bar because width values can't be in % (% would also be great for font sizes). Right now we have the ability to set width/height in PX or PT, but % (relative to parent object) would be great as well. Failing that, #14 should allow use to get the actual width of objects and calculate percentages ourselves. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Hi Jason!
I changed the item numbers above. Ok, now I understood the item 5. The more I work with the Markup Control, more I discover its power. I am impressed. And it is easy to work with it. Example: We use GDI+ without to know the API. We can make a lot of things with it. We may be seated in a gold mine and we don't know :) Maybe in 2 or 3 days I should be sharing my discoveries. Question (for anyone that can help): Is there a way to count how many elements does exist in the MarkupLabel MarkupContext or MarkupUIElement? I am testing techniques to remove elements from it. I remove items from grids using the Grid.Children.RemoveAt function and removing items that are child of other elements using: Set Border.Child = Nothing But I don't know if all the child elements are really removed from the markup control (if the element object and the memory is being released) or only unlinked from the parent element. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Hi all!
I posted the XAML Grid Demo in the XAML Snippets > Samples and Demo Applications. I will continue to post the feature requests here, and the control update will be made there. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
19. To set and change the element properties using the property name and the value as strings.
Example: Border.Properties("Background") = "White" Debug.Print Border.Properties("Background") Border.Properties("Background") = "<LinearGradientBrush ... >" Debug.Print Border.Properties("Background") Border.Properties("CornerRadius") = "10" Debug.Print Border.Properties("Background") And maybe (if possible): Border.Properties("Style") = "{StaticResource GreenBorder}" And maybe (if possible, but not so important as the previous): Border.Properties("Grid.Row") = "3" Border.Properties("Grid.Column") = "3" Debug.Print Border.Properties("Grid.Row") Debug.Print Border.Properties("Grid.Column") Rectangle.Properties("Canvas.Top") = "50" Rectangle.Properties("Canvas.Left") = "25" Debug.Print Border.Properties("Canvas.Top") Debug.Print Border.Properties("Canvas.Left") As the VB6 does not support inheritance, this property (named Properties) is easily exported in an usercontrol, as it is only one. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
20. Resize event for the MarkupLabel control.
21. A Redraw (or Render) property, that we can set to False when we will make a lot of modifications on the elements, and we can set back to True when it's done.
The reason to this function to exist is make the rendering occurs only once in these cases, to make its use faster. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Hi Krog, I've updated the feature request list.
Couple of things: 1) For your request #19, can you explain more why this would be more useful than (let's say) just exposing the MarkupContext or specific markup objects as public properties in a UserControl? Also, a new idea (what do you think): 22. Container object - This object woud be able to hold any ActiveX control so you could integrate all of the already available controls into your markup layouts. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Well, maybe the item 19 is not so important. The reason for the string properties is to exist for the people that are used with the XAML strings. But we really can use the objects.
The item 22 is a good idea, but related to this issue, I think that the codejock team may to decide what is the best way to implement this feature for the VB users. In the ToolkitPro (C++) there is a way to include controls in the markup. It would be good if we could to insert until usercontrols in markup. Maybe using string properties this could to be implemented. <MyControl Type='TextBox' Name='txtUser' Grid.Row='1' Grid.Column='3'> <Properties> <Property Name='Text' Value='Text1'> <Property Name='BackColor' Value='0xffffff'> // or '&Hffffff' or 'White' or 'vbWhite' ??? <Property Name='Font.Name' Value='Tahoma'> // This can be used? </Properties> </MyControl> Or only setting the properties using the object model would to be sufficient: MarkupLabel1.Caption = "<MyControl Type='TextBox' Name='txtUser' />" Set txtUser = MarkupLabel1.MarkupUIElement.FindName("txtUser") txtUser.Text = "Something" txtUser.BackColor = vbWhite txtUser.Font.Name = "Tahoma" But how to register the TextBox as a valid control? And how to register an UserControl as a valid control? And the events? And the TabStops? It appears to be not so easy to implement... I confess that it is not my priority. By now, having the elements ClientTop, ClientLeft, ActualHeight and ActualWidth properties would to be sufficient to put the controls at the required position. Using also the Scroll event of the ScrollViewer. At least it is sufficient to me. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
I was thinking something more along the lines of:
1) Put a MarkupLabel (MarkupLabel1) and a control (let's say a ReportControl, named ReportControl1) on a form. 2) In the Form_Load event add all your Markup objects to create your layout, and also add a MarkupContainer object (as you would any other Markup object) and store a reference to it in a variable (lo_Container) 3) The MarkupContainer object would have a Child property that you could set to any ActiveX control, for example Set lo_Container.Child = ReportControl1. This would attach the ReportControl inline with the rest of your Markup object inside the MarkupLabel control. All of the ReportControl/ActiveX child control events would be handled by the regular control events (no extra work for CJ there). All of the property/method interaction would happen directly with the ActiveX control (no extra work for CJ there). The MarkupContainer object would just have to handle resizing the child (as it resizes), moving the control (as the container object moves) and controlling visibility of the child (as its own visibility changes). We would get the best of both worlds (Xaml/Markup and existing library of ActiveX controls). |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
OK. In this way we do not create a new instance of the control. It is easier to implement, I hope.
|
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Well, I think this is a pretty good list to submit to CJ, unless you have any more additions?
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
By now I have no more additions, but I am still working in the XamlGrid control and some new ideas can arise.
I have another MarkupLabel based control that I am developing and I will release it later :) I still did not have time to see your chart code. I will do it later. It appears to be a great control. The look is great. Congratulations! But you can send it, with a link to this topic. So we can continue adding new ideas. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
I think that the item 19 is a great feature. I will describe its use:
Suppose we have an usercontrol and we want that it has a different look while it has the focus. The application may to set these looks (for NoFocus and Focus states) only once and the usercontrol may to update its look when it receives or loses the focus. The app could to do this: UserControl.BorderFocusProperties("Background") = "xxx" UserControl.BorderFocusProperties("BorderBrush") = "xxx" UserControl.BorderNoFocusProperties("Background") = "yyy" UserControl.BorderNoFocusProperties("BorderBrush") = "yyy" And the usercontrol can use this info and change the look like this: If HasFocus Then For i = 1 To UBound(FocusProps) Border1.Properties(FocusProps(i).Name) = FocusProps(i).Value Next Else For i = 1 To UBound(NoFocusProps) Border1.Properties(NoFocusProps(i).Name) = NoFocusProps(i).Value Next End If Or the MarkupLabel could to have a PropertyBag and use it like this: If HasFocus Then Set Border1.PropertyBag = FocusProps Else Set Border1.PropertyBag = NoFocusProps End If Or better: we could to create and set the styles and change them at run-time. The usercontrol can to create the style and change its properties (received from the app), like this: Private BStyleWithFocus As MarkupStyle Property Let BorderFocusProperties(Name As String, Value As String) Set BStyleWithFocus = MarkupLabel1...Styles.FindName("BorderWithFocus") If BStyleWithFocus = Nothing Then Set BStyleWithFocus = MarkupLabel1...CreateObject("MarkupStyle") BStyleWithFocus.xKey = "BorderWithFocus" 'xKey Or Name BStyleWithFocus.TargetType = "Border" MarkupLabel1.Styles.Add BStyleWithFocus End If BStyleWithFocus.Property(Name) = Value End Property Then the usercontrol can change the element style like this: If HasFocus Then Border1.Style = "{StaticResource BorderWithFocus}" Else Border1.Style = "{StaticResource BorderNoFocus}" End If Another idea (that can be the item 23): When using XAML we can set the properties of the child elements in the parent one, e.g. <StackPanel TextBlock.FontFamily="Tahoma" TextBlock.FontSize="14" TextBlock.FontWeight="Bold"> It would to be good to have this at run-time too, something like this: StackPanel1.Properties("TextBlock.Foreground") = "Green" StackPanel1.Properties("TextBlock.HorizontalAlignment") = "Center" StackPanel1.Properties("TextBlock.FontSize") = "14" I don't know if this can be done using styles. Another item (19 C) (If the codejock team does not have enough time, this is not so important as the previous): Suppose that we want the usercontrol to have some element on a different row and column from a grid when it has the focus: UserControl.BorderFocusProperties("Grid.Row") = "xxx" UserControl.BorderFocusProperties("Grid.Column") = "xxx" UserControl.BorderNoFocusProperties("Grid.Row") = "yyy" UserControl.BorderNoFocusProperties("Grid.Column") = "yyy" Well, I think that this one cannot be done with styles. Without the features above (in the case that the app wants the usercontrol to have a different look at different states) we can use only the object model and then the app may use a lot of code to change the usercontrol look at the usercontrol events, signaling state change. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Item 24: A way to get the ScrollBar Width of the Vertical ScrollViewer, as well as the ScrollBar Height of the Horizontal one. Or only one property for bot purposes: ScrollBarThickness Item 25: (related to the markup and not to the MarkupLabel) An option to show the ScrollViewer ScrollBar only when needed, and hide it when there is no sufficient content to scroll. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Item 26: The ScrollViewer ScrollBar is being shown with a line in its left side, like the following picture: |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
A way to set and change the Background of the elements to a LinearGradientBrush at run-time would be great.
Implementing the item 19 could to be a way to do it, and would be sufficient by now. Example: Border.Properties("Background") = "<LinearGradientBrush ... >" It is important to be able to apply them to the styles too, when creating the styles at tun-time. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Jason and Bernardino
It looks like you are the only one here... It's outrageous that no one of CJ support team hasn't replied on your post. Not a single reply??? It has been a long time since Markup has been upgraded to a higher level. You would expect that the headman of Markup would reply... but no...
Thanks for having you to keep Markup alive
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Hey Aaron, sorry for the delay in getting back to you about this, but thanks for the support. I've had an open ticket for a while now without any feedback from CJ, so it doesn't look like they are much interested in expanding on the markup control. Personally, I think its a shame and a missed opportunity, but there's not much else I can do to promote markup and try and get CJ to see the potential. Maybe if others start to demand some improvements it will help motivate CJ, but perhaps nobody else is interested in markup the way we are and that is why CJ isn't devoting many resources to it?
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Hi all!
Oleg answered a support ticket of mine on 27-Jul-2009, saying that they "have now more priority work, but will return to new Markup features as soon as it will be possible." It appears obvious to me that with a strong XAML implementation we can continue using VB6 for a lot of years. And we don't need too much new things. With these features requested in this topic, and a bit of others spreaded in another topics, we are done. It will be lacking only some features of WPF (the 3D rendering functions and the effects), but that in the other hand make it slow. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Well, I don't know if this is the better place, but here are new tips:
To add the following events on the markup elements: -MouseClick event -MouseDoubleClick event Because we are having to handle this by ourselves, and this is not cool. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |