Sign in to follow this  
Followers 0
GrungeRocker

load a text from a file into an edit

3 posts in this topic

hi guys

its me again :(

i wanted to make sth like an editor but i dont know how to load the text into the edit....

i looked in lazycats quick notepad but it was too complicated....

so here is what i already have:

#include <GuiConstants.au3>

GuiCreate("Texteditor", 516, 540,(@DesktopWidth-516)/2, (@DesktopHeight-540)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$filemenu = GUICtrlCreateMenu ("&File")
$Open = GUICtrlCreateMenuitem ("Open",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$Save = GUICtrlCreateMenuitem("Save", $filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$SaveAs = GUICtrlCreateMenuitem("Save as", $filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$nix1 = GUICtrlCreateMenuitem("____________", $filemenu)
GUICtrlSetState(-1,$gui_disable)
$exit = GUICtrlCreateMenuitem("Exit", $filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$text = 'Programmiert von Artus Krieger'
$Textfeld = GuiCtrlCreateEdit("" & $text, 0, 30, 520, 510)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Open
        $file = FileOpenDialog("Choose file...",@DesktopCommonDir,"All (*.*)")
        $text = FileOpen("" & $file, 0)
        GUICtrlDelete($textfeld)
        $Textfeld = GuiCtrlCreateEdit("" & $text, 0, 30, 520, 510)
    EndSelect
WEnd
Exit

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Click file open and select a file.

#include <GuiConstants.au3>
GUICreate("Texteditor", 516, 540, (@DesktopWidth - 516) / 2, (@DesktopHeight - 540) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$filemenu = GUICtrlCreateMenu("&File")
$Open = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$Save = GUICtrlCreateMenuItem("Save", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$SaveAs = GUICtrlCreateMenuItem("Save as", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$nix1 = GUICtrlCreateMenuItem("____________", $filemenu)
GUICtrlSetState(-1, $gui_disable)
$exit = GUICtrlCreateMenuItem("Exit", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$text = 'Programmiert von Artus Krieger'
$Textfeld = GUICtrlCreateEdit("" & $text, 0, 30, 520, 510)
GUISetState()
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case $msg = $Open
         $file = FileOpenDialog("Choose file...", @DesktopCommonDir, "All (*.*)")
         If Not @error Then
            $Ready = FileOpen($file, 0)
            If $Ready = -1 Then
               MsgBox(0, "Error", "Unable to open file.")
               Exit
            EndIf
            $File_Read = FileRead($file, FileGetSize($file))
            GUICtrlDelete($Textfeld)
            $Textfeld = GUICtrlCreateEdit($File_Read, 0, 30, 520, 510)
         EndIf
   EndSelect
WEnd
Exit
Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

ohh thx...

thats really easy :(

and im soo stupid..

well let us say it so..

i ad got a black out!1

so im happy:D


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

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