James Posted December 22, 2006 Share Posted December 22, 2006 (edited) My newest and latest project is a tabbed notepad . 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. expandcollapse popup;-------------------------------------------- ; ; 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 December 22, 2006 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
theguy0000 Posted December 22, 2006 Share Posted December 22, 2006 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 Link to comment Share on other sites More sharing options...
James Posted December 22, 2006 Author Share Posted December 22, 2006 Thanks. Now I need to know how to open the documents and name the tab with the doc name. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted December 22, 2006 Author Share Posted December 22, 2006 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. expandcollapse popup;-------------------------------------------- ; ; 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 Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
_Kurt Posted December 22, 2006 Share Posted December 22, 2006 (edited) 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 December 22, 2006 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
theguy0000 Posted December 22, 2006 Share Posted December 22, 2006 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?")UNTESTEDPS: you need to add in If $var = 6 then .. If $var = 7 then ..Hope that helps,Kurt*EDIT* 150 posts woo hoothe 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 Link to comment Share on other sites More sharing options...
James Posted December 22, 2006 Author Share Posted December 22, 2006 Yeah, I was going to add that after I had found out how to save and load. I have done save, I need load Lol, its now 152. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted December 22, 2006 Author Share Posted December 22, 2006 Can anyone help with the loading? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
_Kurt Posted December 22, 2006 Share Posted December 22, 2006 Why not this.. : $readline = FileReadLine($OpenDir) GuiCtrlSetData($notepad, $readline) No need to FileOpen or any of that, just add that after your $opendir, change $notepad variable to the appropriate variable, and all should be well. Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
James Posted December 22, 2006 Author Share Posted December 22, 2006 Thanks _Kurt but PaulIA has just done it for me XD I tried that, but it wasn't quite the same. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now