Solved

How can I add a property at runtime?

Posted on 2000-04-05
5
193 Views
Last Modified: 2013-11-25
Is it possible to add properties to exsiting intrinsic controls at run-time? I mean creating new properties not just setting a property's value.
Please give code.

Thanks
0
Comment
Question by:Jaysor
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:wsh2
ID: 2688273
Just take the existing Control and create a User Control of your own making.. <smile>.

Instead of opening a Standard.Exe prokect.. open the one labeled ActiveX Control. Once there, draw what you like to appear on the screen.. and then Click on VB Menu - > Addins -> Addin Manager and add the ActiveX Contorl Interface Wizard. It will now appear on the Addins menu and will help build an Interface for you.

0
 
LVL 1

Accepted Solution

by:
RobMWilliams earned 25 total points
ID: 2688486
No, you can’t add new properties to intrinsic controls at run-time.

You cannot add properties to any controls at runtime, or at any time, actually.  What you can do, as wsh2 mentioned, is use a control inside your own control and add a property, for example, if you had a text box in your own user control and added a spellcheck property, then you would effectively have a text box with a spell check property.

Rob
0
 
LVL 27

Expert Comment

by:Ark
ID: 2689183
Hello
>You cannot add properties to any controls at runtime, or at any time, actually.  
??? What's about SetProp/GetProp API? Of course, they don't look like VB properties, but you can use them.
Cheers
0
 
LVL 1

Expert Comment

by:RobMWilliams
ID: 2689302
>??? What's about SetProp/GetProp API? Of course, they
>don't look like VB properties, but you can use them.


Nah.

A – A “windows property” in terms of the Windows API is nothing like an object’s property, but rather just extra information like a tag that you can set or get at runtime.  

And…

B – you can’t create these properties, you can only set or get them.

In Microsoft’s terms, objects employ encapsulation.  This means that what goes on inside an object is not available outside the object, you can only interact with an object through it’s given properties, methods, and events.

Rob
0
 
LVL 27

Expert Comment

by:Ark
ID: 2691583
Rob,
Agree, but what is object's property? IMHO - extra info about object. And I can "create" property at run time.

Private Sub cmdCreateProp_Click ()
   SetProp Picture1.hWnd, txtPropName, 1
End Sub

And then check this property (for example) in any event.

Cheers
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using web browser with BING 40 122
Visual Studio 2005 text editor 10 39
Help me. 3 56
Create Files based on Cell Values in a Range in Excel 12 41
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question