Function: vb6 dynamic add control
HOW to Create New Button by Freebasic Code?
MY CODE IS RIGHT?
who khnow CWindow how to use?
[/CODE]
Code:
Private Sub Form_Load()
'Add: PICTURE1 control, button control
'Example: Form1.Controls.Add "VB.CommandButton", "cmdObj1", Frame1
Dim NewText1 As TextBox
Set NewText1 = Me.Controls.Add("VB.Textbox", "Text1ABC", Picture1)
NewText1.Visible = True
End Sub
MY CODE IS RIGHT?
who khnow CWindow how to use?
Code:
Function NewControl(ByVal ControlClass As String, ControlName As String, Text As String,Left2 As Long,Top2 As Long ) As .hWnd
'.hWnd CHANGE TO HWND
Dim hWndControl As .hWnd
'Dim pWindow As CWindow Ptr = New CWindow("CWindowNew")
hWndControl = pWindow2->AddControl(ControlClass, Me.hWnd, 102, Text, Left2, Top2, 200, 30, WS_CHILD Or WS_CLIPSIBLINGS Or ES_LEFT Or WS_VISIBLE Or ES_AUTOHSCROLL Or WS_TABSTOP Or ES_WANTRETURN, WS_EX_CLIENTEDGE,, Cast(Any Ptr, @Form2_CODEPROCEDURE))
Return hWndControl
End Function
Dim ObjHwnd As .hWnd, Button4 As Class_Button
ObjHwnd = NewControl("BUTTON", "ButtonX", "'new Button", 0, 0)
Button4.hWnd =ObjHwnd
MsgBox("Button4.Caption=" & Button4.Caption)
Button4.Caption = "New Button XXX"