Solved

Displaying properties from a COM object at runtime

Posted on 2002-03-06
6
201 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
ID: 6850408
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
ID: 6850485
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
ID: 9343307
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:trevorb
ID: 9343422
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
ID: 9348341
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
ID: 9405489
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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