Jump to content

FileOpenDialog help?


Recommended Posts

Hello, i have some problem with my small scripts

I want to Customize FileOpenDialog like: I will change the Text Open or Save into other text i want such as Import, Export etx

How can i do that?

Thanks in advanced!

Posted Image

Edited by LeHuynhNam

4m848p10.gif 

Link to comment
Share on other sites

Hello, i have some problem with my small scripts

I want to Customize FileOpenDialog like: I will change the Text Open or Save into other text i want such as Import, Export etx

How can i do that?

Thanks in advanced!

Posted Image

You should look at the help files before asking here!

FileOpenDialog 
--------------------------------------------------------------------------------

Initiates a Open File Dialog.


FileOpenDialog ( "title", "init dir", "filter" [, options [, "default name" [, hwnd]]] )


Parameters

title | Title text of the Dialog GUI.

William

Link to comment
Share on other sites

Yeah, i want to Replace Open Text in Button with other Text I like eg: Export, Import :blink:

Sorry, misunderstood you.

The ExtMsgBox.au3 UDF lets you do this for message box buttons - maybe you can find a similar for fileOpen?

But as posted above, a small GUI would probably do the trick for you.

I generally word the text in the title bar [which is what I erroneously thought you wanted to change] to suit the button options!

William

Link to comment
Share on other sites

I think I misunderstood you a second time!

From your edits with added screenshot, it seems it's the Windows dialogue that you want to change, not the Autoit bit.

that might be harder unless you're into Windows objects etc. Which I'm certainly not!

William

Edited by saywell
Link to comment
Share on other sites

Thanks for replying

@KaFu: i have to download AutoIT ver 3.2.10.0 to run Siao's Script and i think Siao use Notepad's Save Dialog and then Customize it by use ControlCommand. I've tried to use ControlSetText to change the Save text to other text but failed ;) Someone can give me a point?

4m848p10.gif 

Link to comment
Share on other sites

Updated it to 3.3.6.1, though I can't get the WM_COMMAND working (quickly ;) )...

#include "_FileDialogsEx.au3"

Global Const $CBN_SELCHANGE = 1

$Output = _FileSaveDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_OVERWRITEPROMPT, $OFN_PATHMUSTEXIST, $OFN_DONTADDTORECENT), "", 0, "_FileSave_HookProc")

Func _FileSave_HookProc($hWnd, $Msg, $wParam, $lParam)
    Switch $Msg
        Case $WM_INITDIALOG
            Local $hDlg = _WinAPI_GetParent($hWnd)
            _SendMessage($hDlg, $CDM_SETCONTROLTEXT, $IDOK, "Export", 0, "int", "wstr")
            _SendMessage($hDlg, $CDM_SETCONTROLTEXT, $IDCANCEL, "Not", 0, "int", "wstr")
            ControlCommand($hDlg, "", '[CLASS:ComboBox;Instance:3]', "AddString", 'ANSI')
            $aWinSize = WinGetPos($hDlg, "")
            WinMove($hDlg, "", @DesktopWidth / 2 - $aWinSize[2] / 2, @DesktopHeight / 2 - $aWinSize[3] / 2)
            WinSetTitle($hDlg,"","Export to")

        Case $WM_COMMAND
            Local $hComboEnc = ControlGetHandle($hWnd, "", '[CLASS:ComboBox;Instance:3]')
            Local $iCode = BitShift($wParam, 16)
            If $lParam = $hComboEnc And $iCode = $CBN_SELCHANGE Then
                $sEncoding = ControlCommand($hWnd, "", '[CLASS:ComboBox;Instance:3]', "GetCurrentSelection", "")
            EndIf
            ConsoleWrite($sEncoding & @crlf)

    EndSwitch
EndFunc   ;==>_FileSave_HookProc

_FileDialogsEx.zip

Link to comment
Share on other sites

