Friday, August 6, 2010

I want to place a close button on ActiveX control in VB6 which will end all project where this control wil use

I have created a an ActiveX control in which one Button is Close button.


This button checks some information valid or not if found invalid information all project will end after prompting a message.


HOW CAN I DO IT. I have used ';END'; keyword but saying this keyword will nor supoort in Dll project.





SIPLY: I WANT TO END UP CURRENT PROJECT/SOFTWARE USED MY ACTIVEX CONTROL.





thanks in advanceI want to place a close button on ActiveX control in VB6 which will end all project where this control wil use
The only safe way is to find out top-most parent window and send Windows message to close it. Unloading forms does not neccesarily solves the problem (the container must not be a VB form).


This requires you to learn about finding parent windows (Win API functions, explanations are good in MSDN) and do that for each parent until you find some window that has no parents (top-most) and send Win Message to close it (look in MSDN).





Simpler alternative is to provide an public event e.g. DoShutdown() on your control that is raised when Close button validation fails. On the form that contains your control handle the event and put the ';End'; there.I want to place a close button on ActiveX control in VB6 which will end all project where this control wil use
I woud suggest putting a boolean property on your ocx that says whether or not to end the current application. And then check that property within the actual project. From there unload all forms and end politely.





Hope that helps!
Figure out how to access the PARENT FORM from the ActiveX control, and then UNLOAD the PARENT FORM.

No comments:

Post a Comment