Link to home
Start Free TrialLog in
Avatar of varkon
varkon

asked on

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?
Avatar of diasroshan
diasroshan
Flag of Kuwait image

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
Avatar of varkon
varkon

ASKER

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...
ASKER CERTIFIED SOLUTION
Avatar of tr1l0b1t
tr1l0b1t

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of varkon

ASKER

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?
Hi,

nice post tr1l0b1t  @GetNativePointer,ReleaseNativePointer

guess even i learnt something new...

Cheers,
Rosh