Results 1 to 15 of 15

Thread: Modify Container form using ActiveX Control

  1. #1

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    Question Modify Container form using ActiveX Control

    Suppose I have an activex control on a form, I want to write code in some event of the control which will get and modify the properties of the container form. (Left, Right, Height, Width, etc)
    Any solutions ?
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  2. #2
    Hyperactive Member DovyWeiss's Avatar
    Join Date
    Feb 2002
    Location
    Miami Beach, FL
    Posts
    366
    I'm not sure I fully understand what you mean... but this should work if I understand correctly. When you use the "Me" object in VB it refers to the form that is using it.

    VB Code:
    1. Sub Command1_Click
    2.   Me.Caption = "The button has been clicked"
    3.   'Effect is WhateverYourFormNameIs.Caption = "..."
    4. End Sub

    Is that what you wanted?

  3. #3
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    You use the Parent property

    VB Code:
    1. Private Sub UserControl_Click()
    2. Parent.Width = 300
    3. End Sub
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  4. #4
    Hyperactive Member DovyWeiss's Avatar
    Join Date
    Feb 2002
    Location
    Miami Beach, FL
    Posts
    366
    Yes, Arc is also right... but that code would be inside the code of your own UserControl. If you were using an intrinsic VB control then my code would be in your form.

    Now, Arc... I have a question. How can I trap a parent form's event? i.e. something like Sub Parent_Click() though that itself doesn't work.

  5. #5
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    AS far as i know there is no built in function to do what you ask.

    I imagine you would have to do some subclassing. Which i know nothing about
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  6. #6
    Hyperactive Member DovyWeiss's Avatar
    Join Date
    Feb 2002
    Location
    Miami Beach, FL
    Posts
    366
    OK thanks, I'll either try subclassing or forget about it (I don't actually HAVE to do it)

  7. #7

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    Talking got it

    Thanks Arc, I got it.
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  8. #8
    Hyperactive Member DovyWeiss's Avatar
    Join Date
    Feb 2002
    Location
    Miami Beach, FL
    Posts
    366
    Just a little "survey..." by saying "Thanks Arc I got it" do you mean that you needed to use the Parent object and not the Me object?

  9. #9

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    parent

    I knew about the Me object. I required the Parent object to modify the form through an activex control. If you still didn't understand, download the two attachments from...

    http://www.vbforums.com/showthread.php?postid=911932

    I have used the Parent object, atleast more than 25 times.
    Last edited by 007shahid; Apr 7th, 2002 at 01:34 AM.
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  10. #10
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    What about using..UserControl.Extender.Parent????

  11. #11

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    UserControl.Extender gives you the properties assigned by the form to your control.
    Suppose if you give the statement...

    Code:
        MsgBox UserControl.Extender.Name
    Then if the name is UserControl1 then MsgBox will say UserControl1.

    Extender can be used to assign properties. Suppose you want the control to be always aligned to the bottom (like status bar control), give...
    Code:
         UserControl.Extender.Align = vbAlignBottom
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  12. #12
    Hyperactive Member DovyWeiss's Avatar
    Join Date
    Feb 2002
    Location
    Miami Beach, FL
    Posts
    366
    Thanks 007Shahid, I know how to use all these objects and I just wanted to know which one YOU wanted. So you wanted to modify a container from a UserControl, not modify a container form on an intrinsic control's event.

  13. #13
    Hyperactive Member DovyWeiss's Avatar
    Join Date
    Feb 2002
    Location
    Miami Beach, FL
    Posts
    366
    by the way 007Shahid: my favorite way to post Visual Basic code is to use the [ VBCODE ] and [ /VBCODE] vB tags.
    VB Code:
    1. 'This will be green
    2. Sub MySub (argument As argumentType)
    3.   Me.Caption = "This is all syntax-highlighted."
    4. End Sub

  14. #14

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    VB Code:
    1. 'I hope this comes in green
    Last edited by 007shahid; Apr 8th, 2002 at 07:32 AM.
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  15. #15
    Hyperactive Member DovyWeiss's Avatar
    Join Date
    Feb 2002
    Location
    Miami Beach, FL
    Posts
    366
    Congratulations you did it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width