Solved

How can I add a property at runtime?

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

708 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

18 Experts available now in Live!

Get 1:1 Help Now