Re: Creating new controls?!
- From: <jbk@xxxxxxxx>
- Date: Tue, 1 Aug 2006 19:17:48 +0300
Well, at first, thanx for answering. i found out how to create controls, now
i am missing the most important part!
How do i apply functions to them???
like click or change??? there is the code following that i have already
ready...
'=====================================
Option Explicit
Public Pic1
Private Sub cmdCreatePic_Click()
'these stay the same each time you access the code so they are just Dims
Dim H As Integer
Dim W As Integer
'these don't stay the same each time you access the code so they are Static
Static I As Integer
Static strName As String
'position of pic box
W = I + 375
H = I + 1135
'Making the Pic box
Set Pic1 = Form1.Controls.Add("VB.COMMANDBUTTON", "A" & strName, Form1)
'Comment out the line above and un-comment the line below for a textbox
' Set Pic1 = Form1.Controls.Add("VB.TEXTBOX", "B" & strName, Form1)
Pic1.Caption = "Test"
Pic1.Left = W
Pic1.Top = H
Pic1.Height = 375
Pic1.Width = 1135
Pic1.Visible = True
'making the pic box in a different location each time
I = I + 100
'Have to make the name of the pic box different each time other wise you get
an error
'Because there are ways you can minipulate the item added at run time using
the API
'Which include things like pic1_click() ..and you can respond to a click to
the new control
strName = strName + "B"
End Sub
'======================================
For not being accused by anyone, this is not my code!
I found it on www.planet-source-code.com
So, how can i add functions while creating them?
For being more exactly, i just want to drag them around and by clicking on
them, they should send their "name" to a textbox...
I thought of having already written the code but i cannot forecast how many
controls i will have to create each time...
Can you help me out?
Friendly,
JBK
Ï "J French" <erewhon@xxxxxxxxxx> Ýãñáøå óôï ìÞíõìá
news:44cf0133.1009869918@xxxxxxxxxxxxxxxxxxxxxxx
On Mon, 31 Jul 2006 17:02:36 +0300, <jbk@xxxxxxxx> wrote:
Hello,
can any one help me out here?
I would like to create a new textbox (or picbox,or whatever else) by
clicking on a command button...
but, i dont know how! :-)
also, i dont know if this would make any difference, these new controls
will
be draggable...(If this word exists)
Look into Control Arrays
Dragging is quite easy using APIs
Option Explicit
' Add a Textbox
' Move Textbox on MouseDown & Drag
Private Declare Function ReleaseCapture _
Lib "user32" () As Long
Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Any) As Integer
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Public Sub MoveObject(hwnd As Long)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
MoveObject Me.hwnd
End Sub
Private Sub Text1_MouseDown(Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
MoveObject Text1.hwnd
End Sub
.
- Follow-Ups:
- Re: Creating new controls?!
- From: J French
- Re: Creating new controls?!
- References:
- Creating new controls?!
- From: jbk
- Re: Creating new controls?!
- From: J French
- Creating new controls?!
- Prev by Date: Re: Question about nesting control definitions
- Next by Date: Re: File List Box
- Previous by thread: Re: Creating new controls?!
- Next by thread: Re: Creating new controls?!
- Index(es):
Relevant Pages
|