Guidance
指路人
g.yi.org
software / rapidq / examples / GUI / Dialog / RQDialog / RQDialog.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' RQDIALOG.INC    BILL K  1-2003
'    Displays Window's Open and Save Dialogs
'    The main advantage of this INC is that the Dialog is the Sizeable Type
'    It also  by default shows the windows overwrite warning on the Savedialog
'       this can be optioned out if no warning is desired.
'    All the other parameters are the same as the QDialogs
' USAGE:  MYFILENAME$=RQSHOWDIALOG(MyCaption$, _                ' default is "Open" or "Save"
'                                  MyFilter$, _                 ' default is All Files
'                                  FilterIndex%, _              ' default is 0
'                                  MyInitialDirectory$, _       ' default is current directory
'                                  WantSaveDialog%, _           ' 1=Save  0=Open - default is Open
'                                  NoOverwriteWarning%, _       ' default is 0
'                                  MyFormHandle&)               ' Form handle or 0 .. default is 0 - see below
'
'    WantSaveDialog%=1 for a Save Dialog   =0 for an Open Dialog
'    NoOverwriteWarning%=1 for defeating the default warning when about to overwrite an existing file
'    MyFormHandle& = MyForm.Handle ( so that the dialog knows which form
'                                    to be modal to and where to locate)   =0 for nonmodal(not advised)
'
'  EXAMPLE: FileName$=RQShowDialog("Save File","RQ Files|*.bas;*.rqb","C:\RapidQ",1,0,Form.Handle)
'
     $IFNDEF _RQDIALOGINC
      $DEFINE _RQDIALOGINC
      CONST OFN_OVERWRITEPROMPT = &H2   'display the overwrite warning
      CONST OFN_HIDEREADONLY = &H4      'hide the Open as Readonly checkbox
'
      TYPE OPENFILENAME
       lStructSize AS LONG
       hwndOwner AS LONG
       hInstance AS LONG
       lpstrFilter AS LONG
       lpstrCustomFilter AS LONG
       nMaxCustFilter AS LONG
       nFilterIndex AS LONG
       lpstrFile AS LONG
       nMaxFile AS LONG
       lpstrFileTitle AS LONG
       nMaxFileTitle AS LONG
       lpstrInitialDir AS LONG
       lpstrTitle AS LONG
       flags AS LONG
       nFileOffset AS SHORT
       nFileExtension AS SHORT
       lpstrDefExt AS LONG
       lCustData AS LONG
       lpfnHook AS LONG
       lpTemplateName AS LONG
      END TYPE
      DIM RQDlog AS OPENFILENAME
'
      DECLARE FUNCTION GetSaveFileName LIB "COMDLG32" ALIAS "GetSaveFileNameA" (pOpenfilename AS OPENFILENAME) AS LONG
      DECLARE FUNCTION GetOpenFileName LIB "COMDLG32" ALIAS "GetOpenFileNameA" (pOpenfilename AS OPENFILENAME) AS LONG
'
      FUNCTION  RQshowdialog(capt$,filter$,fltrindex%,initdir$,savedlog%,nooverwriteprompt%,formhnd&) AS STRING
       DEFSTR strcapt, strdrstr, strFile, strFileTitle, strFilter
       DEFLNG rv
       IF capt$="" THEN
        IF savedlog% THEN
         strcapt="Save"
        ELSE
         strcapt="Open"
        END IF
       ELSE
        strcapt=capt$
       END IF
       IF INITDIR$="" THEN
        strdrstr="."     ' will display current directory
       ELSE
        strdrstr=initdir$
       END IF
'   strFile=space$(1024)
       strFile=STRING$(1024,0)
       strFileTitle=STRING$(1024,0)
       IF FILTER$="" THEN
        strFilter = "All Files|*.*" + CHR$(0) + CHR$(0)
       ELSE
        strFilter = filter$ + CHR$(0) + CHR$(0)
       END IF
       strFilter = REPLACESUBSTR$(strFilter, "|", CHR$(0))
       RQDlog.lStructSize = SIZEOF(RQDlog)
       RQDlog.hwndOwner = formhnd&
       RQDlog.hInstance = 0
       RQDlog.lpstrFilter = VARPTR(strFilter)
       RQDlog.nFilterIndex = FLTRINDEX%
       RQDlog.lpstrFile = VARPTR(strFile)
       RQDlog.nMaxFile = LEN(strFile)
       RQDlog.lpstrFileTitle = VARPTR(strFileTitle)
       RQDlog.nMaxFileTitle = LEN(strFileTitle)
       RQDlog.lpstrInitialDir = VARPTR(strdrstr)
       RQDlog.lpstrTitle = VARPTR(strcapt)
       IF nooverwriteprompt% THEN
        RQDlog.flags =OFN_HIDEREADONLY
       ELSE
        RQDlog.flags =OFN_HIDEREADONLY OR OFN_OVERWRITEPROMPT
       END IF
       IF savedlog%=0 THEN
        IF GetOpenFileName(RQDlog) THEN
'          RESULT=ltrim$(rtrim$(strFile))
         RESULT=LEFT$(strFile,INSTR(strFile,CHR$(0))-1)
        END IF
       ELSE
        IF GetSaveFileName(RQDlog) THEN
'          RESULT=ltrim$(rtrim$(strFile))
         RESULT=LEFT$(strFile,INSTR(strFile,CHR$(0))-1)
        END IF
       END IF
      END FUNCTION
     $ENDIF ' _RQDIALOGINC
掌柜推荐
 
 
¥918.00 ·
 
 
¥738.00 ·
 
 
¥1,580.00 ·
 
 
¥920.00 ·
 
 
¥296.00 ·
 
 
¥890.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:54:57