Solved

How can I add a property at runtime?

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

827 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