Thanks KaFu So much Im stuck with it for some days ;)(

i still have a question, i want to change Func _FileSave_HookProc($hWnd, $Msg, $wParam, $lParam) to a Function like

_FileSave_HookProc($TxtOKBtn,$TxtCancelBtn,$TitleOfDialog,$hWnd, $Msg, $wParam, $lParam) but when i edit this and change the Text in _FileSave_HookProc() "Import", "Cancel", "Import To"... to $TxtOKBtn.... nothing happen :) and it change to default OpenDialog ;)

Edited by LeHuynhNam

4m848p10.gif 

Link to comment
Share on other sites

Hey Kafu, My program have to Display many Open or Save Dialogs

one is Import Dialog, One is Export Dialog,etc

And my question is: how can i make _FileSaveDialogEx() as a function which i can modify the Button Text to the text i like whenever i call it?

Like that

_FileSaveDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_OVERWRITEPROMPT, $OFN_PATHMUSTEXIST, $OFN_DONTADDTORECENT), "", 0, "_FileSave_HookProc",$BtnText)

$BTnText is the Text to replace Save text

4m848p10.gif 

Link to comment
Share on other sites

Most easy way would be with a global variable. Be aware that there is a function_FileOpenDialogEx() and _FileSaveDialogEx(). First one can be forced to do some additional checks, like e.g. look-up if file exists or allow multi-select.

#include "_FileDialogsEx.au3"

Global Const $CBN_SELCHANGE = 1
Global $__aDialogDef[3]

$__aDialogDef[0] = "Export to"
$__aDialogDef[1] = "Export"
$__aDialogDef[2] = "Cancel"
$Output = _FileSaveDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_OVERWRITEPROMPT, $OFN_PATHMUSTEXIST, $OFN_DONTADDTORECENT), "", 0, "_FileSave_HookProc")

$__aDialogDef[0] = "Save as"
$__aDialogDef[1] = "Save"
$__aDialogDef[2] = "Cancel"
$Output = _FileSaveDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_OVERWRITEPROMPT, $OFN_PATHMUSTEXIST, $OFN_DONTADDTORECENT), "", 0, "_FileSave_HookProc")

$__aDialogDef[0] = "Open File"
$__aDialogDef[1] = "Open"
$__aDialogDef[2] = "Cancel"
$Output = _FileOpenDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_FILEMUSTEXIST, $OFN_PATHMUSTEXIST, $OFN_ALLOWMULTISELECT), "", 0, "_FileSave_HookProc")

$__aDialogDef[0] = "Import File"
$__aDialogDef[1] = "Import"
$__aDialogDef[2] = "Cancel"
$Output = _FileOpenDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_FILEMUSTEXIST, $OFN_PATHMUSTEXIST, $OFN_ALLOWMULTISELECT), "", 0, "_FileSave_HookProc")

Func _FileSave_HookProc($hWnd, $Msg, $wParam, $lParam)
    Switch $Msg
        Case $WM_INITDIALOG
            Local $hDlg = _WinAPI_GetParent($hWnd)
            _SendMessage($hDlg, $CDM_SETCONTROLTEXT, $IDOK, $__aDialogDef[1], 0, "int", "wstr")
            _SendMessage($hDlg, $CDM_SETCONTROLTEXT, $IDCANCEL, $__aDialogDef[2], 0, "int", "wstr")
            ControlCommand($hDlg, "", '[CLASS:ComboBox;Instance:3]', "AddString", 'ANSI')
            $aWinSize = WinGetPos($hDlg, "")
            WinMove($hDlg, "", @DesktopWidth / 2 - $aWinSize[2] / 2, @DesktopHeight / 2 - $aWinSize[3] / 2)
            WinSetTitle($hDlg, "", $__aDialogDef[0])

        Case $WM_COMMAND
            Local $hComboEnc = ControlGetHandle($hWnd, "", '[CLASS:ComboBox;Instance:3]')
            Local $iCode = BitShift($wParam, 16)
            If $lParam = $hComboEnc And $iCode = $CBN_SELCHANGE Then
                $sEncoding = ControlCommand($hWnd, "", '[CLASS:ComboBox;Instance:3]', "GetCurrentSelection", "")
            EndIf
            ConsoleWrite($sEncoding & @CRLF)

    EndSwitch
EndFunc   ;==>_FileSave_HookProc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...