-
Dec 9th, 2014, 12:14 AM
#1
VB6 Handling of Alpha-Layered Windows with vbRichClient5
Since it was asked in another thread, if there is an easy way to deal with Layered-Windows
in conjunction with the cairo-Drawing of the RC5....
Yes, of course there is - not provided by cairo itself, but by the new Form-Engine (Classes of type cWidgetForm).
If the task is, to use a Layered-Window in conjunction with a VB-Form (on top of a hosted Control on that
VB-Form, which could be e.g. a Video-Control which is playing a Stream or something), then one would
have to provide a synchronizing between the current VBForm- or VB-Control-Position - and the Position of the
Layered Window (the System doesn't support Child-Windows for layering - they currently need to be TopLevel ones).
In this Demo (to avoid SubClassing - thus making it a bit more robust) I've used a Timer, to keep the layered
Window following the desired position on top of the VB-Form (which acts as the "leading Mother-Goose").
Ok, so the following code-snippet shows already, what we need exactly (within a normal VB-Form):
- fOverlay (of type cWidgetForm)
- wOverlay (a small User-Widget, which renders the Png-Images (and a small Animation)
- and the timer for the Position-Syncing
Code:
Private WithEvents fOverlay As cWidgetForm, wOverlay As cwOverlay, WithEvents tmrPosSync As cTimer
Private Sub Form_Load()
Cairo.ImageList.AddImage "P1", App.Path & "\P1.png"
Cairo.ImageList.AddImage "P2", App.Path & "\P2.png"
Set fOverlay = Cairo.WidgetForms.CreateChild(Me.hWnd, True, False)
Set wOverlay = fOverlay.Widgets.Add(New cwOverlay, "Overlay")
wOverlay.Init "P1", "P2"
Set tmrPosSync = New_c.Timer(20, True)
End Sub
At the top of the above Form-Load procedure, we loaded and stored two Png-Images in the global Imagelist.
These are the two "Bubbles", you see at the left and right ends in the following ScreenShot:
And aside from the Reposition-Code...:
Code:
Private Sub Reposition(Optional ByVal IsResize As Boolean)
Dim x&: x = Left / Screen.TwipsPerPixelX - 56
Dim y&: y = (Top + Height / 2) / Screen.TwipsPerPixelY - 56
fOverlay.Move x, y, Width / Screen.TwipsPerPixelX + wOverlay.ImgWidth - 7, wOverlay.ImgHeight
With wOverlay.Widget
If Not IsResize And GetActiveWindow = hWnd And .Alpha < 1 Then .Alpha = .Alpha + 0.03: .Refresh
If Not IsResize And GetActiveWindow <> hWnd And .Alpha > 0 Then .Alpha = .Alpha - 0.08: .Refresh
End With
End Sub
There's not much more in our hosting VB-Form.
That we deal with a real Top-Level-Window here, becomes more apparent when you look at this Shot:
Ok, so the RC5-cWidgetForm-Classes (when hosting a TopLevel-Window) can handle Layering without
any problem - the philosophy there being, that "anything you don't draw is truly invisible".
So, that something *became* visible was ensured by the small cwOverlay-Widget (less than 30 lines of code):
Code:
Option Explicit
Public ImgWidth As Long, ImgHeight As Long, wAnim As cwAnimation
Private mImgKey1 As String, mImgKey2 As String
'****---- Start of cwImplementation-Conventions ----****
Private WithEvents W As cWidgetBase
Private Sub Class_Initialize()
Set W = Cairo.WidgetBase '<- this is required in each cwImplementation...
Set wAnim = Widgets.Add(New cwAnimation, "Anim")
End Sub
Public Property Get Widget() As cWidgetBase: Set Widget = W: End Property
Public Property Get Widgets() As cWidgets: Set Widgets = W.Widgets: End Property
'****---- End of cwImplementation-Conventions ----****
Public Sub Init(ImgKey1, ImgKey2)
mImgKey1 = ImgKey1: ImgWidth = Cairo.ImageList(mImgKey1).Width
mImgKey2 = ImgKey2: ImgHeight = Cairo.ImageList(mImgKey2).Height
End Sub
Private Sub W_ContainerResize()
W.Alpha = 0
W.Move 0, 0, W.Parent.Width, W.Parent.Height
wAnim.Widget.Move 0.8 * ImgWidth, 0, W.Width - 1.77 * ImgWidth, W.Height * 0.9
End Sub
Private Sub W_Paint(CC As cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object)
CC.RenderSurfaceContent mImgKey1, 0, 0, , , , W.Alpha
CC.RenderSurfaceContent mImgKey2, dx_Aligned - ImgWidth, 0, , , , W.Alpha
End Sub
The above Widget is itself Parent of an additional Widget (the one which ensures the "Sinuid Animation").
But I will leave out the 40 lines of Code for that Widget here - just take a look at the Zip, which contains
the complete Demo: AlphaLayering.zip
Happy layering...
Olaf
-
Dec 9th, 2014, 12:42 AM
#2
Frenzied Member
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Amazing!
...so impressive!
I hope I can use vbRichClient5 to rewrite my some projects. But I have to spare some time to learn it.
Not sure .NET can call vbRichClient5.dll properly?
Last edited by Jonney; Dec 9th, 2014 at 12:49 AM.
-
Dec 10th, 2014, 09:02 AM
#3
Junior Member
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Thank you very very much for this awesome example ! It is just more than I expected, I will try it at home tonight !
-
Dec 13th, 2014, 10:51 AM
#4
Junior Member
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
First I would like to thank you a lot for this really good example, it helps me a lot and I'm near to do exactly what I want with it. vbRichClient5 is very powerful !
I have some other objectives to achieve, I will be very grateful if you indicate me what are the good ways to do it.
Below my objectives :
Objective 1 : I want to move/animate/apply special effects to differents PNG of the transparent layer independently but when I move my image, the cWidgetForm is too small.
Question 1 : How can I create a cWidgetForm that match extely with the bottom non-transparent form (same height and width and same position) ?
Question 2 : My final animation will be similar to the bubble move that I've done in the code snippet below . Is it the good way to move my PNG inside the transparent layer ? I really like the fluidity of the "VB6 Cairo-Blending-Performance" example, is it compatible with cWidgetForm ?
Question 3 : I've seen many special effects in your RC5cairoTutorial examples how can I apply some of them to the PNG that are on my transparent layer ? I'm able to apply a blur effect with the second code-snippet below, but is it possible to do more easily (rotations, blur and revert blur...) ?
VB Code:
Private Sub W_Paint(CC As cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object) Static MyXpos As Long Static MyYpos As Long Static MyMov As Long Static direction As Integer Static Alternate As Boolean Dim FloatingMov As Boolean CC.RenderSurfaceContent mImgKey1, 0, 0, , , , W.Alpha ' The first buble don't move If MyXpos > 550 Then FloatingMov = True ' we move the second buble to right of the form, then we do a pendular animation If FloatingMov = False Then CC.RenderSurfaceContent mImgKey2, MyXpos, MyYpos, , , , W.Alpha MyXpos = MyXpos + 1 direction = 1 ' initialise the direction, necessary to determine the direction of the movement Else Alternate = Not Alternate ' just a trick to have a slower pendular animation If Alternate Then If MyMov > 10 Then direction = -1 If MyMov < -10 Then direction = 1 MyMov = MyMov + direction End If ' CC.RenderSurfaceContent mImgKey2, MyXpos + MyMov, MyYpos + MyMov, MyMov + 50, MyMov + 50, , W.Alpha ' Funny zooming animation CC.RenderSurfaceContent mImgKey2, MyXpos + MyMov, MyYpos + MyMov, , , , W.Alpha End If End Sub
Objective2 : I would like to be able to interact with different PNG of the transparent layer.
Question 1 : I've done this code below but it's not very handy, is there a better way to know which picture has been clicked ?
VB Code:
Private Sub W_MouseDown(Button As Integer, Shift As Integer, ByVal x As Single, ByVal y As Single) If x > 500 Then MsgBox "you have clicked on the right bubble, going to blurs it !" Cairo.ImageList(mImgKey2).FastBlur (5) Else Cairo.ImageList(mImgKey1).FastBlur (5) MsgBox "you have clicked on the left bubble, going to blurs it !" End If End Sub
remark: In my example the bubble move fast at the beginning then it is slower when it is above the "Sinuid Animation". Strange isn't it ?
The modified example here for download.
-
Dec 14th, 2014, 02:10 AM
#5
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Originally Posted by schmurtz
Objective 1 : I want to move/animate/apply special effects to differents PNG of the transparent layer independently but when I move my image, the cWidgetForm is too small.
Question 1 : How can I create a cWidgetForm that match extely with the bottom non-transparent form (same height and width and same position) ?
I'd guess what you're really after is, to position the transparent Overlay-Form exactly on top of your VLC-Control?
In any case this is easy enough per GetWindowRect (no matter if the non-transparent VB-Form -
or a VB-Control is the underlying target-window).
So, before anything else - perhaps it's a good idea, to concentrate on these simple things first
(and reduce the above Demo-Projects functionality appropriately).
E.g. when you use the Sources of the animated Demo as they are, but then paste the following into the VB-Form:
Code:
Option Explicit
Private Declare Function GetActiveWindow& Lib "user32" ()
Private Declare Function GetWindowRect& Lib "user32" (ByVal hwnd&, lpRct As Any)
Private WithEvents fOverlay As cWidgetForm, wOverlay As cwOverlay, WithEvents tmrPosSync As cTimer
Private Sub Form_Load()
Set fOverlay = Cairo.WidgetForms.CreateChild(Me.hwnd, True, False)
Set wOverlay = fOverlay.Widgets.Add(New cwOverlay, "Overlay")
Set tmrPosSync = New_c.Timer(20, True)
End Sub
Private Sub Form_Resize()
picSomeControl.Move 40, 30, IIf(ScaleWidth - 80 < 1, 1, ScaleWidth - 80), IIf(ScaleHeight - 60 < 1, 1, ScaleHeight - 60)
picSomeControl.PaintPicture LoadPicture(App.Path & "\Pixar.jpg"), 0, 0, picSomeControl.ScaleWidth, picSomeControl.ScaleHeight
Reposition True
End Sub
Private Sub tmrPosSync_Timer()
Reposition
End Sub
Private Sub Reposition(Optional ByVal IsResize As Boolean)
Dim Rct(0 To 3) As Long
GetWindowRect picSomeControl.hwnd, Rct(0) 'get the screen-coords of our Control
fOverlay.Move Rct(0), Rct(1), Rct(2) - Rct(0), Rct(3) - Rct(1) 'and reposition the Overlay-Wnd accordingly
With wOverlay.Widget
If Not IsResize And GetActiveWindow = hwnd And .Alpha < 1 Then .Alpha = .Alpha + 0.03: .Refresh
If Not IsResize And GetActiveWindow <> hwnd And .Alpha > 0 Then .Alpha = .Alpha - 0.08: .Refresh
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set tmrPosSync = Nothing 'cleanup the cTimer
Set wOverlay = Nothing 'cleanup the Widget
fOverlay.Unload: Set fOverlay = Nothing 'cleanup the WidgetForm
End Sub
Private Sub Form_Terminate()
If Forms.Count = 0 Then New_c.CleanupRichClientDll
End Sub
And when we also ignore the cwAnimation-Widget, as well as the "Png-Bubbles" - and only concentrate
on a very simple Drawing-Output (a simple rounded Rectangle) in the cwOverlayWidget...
(please replace the code in cwOverlay accordingly with the one below):
Code:
Option Explicit
'****---- Start of cwImplementation-Conventions ----****
Private WithEvents W As cWidgetBase
Private Sub Class_Initialize()
Set W = Cairo.WidgetBase '<- this is required in each cwImplementation...
End Sub
Public Property Get Widget() As cWidgetBase: Set Widget = W: End Property
Public Property Get Widgets() As cWidgets: Set Widgets = W.Widgets: End Property
'****---- End of cwImplementation-Conventions ----****
Private Sub W_ContainerResize()
W.Alpha = 0
W.Move 0, 0, W.Parent.Width, W.Parent.Height
End Sub
Private Sub W_Paint(CC As cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object)
DrawOuterRectangle CC, dx_Aligned, dy_Aligned
End Sub
Private Sub DrawOuterRectangle(CC As cCairoContext, dx As Single, dy As Single)
CC.SetLineWidth 4
CC.RoundedRect 3, 3, dx - 6, dy - 6, 8, True 'leave a three pixel wide "outer area" uncovered by our rectangle
CC.SetSourceColor vbRed, W.Alpha
CC.Stroke
End Sub
You will get this simple Output (I've put a Video-ScreenShot into our mockup-VLC-control, which is only a normal PictureBox).
Olaf
-
Dec 14th, 2014, 05:48 AM
#6
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
As to your other questions:
Anything that moves (Sprites) - or requires User-Interaction (Mouse-"Clickability"),
deserves its own Class.
And thus you simply should introduce one - e.g. let's name it cBubble:
Code:
Option Explicit
Private SrfPat As cCairoPattern, mcX#, mcY#, mRadius#, mAngleDeg#, mVX#, mVY#, mColor&
Friend Sub Init(ByVal cX As Double, ByVal cY As Double, ByVal Radius As Double, _
Optional ImageKey$, Optional ByVal SpeedX#, Optional ByVal SpeedY#, Optional ByVal Color&)
mcX = cX: mcY = cY: mRadius = Radius
mVX = SpeedX: mVY = SpeedY: mColor = Color
If Not Cairo.ImageList.Exists(ImageKey) Then Exit Sub
With Cairo.CreateSurface(2 * Radius, 2 * Radius).CreateContext
.RenderSurfaceContent ImageKey, 0, 0, 2 * Radius, 2 * Radius
Set SrfPat = .Surface.CreateSurfacePattern 'wrap the ImageSurface in a cCairoPattern
End With
'do a "shift within the Sprite-Pattern", to bring its Default-TopLeft(0,0) Coord into its center
Set SrfPat.Matrix = SrfPat.Matrix.TranslateCoords(SrfPat.Surface.Width / 2, SrfPat.Surface.Height / 2)
End Sub
Public Sub SetNewPositionState(ByVal dT As Double, ByVal dx&, ByVal dy&) 'just a simple bouncing
If mcX < mRadius Then mVX = Abs(mVX) Else If mcX > dx - mRadius Then mVX = -Abs(mVX)
If mcY < mRadius Then mVY = Abs(mVY) Else If mcY > dy - mRadius Then mVY = -Abs(mVY)
mcX = mcX + mVX * dT
mcY = mcY + mVY * dT
If mAngleDeg > 360 Then mAngleDeg = 0 Else mAngleDeg = mAngleDeg + 0.1 * Sgn(mVX + mVY)
End Sub
Public Sub Draw(CC As cCairoContext, Optional ByVal Alpha# = 1)
CC.Save
CC.TranslateDrawings mcX, mcY 'translate the Context
CC.RotateDrawings mAngleDeg 'now rotate the Coord-System (according to the current Infos in our Body)
If SrfPat Is Nothing Then 'no proper Image was given, so we draw only an "outline"
CC.SetLineWidth 2
CC.ARC 0, 0, mRadius
CC.LineTo 0, 0
CC.SetSourceColor vbBlue, Alpha
CC.Stroke
Else 'let's draw the pre-cached Image-pattern
CC.ARC 0, 0, mRadius - 1 'after applying a soft coloring as the ground-layer for the Png-Bubble
CC.SetSourceColor mColor, Alpha * 0.2
CC.Fill
CC.SetSourcePattern SrfPat
CC.Paint Alpha
End If
CC.Restore
End Sub
Resulting in this Output then (bouncing Bubbles with correct Delta-T based Movement):
Here's the complete code for this simplified Demo in a Zip again:
AlphaLayeringSimple.zip
Olaf
-
Dec 14th, 2014, 12:27 PM
#7
Junior Member
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Many many thanks for this ! I'm really impressed, this is awesome and it will be very useful !
I feel to be so bad because I'm trying (since many hours) to find which bubble has been clicked and I don't find the right way. It seems difficult to me to implement events on bubbles...
By observing your example "Widgets (MouseCursors and ImageKeys)" I've seen that you use multiple cwSimpleWidget to be able to use events from cWidgetBase. So I've decided to create multiple cwOverlay (which can easily manage events) but I alway see only one overlay at time and in my opinion it is not optimised ...
I also found "fOverlay_BubblingEvent" in the example called "Forms with multiple PanelLayouts" ,very interesting but the sender is cwOverlay and it seems impossible to retrieve the cBubble which has been clicked.
I also proposed to compare the position of the mouse to the bubble position but with the non rectangular shape of the bubble it is not so easy.
Is there a way to affect events on bubbles (mouse_down, click ...) or a way to find the precise sender of "BubblingEvent" ?
-
Dec 14th, 2014, 01:47 PM
#8
Hyperactive Member
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
I think that you can use Sender.Key to distinguish between senders within fOverlay_BubblingEvent, but you must create them with different keys: "Overlay1", "Overlay2", ...
-
Dec 14th, 2014, 03:25 PM
#9
Junior Member
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Yes it can be a solution : one cwOverlay by PNG which requires User-Interaction, it mean one cWidgetBase by PNG. I was worried about performance of this solution but may be it's not so bad in terms of optimization because there's always only one cWidgetForm.
I was working on a code to compare the position of the mouse to the bubble position but your idea is probably better
I'm gonna test and compare the 2 solutions. Thanks for the advice, I continue to work on it !
edit : it doesn't work : the send is alway the last cwOverlay created :'( So I have created a new cWidgetForm for each cwOverlay and in this case it works. So to know which bubble has been clicked I have for each bubble : one cWidgetForm which contain one cwOverlay which contain only one cBubble.
Probably not the bast way but it's a solution...
Last edited by schmurtz; Dec 14th, 2014 at 07:44 PM.
-
Dec 14th, 2014, 09:22 PM
#10
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Originally Posted by schmurtz
...one cWidgetForm which contain one cwOverlay which contain only one cBubble.
Ah, please don't - there's no need to...
I've made an extended Demo, which covers the "clickability now" (sorry, forgot that in the earlier one).
So, what we will see now is still:
- One normal VB-Form (hosting one "Mockup-Control", a VB-PicBox which simulates a VLC-VideoControl)
- One Layering-capable cWidgetForm-Class (TopLevel-Window, though not stealing the Focus from the VB-Form).
This single, layered cWidgetForm instance is named fOverlay and managed
(with regards to its size and position) from within the normal VB-Form,
by a Timer-Instance.
And that should not change IMO.
And what we have currently on fOverlay, is its "Main-Widget" wOverlay (a Instance of the Class cwOverlay).
Hierarchy:
fOverlay (instance of cWidgetForm)
....wOverlay (instance of cwOverlay, covering the whole area of the layered fOverlay-Form completely)
This single "fully fOverlay-covering Widget" should also not change IMO.
So, everything we draw, we should draw from *within* cwOverlay.
The new Demo shows two types of "Sub-Regions" which are handled within cwOverlay now:
Hierarchy:
fOverlay (instance of cWidgetForm)
....wOverlay (instance of cwOverlay, covering the whole area of the layered fOverlay-Form completely)
........two instances of cwSimpleStaticWidget (just to show, how to get Events from not constantly moving Areas)
........two instances of the already introduced cBubble (note the leading 'c'-prefix, which signalizes that this is not a widget-class)
The latter two instances of cBubble could have also been implemented in a dedicated small
Widget: cwBubble for example - but there's a difference which we need to consider with
animated Objects which constantly move - and in case we want to be moving them "smoothly".
Any true cwWidget-implementation (which, as the Demo clearly shows, can be nested as child-
widgets in any depth) will ensure a "Pixel-aligned Positioning" of this Widget when placed or moved.
That avoidance of SubPixel-precise positioning is done, to ensure "sharp Borders" when it
comes to internal Drawing-commands on a Widgets CC (in its Paint-Event).
So, if we want to ensure "SubPixel-precise Movements" of certain Sprites within a given
Parent-Widget (against its CC, in this Parent-Widgets W_Paint Event), then we need to
keep these Sprites in separate (non WidgetBase derived and non-'cw'prefixed) normal Classes ...
So cBubble it still is (instead of a real Widget-Implementation as cwBubble).
I hope this explanation was sufficient to shed some light on the differences between the
two different "Child-Area-Types" we handle in our Parent-Widget (wOverlay As cwOverlay) now.
If not entirely clear, then please ask.
Anyways, what it looks like now is:
and here's the updated Code (version 2 of AlphaLayeringSimple)
AlphaLayeringSimple2.zip
Olaf
Last edited by Schmidt; Dec 15th, 2014 at 06:58 AM.
-
Dec 17th, 2014, 05:06 PM
#11
Junior Member
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Today I finally had time to look at the example you've done, and I have another question :
How can I thank you ?!
Your examples are so didactic and vbRichClient is so powerful, it really deserve to be famous !
The only drawback is that vbRichClient is so powerful that it is difficult to illustrate all what can be done with.
I'm working on it tonight, thanks so much again for these awesome examples !
-
Dec 17th, 2014, 09:22 PM
#12
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Just in case, this application of yours is thought to show a simple "Game-like distraction",
in case the User has pressed the Pause-Button on his VLC-VideoControl - *and* you
want this little "Bubble-Game" to scale along properly (with the current size of the VLC-
VideoControl-Container ...
Stuff like that is already covered within the Widget-Engine, not forcing you to introduce
your own Scale- or Zoom-Factor calculations with regards to the Mouse-Coords or the
Sizes of the different Widgets...
All you need, to make your Overlay-Game scale along the current Video-Size would be the
following addition into the Form-Code of the last AlphaLayeringSimple2-example I've posted
above.
To be added into the hosting, normal VB-Form:
Code:
Private Sub fOverlay_ResizeWithDimensions(ByVal NewWidth As Long, ByVal NewHeight As Long)
Const AspectRatio# = 16 / 9
fOverlay.WidgetRoot.Zoom = IIf(NewWidth < NewHeight * AspectRatio, NewWidth, NewHeight * AspectRatio) / 600
End Sub
Which will then result in the following Widget- and Sprite-renderings (as said, all done
on "full-automatic" - so, Mouse-Over, Mouse-Click-Events etc. will work further accordingly -
on the dynamically scaled label-like Static-Widgets, as well as on the moving Bubbles).
Here's a ScreenShot, how the result looks when the Form is maximized:
And this is the scaled Output, when the Video-Window is resized pretty small.
Olaf
-
Jan 11th, 2015, 01:31 PM
#13
Junior Member
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Thanks so much for all these informations and examples, it is very useful to me ! The zoom was so useful too ! Now I can resize quickly my form !
I remark that it is difficult to know from where the event comes when the bubbles are superimposed.
I've got a new question : my form seems a little empty when it loose the focus so I was thinking about a way to keep a picture of the current overlay. Is there an easy way to save the content of the overlay in a jpg for example and paint it on the background of the form when the focus is lost ? Or may be I can copy the content of the overlay into a "classic" cairo control ?
Thank you!
-
Jan 11th, 2015, 02:39 PM
#14
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
The Cairo surface object has a number of methods to write out it's content to an image file (Surface.WriteContentToJpgFile "C:\picture.jpg" is one) and also the ability to Draw it's content to a Device Context; Surface.DrawToDC Picture1.hdc,0,0 for example.
If you don't know where you're going, any road will take you there...
My VB6 love-children: Vee-Hive and Vee-Launcher
-
Jan 13th, 2015, 04:58 AM
#15
Re: VB6 Handling of Alpha-Layered Windows with vbRichClient5
Originally Posted by schmurtz
I remark that it is difficult to know from where the event comes when the bubbles are superimposed.
As Carlos already hinted at in post #8, it's the Event-Bubbling-mechanism which plays a role here...
The Events for MouseInteraction on the Bubbles are determined and raised from within the cwOverlay-WidgetClass's
own, internal W_MouseDown/W_MouseUp Events per W.RaiseBubblingEvent this way:
Code:
Private Sub W_MouseDown(Button As Integer, Shift As Integer, ByVal X As Single, ByVal Y As Single)
Set CP = CPs.CheckControlPointUnderCursor(X, Y)
If Not CP Is Nothing Then W.RaiseBubblingEvent CP, "CP_MouseDown", Button, Shift, X, Y
End Sub
Private Sub W_MouseUp(Button As Integer, Shift As Integer, ByVal X As Single, ByVal Y As Single)
Set CP = CPs.CheckControlPointUnderCursor(X, Y)
If Not CP Is Nothing Then W.RaiseBubblingEvent CP, "CP_MouseUp", Button, Shift, X, Y
End Sub
Any Bubbling-Event is making its way through the hierarchy of (potentially nested) Widgets -
up to the level of the "Root-Form" - and can be intercepted either in the "intermediate WidgetParent-classes"
or in the Root-Window in an EventSink_Routine like this:
Code:
Private Sub fOverlay_BubblingEvent(Sender As Object, EventName As String, P1 As Variant, P2 ...)
If TypeOf Sender Is cControlPoint Then
Me.Caption = EventName & " on " & Sender.Key
ElseIf TypeOf Sender Is cwSimpleStaticWidget Then
Me.Caption = EventName & " on " & Sender.Widget.Key
End If
End Sub
Originally Posted by schmurtz
I've got a new question : my form seems a little empty when it loose the focus so I was thinking about a way to keep a picture of the current overlay. Is there an easy way to save the content of the overlay in a jpg for example and paint it on the background of the form when the focus is lost ? Or may be I can copy the content of the overlay into a "classic" cairo control ?
Colin already gave hints to things you could do - but to determine the best way for "your specific case",
you would need to give a bit mor info about those specifics.
Do we still talk about an Overlay above an animated Sequence-Stream (a video) - which is rendered
on a Control you cannot really influence at the "currently decoded Video-Frame-Level"?
What I mean is - if this is still related to a VLC-Control which is "playing a movie" for example,
then the Overlay-Separation into "a layered TopLevel-Window above it", is perhaps still a good
idea (with regards to performance).
If it's for a different scenario now (as e.g. for a small 2D-game you have complete control over),
then the approach could look entirely different (without using or relying on the Systems AlphaLayering-
mechanism - since the Cairo-related Drawing- and Widget-Classes have complete Alpha-Support).
A bit more detail-info about the background of your current scenario would be nice.
Olaf
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
|