在“另存为”对话框前面显示弹出消息

发布于 2024-10-05 00:22:44 字数 421 浏览 0 评论 0原文

在Windows应用程序中,打开“另存为”对话框后,是否可以在“另存为”对话框前面显示弹出消息?我所得到的只是对话框关闭后弹出窗口显示。

我需要编辑一个用 C++ 编写的旧应用程序(我不是作者),但无法管理此任务。这是代码的一部分:

/* ---- 调用以显示保存文件对话框 ---- */

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

res = GetSaveFileNameW( &ofn );

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

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

谢谢,
伊利亚

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏末染殇 2024-10-12 00:22:44

如果我理解正确,您想在关闭对话框之前检查一些内容(例如文件扩展名)并在不关闭的情况下显示消息。如果是这样,请查看 OPENFILENAME 结构。在这种情况下,您的代码将类似于

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 );

MyHookProc 的代码将如下所示:

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 */
        }
    }
}

希望它会对您有所帮助。

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.

夜唯美灬不弃 2024-10-12 00:22:44

你可以,但这将是一个很大的黑客。您必须创建 FileDialog 并以无模式而不是模式和隐藏方式打开它。所以窗口就在那里,但你看不到它。当您单击“弹出窗口”时,您可以取消隐藏窗口对话框。

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.

农村范ル 2024-10-12 00:22:44

听起来您想扩展保存文件对话框的 GUI。您可以使用自己的对话框资源模板来扩展 GUI,并指定 OFN_ENABLETEMPLATE。这是许多应用程序显示文档预览/元数据的方式。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文