|
-
Apr 27th, 2001, 02:38 PM
#1
If you really want to create them from scratch (and you have VB6) then use the following method.
Code:
Private Sub Command1_Click()
Controls.Add "VB.Label", "Label1"
Me!Label1.Move 0, 0
Me!Label1.Caption = "My Label"
Me!Label1.Visible = True
End Sub
-
Apr 27th, 2001, 02:56 PM
#2
Here's yet another method.
Code:
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal I As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WS_CHILD = &H40000000
Private Const WS_VISIBLE = &H10000000
Private Const WM_SETFONT = &H30
Private Sub Form_Load()
Dim hBtn As Long
Dim hFont As Long
hBtn = CreateWindowEx(0, _
"Button", _
"Button1", _
WS_CHILD Or WS_VISIBLE, _
32, 32, _
64, 64, _
Me.hwnd, 0, _
App.hInstance, 0)
hFont = CreateFont(Me.FontSize, 0, 0, 0, 0, Me.FontItalic, Me.FontUnderline, Me.FontStrikethru, 0, 0, 0, 0, 0, Me.FontName)
SendMessage hBtn, WM_SETFONT, hFont, 0
End Sub
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
|