设置它的回调函数
在对话框初始化时用SetWindowPos设置对话框坐标设置它的回调函数的方法:
http://zyl910vb.51.net/vb/wdzp/MyOpenDlg.htm

解决方案 »

  1.   

    在form_load事件里加上
    me.move x,y,w,h
    x,y,w,h分别是坐标和大小
      

  2.   

    可以使用你的:
    http://www.csdn.net/Expert/TopicView1.asp?id=865808
    我用INPUTBOX进行口令输入,写了一段代码,编译前运行通过,编译后有内存冲突,请各位帮我看看!
    这种方法。
      

  3.   

    谁说不能调
    使用FindWindow函数获取对话框的句柄,然后用SetWindowPos调整它的位置。有点麻烦/。
      

  4.   

    回复人: zyl910(910:分儿,我来了!) (L2002) (  ) 信誉:93  2002-7-20 4:40:21  得分:0  
     
     
      设置它的回调函数
    在对话框初始化时用SetWindowPos设置对话框坐标设置它的回调函数的方法:
    http://zyl910vb.51.net/vb/wdzp/MyOpenDlg.htm
      
     
    ====================================================================
    看MSDN!
    “索引”页
    输入:getopenfilename
    再点“OPENFILENAME”这个连接
    根据结构设置好参数在回调函数接收到WM_INITDIALOG用SetWindowPos设置对话框坐标
      

  5.   

    对话框关闭后才能继续执行程序,所以不能用FindWindow,只能用回调函数。
      

  6.   

    只不过用GetOpenFileName做出的打开文件对话框运行时
    窗体的Timer还可以工作(通用对话框不行)这样可以在Timer中FindWindow并设置位置
    但是这样并没比设置回调函数简单多少
    而且假如还有其他程序的打开文件对话框,那会引起操作混乱
      

  7.   

    Private Declare Function MoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As LongPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    这两个函数配合用和可以实现你要的效果,
    不过好像没什么必要一定要让打开储存对话框到一定的位置~
      

  8.   

    To feihong0233(泓):
    在什么地方用FindWindow?没看见上面我写得话吗!
    通用对话框的“打开对话框”打开时
    Timer会停止
    只有在用GetOpenFileName 或 多线程但这样没比写回调函数简单多少
    VB6多线程又极不稳定在说
    FindWindow不一定找对的
    为了找对
    必须用Hook技术这比写回调函数难写哪里去了
    搂主是个懒人
    不要回复了
    让这个帖子沉下去算了
      

  9.   

    OPENFILENAME
    The OPENFILENAME structure contains information that the GetOpenFileName and GetSaveFileName functions use to initialize an Open or Save As common dialog box. After the user closes the dialog box, the system returns information about the user's selection in this structure. typedef struct tagOFN { // ofn 
        DWORD         lStructSize; 
        HWND          hwndOwner; 
        HINSTANCE     hInstance; 
        LPCTSTR       lpstrFilter; 
        LPTSTR        lpstrCustomFilter; 
        DWORD         nMaxCustFilter; 
        DWORD         nFilterIndex; 
        LPTSTR        lpstrFile; 
        DWORD         nMaxFile; 
        LPTSTR        lpstrFileTitle; 
        DWORD         nMaxFileTitle; 
        LPCTSTR       lpstrInitialDir; 
        LPCTSTR       lpstrTitle; 
        DWORD         Flags; 
        WORD          nFileOffset; 
        WORD          nFileExtension; 
        LPCTSTR       lpstrDefExt; 
        DWORD         lCustData; 
        LPOFNHOOKPROC lpfnHook; 
        LPCTSTR       lpTemplateName; 
    } OPENFILENAME; 
     
    Members
    lStructSize 
    Specifies the length, in bytes, of the structure. 
    hwndOwner 
    Identifies the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner. 
    hInstance 
    If the OFN_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is the handle of a memory object containing a dialog box template. If the OFN_ENABLETEMPLATE flag is set, hInstance identifies a module that contains a dialog box template named by the lpTemplateName member. If neither flag is set, this member is ignored. 
    If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box. lpstrFilter 
    Pointer to a buffer containing pairs of null-terminated filter strings. The last string in the buffer must be terminated by two NULL characters. 
    The first string in each pair is a display string that describes the filter (for example, "Text Files"), and the second string specifies the filter pattern (for example, "*.TXT"). To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.TXT;*.DOC;*.BAK"). A pattern string can be a combination of valid filename characters and the asterisk (*) wildcard character. Do not include spaces in the pattern string. The system does not change the order of the filters. It displays them in the File Types combo box in the order specified in lpstrFilter. If lpstrFilter is NULL, the dialog box does not display any filters. lpstrCustomFilter 
    Pointer to a static buffer that contains a pair of null-terminated filter strings for preserving the filter pattern chosen by the user. The first string is your display string that describes the custom filter, and the second string is the filter pattern selected by the user. The first time your application creates the dialog box, you specify the first string, which can be any nonempty string. When the user selects a file, the dialog box copies the current filter pattern to the second string. The preserved filter pattern can be one of the patterns specified in the lpstrFilter buffer, or it can be a filter pattern typed by the user. The system uses the strings to initialize the user-defined file filter the next time the dialog box is created. If the nFilterIndex member is zero, the dialog box uses the custom filter. 
    If this member is NULL, the dialog box does not preserve user-defined filter patterns. If this member is not NULL, the value of the nMaxCustFilter member must specify the size, in bytes (ANSI version) or 16-bit characters (Unicode version), of the lpstrCustomFilter buffer. nMaxCustFilter 
    Specifies the size, in bytes or characters, of the buffer identified by lpstrCustomFilter. This buffer should be at least 40 characters long. This member is ignored if lpstrCustomFilter is NULL or points to a NULL string. 
    nFilterIndex 
    Specifies the index of the currently selected filter in the File Types control. The buffer pointed to by lpstrFilter contains pairs of strings that define the filters. The first pair of strings has an index value of 1, the second pair 2, and so on. An index of zero indicates the custom filter specified by lpstrCustomFilter. You can specify an index on input to indicate the initial filter description and filter pattern for the dialog box. When the user selects a file, nFilterIndex returns the index of the currently displayed filter. 
    If nFilterIndex is zero and lpstrCustomFilter is NULL, the system uses the first filter in the lpstrFilter buffer. If all three members are zero or NULL, the system does not use any filters and does not show any files in the file list control of the dialog box. lpstrFile 
    Pointer to a buffer that contains a filename used to initialize the File Name edit control. The first character of this buffer must be NULL if initialization is not necessary. When the GetOpenFileName or GetSaveFileName function returns successfully, this buffer contains the drive designator, path, filename, and extension of the selected file. 
    If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer contains the current directory followed by the filenames of the selected files. For Explorer-style dialog boxes, the directory and filename strings are NULL separated, with an extra NULL character after the last filename. For old-style dialog boxes, the strings are space separated and the function uses short filenames for filenames with spaces. You can use theFindFirstFile function to convert between long and short filenames. If the buffer is too small, the function returns FALSE and the CommDlgExtendedError function returns FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the lpstrFile buffer contain the required size, in bytes or characters. nMaxFile 
    Specifies the size, in bytes (ANSI version) or 16-bit characters (Unicode version), of the buffer pointed to by lpstrFile. The GetOpenFileName and GetSaveFileName functions return FALSE if the buffer is too small to contain the file information. The buffer should be at least 256 characters long. 
    lpstrFileTitle 
    Pointer to a buffer that receives the filename and extension (without path information) of the selected file. This member can be NULL. 
    nMaxFileTitle 
    Specifies the size, in bytes (ANSI version) or 16-bit characters (Unicode version), of the buffer pointed to by lpstrFileTitle. This member is ignored if lpstrFileTitle is NULL. 
    lpstrInitialDir 
    Pointer to a string that specifies the initial file directory. 
    Windows NT 5.0 and later; Windows 98 and later: If lpstrInitalDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory. If lpstrInitalDir is NULL and the current directory does not contain any files of the specified filter types, the initial directory is the personal files directory of the current user. To specify the current user's personal files directory as the initial directory, set lpstrInitialDir to the path returned by calling theSHGetSpecialFolderLocation function with the CSIDL_PERSONAL flag. Earlier versions of Windows and Windows NT: If lpstrInitalDir is NULL, the initial directory is the current directory. lpstrTitle 
    Pointer to a string to be placed in the title bar of the dialog box. If this member is NULL, the system uses the default title (that is, Save As or Open). 
    Flags 
    A set of bit flags you can use to initialize the dialog box. When the dialog box returns, it sets these flags to indicate the user's input. This member can be a combination of the following flags: Flag Meaning
      

  10.   

    OFN_ENABLEHOOK  '☆☆ 注意这个属性
     Enables the hook function specified in the lpfnHook member.  
    nFileOffset 
    Specifies the zero-based offset, in bytes (ANSI version) or 16-bit characters (Unicode version), from the beginning of the path to the filename in the string pointed to by lpstrFile. For example, if lpstrFile points to the following string, "c:\dir1\dir2\file.ext", this member contains the value 13 to indicate the offset of the "file.ext" string. 
    If the user selects more than one file, nFileOffset is the offset to the first filename. nFileExtension 
    Specifies the zero-based offset, in bytes (ANSI version) or 16-bit characters (Unicode version), from the beginning of the path to the filename extension in the string pointed to by lpstrFile. For example, if lpstrFile points to the following string, "c:\dir1\dir2\file.ext", this member contains the value 18. If the user did not type an extension and lpstrDefExt is NULL, this member specifies an offset to the terminating null character. If the user typed "." as the last character in the filename, this member specifies zero. 
    lpstrDefExt 
    Points to a buffer that contains the default extension. GetOpenFileName and GetSaveFileName append this extension to the filename if the user fails to type an extension. This string can be any length, but only the first three characters are appended. The string should not contain a period (.). If this member is NULL and the user fails to type an extension, no extension is appended. 
    lCustData 
    Specifies application-defined data that the system passes to the hook procedure identified by the lpfnHook member. When the system sends the WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a pointer to the OPENFILENAME structure specified when the dialog box was created. The hook procedure can use this pointer to get the lCustData value. 
    lpfnHook 
    Pointer to a hook procedure. This member is ignored unless the Flags member includes the OFN_ENABLEHOOK flag. 
    If the OFN_EXPLORER flag is not set in the Flags member, lpfnHook is a pointer to an OFNHookProcOldStyle hook procedure that receives messages intended for the dialog box. The hook procedure returns FALSE to pass a message to the default dialog box procedure or TRUE to discard the message. If OFN_EXPLORER is set, lpfnHook is a pointer to an OFNHookProc hook procedure. The hook procedure receives notification messages sent from the dialog box. The hook procedure also receives messages for any additional controls that you defined by specifying a child dialog template. The hook procedure does not receive messages intended for the standard controls of the default dialog box. lpTemplateName 
    Pointer to a null-terminated string that names a dialog template resource in the module identified by the hInstance member. For numbered dialog box resources, this can be a value returned by the MAKEINTRESOURCE macro. This member is ignored unless the OFN_ENABLETEMPLATE flag is set in the Flags member. 
    If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box. 
      

  11.   

    OFN_EXPLORER 
     Indicates that any customizations made to the Open or Save As dialog box use the new Explorer-style customization methods. For more information, see Explorer-Style Hook Procedures and Explorer-Style Custom Templates.
    By default, the Open and Save As dialog boxes use the Explorer-style user interface regardless of whether this flag is set. This flag is necessary only if you provide a hook procedure or custom template, or set the OFN_ALLOWMULTISELECT flag. If you want the old-style user interface, omit the OFN_EXPLORER flag and provide a replacement old-style template or hook procedure. If you want the old style but do not need a custom template or hook procedure, simply provide a hook procedure that always returns FALSE.
     
    ====================================================================
    Explorer-Style Hook Procedures
    You can customize an Explorer-style Open or Save As dialog box by providing a hook procedure, a custom template, or both. If you provide a hook procedure for an Explorer-style dialog box, the system creates a dialog box that is a child of the default dialog box. The hook procedure acts as the dialog procedure for the child dialog box. This child dialog box is based on the custom template, or on a default template if none is provided. For more information, see Explorer-Style Custom Templates.To enable a hook procedure for an Explorer-style Open or Save As dialog box, use the OPENFILENAME structure when you create the dialog box. Set the OFN_ENABLEHOOK and OFN_EXPLORER flags in the Flags member and specify the address of an OFNHookProc hook procedure in the lpfnHook member. If you provide a hook procedure and omit the OFN_EXPLORER flag, you must use an OFNHookProcOldStyle hook procedure and you will get the old-style user-interface. For more information, see Customizing Old-Style Dialog Boxes. An Explorer-style hook procedure receives a variety of messages while the dialog box is open. These include the following: The WM_INITDIALOG message and other standard dialog box messages such as the WM_CTLCOLORDLG control color message. 
    A set ofWM_NOTIFY notification messages indicating actions taken by the user or other dialog box events. 
    Messages for any additional controls that you defined by specifying a child dialog template. 
    In addition, there is a set of messages that you can send to an Explorer-style dialog box to get information or to control the behavior and appearance of the dialog box.If you provide a hook procedure for an Explorer-style dialog box, the default dialog box procedure creates a child dialog box when the default dialog procedure is processing its WM_INITDIALOG message. The hook procedure acts as the dialog procedure for the child dialog box. At this time, the hook procedure receives its own WM_INITDIALOG message with the lParam parameter set to the address of the OPENFILENAME structure used to initialize the dialog box. After the child dialog finishes processing its own WM_INITDIALOG message, the default dialog procedure moves the standard controls, if necessary, to make room for any additional controls of the child dialog box. The default dialog procedure then sends the CDN_INITDONE notification message to the hook procedure. The hook procedure receivesWM_NOTIFY notification messages indicating actions taken by the user in the dialog box. You can use some of these messages to control the behavior of the dialog box. For example, the hook procedure receives the CDN_FILEOK message when the user chooses a filename and clicks the OK button. In response to this message, the hook procedure can use the SetWindowLong function to reject the selected name and force the dialog box to remain open.The lParam parameter for each WM_NOTIFY message is a pointer to an OFNOTIFY structure that defines the action. The code member in the header for the OFNOTIFY structure contains one of the following notification codes.CDN_FILEOK The user clicked the OK button; the dialog box is about to close.  
    CDN_FOLDERCHANGE The user opened a new folder or directory. 
    CDN_HELP The user clicked the Help button. 
    CDN_INITDONE The system has finished initializing the dialog box, and the dialog box has finished processing the WM_INITDIALOG message. Also, the system has finished arranging controls in the common dialog box to make room for the controls of the child dialog box (if any). 
    CDN_SELCHANGE The user selected a new file or folder from the file list. 
    CDN_SHAREVIOLATION The common dialog box encountered a sharing violation on the file about to be returned. 
    CDN_TYPECHANGE The user selected a new file type from the list of file types. 
    These WM_NOTIFY messages supersede the FILEOKSTRING, LBSELCHSTRING, SHAREVISTRING, and HELPMSGSTRING registered messages used by previous versions of the Open and Save As dialog boxes. However, the hook procedure also receives the superseded message after the WM_NOTIFY message if the WM_NOTIFY processing does not use SetWindowLong to set a nonzero DWL_MSGRESULT value.To retrieve information about the status of the dialog box or to control the behavior and appearance of the dialog box, the hook procedure can send the following messages to the dialog box.CDM_GETFILEPATH Retrieves the path and filename of the selected file. 
    CDM_GETFOLDERIDLIST Retrieves the item identifier list corresponding to the current folder that the dialog box has open. For more information about item identifier lists, seeItem Identifiers and Identifier Lists.  
    CDM_GETFOLDERPATH Retrieves the path of the current folder or directory for the dialog box. 
    CDM_GETSPEC Retrieves the filename (not including the path) of the file currently selected in the dialog box.  
    CDM_HIDECONTROL Hides the specified control. 
    CDM_SETCONTROLTEXT Sets the text in the specified control. 
    CDM_SETDEFEXT Sets the default filename extension for the dialog box. 
      

  12.   

    http://www.csdn.net/expert/topic/308/308742.xml?temp=.9055139
      

  13.   

    有必要用Hook吗?!
    http://www.applevb.com/sourcecode/filedialog_hook.zip