主题:关于GetOpenFileName的问题
从《Windows 程序设计》找出的,关于GetOpenFileName对话框传值的问题
static OPENFILENAME ofn;
....
BOOL DibFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
{
ofn.hwndOwner = hwnd ;
ofn.lpstrFile = pstrFileName ;
ofn.lpstrFileTitle = pstrTitleName ;
ofn.Flags = 0 ;
return GetOpenFileName (&ofn) ;
}
实际的文件名不是要等到return时候的GetOpenFileName (&ofn);对话框选择的结果吗?
2个传入的参数 PTSTR pstrFileName, PTSTR pstrTitleName 是怎样被赋值为用户选择的文件名的? GetOpenFileName函数不是此时还没执行吗,因为是他下边的代码啊。
ofn.lpstrFile = pstrFileName;和
ofn.lpstrFileTitle = pstrTitleName;这2句赋值有什么意义啊?传进来的参数又不是用户通过对话框选择的文件名,就算是下面return时候的GetOpenFileName修改了ofn的这2个字段函数参数PTSTR pstrFileName, PTSTR pstrTitleName也不会跟着一起变化吧???? 难道ofn.lpstrFile和ofn.lpstrFileTitle是指向字符串指针的指针??很明显不是呀? 请问这是怎么回事啊??
static OPENFILENAME ofn;
....
BOOL DibFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
{
ofn.hwndOwner = hwnd ;
ofn.lpstrFile = pstrFileName ;
ofn.lpstrFileTitle = pstrTitleName ;
ofn.Flags = 0 ;
return GetOpenFileName (&ofn) ;
}
实际的文件名不是要等到return时候的GetOpenFileName (&ofn);对话框选择的结果吗?
2个传入的参数 PTSTR pstrFileName, PTSTR pstrTitleName 是怎样被赋值为用户选择的文件名的? GetOpenFileName函数不是此时还没执行吗,因为是他下边的代码啊。
ofn.lpstrFile = pstrFileName;和
ofn.lpstrFileTitle = pstrTitleName;这2句赋值有什么意义啊?传进来的参数又不是用户通过对话框选择的文件名,就算是下面return时候的GetOpenFileName修改了ofn的这2个字段函数参数PTSTR pstrFileName, PTSTR pstrTitleName也不会跟着一起变化吧???? 难道ofn.lpstrFile和ofn.lpstrFileTitle是指向字符串指针的指针??很明显不是呀? 请问这是怎么回事啊??