Results 1 to 14 of 14

Thread: Two OCX Questions: List And Control

  1. #1

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Two OCX Questions: List And Control

    Hello everyone!

    I have two questions related to OCX development:

    1.- How can I achieve a List Property like the one the ComboBoxes have? (Please check the picture)
    2.- One of my events could use a Control as its parameter, just like DragOver and DragDrop do... But whenever I try to add it like this:

    Public Event MyEvent(ctrlGiven As Control)

    the following error raises:

    "Compile error:

    Private object modules cannot be used in public object modules as parameters or return types for public procedures, as public data members, or as fields of public user defined types
    "

    So... Is there a way to pass a Control as a parameter? I mean, without doing something like this:

    Public Event MyEvent(ctrlGiven As Object)

    Thank you for your time!
    Attached Images Attached Images  
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Two OCX Questions: List And Control

    Does this help?

    http://www.vbforums.com/showpost.php...6&postcount=12

    I didn't know about the wizard!

  3. #3

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: Two OCX Questions: List And Control

    Thank you, David... However the List didn't appear in the Properties like in the picture.

    I didn't know about the wizard.. Where is it located?
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Two OCX Questions: List And Control

    It is a VB Add-In. I just added it to try it out.
    You initialte an ActiveX project, place a control, and then launch the wizard.

    Hope that helps!
    Attached Images Attached Images  
    Last edited by dglienna; Feb 7th, 2005 at 06:09 PM.

  5. #5

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: Two OCX Questions: List And Control

    Thank you, David.. I just saw it. I am going to start playing with it to see what happens.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  6. #6

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: Two OCX Questions: List And Control

    Still nothing... I wonder what I am doing wrong.

    Could you please try adding a ComboBox to a UserControl and check if when you add the List Property it will show it in its property browser?
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Two OCX Questions: List And Control

    Sure did. See for yourself. You have to create an ActiveX control, and test it with another exe project at the same time, after you compile it.
    Attached Images Attached Images  

  8. #8

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: Two OCX Questions: List And Control

    Thanks... I did the same and added the property and all of that.

    But please tell me... Did the List appear in your properties' window like in the image I attached before?
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Two OCX Questions: List And Control

    I didn't complete it. I did the simple listbox, and backcolor. They appeared in a class-like module, which is where I'd expect to find the List. Did it:

    VB Code:
    1. 'TO DO: The member you have mapped to contains an array of data.
    2. '   You must supply the code to persist the array.  A prototype
    3. '   line is shown next:
    4.     Combo1.List(Index) = PropBag.ReadProperty("List" & Index, "")
    5. 'TO DO: The member you have mapped to contains an array of data.
    6. '   You must supply the code to persist the array.  A prototype
    7. '   line is shown next:
    8.     Call PropBag.WriteProperty("List" & Index, Combo1.List(Index), "")

    Below is a To Do list of items required to complete the testing, debugging, and bullet-proofing of your UserControl.

    A) Create a test program for your UserControl

    There are two ways to set up a test program for your UserControl, depending on whether you inserted the control in a Standard EXE, or created an ActiveX Control project for it.

    If you created an ActiveX Control project, the following steps will set up a test program:

    1) Save your UserControl.
    2) Close your UserControl's designer, to put the control in run mode.
    3) If you haven't already created a test project, add a Standard EXE project by selecting Add Project from the File menu.
    4) In the Toolbox, double-click your UserControl's icon to place an instance of your UserControl on Form1, in the Standard EXE project. You can move and resize the control as needed.
    5) Save the project group. In later development and test sessions, you can open both projects at once by opening the project group.

    If you inserted the UserControl in an existing Standard EXE project, follow these steps:

    1) Save your UserControl.
    2) Close your UserControl's designer, to put the control in run mode.
    3) In the Project window, double-click Form1 in the Standard EXE project, to open its designer.
    4) In the Toolbox, double-click your UserControl's icon to place an instance of your UserControl on Form1. You can move and resize the control as needed.

    B) Test your control's behavior at design time, and at run time.

    1) Select the control you placed on Form1 in the test project, and press F4 to open the Properties window. Verify that you can see and change the properties you added to your control.
    2) Close Form1 and reopen it, and verify that the property values for your control were correctly saved and retrieved.
    3) Double-click the control you placed on Form1, and verify that the appropriate events appear in the right-hand (Procedure) drop down of the code window.
    4) Add test code to the event procedures for your control.
    5) Add other controls, and put code in their event procedures to test the run-time behavior of your control's properties and methods.
    6) Press F5 to run the test project, and test your control's run-time behavior.

    C) Making a Bullet-Proof, Full-Featured Control (Adding code details the Wizard doesn't provide)

    1) If you have constituent controls on your form, some events and properties may need to be mapped to multiple constituent controls. For example, a BackColor property probably should map to the BackColor properties of the UserControl AND any label controls. The MouseMove event needs to map to the MouseMove events of ALL constituent controls.
    2) Add coordinate translation to all events (such as MouseMove) that specify X and Y coordinates.
    3) For all properties that have enumerations (for example, MousePointer and BorderStyle), change the data type of the property to the appropriate enumeration name (in this case, MousePointerConstants and BorderStyleConstants) so that enumeration elements will show up in the Properties window.
    4) Add any custom enumerations you need for your own properties, plus code to validate them.
    5) Add error trapping to the ReadProperties event, to protect against invalid values or bad data types that might be manually edited into an .frm file. For each property, add code to switch to the default setting when such an error occurs. (See "Saving the Properties of Your Control" and "Creating Design-Time-Only, Run-Time-Only, or Read-Only Run-Time Properties" in Books Online.)
    6) If you have constituent controls, add code to UserControl_Resize to resize them when the control is resized.
    7) Set the Procedure ID for the Enabled property, so your control will behave the same as other ActiveX controls when enabled and disabled.
    8) The wizard maps properties of your control to constituent control (or UserControl) properties of like name. In some cases, you may want to map a property to a property with a different name (for example, ShapeLabel maps its BackColor to the constituent Shape control's FillColor); this remapping must be done manually.
    9) Any properties that might affect the size of your control (such as font size, in a control that has an AutoSize property) should call your resize code from the Property Let.
    10) For user-drawn controls, add code to the UserControl's Paint event to paint your control's appearance. (See "User-Drawn Controls" and "How to Handle Focus in Your Control" in Books Online.)
    11) If one or more properties of your control will be data-bound, see "Binding a Control to a Data Source," in Books Online.
    12) Add additional features to your control. You may find it useful to peruse the topics in "Visual Basic ActiveX Control Features," in Books Online.

    (See the CtlPlus.vbg sample application for examples of these work items.)

    You can modify your control by running the Wizard again, and selecting your UserControl.

    Use the Property Page Wizard to create Property Pages for your UserControls.

    For more information on creating and testing ActiveX Controls, please read Chapter 4, "Creating an ActiveX Control," and Chapter 9, "Building ActiveX Controls."

    Chapter 6, "General Principles of Component Design," and Chapter 7, "Debugging, Testing, and Deploying ActiveX Components," contain additional information you may find useful.
    Last edited by dglienna; Feb 7th, 2005 at 09:20 PM.

  10. #10

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: Two OCX Questions: List And Control

    Yes, I had read that... But it doesn't appear in the Property List as in the picture...

    Maybe something else is needed to do? I just don't know... I am getting desperate. This shouldn't be that complictated, right?
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Two OCX Questions: List And Control

    I screwed mine up, i think. it keeps opening the form in IE, even though I made another project. i haven't been able to add any items, but there is a usercontrol1_click event in the form, so I believe that you could get the .list(.listindex-1) value. I have a vbg of both forms, and no problem adding the usercontrol to new forms. not sure what's missing.

  12. #12

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: Two OCX Questions: List And Control

    David:
    I have no problem with writing and loading the elements, I get all the elements of the List and populate the UserControl with them.

    My problem has been "how can I make the List Property appear in the Properties".

    So I want the users of my control to be able to add from the IDE Items to the List of it without having to do it by code. Just like the ComboBox and the ListBox do...

    In the picture I attached at the very beginning of this thread you can see the List Property and you can edit it from the IDE. Mine doesn't appear there. I get ListIndex -1 but not List.

    Am I explaining myself correctly?

    Thank you once again.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Two OCX Questions: List And Control

    Yes, and I'm sorry that I can't help. I thought that you could add properties in the IDE, but couldn't for the usercontrol. I'll let you know if I find anything else out.

  14. #14

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: Two OCX Questions: List And Control

    Thank you, David. I will keep trying meanwhile... Right now I am experimenting with the "Procedure Attributes"
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

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