How to add control to a specific tab at runtime

How to add control to a specific tab at runtime

Anonymous
Not applicable
306 Views
6 Replies
Message 1 of 7

How to add control to a specific tab at runtime

Anonymous
Not applicable
I'm trying to add the VoloView control to a specific tab at runtime. The
code that I have works but it adds it to the last tab that I was working on
in the editor. I would like to be able to add it to a specific tab just in
case I forget to switch back to the appropriate tab.

'Set the TabMain control to the first tab
TabMain.Tab = 0
' Add the Volo View Control to Preview the Layouts if it's installed
' on the user's system already
Set AvViewX1 = Controls.Add("AvViewX.AvViewX.1", "AvViewX2", _
TabMain)

Thanks,

--
Rodney McManamy - President
MACSolids - Maximizing AutoCAD Solids
website: www.macsolids.com
0 Likes
307 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
This sounds similar to something I was trying to find out how to do,
add a control, of whatever kind, to a form - programmatically.
In your example it's similar to what I was trying but i don't know what the
args are for different controls. Where did you find the info on this? I've
been reading the help on vbe. but cant find any info on what arg to supply
to add for example a textbox to Form1

I was trying something like
Dim NewText as Textbox
Set NewText = Form1.Controls.Add(
...this is where i'm stuck
the info tip is asking for bstrProgId as String,[name],[visible])as Control
from the help under progid:

Returns the ProgID (programmatic ID) for the control represented by the
VBControl object.
Syntax
object.ProgID

but when I try that in a sub there's no method available
'just trying to find what the progid for a textbox was
Private Sub TextBox2_Change()
Debug.Print TextBox2.progid
End Sub

when I follow the applies to link in the help for ProgId it takes me to Add
ins - can you not put regular controls on a form programatically?

I don't need it to happen at runtime, design time would do for me.
Do you know anything about this?
Thanks
Mark


"Rodney McManamy" wrote in message
news:016C0884B8D4B32FBB1D383C623C75DD@in.WebX.maYIadrTaRb...
> I'm trying to add the VoloView control to a specific tab at runtime. The
> code that I have works but it adds it to the last tab that I was working
on
> in the editor. I would like to be able to add it to a specific tab just
in
> case I forget to switch back to the appropriate tab.
>
> 'Set the TabMain control to the first tab
> TabMain.Tab = 0
> ' Add the Volo View Control to Preview the Layouts if it's installed
> ' on the user's system already
> Set AvViewX1 = Controls.Add("AvViewX.AvViewX.1", "AvViewX2", _
> TabMain)
>
> Thanks,
>
> --
> Rodney McManamy - President
> MACSolids - Maximizing AutoCAD Solids
> website: www.macsolids.com
>
>
0 Likes
Message 3 of 7

Anonymous
Not applicable
Luckily I got as far as I did because I found it on the ADN site. I also
found some stuff in the MSDN Help but unfortunatelly I didn't bookmark it.
Try searching for VBControlExtender and you might find what you need.

Here's what little I understand

'This dimensions it as basically a generic control object
Dim WithEvents AvViewX1 As VBControlExtender

'Now we need to create the control
'
'"AvViewZ.AvViewX.1" = the name of the volo view activeX control
'that is registered in the Windows Registry. If it's not properly
registered then
'the control won't be added and AvViewX1 will be nothing. Not a problem in
'my app since the user just won't be able to preview the drawings.
'
'"AvViewX2" is the name that I am going to give the control so it doen't
conflict
'with any other names.
'
'TabMain is the control that I am going to add it to. I could add it to a
tab, the form, or probably even a frame.
Set AvViewX1 = Controls.Add("AvViewX.AvViewX.1", "AvViewX2", _
TabMain)

Now comes the tricky part. The basic properties like Visible and Enabled
can be accessed by:
AvViewX1.Visible = False

But any extended properties or methods must be accessed by:
AvViewX1.object.ShadingMode

That's about all that I've figured out so far.


--
Rodney McManamy - President
MACSolids - Maximizing AutoCAD Solids
website: www.macsolids.com
"Mark Propst" wrote in message
news:61BE08E0D96A4B58E6972969857E0392@in.WebX.maYIadrTaRb...
> This sounds similar to something I was trying to find out how to do,
> add a control, of whatever kind, to a form - programmatically.
> In your example it's similar to what I was trying but i don't know what
the
> args are for different controls. Where did you find the info on this?
I've
> been reading the help on vbe. but cant find any info on what arg to supply
> to add for example a textbox to Form1
>
> I was trying something like
> Dim NewText as Textbox
> Set NewText = Form1.Controls.Add(
> ...this is where i'm stuck
> the info tip is asking for bstrProgId as String,[name],[visible])as
Control
> from the help under progid:
>
> Returns the ProgID (programmatic ID) for the control represented by the
> VBControl object.
> Syntax
> object.ProgID
>
> but when I try that in a sub there's no method available
> 'just trying to find what the progid for a textbox was
> Private Sub TextBox2_Change()
> Debug.Print TextBox2.progid
> End Sub
>
> when I follow the applies to link in the help for ProgId it takes me to
Add
> ins - can you not put regular controls on a form programatically?
>
> I don't need it to happen at runtime, design time would do for me.
> Do you know anything about this?
> Thanks
> Mark
>
>
> "Rodney McManamy" wrote in message
> news:016C0884B8D4B32FBB1D383C623C75DD@in.WebX.maYIadrTaRb...
> > I'm trying to add the VoloView control to a specific tab at runtime.
The
> > code that I have works but it adds it to the last tab that I was working
> on
> > in the editor. I would like to be able to add it to a specific tab just
> in
> > case I forget to switch back to the appropriate tab.
> >
> > 'Set the TabMain control to the first tab
> > TabMain.Tab = 0
> > ' Add the Volo View Control to Preview the Layouts if it's installed
> > ' on the user's system already
> > Set AvViewX1 = Controls.Add("AvViewX.AvViewX.1", "AvViewX2", _
> > TabMain)
> >
> > Thanks,
> >
> > --
> > Rodney McManamy - President
> > MACSolids - Maximizing AutoCAD Solids
> > website: www.macsolids.com
> >
> >
>
>
0 Likes
Message 4 of 7

