• Welcome to Jose's Read Only Forum 2023.
 

trouble with my visual com control endeavor

Started by Frederick J. Harris, September 16, 2010, 03:16:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frederick J. Harris

Well, wouldn't you know it, I finally got my Visual COM Control (ActiveX Control perhaps?) finshed and translated to PowerBASIC, but I've got a bug.  Drats!  I'm gonna take one mean beating finding it too!  I've got it working as perfect as perfect can be in C, as that's how I wrote the original.  The C version works perfectly in Visual Basic, C, C++ and PowerBASIC.  Can't break it no how.  I thought translating it to PowerBASIC would be a piece of cake but I blew it somewhere.  As a matter of fact, the PowerBASIC 9 host works perfectly with it, and had I only tested it with PowerBASIC, I wouldn't know there was a problem.  However, my C++ test host crashes on closing (until you close the app it works perfect), and Visual Basic exes crash soon after start up.  Strangely enough it works perfectly in the design environment when VB is running it in debug (pseudo-code) mode.  My guess is memory corruption from a pointer error somewhere.  Drats!!!!

What it is is a COM version of this custom control demo I posted here some time back....

http://www.jose.it-berater.org/smfforum/index.php?topic=2907.0

I got that idea from Chris Boss in his custom control tutorial.  Its really got me bummed out.  I've gotta find the error somehow. 

Chris Boss

Frederick,

While I am very experienced with designing custom controls, I have little or no knowledge of COM.
I would be very interested in seeing how you wrote your control and would be willing to see if I can find any bugs for you.
At least the normal API stuff, I may be able to spot any problems.

Maybe I can help you find your bug and in the process learn something about building a COM based control in the process.
(a fair trade I think)

My debugging skills are probably as good as it gets!

I would really like to add an ActiveX container to the next version of EZGUI, but I don't want to use ATL.
I would like to do it low level (got some good books on the subject, but its a lot of reading).

If interested send me a copy via email to:
chrisboss@centurylink.net


Chris Boss

Just an aside, since you are working on a custom control, which I may not have discussed well in any of my tutorials on custom controls:

It is very important to not register a new control class from within the LibMain function in a DLL, particularly if your DLL is automatically loaded by an EXE (meaning your app calls sub/functions declared in your code). It may be tolerated though if the DLL is loaded after the EXE starts up via a call to LoadLibrary.

The reason is that certain API's in the operating system should not be called from LibMain during the attach entry.

Read the API docs under the heading:

DLLMain

see the remarks section.

I have found that I can get around this to some degree in EZGUI, because the apps EXE loads the main runtime DLL automatically (declares defined in app), but then once the app begins executing, the main runtime DLL then loads some custom control DLL's and they do register in libmain with no problem. I believe because the main runtime DLL is loaded already, the OS has loaded all it needs, so by the time the custom control is loaded there are few problems.

But in most instances, especially when writing an SDK or DDT style app, a custom control in a DLL can have problems if it registers its class in LibMain.

If one does this it can cause unexpected results hard to track down.

Frederick J. Harris

Hi Chris!

     I just got the thing running yesterday and discovered the problem, and in the several hours I threw at it was unable to solve it.  I'll throw today at it and check out some of the likely possibilities.  If I can't solve it today and present a piece of code that I'm comfortable is without serious conceptual errors, I'll post it so some keener minds can have a look at it.  At this point I suspect problems with my connection point implementation.  That was trickier in PowerBASIC than in C because I had to use Call Dword instead of the easier

pUnkSink->lpVtbl->QueryInterface(pUnkSink, &IID_IOutGoing, (void**)&g_pOutGpoing);

C syntax.  Otherwise everything was just about a simple line by line easy translation.  I just need to look closer at everything.  Or maybe the problem is elsewhere.  Something dumb.

However, my intention is to make the code available and put together a tutorial on it if I get it working. 

I do appreciate your offer to help though.  That custom control tutorial you put together years back really, really helped me.  That's why I always mention your name when I mention anything about that subject. 

Well, I'd like to get started trying to track this down.  If I can't get it today I'll be in touch.  Until then...

Fred


Frederick J. Harris

Making progress.  Got the C++ host problem solved.  I had forgotten the dwCookie parameter in the IConnectionPoint::Unadvise() call.  So I think that problem is unrelated to my problem with VB6 choking on it.  I'll see.