Solved

How can I add a property at runtime?

Posted on 2000-04-05
5
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 28

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 28

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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.
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…

730 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