-
Jun 19th, 2024, 09:23 AM
#1
Thread Starter
Frenzied Member
Draw VB6-Form with RC6.Cairo
Hi Olaf,
I'm trying to use RC6.Cairo to draw VB6-Forms, including TitleBar(MinButon, MaxButton, CloseButton) and Form-Borders.
Could you provide some code in RC6.cWidgetForm that does the above? Thanks!
-
Jun 19th, 2024, 12:00 PM
#2
Re: Draw VB6-Form with RC6.Cairo
The following thread should contain sufficient inspiration, I guess... (including resize at the borders)
https://www.vbforums.com/showthread....gets-cwMDIMock
Olaf
-
Jun 22nd, 2024, 09:51 AM
#3
Thread Starter
Frenzied Member
Re: Draw VB6-Form with RC6.Cairo
Last edited by SearchingDataOnly; Jun 22nd, 2024 at 10:01 AM.
-
Jun 22nd, 2024, 03:38 PM
#4
Re: Draw VB6-Form with RC6.Cairo
1) If you don't want Font-Symbols (for Minimize, Normal, Close), then the DrawingAlgos are:
- Minimize: CC.DrawLine
- Normalize: CC.Rectangle
- Close: two CC.DrawLine-calls (for the "X")
The x, y Offsets for these Cairo-Drawing-calls can be derived via simple Algebra -
relative to the "greyish ButtonArea" which is already drawn...
2) The Problem here is your misunderstanding of the Widget-Engines Refresh-mechanism.
(a W.Refresh only refreshes its own area, including only its own children - not its "surroundings")
W.Parent.Refresh is the better call, after you changed a Widgets size on its hosting (Parent)Container-Widget or -Root)
3) For a "mocked Form-Host" (which is fixed anyways with its TopLeft-corner) -
the "8 Mini-Rect-Knobs" are overkill IMO - why not just use the normal Form-Borders (at the right and bottom-edge) for resizing...
Points 2 and 3 are fixed with the following new code for your Form1:
Code:
Option Explicit
Private WithEvents MockW As cWidgetBase
Private Sub Form_Initialize()
Me.ScaleMode = vbPixels
End Sub
Private Sub Form_Load()
Set MockW = ucPanel1.Widgets.Add(New cwMDIMock, "MyForm", 0, 0, 300, 240).Widget
MockW.Moveable = False
MockW.Object.Caption = "Hello World"
MockW.Parent.Refresh
End Sub
Private Sub MockW_MouseDown(Button As Integer, Shift As Integer, ByVal x As Single, ByVal y As Single)
MockW.Moveable = False
End Sub
Private Sub MockW_MouseMove(Button As Integer, Shift As Integer, ByVal x As Single, ByVal y As Single)
Static lastX!, lastL!, lastW!, fx!
Static lastY!, lastT!, lastH!, fy!
Dim nWidth!, nHeight!, dx!, dy!
If Button = 0 Then
MockW.Root.GetMouseCursorPos lastX, lastY
lastL = 0: lastW = MockW.Width: fx = 1
lastT = 0: lastH = MockW.Height: fy = 1
MockW.MousePointer = IDC_ARROW
Const r = 8 'catch-distance to borders
If x > MockW.Width - r Then MockW.MousePointer = IDC_SIZEWE: fx = 0
If y > MockW.Height - r Then MockW.MousePointer = IDC_SIZENS: fy = 0
If x > MockW.Width - r And y > MockW.Height - r Then MockW.MousePointer = IDC_SIZENWSE
MockW.Root.MousePointer = MockW.MousePointer 'this final "take-over"-call into the root, will cause an immediate cursor refresh
ElseIf Button = vbLeftButton And MockW.MousePointer <> IDC_ARROW Then
MockW.Root.GetMouseCursorPos dx, dy
dx = dx - lastX: nWidth = lastW + dx - 2 * fx * dx: If nWidth < 96 * MockW.Zoom Then nWidth = 96 * MockW.Zoom
dy = dy - lastY: nHeight = lastH + dy - 2 * fy * dy: If nHeight < 32 * MockW.Zoom Then nHeight = 32 * MockW.Zoom
Select Case MockW.Root.MousePointer 'Resize-Handling (dependent on the current MousePointer)
Case IDC_SIZEWE: MockW.Move lastL + fx * dx, lastT, nWidth, lastH
Case IDC_SIZENS: MockW.Move lastL, lastT + fy * dy, lastW, nHeight
Case IDC_SIZENWSE: MockW.Move lastL + fx * dx, lastT + fy * dy, nWidth, nHeight
End Select
MockW.Parent.Refresh 'when the size of a widget-changes, the refresh is needed on the Parent!
End If
End Sub
As for Point 1) ...(the Drawings for your Min, Norm, Close-Buttons) ...
I leave to you as an exercise... 
Hint: It needs to be implemented via the W_Paint-Event of cwMDIMock -
via the usual "State-Machine"-like mechanism -
where you set an external Prop, as e.g. MinButton = True -
followed by a W.Refresh -
which in turn triggers W_Paint (calling the re-Draw-routine) -
which in turn renders something into the area of the MinButton, when the internal m_MinButton-State = True)
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
|