GameOveR-xD Posted July 3, 2015 Share Posted July 3, 2015 GUICtrlCreateEdit veya _GUICtrlEdit_Create ile oluşturulan geniş metin kutusunda belirli kodu aratıp belirlediğim değerle değiştirmek istiyorum. Basit bir HTML editör yamayı düşünüyorum. Belli tagları seçtiğim metine eklemek için aşağıdaki kodu buldum ancak, kutuya yazılan metinde arama yaptırıp <br/> tagı varsa onu silmesini istiyorum ama bi türlü yapamadım. Aşağıdaki kodu denedim, işe yaramıyor. <_< #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 149, 192, 124) $Edit1 = _GUICtrlEdit_Create($Form1, "Only a test edit control", 8, 8, 193, 105) $Button1 = GUICtrlCreateButton("Replace", 136, 120, 65, 17) $Button2 = GUICtrlCreateButton("Delete", 60, 120, 65, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _TAG("<b>","</b>",$Edit1) Case $Button2 If StringInStr($Edit1, "<br/>") Then StringReplace($Edit1, "<br/>", "") Else MsgBox(0, "Hata", "<br/> kodu bulunamadı!") EndIf EndSwitch WEnd Func _TAG($sOpenTag,$sCloseTag,$hEdit) $sSelPos = _GUICtrlEdit_GetSel($hEdit) $sSelString = StringMid(_GUICtrlEdit_GetText($hEdit), $sSelPos[0] + 1, $sSelPos[1] - $sSelPos[0]) _GUICtrlEdit_ReplaceSel($Edit1, $sOpenTag & $sSelString & $sCloseTag) EndFunc;_TAG Quote Link to comment Share on other sites More sharing options...
blackman12 Posted July 4, 2015 Share Posted July 4, 2015 #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 149, 192, 124) $Edit1 = _GUICtrlEdit_Create($Form1, "Only a test edit control", 8, 8, 193, 105) $Button1 = GUICtrlCreateButton("Replace", 136, 120, 65, 17) $Button2 = GUICtrlCreateButton("Delete", 60, 120, 65, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _TAG("<b>","</b>",$Edit1) Case $Button2 $oku = _GUICtrlEdit_GetText($Edit1) If StringInStr($oku, "<br/>") Then $oku = StringReplace($oku, "<br/>", "") _GUICtrlEdit_SetText($Edit1,$oku) Else MsgBox(0, "Hata", "<br/> kodu bulunamadı!") EndIf EndSwitch WEnd Func _TAG($sOpenTag,$sCloseTag,$hEdit) $sSelPos = _GUICtrlEdit_GetSel($hEdit) $sSelString = StringMid(_GUICtrlEdit_GetText($hEdit), $sSelPos[0] + 1, $sSelPos[1] - $sSelPos[0]) _GUICtrlEdit_ReplaceSel($Edit1, $sOpenTag & $sSelString & $sCloseTag) EndFunc;_TAG edit kutuphanesi kodlarını kullanmalısın eğer editi kutuphaneyle oluşturduysan. bu basit bir örnek bana pm at yarın buraya daha gelişmiş bi örnek koyayım UPP de kullandığımı. Quote Link to comment Share on other sites More sharing options...
GameOveR-xD Posted July 4, 2015 Author Share Posted July 4, 2015 (edited) edit kutuphanesi kodlarını kullanmalısın eğer editi kutuphaneyle oluşturduysan. bu basit bir örnek bana pm at yarın buraya daha gelişmiş bi örnek koyayım UPP de kullandığımı. Elinize sağlık hocam, bu kodlar çalışıyor ancak ben tablı bir proje kullanmayı düşünüyorum bunu birden fazla metin kutusu olan yerde nasıl kullanabiliriz. Aşağıda örnek bi kodlama oluşturdum. Ctrl + A seçeneği de ekledim metnin tümünü seçmek için. Ancak bir türlü aktif olan kısımda düzenleme yapabilecek şekile getiremedim, kod sadece $Kod1 alanında çalışıyor. Fazla bilgim olmadığından kod üzerinde çok bir düzenleme yapamıyorum. [spoiler] #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> #include <WinAPI.au3> Global $Information, $ScreenShots, $GamePlay, $NFO, $Req, $h1, $h2, $h3, $h4, $h5 HotKeySet("^a", "_selectall") #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("Form1", 1110, 384, 173, 211) $BKaydet = GUICtrlCreateButton("Kaydet !", 16, 8, 129, 25) $BTemizle = GUICtrlCreateButton("Temizle", 160, 8, 129, 25) $Tab1 = GUICtrlCreateTab(8, 48, 1097, 329) $TabSheet1 = GUICtrlCreateTabItem("Kod1") $Kod1 = GUICtrlCreateEdit("", 8, 66, 1081, 321) GUICtrlSetData(-1, "") $TabSheet2 = GUICtrlCreateTabItem("Kod2") $Kod2 = GUICtrlCreateEdit("", 8, 66, 1081, 321) GUICtrlSetData(-1, "") $TabSheet3 = GUICtrlCreateTabItem("Kod3") $Kod3 = GUICtrlCreateEdit("", 8, 66, 1081, 321) GUICtrlSetData(-1, "") $TabSheet4 = GUICtrlCreateTabItem("Kod4") $Kod4 = GUICtrlCreateEdit("", 8, 66, 1081, 321) GUICtrlSetData(-1, "") $TabSheet5 = GUICtrlCreateTabItem("Kod5") $Kod5 = GUICtrlCreateEdit("", 8, 66, 1081, 321) GUICtrlSetData(-1, "") GUICtrlCreateTabItem("") $BBorder = GUICtrlCreateButton("Border Ekle", 336, 8, 129, 25) $BKaldir = GUICtrlCreateButton("<br/> Kaldır", 472, 8, 129, 25) GUISetState(@SW_SHOW) $h1 = GUICtrlGetHandle($Kod1) $h2 = GUICtrlGetHandle($Kod2) $h3 = GUICtrlGetHandle($Kod3) $h4 = GUICtrlGetHandle($Kod4) $h5 = GUICtrlGetHandle($Kod5) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BBorder _TAG(' ', 'style="border: 3px solid #000000;"',$Kod1) Case $BKaldir $oku = _GUICtrlEdit_GetText($Kod1) If StringInStr($oku, "<br/>") Then $oku = StringReplace($oku, "<br/>", "") _GUICtrlEdit_SetText($Kod1,$oku) Else MsgBox(0, "Hata", "<br/> kodu bulunamadı!") EndIf Case $BKaydet If Not FileExists(@ScriptDir & "\Konular\") Then DirCreate (@ScriptDir & "\Konular\") If FileExists(@ScriptDir & "\Konular\Konu.html") Then MsgBox(16, "Hata!", "Bu konu daha önce oluşturulmuş!") Else yaz() EndIf Else If FileExists(@ScriptDir & "\Konular\Konu.html") Then MsgBox(16, "Hata!", "Bu konu daha önce oluşturulmuş!") Else yaz() EndIf EndIf EndSwitch WEnd Func _TAG($sOpenTag,$sCloseTag,$hEdit) $sSelPos = _GUICtrlEdit_GetSel($hEdit) $sSelString = StringMid(_GUICtrlEdit_GetText($hEdit), $sSelPos[0] + 1, $sSelPos[1] - $sSelPos[0]) _GUICtrlEdit_ReplaceSel($Kod1, $sOpenTag & $sSelString & $sCloseTag) EndFunc;_TAG Func _selectall() Local $hWnd = _WinAPI_GetFocus() Switch $hWnd Case 0 Case $h1, $h2, $h3, $h4, $h5 _GUICtrlEdit_SetSel($hWnd, 0, -1) Return EndSwitch HotKeySet("^a") Send("^a") HotKeySet("^a", "_selectall") EndFunc ;==>_selectall Func yaz() FileWriteLine(@ScriptDir & "\Konular\Konu.html", '<!DOCTYPE html>') FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod1' & GUICtrlRead($Kod1)) FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod1Bitiş') FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod2' & GUICtrlRead($Kod2)) FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod2Bitiş') FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod3' & GUICtrlRead($Kod3)) FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod3Bitiş') FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod4' & GUICtrlRead($Kod4)) FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod4Bitiş') FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod5' & GUICtrlRead($Kod5)) FileWriteLine(@ScriptDir & "\Konular\Konu.html", 'Kod5Bitiş') EndFunc ;==>yaz [/spoiler] Edited July 4, 2015 by GameOveR-xD Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.