Solved

How can I add a property at runtime?

Posted on 2000-04-05
5
192 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

896 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now