Drucken option

  • Also ich habe mal schnell ein textverarbeitungsprogramm gemacht kann mir da jemand helfen wie ich beim drucken button im menü eine funktion einbauen also in de while schleife oder so wie dies geht so dass man denn text nicht nur öffnen und speichern kann sondern auch drucken :?:

    Einmal editiert, zuletzt von simon (5. März 2009 um 16:54)

  • Hier ist der Quellcode:

    Spoiler anzeigen
    [autoit]

    #include <array.au3>
    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    #Include <GuiStatusBar.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $names = _ArrayCreate("","") ;# Benutzernamen
    Global $pws = _ArrayCreate("","") ;# Passwörter

    [/autoit] [autoit][/autoit] [autoit]

    $bp_login = Login("SB Word 1.5 - Login",$names,$pws)
    Switch @error
    Case 0
    msgbox(64,"","Willkommen " & $bp_login)
    Case 1
    Exit
    Case 2
    msgbox(49,"","Falsches Passwort oder falscher Username!")
    Exit
    Case 3
    msgbox(49,"","Array - System Fehler ")
    Exit
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Hier dein Programm hin!
    $gui = GUICreate("SB Schulword",1270,750,0,0)

    [/autoit] [autoit][/autoit] [autoit]

    $filemenu = GUICtrlCreateMenu ("&Datei")
    $open = GUICtrlCreateMenuitem ("Öffnen",$filemenu)
    ;GUICtrlSetState(-1,$GUI_DEFBUTTON)
    $helpmenu = GUICtrlCreateMenu ("Info")
    $saveitem = GUICtrlCreateMenuitem ("Speichern",$filemenu)
    ;GUICtrlSetState(-1,$GUI_DISABLE)
    $infoitem = GUICtrlCreateMenuitem ("?",$helpmenu)
    $frageitem = GUICtrlCreateMenuItem ("Fragen",$helpmenu)
    $hpitem1 = GUICtrlCreateMenuItem("Homepage",$helpmenu)
    $hpitem2 = GUICtrlCreateMenuItem ("2. Homepage",$helpmenu)

    [/autoit] [autoit][/autoit] [autoit]

    $helpmenu = GUICtrlCreateMenu("Fragen",$helpmenu)
    $frageitem2 = GUICtrlCreateMenuItem("Fragen",$helpmenu)

    [/autoit] [autoit][/autoit] [autoit]

    $helpitem = GUICtrlCreateMenuitem ("Hilfe",$helpmenu)
    $exititem = GUICtrlCreateMenuitem ("Beenden",$filemenu)
    $recentfilesmenu = GUICtrlCreateMenu ("Dateien",$filemenu,1)

    [/autoit] [autoit][/autoit] [autoit]

    $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2); Erstellt eine Trennlinie (hier: leere Zeile)

    [/autoit] [autoit][/autoit] [autoit]

    $viewmenu = GUICtrlCreateMenu("Ansicht",-1,1) ; wird vor dem "?" Menü erstellt
    $viewstatusitem = GUICtrlCreateMenuitem ("Statusleiste",$viewmenu)
    GUICtrlSetState(-1,$GUI_CHECKED)
    GUICtrlSetState(-1,$GUI_FOCUS)
    ;$cancelbutton = GUICtrlCreateButton ("Abbrechen",1000,660,100,30)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreatePic(@WorkingDir & "/kjkj.bmp",0,0,1270,750)
    GUICtrlCreatePic(@WorkingDir & "/SB Word.jpg",10,10,450,150)

    [/autoit] [autoit][/autoit] [autoit]

    $text_input = GUICtrlCreateEdit("",20,170,1230,520)
    GUICtrlSetFont (-1, "15",400,2+4)
    GUICtrlSetColor(-1,"0xCCFF66")
    GUICtrlSetBkColor(-1,"0x000033")

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Hallo und Herzlich Willkommen zu meinem neuen Word 1.5",470,70,1000,30)
    GUICtrlSetFont(-1,16,400,2+4,"Luciada Handwriting")
    GUICtrlSetColor(-1,"0x66FF33")
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1,"0xFFFFFF")

    [/autoit] [autoit][/autoit] [autoit]

    ;# Statusbar:
    $hStatus = _GUICtrlStatusBar_Create($gui)
    _GUICtrlStatusBar_SetText($hStatus,"Bereit.")
    ;# Statusbar ENDE

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState ()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    $wait = 1000
    If $msg = $open Then
    $file = FileOpenDialog("Wählen Sie eine Datei aus...",@WorkingDir,"Alle (*.txt) , (*.html")
    $file_open = FileOpen($file,0)
    $read_open = FileRead($file_open)
    GUICtrlSetData($text_input,$read_open)
    FileClose($file_open)
    _GUICtrlStatusBar_SetText($hStatus,"Datei öffnen...")
    Sleep($wait)
    _GUICtrlStatusBar_SetText($hStatus,"Bereit.")
    EndIf
    If $msg = $viewstatusitem Then
    If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
    GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
    _GUICtrlStatusBar_ShowHide ($hStatus, @SW_HIDE)
    Else
    GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
    _GUICtrlStatusBar_ShowHide ($hStatus, @SW_SHOW)
    EndIf
    EndIf
    If $msg = $saveitem Then
    $text_read = GUICtrlRead($text_input)
    $save_pfad = FileSaveDialog("Bitte wähle den Speicherpfad",@WorkingDir,"Textdatei (*.txt)") ; Textdatei Filter
    $file = FileOpen($save_pfad&".txt", 2) ; TEXTDATEI festlegen
    If $file = -1 Then
    MsgBox(0, "Fehler", "Die Datei konnte nicht geöffnet werden.")
    Exit
    EndIf
    FileWriteLine($file,$text_read)
    FileClose($file)
    _GUICtrlStatusBar_SetText($hStatus,"Datei speichern...")
    Sleep($wait)
    _GUICtrlStatusBar_SetText($hStatus,"Bereit.")
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then ExitLoop
    If $msg = $infoitem Then Msgbox(64,"Info","Hallo wenn du fragen zu diesem Programm hast, dann schicke bitte eine e-mail an [email='simon-buchner1@gmx.de'][/email]. Vielen Dank für das Downloaden")
    If $msg = $helpitem Then MsgBox(0,"Hilfe","Zur Hilfe bitte sende eine e-mail an [email='simon-buchner1@gmx.de'][/email] oder an simon-buchner2@gmx.de")
    If $msg = $frageitem Then MsgBox (0,"Fragen","Bei Fragen E-Mail an simon-buchner1@gmx.de")
    If $msg = $hpitem1 Then ShellExecute("http://www.simon-buchner.npage.de")
    If $msg = $hpitem2 Then ShellExecute("http://www.simon-buchner.de.tl")
    If $msg = $frageitem2 Then MsgBox(0,"Fragen","Zur beantwortung der Fragen wendet euch bitte mit einer e-mail an [email='simon-buchner1@gmx.de'][/email] .Danke!!!")
    WEnd
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func Login($sTitle,$sUsername,$sPassword,$BgColor = 0x000000,$TxtColor = 0xFFFFFF,$BtnColor = 0x000000)
    $LoginGui = GuiCreate($sTitle,250,140)
    $NameLabel = GuiCtrlCreateLabel("Username",12,11)
    $Name = GuiCtrlCreateInput("",70,10,165)
    $PwLabel = GuiCtrlCreateLabel("Passwort",12,40)
    $Pw = GuiCtrlCreateInput("",70,38,165,-1,0x0020)
    $Login = GuiCtrlCreateButton("Login",75,67,100,Default,0x0001)
    $load = GUICtrlCreateProgress(76,100,100,15)
    GUICtrlSetState(-1,$GUI_HIDE)
    $loading_label = GUICtrlCreateLabel("",90,120,100)
    GuiCtrlSetColor(-1,$TxtColor)

    [/autoit] [autoit][/autoit] [autoit]

    GuiSetBkColor($BgColor,$LoginGui)
    GuiCtrlSetColor($NameLabel,$TxtColor)
    GuiCtrlSetColor($PwLabel,$TxtColor)
    GuiCtrlSetBkColor($Login,$BtnColor)
    GuiCtrlSetColor($Login,$TxtColor)
    GuiSetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GuiGetMsg()
    Case $GUI_EVENT_CLOSE
    GuiDelete($LoginGui)
    SetError(1)
    Return 0
    Case $Login
    GUICtrlSetState($load,$GUI_SHOW)
    For $i = 0 To 100
    GUICtrlSetData($load, $i)
    If $i=40 Then GUICtrlSetData($loading_label,"Überprüfung...")
    If $i=90 Then GUICtrlSetData($loading_label,"Start...")
    If $i=120 Then GUICtrlSetData($loading_label,"Fertig...")
    sleep(150)
    $i = $i + 9
    Next
    If Not IsArray($sUsername) and Not IsArray($sPassword) Then
    If GuiCtrlRead($Name) = $sUsername and GuiCtrlRead($Pw) = $sPassword Then
    GuiDelete($LoginGui)
    Return $sUsername
    Else
    GuiDelete($LoginGui)
    SetError(2)
    Return 0
    EndIf
    ElseIf IsArray($sUsername) and IsArray($sPassword) Then
    If (UBound($sUsername,0) <> 1) or (UBound($sPassword,0) <> 1) or (UBound($sUserName,1) <> UBound($sPassword,1)) Then
    GuiDelete($LoginGui)
    SetError(3)
    Return 0
    EndIf
    $UN = GuiCtrlRead($Name)
    $UP = GuiCtrlRead($Pw)
    For $i = 0 to UBound($sUsername)-1
    If $UN = $sUsername[$i] and $UP = $sPassword[$i] Then
    GuiDelete($LoginGui)
    Return $sUserName[$i]
    EndIf
    Next
    GuiDelete($LoginGui)
    SetError(2)
    Return 0
    Else
    GuiDelete($LoginGui)
    SetError(3)
    Return 0
    EndIf
    EndSwitch
    WEnd
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von simon (5. März 2009 um 17:19)