home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
-
- Code to support the UI that allows the user to choose and open,
- or even to create a new library file. It also directs the opening
- or creating of the new file.
-
- *********************************************************************/
-
- #include <windows.h>
- #include "pmplugin.h"
-
- //=============================================================== defines
- //=============================================================== globals
- extern PMHandle ghDLL;
-
- /*extern char szScriptsPath[MAX_PATH];
- extern char szScriptsDisabledPath[MAX_PATH];
-
- extern HANDLE hMainDirectory;
- extern HANDLE hDisplayList; // the display list
- extern long gSelectedHash;
- extern long gSelectedDisplayI;
- */
-
- BOOL FGetOpenFileName(char *szPName, short cbPSz, char *szSName, short cbSSz );
-
- //=============================================================== structs
-
- //=============================================================== prototypes
- UINT CALLBACK OpenDlgHook( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
-
- //=============================================================== functions
-
- //-------------------------------------------------------------------
- // returns the path of the directory containing the currently selected script.
- // if no script is showing, it returns the main scripts directory
-
- //-------------------------------------------------------------------
- BOOL FGetOpenFileName(char *szPName, short cbPSz, char *szSName, short cbSSz )
- {
- char szFilter[40];
- char szDTitle[40];
- char szDefaultExtension[12];
- char *szPath = NULL;
- short i;
- DWORD flags;
- OPENFILENAME ofn;
- BOOL fGotName;
-
- // prep the buffers
- szPName[0] = 0;
- szSName[0] = 0;
-
- strcpy(szFilter, "PageMaker Publication (*.p65)!*.p65!PageMaker Template (*.t65)!*.t65.*!!");
-
- // replace the exclamation points in the filter string with 0s
- for ( i = 0; szFilter[i]; i++ )
- if ( szFilter[i] == '!' )
- szFilter[i] = 0;
-
- // get the default extension string
- strcpy (szDefaultExtension, "p65");
-
- // set up the appropriate flags
- flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
-
- // prep the open file name structure
- ZeroMemory( &ofn, sizeof(ofn) );
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = GetActiveWindow();
- ofn.hInstance = ghDLL;
- ofn.lpstrFilter = szFilter;
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = szPName;
- ofn.nMaxFile = cbPSz;
- ofn.lpstrFileTitle = szSName;
- ofn.nMaxFileTitle = cbSSz;
- ofn.lpstrTitle = "My Open Dialog Box";
- ofn.Flags = flags;// | OFN_ENABLEHOOK;
- ofn.lpstrDefExt = szDefaultExtension;
- // ofn.lpfnHook = ScriptFileDlgHook;
-
- // if this is the new dialog, find out the path we should use
- fGotName = GetOpenFileName( &ofn );
-
- // leave with the right answer
- return fGotName;
- }
-
- //-------------------------------------------------------------------
- //typedef UINT (APIENTRY *LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
- UINT CALLBACK OpenDlgHook( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
- {
- // if we are setting up, then center the dialog
- // if ( msg == WM_INITDIALOG )
- // CenterWindow( hwnd, CW_CenterPos|CW_CenterParent );
-
- // we never actually overtake a message, so just always return false
- return FALSE;
- }
-