Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am syncing the saving of my application data with the file saving of the plug-in my com dll is plugged into. I have successfully hooked File,save and Ctrl-S. There is one final saving scenario that I would like to cover.

When the application's data file is changed and the user closes the application with File Close or the Red X, then the application pops up a MessageBox with the familiar, "Save changes to filename?"

I can see when the MessageBox pops up using the code in a WH_CBT hookproc below.

C++
if(nCode == HCBT_ACTIVATE)
{
    char WindowString[40];
    GetWindowText((HWND)wParam,WindowString,40);
    if(!strcmp(WindowString,"The Application's Name"))
    {
        HWND txtLabel = GetDlgItem((HWND)wParam,0xffff);
        GetWindowText(txtLabel,WindowString,16);

        if(!strcmp(WindowString,"Save changes to"))
            // Save our 2k of data quickly as we are closing...
        }
    }
}


Now when the user clicks Yes, a WM_NOTIFY is sent out with the ID but I can's seem to trap
that message in any hook type tried thus far. And googling around, I find myself in a sea of MessageBox modification threads.

Is catching the Yes button push possible? Must be if Spy++ can do it.

Thanks

:Ron
Posted
Updated 11-Mar-13 16:39pm
v4
Comments
Sergey Alexandrovich Kryukov 11-Mar-13 22:48pm    
Why hooking message box at all?
—SA
Ron Anders 11-Mar-13 23:03pm    
Gotta save my data when the application I am plugged into (as a 3rd party) saves it's
as my data and it's data are to stay in sync.

The application is a commercial compiled one not mine and there is no API provided in the plug-in spec I an plugged into.

:Ron
H.Brydon 11-Mar-13 23:23pm    
It's been too long for me to remember the WM_xxx message to hook but it exists somewhere. First, are you sure that answering "yes" doesn't trigger one of your existing hooks? I would think that that sequence would fold into what you have already.

The message for File->Close and "the red X" are unfortunately different (I've forgotten the details but I know I had to handle both).

Sorry, no answer but a little direction.
Ron Anders 11-Mar-13 23:28pm    
The File Close and RED X are already handled by the application.

I just need to to quick save upon YES

1 solution

Gotta save my data when the application I am plugged into (as a 3rd party) saves it's
as my data and it's data are to stay in sync.

The application is a commercial compiled one not mine and there is no API provided in the plug-in spec I an plugged into.

:Ron
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900