Sign in to follow this  
Followers 0
Andreik

My notepad and resize mode

8 posts in this topic

#1 ·  Posted (edited)

I want to create my own notepad in romanian language and I have some problems with resizing mode. The window can modify his dimension with mouse or maximize button and in same time should resize my edit control.

This is the code:

#Include <GuiEdit.au3>

Global $PATH = ""
Global $EDIT
Global $BAR

$MAIN = GUICreate("Notepad",600,400,-1,-1,0x14CF0000,0x00000110)
$EDIT = _GUICtrlEdit_Create($MAIN,"",0,0,600,380,0x50300104,0x00000200)
CreateFileMenu()
CreateEditMenu()
CreateFormatMenu()
CreateViewMenu()
CreateHelpMenu()
GUISetState()

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case $NEW
            Call("_New_")
        Case $OPEN
            Call("_Open_")
;~      Case $SAVE
;~          Call("_Save_")
;~      Case $SAVE_AS
;~          Call("_Save_As_")
;~      Case $PRINT
;~          Call("_Print_")
;~      Case $EXIT
;~          Call("_Exit_")
;~      Case $UNDO
;~          _GUICtrlEdit_Undo($EDIT)
;~      Case $COPY
;~          Call("_Copy_")
;~      Case $PASTE
;~          Call("_Paste_")
;~      Case $DELETE
;~          Call("_Delete_")
;~      Case $FIND
;~          _GUICtrlEdit_Find($EDIT,True)
;~      Case $GOTO
;~          Call("_GoTo_")
;~      Case $SELECT_ALL
;~          _GUICtrlEdit_SetSel($EDIT,0,-1)
;~      Case $TIME_DATE
;~          Call("_Time_Date_")
;~      Case $WORD_WRAP
;~          Call("_WordWrap_")
;~      Case $FONT
;~          Call("_Font_")
;~      Case $STATUS_BAR
;~          Call("_StatusBar_")
;~      Case $ABOUT
;~          Call("_About_")
        Case -6
            GUICtrlSetResizing($EDIT,1)
        Case -3
            Exit
    EndSwitch
    Sleep(5)
WEnd

Func _New_()
    $WARINIG = MsgBox(0x4,"Notepad","Esti sigur?")
    If $WARINIG = 6 Then _GUICtrlEdit_SetText($EDIT,"")
EndFunc

Func _Open_()
    $WARINIG = MsgBox(0x4,"Notepad","Esti Sigur?")
    If $WARINIG = 6 Then
        $ENCODING = SetEncode()
        If $ENCODING <> -1 Then $ENCODING = "ANSI"
        $PATH = FileOpenDialog("Open",@ScriptDir,"Text (*.txt)|All (*.*)",1)
        If Not @error Then
            Local $FILE = FileOpen($PATH,$ENCODING)
            Local $TEXT = FileRead($FILE)
            FileClose($FILE)
            _GUICtrlEdit_SetText($EDIT,$TEXT)
        EndIf
    EndIf
EndFunc

Func CreateFileMenu()
    $MENU_FILE = GUICtrlCreateMenu("&Fisier")
    Global $NEW = GUICtrlCreateMenuItem("Nou        CTRL+N",$MENU_FILE)
    Global $OPEN = GUICtrlCreateMenuItem("Deschide   CTRL+O",$MENU_FILE)
    Global $SAVE = GUICtrlCreateMenuItem("Salveaza   CTRL+S",$MENU_FILE)
    Global $SAVE_AS = GUICtrlCreateMenuItem("Salveaza ca...",$MENU_FILE)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_FILE)
    Global $PRINT = GUICtrlCreateMenuItem("Printeaza    CTRL+P",$MENU_FILE)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_FILE)
    Global $EXIT = GUICtrlCreateMenuItem("Iesire",$MENU_FILE)
EndFunc

