Simple controls and a very simple question 
Author Message
 Simple controls and a very simple question

I have a blank form and I want to add a checkbox, or a radio button, or
whatever to it when I press a command button. What I don't want to do is add
the control to the form, then set visible to true, or false. What I want to
do is to add a checkbox, a radio button, a frame, or whatever using program
code to display it on the form (using VB6). All my "beginners" books don't
tell me how to do this. It must be very simple to do but how?

Thank you & Merry Christmas



Fri, 14 Jun 2002 03:00:00 GMT  
 Simple controls and a very simple question
Hello,

here some code for other controls, but I think this isn't useable for
Checkboxes or some other intrinsic VB-Controls.

Dim WithEvents SS As Threed.SSCommand
Dim WithEvents MM As MCI.MMControl

Private Sub Command1_Click()
    Licenses.Add "Threed.SSCommand", "mgkgtgnnmnmninigthkgogggvmkhinjggnvm"
    Call Me.Controls.Add("Threed.SSCommand", "SS", Me)
    Me.Controls("SS").Visible = True
    Set SS = Me.Controls("SS").object
End Sub

Private Sub Command2_Click()
    Licenses.Add "MCI.MMControl", ""
    Me.Controls.Add "MCI.MMControl", "mm", Me
    Me.Controls("mm").Visible = True
    Set Grid = Me.Controls("mm").object
End Sub

Private Sub MM_Done(NotifyCode As Integer)
    MsgBox "Done"
End Sub

Private Sub SS_Click()
    MsgBox "hallo"
End Sub

For the ADD to work there is a ProgID needed within the Registry, but there
is no one for the intrinsic subclassed windowscontrols.

I think you have to use the old fashioned style using a hidden control and
make it visible. :)

Best Regards
Josef Vetter



Quote:
> I have a blank form and I want to add a checkbox, or a radio button, or
> whatever to it when I press a command button. What I don't want to do is
add
> the control to the form, then set visible to true, or false. What I want
to
> do is to add a checkbox, a radio button, a frame, or whatever using
program
> code to display it on the form (using VB6). All my "beginners" books don't
> tell me how to do this. It must be very simple to do but how?

> Thank you & Merry Christmas



Fri, 14 Jun 2002 03:00:00 GMT  
 Simple controls and a very simple question
Hello,

I found an other registered control to do this.

Dim WithEvents ch As Threed.SSCheck

'example Event
Private Sub ch_Click(Value As Integer)
    MsgBox "Hello"
End Sub

'Add the control
Private Sub Command3_Click()
  Licenses.Add "Threed.SSCheck", "Some Licencestring"
  Call Me.Controls.Add("Threed.SSCheck", "check", Me)
  Me.Controls("check").Visible = True
  Set ch = Me.Controls("check").object
End Sub

Best Regards
Josef Vetter



Quote:
> I have a blank form and I want to add a checkbox, or a radio button, or
> whatever to it when I press a command button. What I don't want to do is
add
> the control to the form, then set visible to true, or false. What I want
to
> do is to add a checkbox, a radio button, a frame, or whatever using
program
> code to display it on the form (using VB6). All my "beginners" books don't
> tell me how to do this. It must be very simple to do but how?

> Thank you & Merry Christmas



Fri, 14 Jun 2002 03:00:00 GMT  
 Simple controls and a very simple question
Hi Lance,

It is not as simple as you think. If you are using VB 6 you can do this this
way for an intrinsic control:

Private WithEvents cmdNewButton As CommandButton

Private Sub AddButton()
   Set cmdNewButton = Controls.Add("VB.CommandButton", "cmdNewButton")
   With cmdNewButton
      .Top = 200
      .Left = 400
      .Width = 2000
      .Caption = "ButtonText"
      .Visible = True
   End With
End Sub

Private Sub RemoveButton()
   Form1.Controls.Remove "cmdNewButton"
End Sub

For an external control it is more work:

Private WithEvents NewDBList As VBControlExtender

Private Sub AddDBList()
  Licenses.Add "MSDBCtls.DBList.1"
  Set NewDBList = Me.Controls.Add("MSDBCtls.DBList.1", "TheDBList")
  NewDBList.Move 300, 300
  NewDBList.Height = 3000
  NewDBList.Visible = True
End Sub

Private Sub RemoveDBList()
  Me.Controls.Remove "TheDBList"
  Licenses.Remove "MSDBCtls.DBList.1"
  Set NewDBList = Nothing
End Sub

And, if you only have a version prior to 6.0, you must have an instance of
the needed control on the form. Besides you must set the index property of
this control to 0. Then you can use the following code to add a new control
to the control array:

  Dim ctrl As TextBox
  Load Text1(1)
  Set ctrl = Text1(1)
  With ctrl
    .Top = 50
    .Left = 50
    .Height = 500
    .Width = 2000
    .Visible = True
  End With

I hope this explains the differencies.

- Jens -



Quote:
> I have a blank form and I want to add a checkbox, or a radio button, or
> whatever to it when I press a command button. What I don't want to do is
add
> the control to the form, then set visible to true, or false. What I want
to
> do is to add a checkbox, a radio button, a frame, or whatever using
program
> code to display it on the form (using VB6). All my "beginners" books don't
> tell me how to do this. It must be very simple to do but how?

> Thank you & Merry Christmas



Fri, 14 Jun 2002 03:00:00 GMT  
 Simple controls and a very simple question
Hmmm... this all looks a little more complicated that I initially thought it
would be. Thank you both for your  comments, I'll be sure to try things out
tomorrow morning.
Lance


Quote:
> I have a blank form and I want to add a checkbox, or a radio button, or
> whatever to it when I press a command button. What I don't want to do is
add
> the control to the form, then set visible to true, or false. What I want
to
> do is to add a checkbox, a radio button, a frame, or whatever using
program
> code to display it on the form (using VB6). All my "beginners" books don't
> tell me how to do this. It must be very simple to do but how?

> Thank you & Merry Christmas



Fri, 14 Jun 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VB5 Pro Masked Edit control - A simple, simple question

2. Simple Question: Assigning Icon to an App : Simple Question

3. simple question...what was the source code for this simple custom action (rules wizard)

4. SIMPLE QUESTION : SIMPLE ANSWER?

5. SIMPLE QUESTION : SIMPLE ANSWER?

6. SIMPLE QUESTION, please SIMPLE ANSWER

7. SIMPLE SIMPLE ListView Question. Please help

8. Simple Question...simple answer???

9. HELP! simple question need simple answer

10. Simple simple ADO question

11. HELP! simple question need simple answer

12. HELP! simple question need simple answer

 

 
Powered by phpBB® Forum Software