开发者

show pop-up message in front of SaveAs dialog

In Windows application, is it possible to show a popup message in front of SaveAs dialog after SaveAs dialog is开发者_开发百科 being opened? All I managed to get is that popup shows after dialog is closed.

I need to edit an old application written in C++ (I am not author) but can't manage this task. This is part of code:

/* ---- called to display the save file dialog ---- */

ofn.hwndOwner = hwnd; 
ofn.lpstrFile = lpstrFileName; 
ofn.lpstrTitle = lpstrTitleName;

res = GetSaveFileNameW( &ofn );

/* ---- fix file extension ---- */

MessageBox(NULL, "Test", "Testing", MB_OK);

Thanks,

Ilija


If I understand you correct, you want check some stuff (for example, file extension) before closing dialog and show message withou closing. If it's so please look at OFN_ENABLEHOOK flag in OPENFILENAME Structure. In this case your code will look something like

ofn.hwndOwner = hwnd; 
ofn.lpstrFile = lpstrFileName; 
ofn.lpstrTitle = lpstrTitleName;

/* enables the hook function */
ofn.Flags |= OFN_ENABLEHOOK;
ofn.ofn.lpfnHook = (LPOFNHOOKPROC) MyHookProc;

/* some code here */

res = GetSaveFileNameW( &ofn );

Code for MyHookProc will look like this:

static UINT CALLBACK MyHookProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if (uMsg == WM_NOTIFY) {
        OFNOTIFYW *notify = (OFNOTIFYW *) lParam;

        if (notify->hdr.code == CDN_FILEOK) {
            /* your code here */
        }
    }
}

Hope it will be helpful for you.


You can but it would be quite a hack. You would have to create the FileDialog and open it modeless rather than modal, and hidden. So the window is there but you can't see it. When you click your "popup" you can then could unhide the windows dialog.


It sounds like you want to extend the GUI of a save file dialog box. You can extend the GUI by using your own dialog resource template, and specify OFN_ENABLETEMPLATE. This is how many apps show previews / metadata of documents.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