Func CreateEditMenu()
    $MENU_EDIT = GUICtrlCreateMenu("&Editare")
    Global $UNDO = GUICtrlCreateMenuItem("Inapoi                 CTRL+U",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $CUT = GUICtrlCreateMenuItem("Taie                    CTRL+X",$MENU_EDIT)
    Global $COPY = GUICtrlCreateMenuItem("Copy                   CTRL+C",$MENU_EDIT)
    Global $PASTE = GUICtrlCreateMenuItem("Lipeste                CTRL+V",$MENU_EDIT)
    Global $DELETE = GUICtrlCreateMenuItem("Sterge                   DEL",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $FIND = GUICtrlCreateMenuItem("Cauta                 CTRL+F",$MENU_EDIT)
    Global $GOTO = GUICtrlCreateMenuItem("Salt la                CTRL+G",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $SELECT_ALL = GUICtrlCreateMenuItem("Selecteaza tot   CTRL+A",$MENU_EDIT)
    Global $TIME_DATE = GUICtrlCreateMenuItem("Data/Timp            F5",$MENU_EDIT)
EndFunc

Func CreateFormatMenu()
    $MENU_FORMAT = GUICtrlCreateMenu("&Formatare")
    Global $WORD_WRAP = GUICtrlCreateMenuItem("Word Wrap",$MENU_FORMAT)
    Global $FONT = GUICtrlCreateMenuItem("Font...",$MENU_FORMAT)
EndFunc

Func CreateViewMenu()
    $MENU_VIEW = GUICtrlCreateMenu("&Vizualizare")
    Global $STATUS_BAR = GUICtrlCreateMenuItem("Status Bar",$MENU_VIEW)
EndFunc

Func CreateHelpMenu()
    $MENU_HELP = GUICtrlCreateMenu("&Ajutor")
    Global $ABOUT = GUICtrlCreateMenuItem("Despre",$MENU_HELP)
EndFunc

Func SetEncode()
$ENC_GUI = GUICreate("Notepad",200,55,-1,-1,0x16C00000)
$COMBO = GUICtrlCreateCombo("",5,5,190,20)
GUICtrlSetData($COMBO,"ANSI|Binary|Unicode UTF16 Little Endian|Unicode UTF16 Big Endian|Unicode UTF 8")
$ACCEPT = GUICtrlCreateButton("Accept",20,30,65,20)
$CANCEL = GUICtrlCreateButton("Cancel",120,30,65,20)
GUISetState(@SW_SHOW,$ENC_GUI)
While True
    $ENC_MSG = GUIGetMsg()
    If $ENC_MSG = $ACCEPT Then
        $ENC_TYPE = GUICtrlRead($COMBO)
        GUIDelete($ENC_GUI)
        Return EncodeToNumber($ENC_TYPE)
    ElseIf $ENC_MSG = $CANCEL Then
        GUIDelete($ENC_GUI)
        Return -1
    EndIf
    Sleep(20)
WEnd
EndFunc

Func EncodeToNumber($TYPE)
    If $TYPE = "ANSI" Then
        Return 0
    ElseIf $TYPE = "Binary" Then
        Return 16
    ElseIf $TYPE = "Unicode UTF16 Little Endian" Then
        Return 32
    ElseIf $TYPE = "Unicode UTF16 Big Endian" Then
        Return 64
    ElseIf $TYPE = "Unicode UTF 8" Then
        Return 128
    Else
        Return -1
    EndIf
EndFunc
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites



Andreik,

Try this for size. It uses the Windows message when the main GUI is resized to set the edit to the new size. New lines are marked <<<<<<<<<<<<<<<<<<<<

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>

Global $PATH = ""
Global $EDIT
Global $BAR

Global $iGUIWidth = 600, $iGUIHeight = 400, $fResized = False  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$MAIN = GUICreate("Notepad",600,400,-1,-1,0x14CF0000,0x00000110)
$EDIT = _GUICtrlEdit_Create($MAIN,"",0,0,600,380,0x50300104,0x00000200)
CreateFileMenu()
CreateEditMenu()
CreateFormatMenu()
CreateViewMenu()
CreateHelpMenu()
GUISetState()

; When window is resized, run this function
GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case $NEW
            Call("_New_")
        Case $OPEN
            Call("_Open_")
;~      Case $SAVE
;~          Call("_Save_")
;~      Case $SAVE_AS
;~          Call("_Save_As_")
;~      Case $PRINT
;~          Call("_Print_")
;~      Case $EXIT
;~          Call("_Exit_")
;~      Case $UNDO
;~          _GUICtrlEdit_Undo($EDIT)
;~      Case $COPY
;~          Call("_Copy_")
;~      Case $PASTE
;~          Call("_Paste_")
;~      Case $DELETE
;~          Call("_Delete_")
;~      Case $FIND
;~          _GUICtrlEdit_Find($EDIT,True)
;~      Case $GOTO
;~          Call("_GoTo_")
;~      Case $SELECT_ALL
;~          _GUICtrlEdit_SetSel($EDIT,0,-1)
;~      Case $TIME_DATE
;~          Call("_Time_Date_")
;~      Case $WORD_WRAP
;~          Call("_WordWrap_")
;~      Case $FONT
;~          Call("_Font_")
;~      Case $STATUS_BAR
;~          Call("_StatusBar_")
;~      Case $ABOUT
;~          Call("_About_")
        Case -6
            GUICtrlSetResizing($EDIT,1)
        Case -3
            Exit
    EndSwitch

    If $fResized = True Then  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        ControlMove($MAIN, "", $EDIT, 0, 0, $iGUIWidth, $iGUIHeight - 20)
        $fResized = False
    EndIf  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

WEnd

Func _New_()
    $WARINIG = MsgBox(0x4,"Notepad","Esti sigur?")
    If $WARINIG = 6 Then _GUICtrlEdit_SetText($EDIT,"")
EndFunc

Func _Open_()
    $WARINIG = MsgBox(0x4,"Notepad","Esti Sigur?")
    If $WARINIG = 6 Then
        $ENCODING = SetEncode()
        If $ENCODING <> -1 Then $ENCODING = "ANSI"
        $PATH = FileOpenDialog("Open",@ScriptDir,"Text (*.txt)|All (*.*)",1)
        If Not @error Then
            Local $FILE = FileOpen($PATH,$ENCODING)
            Local $TEXT = FileRead($FILE)
            FileClose($FILE)
            _GUICtrlEdit_SetText($EDIT,$TEXT)
        EndIf
    EndIf
EndFunc

Func CreateFileMenu()
    $MENU_FILE = GUICtrlCreateMenu("&Fisier")
    Global $NEW = GUICtrlCreateMenuItem("Nou        CTRL+N",$MENU_FILE)
    Global $OPEN = GUICtrlCreateMenuItem("Deschide   CTRL+O",$MENU_FILE)
    Global $SAVE = GUICtrlCreateMenuItem("Salveaza   CTRL+S",$MENU_FILE)
    Global $SAVE_AS = GUICtrlCreateMenuItem("Salveaza ca...",$MENU_FILE)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_FILE)
    Global $PRINT = GUICtrlCreateMenuItem("Printeaza    CTRL+P",$MENU_FILE)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_FILE)
    Global $EXIT = GUICtrlCreateMenuItem("Iesire",$MENU_FILE)
EndFunc

Func CreateEditMenu()
    $MENU_EDIT = GUICtrlCreateMenu("&Editare")
    Global $UNDO = GUICtrlCreateMenuItem("Inapoi                 CTRL+U",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $CUT = GUICtrlCreateMenuItem("Taie                    CTRL+X",$MENU_EDIT)
    Global $COPY = GUICtrlCreateMenuItem("Copy                   CTRL+C",$MENU_EDIT)
    Global $PASTE = GUICtrlCreateMenuItem("Lipeste                CTRL+V",$MENU_EDIT)
    Global $DELETE = GUICtrlCreateMenuItem("Sterge                   DEL",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $FIND = GUICtrlCreateMenuItem("Cauta                 CTRL+F",$MENU_EDIT)
    Global $GOTO = GUICtrlCreateMenuItem("Salt la                CTRL+G",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $SELECT_ALL = GUICtrlCreateMenuItem("Selecteaza tot   CTRL+A",$MENU_EDIT)
    Global $TIME_DATE = GUICtrlCreateMenuItem("Data/Timp            F5",$MENU_EDIT)
EndFunc

Func CreateFormatMenu()
    $MENU_FORMAT = GUICtrlCreateMenu("&Formatare")
    Global $WORD_WRAP = GUICtrlCreateMenuItem("Word Wrap",$MENU_FORMAT)
    Global $FONT = GUICtrlCreateMenuItem("Font...",$MENU_FORMAT)
EndFunc

Func CreateViewMenu()
    $MENU_VIEW = GUICtrlCreateMenu("&Vizualizare")
    Global $STATUS_BAR = GUICtrlCreateMenuItem("Status Bar",$MENU_VIEW)
EndFunc

Func CreateHelpMenu()
    $MENU_HELP = GUICtrlCreateMenu("&Ajutor")
    Global $ABOUT = GUICtrlCreateMenuItem("Despre",$MENU_HELP)
EndFunc

Func SetEncode()
$ENC_GUI = GUICreate("Notepad",200,55,-1,-1,0x16C00000)
$COMBO = GUICtrlCreateCombo("",5,5,190,20)
GUICtrlSetData($COMBO,"ANSI|Binary|Unicode UTF16 Little Endian|Unicode UTF16 Big Endian|Unicode UTF 8")
$ACCEPT = GUICtrlCreateButton("Accept",20,30,65,20)
$CANCEL = GUICtrlCreateButton("Cancel",120,30,65,20)
GUISetState(@SW_SHOW,$ENC_GUI)
While True
    $ENC_MSG = GUIGetMsg()
    If $ENC_MSG = $ACCEPT Then
        $ENC_TYPE = GUICtrlRead($COMBO)
        GUIDelete($ENC_GUI)
        Return EncodeToNumber($ENC_TYPE)
    ElseIf $ENC_MSG = $CANCEL Then
        GUIDelete($ENC_GUI)
        Return -1
    EndIf
    Sleep(20)
WEnd
EndFunc

Func EncodeToNumber($TYPE)
    If $TYPE = "ANSI" Then
        Return 0
    ElseIf $TYPE = "Binary" Then
        Return 16
    ElseIf $TYPE = "Unicode UTF16 Little Endian" Then
        Return 32
    ElseIf $TYPE = "Unicode UTF16 Big Endian" Then
        Return 64
    ElseIf $TYPE = "Unicode UTF 8" Then
        Return 128
    Else
        Return -1
    EndIf
EndFunc

Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    #forceref $Msg
    If $Hwnd = WinGetHandle($MAIN) Then
        $iGUIWidth = BitAND($lParam, 0xFFFF)
        $iGUIHeight = BitShift($lParam, 16)
        $fResized = True
    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>MY_WM_SIZE ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Hope this is what you wanted.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks Melba.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

One more thing. If I create a status bar always is overlay with my edit control. I create $BAR_ON to know when it's need a space in my GUI for status bar ($BAR_SIZE specify the size).

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>

Global $PATH = ""
Global $EDIT
Global $BAR
Global $BAR_ON = False

Global $iGUIWidth = 600, $iGUIHeight = 400, $fResized = False  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$MAIN = GUICreate("Notepad",600,400,-1,-1,0x14CF0000,0x00000110)
$EDIT = _GUICtrlEdit_Create($MAIN,"",0,0,600,380,0x50300104,0x00000200)
CreateFileMenu()
CreateEditMenu()
CreateFormatMenu()
CreateViewMenu()
CreateHelpMenu()
GUISetState()

; When window is resized, run this function
GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case $NEW
            Call("_New_")
        Case $OPEN
            Call("_Open_")
;~      Case $SAVE
;~          Call("_Save_")
;~      Case $SAVE_AS
;~          Call("_Save_As_")
;~      Case $PRINT
;~          Call("_Print_")
;~      Case $EXIT
;~          Call("_Exit_")
;~      Case $UNDO
;~          _GUICtrlEdit_Undo($EDIT)
;~      Case $COPY
;~          Call("_Copy_")
;~      Case $PASTE
;~          Call("_Paste_")
;~      Case $DELETE
;~          Call("_Delete_")
;~      Case $FIND
;~          _GUICtrlEdit_Find($EDIT,True)
;~      Case $GOTO
;~          Call("_GoTo_")
;~      Case $SELECT_ALL
;~          _GUICtrlEdit_SetSel($EDIT,0,-1)
;~      Case $TIME_DATE
;~          Call("_Time_Date_")
;~      Case $WORD_WRAP
;~          Call("_WordWrap_")
;~      Case $FONT
;~          Call("_Font_")
     Case $STATUS_BAR
         Call("_StatusBar_")
;~      Case $ABOUT
;~          Call("_About_")
        Case -3
            Exit
    EndSwitch

    If $fResized = True Then  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        If $BAR_ON Then
            $BAR_SIZE = 20
        Else
            $BAR_SIZE = 0
        EndIf
        ControlMove($MAIN, "", $EDIT, 0, 0, $iGUIWidth, $iGUIHeight-$BAR_SIZE)
        $fResized = False
    EndIf  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

WEnd

Func _StatusBar_()
    $BAR_ON = Not $BAR_ON
    If $BAR_ON Then
        Local $PART[2] = [500,100]
        $BAR = _GUICtrlStatusBar_Create($EDIT,$PART)
        $RESIZE = True
    Else
        _GUICtrlStatusBar_Destroy($BAR)
        $RESIZE = True
    EndIf
EndFunc

Func _New_()
    $WARINIG = MsgBox(0x4,"Notepad","Esti sigur?")
    If $WARINIG = 6 Then _GUICtrlEdit_SetText($EDIT,"")
EndFunc

Func _Open_()
    $WARINIG = MsgBox(0x4,"Notepad","Esti Sigur?")
    If $WARINIG = 6 Then
        $ENCODING = SetEncode()
        If $ENCODING <> -1 Then $ENCODING = "ANSI"
        $PATH = FileOpenDialog("Open",@ScriptDir,"Text (*.txt)|All (*.*)",1)
        If Not @error Then
            Local $FILE = FileOpen($PATH,$ENCODING)
            Local $TEXT = FileRead($FILE)
            FileClose($FILE)
            _GUICtrlEdit_SetText($EDIT,$TEXT)
        EndIf
    EndIf
EndFunc

Func CreateFileMenu()
    $MENU_FILE = GUICtrlCreateMenu("&Fisier")
    Global $NEW = GUICtrlCreateMenuItem("Nou        CTRL+N",$MENU_FILE)
    Global $OPEN = GUICtrlCreateMenuItem("Deschide   CTRL+O",$MENU_FILE)
    Global $SAVE = GUICtrlCreateMenuItem("Salveaza   CTRL+S",$MENU_FILE)
    Global $SAVE_AS = GUICtrlCreateMenuItem("Salveaza ca...",$MENU_FILE)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_FILE)
    Global $PRINT = GUICtrlCreateMenuItem("Printeaza    CTRL+P",$MENU_FILE)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_FILE)
    Global $EXIT = GUICtrlCreateMenuItem("Iesire",$MENU_FILE)
EndFunc

Func CreateEditMenu()
    $MENU_EDIT = GUICtrlCreateMenu("&Editare")
    Global $UNDO = GUICtrlCreateMenuItem("Inapoi                 CTRL+U",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $CUT = GUICtrlCreateMenuItem("Taie                    CTRL+X",$MENU_EDIT)
    Global $COPY = GUICtrlCreateMenuItem("Copy                   CTRL+C",$MENU_EDIT)
    Global $PASTE = GUICtrlCreateMenuItem("Lipeste                CTRL+V",$MENU_EDIT)
    Global $DELETE = GUICtrlCreateMenuItem("Sterge                   DEL",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $FIND = GUICtrlCreateMenuItem("Cauta                 CTRL+F",$MENU_EDIT)
    Global $GOTO = GUICtrlCreateMenuItem("Salt la                CTRL+G",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $SELECT_ALL = GUICtrlCreateMenuItem("Selecteaza tot   CTRL+A",$MENU_EDIT)
    Global $TIME_DATE = GUICtrlCreateMenuItem("Data/Timp            F5",$MENU_EDIT)
EndFunc

Func CreateFormatMenu()
    $MENU_FORMAT = GUICtrlCreateMenu("&Formatare")
    Global $WORD_WRAP = GUICtrlCreateMenuItem("Word Wrap",$MENU_FORMAT)
    Global $FONT = GUICtrlCreateMenuItem("Font...",$MENU_FORMAT)
EndFunc

Func CreateViewMenu()
    $MENU_VIEW = GUICtrlCreateMenu("&Vizualizare")
    Global $STATUS_BAR = GUICtrlCreateMenuItem("Status Bar",$MENU_VIEW)
EndFunc

Func CreateHelpMenu()
    $MENU_HELP = GUICtrlCreateMenu("&Ajutor")
    Global $ABOUT = GUICtrlCreateMenuItem("Despre",$MENU_HELP)
EndFunc

Func SetEncode()
$ENC_GUI = GUICreate("Notepad",200,55,-1,-1,0x16C00000)
$COMBO = GUICtrlCreateCombo("",5,5,190,20)
GUICtrlSetData($COMBO,"ANSI|Binary|Unicode UTF16 Little Endian|Unicode UTF16 Big Endian|Unicode UTF 8")
$ACCEPT = GUICtrlCreateButton("Accept",20,30,65,20)
$CANCEL = GUICtrlCreateButton("Cancel",120,30,65,20)
GUISetState(@SW_SHOW,$ENC_GUI)
While True
    $ENC_MSG = GUIGetMsg()
    If $ENC_MSG = $ACCEPT Then
        $ENC_TYPE = GUICtrlRead($COMBO)
        GUIDelete($ENC_GUI)
        Return EncodeToNumber($ENC_TYPE)
    ElseIf $ENC_MSG = $CANCEL Then
        GUIDelete($ENC_GUI)
        Return -1
    EndIf
    Sleep(20)
WEnd
EndFunc

Func EncodeToNumber($TYPE)
    If $TYPE = "ANSI" Then
        Return 0
    ElseIf $TYPE = "Binary" Then
        Return 16
    ElseIf $TYPE = "Unicode UTF16 Little Endian" Then
        Return 32
    ElseIf $TYPE = "Unicode UTF16 Big Endian" Then
        Return 64
    ElseIf $TYPE = "Unicode UTF 8" Then
        Return 128
    Else
        Return -1
    EndIf
EndFunc

Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    #forceref $Msg
    If $Hwnd = WinGetHandle($MAIN) Then
        $iGUIWidth = BitAND($lParam, 0xFFFF)
        $iGUIHeight = BitShift($lParam, 16)
        $fResized = True
    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>MY_WM_SIZE ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Andreik,

In response to your PM about "GoTo line" - have a look at this:

#include <GUIConstantsEx.au3>
#Include <GuiEdit.au3>
#Include <WinAPI.au3>

$hGUI = GUICreate("Test", 500, 500)

$hEdit = GUICtrlCreateEdit("", 10, 10, 480, 380)

For $i = 1 To 100
    _GUICtrlEdit_AppendText($hEdit, "Line " & $i & @CRLF)
Next

$hLabel = GUICtrlCreateLabel("", 10, 410, 20, 20)

$hInput = GUICtrlCreateInput("", 50, 410, 40, 20)

$hButton = GUICtrlCreateButton("GoTo", 120, 410, 80, 30)

GUISetState()

$iCurr_Line = _GUICtrlEdit_LineFromChar($hEdit)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            $iNew_Line = GUICtrlRead($hInput)
            GUICtrlSetData($hInput, "")
            _WinAPI_SetFocus(ControlGetHandle($hGUI, "", $hEdit))

            $iLine_Diff = $iNew_Line - (_GUICtrlEdit_LineFromChar($hEdit) + 1)

            If $iLine_Diff > 0 Then
                For $i = 1 To $iLine_Diff
                    Send("{DOWN}")
                Next
            ElseIf $iLine_Diff < 0 Then
                For $i = 1 To Abs($iLine_Diff)
                    Send("{UP}")
                Next
            EndIf
    EndSwitch

    If _GUICtrlEdit_LineFromChar($hEdit) <> $iCurr_Line Then
        GUICtrlSetData($hLabel, _GUICtrlEdit_LineFromChar($hEdit) + 1)
        $iCurr_Line = _GUICtrlEdit_LineFromChar($hEdit)
    EndIf

WEnd

It is still a bit rough around the edges. Just put the GoTo line number into the input and press 'GoTo'. But it gives you a starting point! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Andreik,

In response to your PM about "GoTo line" - have a look at this:

#include <GUIConstantsEx.au3>
#Include <GuiEdit.au3>
#Include <WinAPI.au3>

$hGUI = GUICreate("Test", 500, 500)

$hEdit = GUICtrlCreateEdit("", 10, 10, 480, 380)

For $i = 1 To 100
    _GUICtrlEdit_AppendText($hEdit, "Line " & $i & @CRLF)
Next

$hLabel = GUICtrlCreateLabel("", 10, 410, 20, 20)

$hInput = GUICtrlCreateInput("", 50, 410, 40, 20)

$hButton = GUICtrlCreateButton("GoTo", 120, 410, 80, 30)

GUISetState()

$iCurr_Line = _GUICtrlEdit_LineFromChar($hEdit)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            $iNew_Line = GUICtrlRead($hInput)
            GUICtrlSetData($hInput, "")
            _WinAPI_SetFocus(ControlGetHandle($hGUI, "", $hEdit))

            $iLine_Diff = $iNew_Line - (_GUICtrlEdit_LineFromChar($hEdit) + 1)

            If $iLine_Diff > 0 Then
                For $i = 1 To $iLine_Diff
                    Send("{DOWN}")
                Next
            ElseIf $iLine_Diff < 0 Then
                For $i = 1 To Abs($iLine_Diff)
                    Send("{UP}")
                Next
            EndIf
    EndSwitch

    If _GUICtrlEdit_LineFromChar($hEdit) <> $iCurr_Line Then
        GUICtrlSetData($hLabel, _GUICtrlEdit_LineFromChar($hEdit) + 1)
        $iCurr_Line = _GUICtrlEdit_LineFromChar($hEdit)
    EndIf

WEnd

It is still a bit rough around the edges. Just put the GoTo line number into the input and press 'GoTo'. But it gives you a starting point! :)

M23

I though that exists a good method. This one I use already. Please check post#4 and see if you can help me more there.

Thanks.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Andreik,

A fix for the status bar problem. The first problem was that you had put the status bar inside the edit rather than the GUI. :)

This is the result of much experimentation on one of my own scripts. Do not ask why it works - it just does! :) :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>

Global $PATH = ""
Global $EDIT
Global $BAR, $BAR_SIZE  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Global $BAR_ON = False

Global $iGUIWidth = 600, $iGUIHeight = 400, $fResized = False

; Create main GUI too short - we will resize it later
$MAIN = GUICreate("Notepad",600,385,-1,-1,0x14CF0000,0x00000110) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$EDIT = _GUICtrlEdit_Create($MAIN,"",0,0,600,380,0x50300104,0x00000200)
CreateFileMenu()
CreateEditMenu()
CreateFormatMenu()
CreateViewMenu()
CreateHelpMenu()

; Create and hide status bar   ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Local  $PART[2] = [500,100]
Global $BAR = _GUICtrlStatusBar_Create($MAIN,$PART)
Global $BAR_SIZE = _GUICtrlStatusBar_GetHeight($BAR) +5
_GUICtrlStatusBar_ShowHide ($BAR, @SW_HIDE) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUISetState()

; Set main GUI to correct size minus status bar
WinMove($MAIN, "", Default, Default, 600, 400) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; When window is resized, run this function
GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case $NEW
            Call("_New_")
        Case $OPEN
            Call("_Open_")
;~      Case $SAVE
;~          Call("_Save_")
;~      Case $SAVE_AS
;~          Call("_Save_As_")
;~      Case $PRINT
;~          Call("_Print_")
;~      Case $EXIT
;~          Call("_Exit_")
;~      Case $UNDO
;~          _GUICtrlEdit_Undo($EDIT)
;~      Case $COPY
;~          Call("_Copy_")
;~      Case $PASTE
;~          Call("_Paste_")
;~      Case $DELETE
;~          Call("_Delete_")
;~      Case $FIND
;~          _GUICtrlEdit_Find($EDIT,True)
;~      Case $GOTO
;~          Call("_GoTo_")
;~      Case $SELECT_ALL
;~          _GUICtrlEdit_SetSel($EDIT,0,-1)
;~      Case $TIME_DATE
;~          Call("_Time_Date_")
;~      Case $WORD_WRAP
;~          Call("_WordWrap_")
;~      Case $FONT
;~          Call("_Font_")
     Case $STATUS_BAR
         Call("_StatusBar_")
;~      Case $ABOUT
;~          Call("_About_")
        Case -3
            Exit
    EndSwitch

    If $fResized = True Then
        If $BAR_ON = True Then
            ControlMove($MAIN, "", $EDIT, 0, 0, $iGUIWidth, $iGUIHeight - $BAR_SIZE)
            ControlMove($MAIN, "", $BAR, 0, $iGUIHeight - $BAR_SIZE, $iGUIWidth) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Else
            ControlMove($MAIN, "", $EDIT, 0, 0, $iGUIWidth, $iGUIHeight)
        EndIf
        $fResized = False
    EndIf

WEnd

Func _StatusBar_() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $aWin_Pos = WinGetPos($MAIN)
    If $BAR_ON = True Then
        _GUICtrlStatusBar_ShowHide ($BAR, @SW_HIDE)
        ; Resize main window
        WinMove($MAIN, "", Default, Default, $aWin_Pos[2], $aWin_Pos[3] - $BAR_SIZE)
        $BAR_ON = False
    Else
        ; Resize main window
        WinMove($MAIN, "", Default, Default, $aWin_Pos[2], $aWin_Pos[3] + $BAR_SIZE)
        ; Show Status bar
        _GUICtrlStatusBar_ShowHide ($BAR, @SW_SHOW)
        $BAR_ON = True
    EndIf
EndFunc ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


Func _New_()
    $WARINIG = MsgBox(0x4,"Notepad","Esti sigur?")
    If $WARINIG = 6 Then _GUICtrlEdit_SetText($EDIT,"")
EndFunc

Func _Open_()
    $WARINIG = MsgBox(0x4,"Notepad","Esti Sigur?")
    If $WARINIG = 6 Then
        $ENCODING = SetEncode()
        If $ENCODING <> -1 Then $ENCODING = "ANSI"
        $PATH = FileOpenDialog("Open",@ScriptDir,"Text (*.txt)|All (*.*)",1)
        If Not @error Then
            Local $FILE = FileOpen($PATH,$ENCODING)
            Local $TEXT = FileRead($FILE)
            FileClose($FILE)
            _GUICtrlEdit_SetText($EDIT,$TEXT)
        EndIf
    EndIf
EndFunc

Func CreateFileMenu()
    $MENU_FILE = GUICtrlCreateMenu("&Fisier")
    Global $NEW = GUICtrlCreateMenuItem("Nou        CTRL+N",$MENU_FILE)
    Global $OPEN = GUICtrlCreateMenuItem("Deschide   CTRL+O",$MENU_FILE)
    Global $SAVE = GUICtrlCreateMenuItem("Salveaza   CTRL+S",$MENU_FILE)
    Global $SAVE_AS = GUICtrlCreateMenuItem("Salveaza ca...",$MENU_FILE)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_FILE)
    Global $PRINT = GUICtrlCreateMenuItem("Printeaza    CTRL+P",$MENU_FILE)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_FILE)
    Global $EXIT = GUICtrlCreateMenuItem("Iesire",$MENU_FILE)
