ReneMiner
31-01-2015, 18:55
it runs, but it's just an incomplete sketch.
#MINVERSION 1.9.15.0
#INCLUDE Once "UI_OOP_wrapper.tBasicU"
Type t_myWindow Extends cWindow
' instead of ControlID ;)
CloseButton As DWord
OtherButton As DWord ' this could be some array "OtherButton(123) too...
someLabel As DWord
'Static sType As String Value "t_myWindow"
'( i wish that were possible and all extended types would have their own sType then) -
' perhaps a built-in Static Typename on all udts could solve the TypeOf-Question for udts...
End Type
Dim myWindow(3) As t_myWindow
' either dimension dialogs as global
' see cCommandButton_Click therefor how to use "by varname"
' or dialogs maybe local to tBMain, then see cLabel_Click()
Function TBMain()
Long numberOfDialogsAlive
With myWindow(1)
.TypeID( "t_myWindow" ) ' this is mandatory
.Init(0, "Just a window", -1, -1, 320, 240)
.SetBackcolor(%RGB_INDIANRED)
.CloseButton = myWindow(1).CreateControl( "cCommandButton", "Close 1", 10, 200, 300, 30 )
.OtherButton = myWindow(1).CreateControl( "cCommandButton", "other button", 10, 40, 300, 30)
' want to change/add something to this button?
Local lBtn As cCommandButton At .otherButton
With lBtn
.SetFont(Font_Create("courier new", 12))
.SetTooltip("just here to annoy you")
End With
.ShowModeless()
End With
With myWindow(2)
.TypeID( "t_myWindow" )
.Init(0, "another window", 100, 100, 320, 240)
.SetBackcolor(%RGB_GREEN)
.CloseButton = myWindow(2).CreateControl( "cCommandButton", "Close 2", 10, 30, 300, 30 )
.OtherButton = myWindow(2).CreateControl( "cCommandButton", "the other other button", 10, 140, 300, 30)
SetAt( lBtn, .otherButton )
With lBtn
.SetTooltip("just here to confuse you")
.SetFont(Font_Create("comic sans ms", 14))
End With
.someLabel = myWindow(2).CreateControl("cLabel","label the label", 10, 200, 300, 30 )
.ShowModeless()
End With
With myWindow(3)
.TypeID( "t_myWindow" )
.Init(0, "one more window", 300, 300, 320, 240)
.SetBackcolor(%RGB_MIDNIGHTBLUE)
.CloseButton = myWindow(3).CreateControl("cCommandButton", "Close 3", 10, 100, 300, 30 )
.someLabel = myWindow(3).CreateControl("cLabel","wow a label", 10, 30, 300, 30 )
.ShowModeless()
End With
Do
Dialog DoEvents To numberofDialogsAlive
Loop While numberofDialogsAlive
End Function
Sub cCommandButton_Click(ByRef lButton As cCommandButton)
Local i As Long
For i = 1 To UBound(myWindow)
Select Case VarPtr(lButton)
Case myWindow(i).CloseButton
If myWindow(i).Destroy() Then Nop ' *** see below
Exit Sub ' no need to check other windows buttons now...
Case myWindow(i).otherButton
lButton.SetText( IIf$(lButton.GetText = "i was clicked", "hit me once more", "i was clicked" ))
Exit Sub
End Select
Next
End Sub
Sub cLabel_Click(ByRef lLabel As cLabel)
Local lDialog Like lLabel.DialogType At lLabel.DialogPtr
lDialog.SetCaption(IIf$( lDialog.GetCaption = "my label was clicked", "hit my label again", "my label was clicked" ))
End Sub
' Dim lControl As t_UI_Control At myWindow(1).otherbutton ... if need only base-type-functionality
' Dim lRealControl Like lControl.GetType() At Varptr(lControl) ... the real control type now
' Dim lRealControl Like Heap_Get(Peek(Dword, myWindow(1).otherButton)) At myWindow(1).otherButton
' ... both the above in one step - no pre-layover
' Dim lBtn As cCommandButton At myWindow.otherButton ' sure about the type? then this.
all included in attachement
Also some
*** issue discovered:
if a type-functions result does not get requested then some using "like" dimensioned variable inside this type-function will keep it's type in the next functions execution - this should not happen. That's why .Destroy gets "requested" here instead of simple be called
+ already new ideas, await a better version soon
#MINVERSION 1.9.15.0
#INCLUDE Once "UI_OOP_wrapper.tBasicU"
Type t_myWindow Extends cWindow
' instead of ControlID ;)
CloseButton As DWord
OtherButton As DWord ' this could be some array "OtherButton(123) too...
someLabel As DWord
'Static sType As String Value "t_myWindow"
'( i wish that were possible and all extended types would have their own sType then) -
' perhaps a built-in Static Typename on all udts could solve the TypeOf-Question for udts...
End Type
Dim myWindow(3) As t_myWindow
' either dimension dialogs as global
' see cCommandButton_Click therefor how to use "by varname"
' or dialogs maybe local to tBMain, then see cLabel_Click()
Function TBMain()
Long numberOfDialogsAlive
With myWindow(1)
.TypeID( "t_myWindow" ) ' this is mandatory
.Init(0, "Just a window", -1, -1, 320, 240)
.SetBackcolor(%RGB_INDIANRED)
.CloseButton = myWindow(1).CreateControl( "cCommandButton", "Close 1", 10, 200, 300, 30 )
.OtherButton = myWindow(1).CreateControl( "cCommandButton", "other button", 10, 40, 300, 30)
' want to change/add something to this button?
Local lBtn As cCommandButton At .otherButton
With lBtn
.SetFont(Font_Create("courier new", 12))
.SetTooltip("just here to annoy you")
End With
.ShowModeless()
End With
With myWindow(2)
.TypeID( "t_myWindow" )
.Init(0, "another window", 100, 100, 320, 240)
.SetBackcolor(%RGB_GREEN)
.CloseButton = myWindow(2).CreateControl( "cCommandButton", "Close 2", 10, 30, 300, 30 )
.OtherButton = myWindow(2).CreateControl( "cCommandButton", "the other other button", 10, 140, 300, 30)
SetAt( lBtn, .otherButton )
With lBtn
.SetTooltip("just here to confuse you")
.SetFont(Font_Create("comic sans ms", 14))
End With
.someLabel = myWindow(2).CreateControl("cLabel","label the label", 10, 200, 300, 30 )
.ShowModeless()
End With
With myWindow(3)
.TypeID( "t_myWindow" )
.Init(0, "one more window", 300, 300, 320, 240)
.SetBackcolor(%RGB_MIDNIGHTBLUE)
.CloseButton = myWindow(3).CreateControl("cCommandButton", "Close 3", 10, 100, 300, 30 )
.someLabel = myWindow(3).CreateControl("cLabel","wow a label", 10, 30, 300, 30 )
.ShowModeless()
End With
Do
Dialog DoEvents To numberofDialogsAlive
Loop While numberofDialogsAlive
End Function
Sub cCommandButton_Click(ByRef lButton As cCommandButton)
Local i As Long
For i = 1 To UBound(myWindow)
Select Case VarPtr(lButton)
Case myWindow(i).CloseButton
If myWindow(i).Destroy() Then Nop ' *** see below
Exit Sub ' no need to check other windows buttons now...
Case myWindow(i).otherButton
lButton.SetText( IIf$(lButton.GetText = "i was clicked", "hit me once more", "i was clicked" ))
Exit Sub
End Select
Next
End Sub
Sub cLabel_Click(ByRef lLabel As cLabel)
Local lDialog Like lLabel.DialogType At lLabel.DialogPtr
lDialog.SetCaption(IIf$( lDialog.GetCaption = "my label was clicked", "hit my label again", "my label was clicked" ))
End Sub
' Dim lControl As t_UI_Control At myWindow(1).otherbutton ... if need only base-type-functionality
' Dim lRealControl Like lControl.GetType() At Varptr(lControl) ... the real control type now
' Dim lRealControl Like Heap_Get(Peek(Dword, myWindow(1).otherButton)) At myWindow(1).otherButton
' ... both the above in one step - no pre-layover
' Dim lBtn As cCommandButton At myWindow.otherButton ' sure about the type? then this.
all included in attachement
Also some
*** issue discovered:
if a type-functions result does not get requested then some using "like" dimensioned variable inside this type-function will keep it's type in the next functions execution - this should not happen. That's why .Destroy gets "requested" here instead of simple be called
+ already new ideas, await a better version soon