Win32API Cant使用按钮单击打开对话框 [英] Win32API Cant open DialogBox using button click

查看:58
本文介绍了Win32API Cant使用按钮单击打开对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我陷入了Win32中的Openbox的困扰.
我已经读过这篇文章
(http://www.codeproject.com/Articles/3984/Customizing-the-quot-Browse-for-folder-quot-dialog).

该家伙使用一个对话框来调用文件夹浏览器"框,因为它在主图片上可见.
但是我不能只使用VIEW按钮而不使用中间的OpenBox来称呼它.

请帮助.
非常抱歉,我的英语不对,希望您能理解我/

Hi everyone.I got stuck with the Openbox in win32.
I''ve read this article
(http://www.codeproject.com/Articles/3984/Customizing-the-quot-Browse-for-folder-quot-dialog).

That dude used a dialog box to call Folder Browser-box as it is visible on the main picture.
But I can''t call it just pushing the VIEW button without using intermediate OpenBox.

HELP PLEASE.
And sorry for my wrong English, I hope you understand me/

推荐答案

您好,

请参见下面的代码.注意:我未能初始化/清理该任务所需的外壳内存.您可能会在此处看到这样做的示例:浏览文件夹使用Core WIN32的OnButtonClick [ ^ ]

控制台应用程序
Hello,

Please see the code below. Note: I have failed to initialize/cleanup the shell memory need for the task. You may see an example of doing so here: To Browse a Folder OnButtonClick using Core WIN32[^]

Console Application
#include <windows.h>
#include <shlobj.h>
#include <stdio.h>

int main()
{
    BROWSEINFO bInfo;
    LPITEMIDLIST pidl;
    char pszBuffer[MAX_PATH];

    bInfo.hwndOwner = NULL;
    bInfo.pidlRoot         =   NULL;
    bInfo.pszDisplayName   =   pszBuffer;
    bInfo.lpszTitle        =   "Select a Directory";
    bInfo.ulFlags          =   BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
    bInfo.lpfn             =   NULL;
    bInfo.lParam           =   0;

    if(pidl = SHBrowseForFolder(&bInfo))
    {
        // Copy the path directory to the buffer
        if(SHGetPathFromIDList(pidl,pszBuffer))
        {
            // pszBuffer now holds the directory path
            printf(("You selected the directory: %s\n"),pszBuffer);
        }
        else
            printf("Selected item not a folder\n");
    }
    else
        printf("User cancelled OR failure with: SHBrowseForFolder(&bInfo);");

    return 0;
}


这篇关于Win32API Cant使用按钮单击打开对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