We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

varkon
varkon asked
on
Medium Priority
382 Views
Last Modified: 2013-12-26
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?
Comment
Watch Question

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

Author

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...
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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

nice post tr1l0b1t  @GetNativePointer,ReleaseNativePointer

guess even i learnt something new...

Cheers,
Rosh
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.