home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 93win / data1.cab / DLL_Toolkit / Source / HTBfileopen / HTBfileopen.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-03-02  |  2.8 KB  |  97 lines

  1. #include "stdafx.h"
  2. #include "HTBfileopen.h"
  3. #include "export.h"
  4.  
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10.  
  11. BEGIN_MESSAGE_MAP(CHTBfileopenApp, CWinApp)
  12.     //{{AFX_MSG_MAP(CHTBfileopenApp)
  13.         // NOTE - the ClassWizard will add and remove mapping macros here.
  14.         //    DO NOT EDIT what you see in these blocks of generated code!
  15.     //}}AFX_MSG_MAP
  16. END_MESSAGE_MAP()
  17.  
  18. CHTBfileopenApp::CHTBfileopenApp()
  19. {
  20. }
  21.  
  22. CHTBfileopenApp theApp;
  23.  
  24. void Fileopen(void *RetBuffer, char * FoRetVal, char * foP1, char * foP2, char * foP3, long foP4) 
  25. {
  26.     AFX_MANAGE_STATE(AfxGetStaticModuleState());
  27.  
  28.     DWORD dwFlags;                                                //Flag to define Dialog Box style and appearence.    
  29.     dwFlags = foP4;
  30.  
  31.         
  32.     BOOL     bOpenFileDialog    = TRUE;                        
  33.     LPCTSTR  lpszDefExt            = foP1;                            //The default filename extension. 
  34.     LPCTSTR     lpszFileName        = foP2;                            //The initial filename that appears in the filename edit box. 
  35.     LPCTSTR  lpszFilter            = foP3;                            //file extension filters.
  36.     
  37.     CWnd* pParentWnd;
  38.     pParentWnd = CWnd::FromHandle(g_hBasicWindow);
  39.     pParentWnd = pParentWnd->GetTopWindow();
  40.     
  41.         
  42.     CFileDialog FileOpener(bOpenFileDialog,                        //CFileDialog assignment. 
  43.                     lpszDefExt, 
  44.                     lpszFileName, 
  45.                     dwFlags, 
  46.                     lpszFilter, 
  47.                     pParentWnd);
  48.  
  49.     FileOpener.m_ofn.hwndOwner = g_hBasicWindow;
  50.     
  51.     
  52.     FileOpener.DoModal();                                        //call the assignment.
  53.  
  54.     if(OFN_ALLOWMULTISELECT & dwFlags)                            //if the multiselect flag is set then
  55.     {                                                            //put all the names into the HTB buffer
  56.         POSITION pos;
  57.         pos = FileOpener.GetStartPosition();
  58.         while(pos)
  59.         {
  60.             strcpy(FoRetVal, FileOpener.GetNextPathName(pos));    //copy the string to FoRetVal.
  61.             PutBuffer(RetBuffer,FoRetVal,1);                    //put the string in the HTB buffer
  62.         }
  63.     }
  64.     else
  65.     {
  66.         strcpy(FoRetVal, FileOpener.GetPathName());                //copy the string to FoRetVal.
  67.         PutBuffer(RetBuffer,FoRetVal,1);                        //put the string in the HTB buffer
  68.     }
  69. }
  70.  
  71. void Saveas(char * SaRetVal, char * SaP1, char * SaP2, char * SaP3, long SaP4) 
  72. {
  73.     
  74.     DWORD dwFlags;                                        //Flag to define Dialog Box style and appearence.    
  75.     dwFlags = SaP4;
  76.     
  77.     
  78.     BOOL     bSaveAsDialog        = FALSE;                        
  79.     LPCTSTR  lpszDefExt            = SaP1;                    //The default filename extension.
  80.     LPCTSTR     lpszFileName        = SaP2;                    //The initial filename that appears in the filename edit box.    
  81.     LPCTSTR  lpszFilter            = SaP3;                    //file extension filters.
  82.     
  83.     CWnd* pParentWnd;
  84.     pParentWnd = CWnd::FromHandle(g_hBasicWindow);
  85.     pParentWnd = pParentWnd->GetTopWindow();
  86.  
  87.     CFileDialog SaveAsFunc(bSaveAsDialog,                //CFileDialog assignment.
  88.                     lpszDefExt, 
  89.                     lpszFileName, 
  90.                     dwFlags, 
  91.                     lpszFilter, 
  92.                     pParentWnd);
  93.  
  94.     SaveAsFunc.DoModal();                                //call the assignment.
  95.     strcpy(SaRetVal, SaveAsFunc.GetPathName());            //copy the string to SaRetVal.
  96. }
  97.