Solved

Displaying properties from a COM object at runtime

Posted on 2002-03-06
6
198 Views
Last Modified: 2013-11-23
Hi All,

I have a question I hope you can answer. A company has sent me a COM object to assist me in interfacing with their SMS (text message) API.

I've installed the COM object via the import type library and all this worked fine.

But the runtime properties of the component created are those of a generic COM object e.g. AutoConnect, ConnectKind etc. I know the COM object has public properties and events because I can access them at runtime e.g. smsTo, smsFrom. But some I would like to set at design time because they never change - just me being lazy I guess because I could set them on program initialisation.

Is there anyway I can easily get the public properties/events of the COM object to display at design time instead of the standard ones? Or would I need to write my own 'wrapper' around the COM object? If this is the case, what is the best method for doing that?

Sorry if I have missed something glaring obvious (like it can't be done easily!) but I don't do hardly any programming with my own components or COM objects - I tend to stay with the standard stuff or bought in third party components.

TIA - Trevor.
0
Comment
Question by:trevorb
  • 3
  • 2
6 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 200 total points
Comment Utility
Open the type library and view it as source. There's your COM wrapper... :-)
How to do that? Use the menu: "View/Toggle form/unit" or press key F12.

Okay, look in this source for the COM object you're using. You will find quite a lot of methods with the additional parameters and whatever else Delphi can extract from the COM object. It will probably show you some useful hints too but it does look a bit complex sometimes.
The code insight will also show you this information if the variable you use to contain the object is of the type of the object. If it's an OleVariant then Delphi has no way knowing what methods it supports.
0
 

Author Comment

by:trevorb
Comment Utility
Thanks for the initial help workshop_alex, but perhaps I wasn't clear in what I was trying to achieve - sorry.

I've already looked at the source generated by the import type library so I know what properties I have available. And my initial software already uses these. I can set and read these at runtime. But they don't appear in the Object Inspector. All I get in there are generic (?) COM object properties like AutoConnect, ConnectKind etc I was hoping the public properties from the actual object would (could?) be displayed there like smsUserName, smsPassword etc stuff that I only need to set once and forget about.

I've imported other stuff before (like the Adobe PDF object and Twain Control) and these normally display the public properties associated with the object.

Again, I apologise if I've completely misunderstood what is achievable here.

Trevor.
0
 

Expert Comment

by:CleanupPing
Comment Utility
trevorb:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:trevorb
Comment Utility
Sorry I didn't close the question, I was hoping for further comment because I still have problems with both of these. But I will close this topic off if you feel I must. I will award the points to workshop_alex as at least he went someway to helping me. I was just hoping that some day someone might answer my question.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
Comment Utility
Oh, I forgot about this question, apparantly. Sorry about that...

Now, to get back at this, the properties of the COM object are public, not published. So you won't see them in the object inspector. Actually, this is not a bad thing because otherwise the COM objects would also be active during design time. That would make development a bit more difficult. Some COM objects will work quite nice from the IDE but others can be too complex for the IDE to handle correctly. Furthermore, if you'd run the application you'd create a second COM object. And this might affect the way your application handles itself.

Developing with COM objects if a lot easier when they're only active at runtime. Personally, I don't even use the Delphi wrappers and create the *_TLB.pas files without the wrapper code. You might not want to activate the COM objects while in design-time because the COM object itself might also initialize a lot of other things. And if you can't activate them, you can't set their properties either.
0
 

Author Comment

by:trevorb
Comment Utility
Cheers for the extra info Workshop_Alex, appreciated. An extra 12 months experience now means I can see the reasoning behind the points you are making. Thanks!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

13 Experts available now in Live!

Get 1:1 Help Now