,怎样实现打开?在线等待

clin2y 2003-02-08 01:50:28
我用建立一个基于Form的单文档应用程序,并将文档扩展名命名为.cmp,现在双击任何.cmp文件,能够执行我的应用程序,可是我文件的内容打不开。我重载了OnFileOpen(),所以直接用文件下的‘打开’可以实现文件的打开,要解决的问题是,怎样实现双击文件打开呢?
...全文
22 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hnyyy 2003-02-08
  • 打赏
  • 举报
回复
不需要在OnOpenDocument(LPCTSTR lpszPathName)里向FormView发送消息,比如放在FormView的OnInitialUpdate()中应该就可以初始化。
hnyyy 2003-02-08
  • 打赏
  • 举报
回复
OnOpenDocument(LPCTSTR lpszPathName)里只负责读出数据,至于初始化到树里,那应放在FormView里了。

clin2y 2003-02-08
  • 打赏
  • 举报
回复
hnyyy(前进) :
我的Form里有树控件,而且要将.cmp文件里的某些内容初始化到树里,怎么办呢?我企图给FormView发送消息,但是执行OnOpenDocument(LPCTSTR lpszPathName)时,FormView还没有产生呀.
masterz 2003-02-08
  • 打赏
  • 举报
回复
Working with the Associations
Whenever a certain file extension say, ".abd", has to be associated with a particular program, a key named ".abd" has to be created under the HKEY_CLASSES_ROOT root key in the Windows Registry. The default value is then set to a short identifier for the file type; in this case, it could be "abd_ext" (NOTE: The identifier should not have any spaces in it!). Next, another key, by the name of the identifier, is created under the HKEY_CLASSES_ROOT root key, and its default value is set to a short description of the file type (for example, "My own file type"). Under the identifier key, a key called "Defaulticon" is created, and its default value is set to the complete path of the icon that is to be shown for files having that extension. Also, under the identifier key, another key by the name of "shell" is created. This key contains all the file commands that are registered for the given file extension (as in "Open", "Print", "Preview", and so forth). Within the "shell" key, one key for each file command is created, using the name of the command, say, for example, "Open". Now, within the "Open" key (or whatever command is being set), another key, called "command" is created. The default value of this key is set to the complete path of the program to be used, along with whatever command line parameters are neccessary; for example "c:\windows\notepad.exe" "%1".

That's it! Having done all that, the file extension will be registered with the chosen program. Shown below is a screenshot taken in Regedit, showing the Registry keys and tree that are created to register the .abd file extension with the program "c:\Program files\app.exe", using the identifier abd_ext. Also, another file command, "Print", has been registered for this file type.

Q122787
SAMPLE: FileAsso.exe Demonstrates How to Use File Associations
cheng_young 2003-02-08
  • 打赏
  • 举报
回复
add vc component: Document registration
xyw2278 2003-02-08
  • 打赏
  • 举报
回复
VC向导只是帮助你关联你的文件和应用程序

至于到底怎么打开你自己的文件
你的自己的编写具体的代码
用CFile类
Open

Read

Write
来完成你所需要的工作
qrlvls 2003-02-08
  • 打赏
  • 举报
回复
应该通过序列化的方法来处理
hnyyy 2003-02-08
  • 打赏
  • 举报
回复
单文档应用程序你不必重载OnFileOpen(),确实不想使用其默认的序列化保存文件的话,可以将代码写在OnOpenDocument(LPCTSTR lpszPathName)内。

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