Anonymous
Not applicable
awesome, thanks for the heads up, off to the msdn.... :-)~
Mark

Rodney McManamy wrote in message
news:6F645E83DB94830A83AD967F79997C3F@in.WebX.maYIadrTaRb...
> Luckily I got as far as I did because I found it on the ADN site. I also
0 Likes
Message 5 of 7

Anonymous
Not applicable
Mark,

Just so you know I finally ended up giving up on the specific tab for the
time being. I ended up inserting a picturebox control at design time on the
Tab where I want the Volo View control. I then added at runtime the volo
view control to the picturebox instead of the tab control. Works great plus
I needed the picturebox control to display the white background when I hide
the volo view control while it's loading a drawing anyways.

--
Rodney McManamy - President
MACSolids - Maximizing AutoCAD Solids
website: www.macsolids.com
"MP" wrote in message
news:1B08B3079ED1041F87F91E7AA5B6B185@in.WebX.maYIadrTaRb...
> awesome, thanks for the heads up, off to the msdn.... :-)~
> Mark
>
> Rodney McManamy wrote in message
> news:6F645E83DB94830A83AD967F79997C3F@in.WebX.maYIadrTaRb...
> > Luckily I got as far as I did because I found it on the ADN site. I
also
>
>
>
0 Likes
Message 6 of 7

Anonymous
Not applicable
Sounds like yer flyin man! neat idea.
I checked out everything I could on the VBControlExtender and tried
everything the way I thought I read it but nothing worked so I gave up on
that project for now...
now trying to figure out a control array control I could add at design time
to wrap up some functionality so I don't have to rewrite the wheel
everytime...even cut and paste is a pain when there should be a better way!
:)

the last note on the help for vbcontrolextender says: "intrinsic controls
cannot be set to the variable"
I don't know if that means what I think it sounds like it means, which is: I
can't add a textbox to a form using code.
It sounds like maybe it only works on 3rd party controls? maybe if I make
my ActiveX control it would create one of those?
I've tried to understand the stuff on vbe but still don't get it...it wants
a progId but the object errors with no ProgId property......... oh well
call me the worlds best generator of errors, not the dumbest newbie vb'er
ever! :-)~


Rodney McManamy wrote in message
news:AD15975B4F6521BFEB52CE32510B53DC@in.WebX.maYIadrTaRb...
> Mark,
>
0 Likes
Message 7 of 7

Anonymous
Not applicable
The guy who would probably know is the Ralph the Wonder Llama at
vbdesign.net He has a good site and produces a nice newsletter on VB/VBA
for AutoCAD if you don't already get it.
--
Rodney McManamy - President
MACSolids - Maximizing AutoCAD Solids
website: www.macsolids.com
"MP" wrote in message
news:6D1535F76F27CDCD07DFF11FB51F9E51@in.WebX.maYIadrTaRb...
> Sounds like yer flyin man! neat idea.
> I checked out everything I could on the VBControlExtender and tried
> everything the way I thought I read it but nothing worked so I gave up on
> that project for now...
> now trying to figure out a control array control I could add at design
time
> to wrap up some functionality so I don't have to rewrite the wheel
> everytime...even cut and paste is a pain when there should be a better
way!
> 🙂
>
> the last note on the help for vbcontrolextender says: "intrinsic controls
> cannot be set to the variable"
> I don't know if that means what I think it sounds like it means, which is:
I
> can't add a textbox to a form using code.
> It sounds like maybe it only works on 3rd party controls? maybe if I make
> my ActiveX control it would create one of those?
> I've tried to understand the stuff on vbe but still don't get it...it
wants
> a progId but the object errors with no ProgId property......... oh well
> call me the worlds best generator of errors, not the dumbest newbie vb'er
> ever! :-)~
>
>
> Rodney McManamy wrote in message
> news:AD15975B4F6521BFEB52CE32510B53DC@in.WebX.maYIadrTaRb...
> > Mark,
> >
>
>
>
0 Likes