Results 1 to 11 of 11

Thread: Quick Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    Omaha, NE
    Posts
    263

    Talking Quick Question

    I have an ActiveX control project, which contains a .frm and a .ctl. I need to reference one of the elements on the control from the form. Anyone know how to do this? It doesn't seem that the following works:

    controlname!element.property

    So I am wondering if there is a different syntax needed in this scenario.

    Thanks in advance.

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    This might help.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    You need to set the variable reference in your form (this creates a class reference). You'd do it something like this:

    VB Code:
    1. '=================
    2. ' Define global for form
    3. '=================
    4.  
    5. Dim Obj_class as [classname]
    6.  
    7. Private Sub Form_Load()
    8.    
    9.    Set Obj_Class = New [classname]
    10.    
    11.     '====================
    12.     ' Now you should be able to
    13.     ' use the class.
    14.     '====================
    15.  
    16. End Sub

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    Omaha, NE
    Posts
    263
    I think memnoch is on point with what I'm looking for. TPR's thought would be good, but I'm dealing with an ActiveX control, not an ActiveX .dll or .exe, so I don't have the ability to reference objects of a class, since it is a .ctl, not a .cls. Thanks anyway, I'll let you all know how it turns out.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    Omaha, NE
    Posts
    263

    No dice so far...

    I can't seem to crack this one. The help that you offered, Memnoch, applies to property pages of a control. What I am specifically dealing with, is I have a .ctl and a .frm in the same project.

    All that is on the form is a list box, which is populated by the user. Upon clicking enter, I want the contents of the listbox to populate a control in the .ctl I can not seem to gain a reference to the control at runtime though...hence, my dilemma.

  6. #6
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    Take a look at this sample project. All you should have to do to access a .ctl is to add it to the project just like you would a form or class or module. The only caviot being that the usercontrol has to be on the form drawn on the form to use it. I'm not sure you can initialize it any other way. But hopfully the sample project will help. Its very simple. Type in the top box and hit the button to transfer the text to the usercontrol textbox. As I said, very simple but hopefully what you are looking for?
    Attached Files Attached Files

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    Omaha, NE
    Posts
    263

    Cool

    The problem, is that this is going to be packaged into a .cab file for download to PCs across my company. So, my UserControl is going to be referenced directly on the web page, I can't reference a form that I have put the user control on (at least I am unaware of this capability if it does indeed exist.)

  8. #8
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    Well, it would have been easier if you would have said what you are doing with it. The answer is no.

    While Microsoft doesn't have a sparkling security record, allowing type of referencing would be irresponsible. To my knowledge, a usercontrol running within IE is bound within this application. While it can access system resources and the like, it cannot be accessed through the browser itself. Only other html elements on your page can access the usercontrol.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    Omaha, NE
    Posts
    263
    I don't want to access these properties through the HTML, I want to reference the controls which are on the .ctl (the user control) from the .frm; all are in the same VB Project.

  10. #10
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    I don't think I understand what is the difference then between what you want to do and the example I posted. If you mean you want to do something like:

    usercontrol.textbox1.text = "Put text here"

    You can't. The usercontrol doesn't publically expose the controls to form that is hosting it. Rather, the programmer must expose the controls themselves. Like in the example, I created a set text and Get Text function. If you had multiple controls, You could place the controls in a control array and enumerate the controls for a hwnd that is set and got as a property.

    Is this what your asking.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    Omaha, NE
    Posts
    263
    You're on the right track with what I am wanting to do here is a link to the page that memnoch suggested earlier. It would do what I want, but my problem is that I need a reference to the particular user control in use and I can't figure out how to get it.

    But, it seems that by using the "friend" function I can expose the controls for run-time manipulation from the form; again, I just need to get the specific reference.

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