CCommonDlg如何自动滚动 [英] CCommonDlg how to scroll automaticly

查看:91
本文介绍了CCommonDlg如何自动滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hey Guys,



我正在使用CCommonDlg对话框在我们的应用程序中显示FileOpen / Save对话框。

我的先行者在这家公司实现了这个Dialog,我现在必须添加一些功能。



他已经做了很多东西和方法,但主要是在DoModal()函数。

这里他调用:: GetOpenFileName()或:: GetSaveFileName()并传递一个OPENFILENAME结构作为参数:



Hey Guys,

i'm using a CCommonDlg Dialog to show a FileOpen/Save Dialog in our Application.
My forerunner in this company implemented this Dialog and i have to add some functionality now.

He had done a lot of stuff and methods in this, but the main part is in the DoModal() Function.
Here he calls ::GetOpenFileName() or ::GetSaveFileName() and pass an OPENFILENAME structure as parameter:

INT nResult;
if( m_bOpenFileDialog )
    nResult = ::GetOpenFileName( &m_ofn );
else
    nResult = ::GetSaveFileName( &m_ofn );





我的问题现在,在OPENFILENAME结构中已经是初始文件名集。

当对话框现在显示时,文件选择器显示文件列表的开头而不是m_ofn指定的初始文件名中的前一个。 />
用户必须向下滚动到所选文件,如下所示:

http://img842.imageshack.us/img842/7753/blvp.png [ ^ ]。



有没有办法自动滚动到所选项目?



非常感谢您的答案!



My "problem" is now, that in the OPENFILENAME structure is already an initial filename set.
When the dialog now shows, the file-chooser shows the beginning of the file list and not the previous in m_ofn specified initial file name.
The User has to scroll down to the selected file like this:
http://img842.imageshack.us/img842/7753/blvp.png[^].

Is there a way to automatically scroll to the selected item?

Thank you so much for answers!

推荐答案

尝试获取每个Spy ++的列表视图的ID或名称。



使用FindWindow获取句柄,然后通过发布LVM_SETSELECTIONMARK使用列表视图api。问题可能是找到合适的项目。可能你需要循环所有...



http://msdn.microsoft.com/en-us/library/aa933027.aspx [ ^ ]
try to get the ID or name of the list view per Spy++.

Use FindWindow to get the handle and than use the list view api by posting the LVM_SETSELECTIONMARK. A problem can be to find the right item. May you have to loop trough all...

http://msdn.microsoft.com/en-us/library/aa933027.aspx[^]


这篇文章与您的部分问题重叠:



实现只读'文件打开'或'文件保存'常用对话框 [ ^ ]



向下滚动到文章打开对话框的文章截图。查看列表视图控件?



http://www.codeproject。 com / KB / dialog / DavidKotchanFileDialog / FileOpen_Layout.gif [ ^ ]



获取列表视图的窗口句柄。链接的文章有代码可以做到这一点。使用该句柄,您可以在文件打开对话框中继承列表视图控件。从那里,您可以操作列表控件以为用户预先选择文件。



SysListView32控件的MFC C ++包装器包括搜索项目,选择项目以及确定项目是否可见。
This article overlaps part of your question:

Implementing a Read-Only 'File Open' or 'File Save' Common Dialog[^]

Scroll down to the article's screenshot of a file open dialog. See the list view control?

http://www.codeproject.com/KB/dialog/DavidKotchanFileDialog/FileOpen_Layout.gif[^]

Obtain the window handle to the list view. The linked article has code to do that. With that handle, you can subclass the list view control inside the file open dialog. From there, you can manipulate the list control to have the file preselected for the user.

The MFC C++ wrapper for the SysListView32 control includes searching items, selecting an item, and determining whether an item is visible.


这篇关于CCommonDlg如何自动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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