Jump to content

Problem FileOpenDiaLog


Recommended Posts

Me had used code FileOpenDiaLog:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 317, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("................................................", 72, 13, 148, 17)
$browse = GUICtrlCreateButton("Browse", 232, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
if $browse = $msg Then
    $message = "Chose a file"

$var = FileOpenDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 1 )

If @error Then
        MsgBox(4096,"","No File(s) chosen")
Else
    guictrlsetdata($patch,$var)
EndIf
endif
if $msg = $GUI_EVENT_CLOSE then exit
WEnd

With with long patch then $patch don't show full patch in 1 line

Now i'm want show Patch C:\MyDocuments and Setting\User\My Documents\exam.jpg then show

C:\MyDocuments an...\exam.jpg

As for file exam.jpg in E:\Pic\Exam\exam.jpg then show full patch is E:\Pic\Exam\exam.jpg

Show patch = width size of $patch :P

Please you help me :unsure:( Because i'm making project then very need :D

Thanks you !!!

Edited by anhchangtk
Link to comment
Share on other sites

Like this?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 397, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("........................................................", 72, 13, 228, 17)
$browse = GUICtrlCreateButton("Browse", 312, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
    If $browse = $Msg Then
        $message = "Chose a file"

        $var = FileOpenDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 1)

        If @error Then
            MsgBox(4096, "", "No File(s) chosen")
        Else
            $var = FileGetShortName($var)
            $tmp = StringTrimLeft($var, 3)
            $tmp = StringRegExpReplace($tmp, '(?<=\\).*?(?=\\)', '...')
            $tmp = StringLeft($var, 3) & $tmp
            GUICtrlSetData($patch, $tmp)
        EndIf
    EndIf
    If $Msg = $GUI_EVENT_CLOSE Then Exit
WEnd
Link to comment
Share on other sites

Now i'm use script of you

Me edit line $var = FileGetShortName($var) to $var1 = FileGetShortName($var)

And me use code:

$f=GUICtrlRead($var)

$f=FileReadLine($f, 1)

AutoIt don't know :-s it been error :P

Please you help me :unsure:

Edited by anhchangtk
Link to comment
Share on other sites

@anhchangtk,

Does this help?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global Const $SS_PATHELLIPSIS = 0x008000
$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 350, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("................................................", 72, 13, 180, 17, $SS_PATHELLIPSIS)
$browse = GUICtrlCreateButton("Browse", 265, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
if $browse = $msg Then
    $message = "Chose a file"

$var = FileOpenDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 1 )

If @error Then
        MsgBox(4096,"","No File(s) chosen")
Else
    guictrlsetdata($patch,$var)
        guiCtrlSetTip($Patch,$Var)
EndIf
endif
if $msg = $GUI_EVENT_CLOSE then exit
WEnd

Credit to Smoke_N and martin:

http://www.autoitscript.com/forum/index.ph...st&p=605551

Link to comment
Share on other sites

@Authenticity: thanks you :P me had sucess

@ResNullius: ok thanks you :unsure: but over

Set Global $SS_PATHELLIPSIS = 0x008000 and $SS_WORDELLIPSIS = 0x00C000

Can set $SS_PATHELLIPSIS = order ?

Ahh now me use the code

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global Const $SS_PATHELLIPSIS = 0x008000
$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 350, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("................................................", 72, 13, 180, 17, $SS_PATHELLIPSIS)
$browse = GUICtrlCreateButton("Browse", 265, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
if $browse = $msg Then
    $message = "Chose a file"

$var = FileOpenDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 1 )

If @error Then
        MsgBox(4096,"","No File(s) chosen")
    Else
        $var = FileGetShortName($var)  [b]; me had add code :) => result very good :)[/b]
    guictrlsetdata($patch,$var)
        guiCtrlSetTip($Patch,$Var)
EndIf
endif
if $msg = $GUI_EVENT_CLOSE then exit
WEnd

But me want app to FileSaveDiaLog with script

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global Const $SS_PATHELLIPSIS = 0x008000
$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 350, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("................................................", 72, 13, 180, 17, $SS_PATHELLIPSIS)
$browse = GUICtrlCreateButton("Browse", 265, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
if $browse = $msg Then
    $message = "Chose a file"

$var = FileSaveDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 16 )

If @error Then
        MsgBox(4096,"","No File(s) chosen")
    Else
        $var = FileGetShortName($var)
    guictrlsetdata($patch,$var)
        guiCtrlSetTip($Patch,$Var)
        EndIf
endif
if $msg = $GUI_EVENT_CLOSE then exit
WEnd

The script don't show as like :D

It's show is patch is:

C:\Documents and Settings\...\test.jpg

The script FileGetShortName () don't run :D

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...