Jump to content
Sign in to follow this  
James

Tabbed notepad help

Recommended Posts

My newest and latest project is a tabbed notepad :P.

Currently:

The GUI

The Tabs

Add new tabs by pressing CTRL + T

Now I need to save what is in the tabs. I have the FileSaveDialog done, but it doesnt save, because I dont know how to make it.

;--------------------------------------------
;
; Name: BetaPad
; Author: Secure_ICT
; Description: A nice text editor with tabs
; Credit: theguy0000
;
;--------------------------------------------

#include <GUIConstants.au3>
#include <Array.au3>

Global $Functions
HotKeySet("^t", "newtab")

#Region ### START Koda GUI section ### Form=c:\program files\koda\templates\tabbed pages.kxf
$dlgTabbed = GUICreate("BetaPad - Secure_ICT", 413, 400, 303, 219)
GUISetIcon("")
$pages = GUICtrlCreateTab(8, 104, 396, 288)
$TabSheet1 = GUICtrlCreateTabItem("Document 1")
GUICtrlSetState(-1,$GUI_SHOW)
$doc1 = GUICtrlCreateEdit("", 16, 128, 385, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "")
$TabSheet2 = GUICtrlCreateTabItem("Document 2")
$doc2 = GUICtrlCreateEdit("", 16, 128, 385, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "")
$TabSheet3 = GUICtrlCreateTabItem("Document 3")
$doc3 = GUICtrlCreateEdit("", 16, 128, 385, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "")
GUICtrlCreateTabItem("")
$optgroup = GUICtrlCreateGroup("BetaPad - Options", 8, 8, 393, 89)
$save = GUICtrlCreateButton("Save", 120, 24, 73, 25, 0)
$open = GUICtrlCreateButton("Open", 200, 24, 73, 25, 0)
$label = GUICtrlCreateLabel("Search", 16, 64, 38, 17)
$google = GUICtrlCreateInput("", 56, 64, 249, 21)
$googleit = GUICtrlCreateButton("Google it!", 312, 64, 81, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Func newtab()
    $Functions = Not $Functions
    While $Functions
        Sleep(100)
        GUICtrlSetData(-1, "") 
        $TabSheet2 = GUICtrlCreateTabItem("New Tab")
        $newdoc = GUICtrlCreateEdit("", 16, 128, 385, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
        ExitLoop
    WEnd
EndFunc

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        Case $Msg = $save
            $SaveDir = FileSaveDialog("Save",@MyDocumentsDir,"Text Document(*.txt)|Secure Document(*.ict)|Autoit Doccument(*.au3)",16)
            Switch GUICtrlRead ($pages)
                Case 0
                    $text = GUICtrlRead ($doc1)
                Case 1
                    $text = GUICtrlRead ($doc2)
                Case 2
                    $text = GUICtrlRead ($doc3)
            EndSwitch
            $filehandle = FileOpen ($SaveDir, 2)
            FileWrite ($filehandle, $text)
            FileClose ($filehandle)
    EndSelect
WEnd

Also how do I do I open the file in an empty tab?

Thanks

Secure

P.S Merry Christmas!

Edit: Added new tabs and Save thanks to theguy0000

Edited by Secure_ICT

Share this post


Link to post
Share on other sites

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        Case $Msg = $save
            $SaveDir = FileSaveDialog("Save",@MyDocumentsDir,"Text Document(*.txt)|Secure Document(*.ict)|Autoit Doccument(*.au3)",16)
            Switch GUICtrlRead ($pages)
                Case 0
                    $text = GUICtrlRead ($doc1)
                Case 1
                    $text = GUICtrlRead ($doc2)
                Case 2
                    $text = GUICtrlRead ($doc3)
            EndSwitch
            $filehandle = FileOpen ($SaveDir, 2)
            FileWrite ($filehandle, $text)
            FileClose ($filehandle)
    EndSelect
WEnd


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Well I got it to load a new tab with the name of the file place. But my real problem is that I cannot make it open the text itself.

;--------------------------------------------
;
; Name: BetaPad
; Author: Secure_ICT
; Description: A nice text editor with tabs
; Credit: theguy0000
;
;--------------------------------------------

#include <GUIConstants.au3>
#include <ie.au3>
#include <GuiTab.au3>

Global $Functions
HotKeySet("^t", "newtab")
HotKeySet("^{F3}", "closeall")

#Region ### START Koda GUI section ### Form=c:\program files\koda\templates\tabbed pages.kxf
$dlgTabbed = GUICreate("BetaPad - Secure_ICT", 413, 400, 303, 219)
GUISetIcon("")
$pages = GUICtrlCreateTab(8, 104, 396, 288)
$TabSheet1 = GUICtrlCreateTabItem("Document 1")
GUICtrlSetState(-1,$GUI_SHOW)
$doc1 = GUICtrlCreateEdit("", 16, 128, 385, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "")
$TabSheet2 = GUICtrlCreateTabItem("Document 2")
$doc2 = GUICtrlCreateEdit("", 16, 128, 385, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "")
$TabSheet3 = GUICtrlCreateTabItem("Document 3")
$doc3 = GUICtrlCreateEdit("", 16, 128, 385, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "")
GUICtrlCreateTabItem("")
$optgroup = GUICtrlCreateGroup("BetaPad - Options", 8, 8, 393, 89)
$save = GUICtrlCreateButton("Save", 120, 24, 73, 25, 0)
$open = GUICtrlCreateButton("Open", 200, 24, 73, 25, 0)
$label = GUICtrlCreateLabel("Search", 16, 64, 38, 17)
$google = GUICtrlCreateInput("", 56, 64, 249, 21)
$googleit = GUICtrlCreateButton("Google it!", 312, 64, 81, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Func newtab()
    $Functions = Not $Functions
    While $Functions
        Sleep(100)
        GUICtrlSetData(-1, "") 
        $TabSheet2 = GUICtrlCreateTabItem("New Tab")
        $newdoc = GUICtrlCreateEdit("", 16, 128, 385, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
        ExitLoop
    WEnd
EndFunc

Func closeall()
    $Functions = Not $Functions
    While $Functions
        Sleep(100)
        _GUICtrlTabDeleteAllItems($pages)
    ExitLoop
WEnd
EndFunc

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        Case $Msg = $save
            $SaveDir = FileSaveDialog("Save",@MyDocumentsDir, "Text Document(*.txt)|Secure Document(*.ict)|Autoit Doccument(*.au3)",16)
            Switch GUICtrlRead($pages)
                Case 0
                    $text = GUICtrlRead($doc1)
                Case 1
                    $text = GUICtrlRead($doc2)
                Case 2
                    $text = GUICtrlRead($doc3)
            EndSwitch
            $filehandle = FileOpen($SaveDir, 2)
            FileWrite($filehandle, $text)
            FileClose($filehandle)
        Case $msg = $open
            $OpenDir = FileOpenDialog("Open", @MyDocumentsDir, "Text Document(*.txt)|Secure Document(*.ict)|Autoit Doccument(*.au3)",16)
            Switch GuiCtrlRead($pages)
            Case 0
                GUICtrlCreateTabItem($OpenDir)
            EndSwitch
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

Little idea: warn the user if it will overwrite something.

Example:

$SaveDir = FileSaveDialog("Save",@MyDocumentsDir,"Text Document(*.txt)|Secure Document(*.ict)|Autoit Doccument(*.au3)",16)

If FileExists($SaveDir) Then Msgbox(64,"","The file you have selected already exists" & @CRLF & "Would you like to overwrite the selected file?")

UNTESTED

PS: you need to add in If $var = 6 then .. If $var = 7 then ..

Hope that helps,

Kurt

*EDIT* 150 posts woo hoo

Edited by _Kurt

Share this post


Link to post
Share on other sites

Little idea: warn the user if it will overwrite something.

Example:

$SaveDir = FileSaveDialog("Save",@MyDocumentsDir,"Text Document(*.txt)|Secure Document(*.ict)|Autoit Doccument(*.au3)",16)

If FileExists($SaveDir) Then Msgbox(64,"","The file you have selected already exists" & @CRLF & "Would you like to overwrite the selected file?")

UNTESTED

PS: you need to add in If $var = 6 then .. If $var = 7 then ..

Hope that helps,

Kurt

*EDIT* 150 posts woo hoo

the flag 16 in FileSaveDialog does just that.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

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  

×
×
  • Create New...