Jump to content
Sign in to follow this  
LeHuynhNam

FileOpenDialog help?

Recommended Posts

LeHuynhNam

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 

Share this post


Link to post
Share on other sites
saywell

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

Share this post


Link to post
Share on other sites
LeHuynhNam

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


4m848p10.gif 

Share this post


Link to post
Share on other sites
LeHuynhNam

Bump


4m848p10.gif 

Share this post


Link to post
Share on other sites
saywell

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

Share this post


Link to post
Share on other sites
LeHuynhNam

Thanks for all reply, Im trying to solve this problem :blink:


4m848p10.gif 

Share this post


Link to post
Share on other sites
saywell

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

Share this post


Link to post
Share on other sites
KaFu
LeHuynhNam

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 

Share this post


Link to post
Share on other sites
KaFu

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

Share this post


Link to post
Share on other sites
LeHuynhNam

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 

Share this post


Link to post
Share on other sites
KaFu
LeHuynhNam

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 

Share this post


Link to post
Share on other sites
KaFu

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

Share this post


Link to post
Share on other sites
LeHuynhNam

Thanks KaFu so much :)

I did it. i cant think it is so easy like that ;)


4m848p10.gif 

Share this post


Link to post
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
Sign in to follow this  

×