Manipulate and close/release an visual OLE control (PB7)

I've created a COM object which contains a form of "canvas" for drawing. This component exposes some functions which allow me to manipulate it through pb. I've managed to load the object in a window, by inserting it as an OLE custom Control (Insert > Control > OLE > InsertControl...).

The object seems to work ok, and I can access its methods using controlName.object.method(). So far so good. My problem is when I close the application, it crashes. I thought that I need to destroy the control in the window's close() event. That does not seem to work though. Or calling the controlName.clear() function. Is there a way to release the object's memory and avoid crashing the application?
varkonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

diasroshanCommented:
Hi,

why dont u create/destroy ur object everytime u need to use it and finish using it... instead of the close event...

lole_object = create oleobject
...
blah..
blah...
....
If IsValid(lole_object) then destroy lole_object

if absolutely required to destroy in the close event then try the script,
If IsValid(lole_object) then destroy lole_object

Also,
Another suggestion is to apply the latest patch of the PB version ur using...
u can find it on www.sybase.com
downloads section...

Cheers,
Rosh
0
varkonAuthor Commented:
Yes, I've already installed all available patches... Furthermore, since this is a visual COM I cannot "see" it on screen by using:

OLEObject myOLE
integer res
myOLE = CREATE OLEObject
res = myOLE.ConnectToNewObject("...")
blah..
blah..
.....

The only way I found so as to "see" the object is the one described in the original question...
0
tr1l0b1tCommented:
Hi varkon,
try this in the Close event of your window :

ULong lul_pointer
myOLE.GetNativePointer(lul_pointer)
myOLE.ReleaseNativePointer(lul_pointer)

Please, let me know if it works
Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
varkonAuthor Commented:
tr1l0b1t it works!! Thank you very much. However, I've read the documentation about those two methods and I still do not understand how they are related with my problem. Could you explain this to me please?
0
diasroshanCommented:
Hi,

nice post tr1l0b1t  @GetNativePointer,ReleaseNativePointer

guess even i learnt something new...

Cheers,
Rosh
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.