LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I intercept a Close command?

Hi,
 
I want to be able to intercept a Close message initiated by the user right-clicking my apps taskbar button and selecting Close from the resulting context menu. The button in question is the one that is created when a CVI executable first runs, i.e. not one directly associated with a CVI panel. I think it relates to something called a frame window which has a class name "CVIRTLVFrame4194304".
 
At the moment when the user does this, my app closes immediately without any the confirmation popups that I have chosen to present when other methods of exiting are used.
 
I think what I need to do is intercept the Windows message (WM_CLOSE ?) before it is handled by the default window procedure and route it to my own callback, rather than let the default windows procedure simply end the task.
 
Can anyone give me any guidance?
 
Thanks
 
Jamie
0 Kudos
Message 1 of 5
(4,702 Views)
Maybe not entirely applicable to your actual problem, but this is a thread that presents various solutions about handling windows closing messages.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(4,692 Views)

Jamie,

You could try this:
  SetSystemAttribute (ATTR_TASKBAR_BUTTON_VISIBLE, 0);

Regards,
Colin.
 
0 Kudos
Message 3 of 5
(4,688 Views)
Jamie,

You need to respond to the EVENT_END_TASK event that is sent to the main callback. Here's some example code that will never allow the Close command to do anything:

main()
{
    ...
    InstallMainCallback (maincb, 0, 0);
    ...
}

int CVICALLBACK maincb (int panelOrMenuBarHandle, int controlOrMenuItemID,
    int event, void *callbackData, int eventData1, int eventData2)
{
    if (event == EVENT_END_TASK)
        return 1;
    else
        return 0;
}


Message 4 of 5
(4,664 Views)

Thanks to all of you. Much appreciated.

 

Jamie

0 Kudos
Message 5 of 5
(4,660 Views)