EndFunc

Func CreateEditMenu()
    $MENU_EDIT = GUICtrlCreateMenu("&Editare")
    Global $UNDO = GUICtrlCreateMenuItem("Inapoi                 CTRL+U",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $CUT = GUICtrlCreateMenuItem("Taie                    CTRL+X",$MENU_EDIT)
    Global $COPY = GUICtrlCreateMenuItem("Copy                   CTRL+C",$MENU_EDIT)
    Global $PASTE = GUICtrlCreateMenuItem("Lipeste                CTRL+V",$MENU_EDIT)
    Global $DELETE = GUICtrlCreateMenuItem("Sterge                   DEL",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $FIND = GUICtrlCreateMenuItem("Cauta                 CTRL+F",$MENU_EDIT)
    Global $GOTO = GUICtrlCreateMenuItem("Salt la                CTRL+G",$MENU_EDIT)
    $SEPARATOR = GUICtrlCreateMenuItem("",$MENU_EDIT)
    Global $SELECT_ALL = GUICtrlCreateMenuItem("Selecteaza tot   CTRL+A",$MENU_EDIT)
    Global $TIME_DATE = GUICtrlCreateMenuItem("Data/Timp            F5",$MENU_EDIT)
EndFunc

Func CreateFormatMenu()
    $MENU_FORMAT = GUICtrlCreateMenu("&Formatare")
    Global $WORD_WRAP = GUICtrlCreateMenuItem("Word Wrap",$MENU_FORMAT)
    Global $FONT = GUICtrlCreateMenuItem("Font...",$MENU_FORMAT)
EndFunc

Func CreateViewMenu()
    $MENU_VIEW = GUICtrlCreateMenu("&Vizualizare")
    Global $STATUS_BAR = GUICtrlCreateMenuItem("Status Bar",$MENU_VIEW)
EndFunc

Func CreateHelpMenu()
    $MENU_HELP = GUICtrlCreateMenu("&Ajutor")
    Global $ABOUT = GUICtrlCreateMenuItem("Despre",$MENU_HELP)
EndFunc

Func SetEncode()
$ENC_GUI = GUICreate("Notepad",200,55,-1,-1,0x16C00000)
$COMBO = GUICtrlCreateCombo("",5,5,190,20)
GUICtrlSetData($COMBO,"ANSI|Binary|Unicode UTF16 Little Endian|Unicode UTF16 Big Endian|Unicode UTF 8")
$ACCEPT = GUICtrlCreateButton("Accept",20,30,65,20)
$CANCEL = GUICtrlCreateButton("Cancel",120,30,65,20)
GUISetState(@SW_SHOW,$ENC_GUI)
While True
    $ENC_MSG = GUIGetMsg()
    If $ENC_MSG = $ACCEPT Then
        $ENC_TYPE = GUICtrlRead($COMBO)
        GUIDelete($ENC_GUI)
        Return EncodeToNumber($ENC_TYPE)
    ElseIf $ENC_MSG = $CANCEL Then
        GUIDelete($ENC_GUI)
        Return -1
    EndIf
    Sleep(20)
WEnd
EndFunc

Func EncodeToNumber($TYPE)
    If $TYPE = "ANSI" Then
        Return 0
    ElseIf $TYPE = "Binary" Then
        Return 16
    ElseIf $TYPE = "Unicode UTF16 Little Endian" Then
        Return 32
    ElseIf $TYPE = "Unicode UTF16 Big Endian" Then
        Return 64
    ElseIf $TYPE = "Unicode UTF 8" Then
        Return 128
    Else
        Return -1
    EndIf
EndFunc

Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg
    If $Hwnd = WinGetHandle($MAIN) Then
        $iGUIWidth = BitAND($lParam, 0xFFFF)
        $iGUIHeight = BitShift($lParam, 16)
        $fResized = True
    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>MY_WM_SIZE

Anything else tonight - or can I watch my recording of the great Cav winning yet another stage of the Tour de France? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks alot. All work fine. I need to fix some functions and then my notepad will be finished.


When the words fail... music speaks

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  
Followers 0