Solved

Displaying properties from a COM object at runtime

Posted on 2002-03-06
6
200 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

16 Experts available now in Live!

Get 1:1 Help Now