arcker Posted February 6, 2007 Share Posted February 6, 2007 (edited) New => Version 3Included internal callbacksfixed some issues_____here is the first script that i made with the rich edit control v4.1features (for now) :set Boldset Italicset Underlineset colorset background colorset fontnamein the future :Auto Syntax Highlighting (in progress, just to know how the EM_EXTEXTRANGE function works)Police set requirements : AutoIt3Lib from PaulIA & A3LRichEdit ( /!\ it's not the final version ) & Win Xp Sp1 at leastthe first purpose of this project is to show how richedit works, and to prove it's almost as easy as simple editNew version (2)- included setfontsize of grham- updated to last dllstruct and last Autoit3lib version- with the help of piccaso for his callback functions, i've managed to include save a load function.really cool isn't it ?Comments are welcomeAutoitPadexpandcollapse popup;AutoItPad ;using richedit control v5.1 ;new : Save & Load (thx Piccaso) ;new : 17/12/2007 Implemented Internal Callback. Can Load Huge files. ;By arcker $library = _WinAPI_LoadLibrary ("MSFTEDIT.DLL") ;load the library for the 4.1 version (it's good to know) ConsoleWrite($library & @CRLF) $RichEditClass = "RichEdit50W" ;Name of the 4.1 Rich Edit Control #include<Guiconstants.au3> #include<guiedit.au3> #include<GuiMenu.au3> #include<GuiToolBar.au3> #include<GuiComboBox.au3> #include"A3LRichEdit.au3" ;#include"Misc.au3" ;#include"FontUDF.au3" ;back colors constansts Global Const $RE_BK_RED = 0x00FF0000 Global Const $RE_BK_BLUE = 0x00FF0000 Global Const $RE_BK_GREEN = 0xFF000000 Global Const $RE_BK_WHITE = 0x00000000 ;some constants Dim $toggle = 0 ;Const $EM_GETLINECOUNT = 0xBA ;the gui ;_WinAPI_CloseHandle($library) $Form1 = GUICreate("Rich Edit", 800, 600, Default, Default, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX)) ;****************************************************************************************** ;create the menu ;****************************************************************************************** ; Create File menu Global $hGUI, $hFile, $hEdit, $hHelp, $hMain Global Enum $idNew = 1000, $idOpen, $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout $hFile = _GUICtrlMenu_CreateMenu () ; Create File menu $hFile = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_AddMenuItem ($hFile, "&New", $idNew) _GUICtrlMenu_AddMenuItem ($hFile, "&Open", $idOpen) _GUICtrlMenu_AddMenuItem ($hFile, "&Save", $idSave) _GUICtrlMenu_AddMenuItem ($hFile, "", 0) _GUICtrlMenu_AddMenuItem ($hFile, "E&xit", $idExit) ; Add a solid color bitmap $hBMP = _WinApi_CreateSolidBitmap ($hGUI, 0xFF0000, 16, 16) _GUICtrlMenu_SetItemBmp ($hFile, 2, $hBMP) ; Create Edit menu $hEdit = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_AddMenuItem ($hEdit, "&Cut", $idCut) _GUICtrlMenu_AddMenuItem ($hEdit, "C&opy", $idCopy) _GUICtrlMenu_AddMenuItem ($hEdit, "&Paste", $idPaste) ; Create Help menu $hHelp = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_AddMenuItem ($hHelp, "&About", $idAbout) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_AddMenuItem ($hMain, "&File", 0, $hFile) _GUICtrlMenu_AddMenuItem ($hMain, "&Edit", 0, $hEdit) _GUICtrlMenu_AddMenuItem ($hMain, "&Help", 0, $hHelp) ; Set the window menu _GUICtrlMenu_SetMenu ($Form1, $hMain) ;****************************************************************************************** ;create the toolbar ;****************************************************************************************** Global $hToolbar, $aStrings[4] $hToolbar = _GuiCtrlToolBar_Create ($Form1) $aStrings[0] = _GuiCtrlToolBar_AddString ($hToolbar, "Bold") $aStrings[1] = _GuiCtrlToolBar_AddString ($hToolbar, "Italic") $aStrings[2] = _GuiCtrlToolBar_AddString ($hToolbar, "Underline") $aStrings[3] = _GuiCtrlToolBar_AddString ($hToolbar, "Police") _GuiCtrlToolBar_AddButton ($hToolbar, 2001, 0, $aStrings[0]) _GuiCtrlToolBar_AddButton ($hToolbar, 2002, 1, $aStrings[1]) _GuiCtrlToolBar_AddButton ($hToolbar, 2003, 2, $aStrings[2]) _GuiCtrlToolBar_AddButtonSep ($hToolbar) _GuiCtrlToolBar_AddButton ($hToolbar, 2004, -2, $aStrings[3]) $policelist = _WinAPI_CreateWindowEx (0, "ComboBox", "", BitOR($CBS_DROPDOWN, $WS_VISIBLE, $WS_TABSTOP, $WS_VSCROLL, $WS_CHILD), 250, 15, 300, 20, $hToolbar) $fontlistgne = _WinAPI_CreateWindowEx (0, "ComboBox", "", BitOR($CBS_DROPDOWN, $WS_VISIBLE, $WS_TABSTOP, $WS_VSCROLL, $WS_CHILD), 570, 15, 50, 20, $hToolbar) ;****************************************************************************************** ;Create the RichEdit Control ;****************************************************************************************** $richedit = _WinAPI_CreateWindowEx ($WS_EX_CLIENTEDGE, $RichEditClass, "", BitOR($WS_CHILD, $ES_WANTRETURN, $ES_NOHIDESEL, $WS_HSCROLL, $WS_VSCROLL, $WS_VISIBLE, $ES_MULTILINE), 0, 50, 700, 500, $Form1) ConsoleWrite($richedit & @CRLF) $addbutton = GUICtrlCreateButton("Add Text", 720, 50, 60) $gettext = GUICtrlCreateButton("Get Sel Text", 710, 80, 80) $getlinecount = GUICtrlCreateButton("Get Line Count", 710, 110, 80) $getscrollpos = GUICtrlCreateButton("Get Scroll Pos", 710, 140, 80) $limittext = GUICtrlCreateButton("Limit text", 710, 170, 80) $setpassword = GUICtrlCreateButton("Set password", 710, 200, 80) $setreadonly = GUICtrlCreateButton("Set Read Only", 710, 230, 80) $randomselect = GUICtrlCreateButton("Random Select", 710, 260, 80) $increasefontsize = GUICtrlCreateButton("Inc Font Size", 710, 290, 80) $decreasefontsize = GUICtrlCreateButton("Dec Font Size", 710, 320, 80) $getcharformat = GUICtrlCreateButton("Get Format", 710, 350, 80) $findbutton = GUICtrlCreateButton("Find", 720, 380, 60) $setrandomcolor = GUICtrlCreateButton("Set Format", 710, 410, 80) $demo = GUICtrlCreateButton("Launch Demo", 710, 440, 80) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_SIZE, "WM_SIZE") ;sleep(1000) ;set font list Global $iGUIH = _WinAPI_GetClientHeight ($Form1) Global $iGUIW = _WinAPI_GetClientWidth ($Form1) $fontlist = _FontGetList() For $i = 1 To $fontlist[0] DllCall("user32.dll", "int", "SendMessage", "hwnd", $policelist, "int", $CB_ADDSTRING, "int", 0, "str", $fontlist[$i]) Next For $i = 8 To 72 Step 2 ConsoleWrite ($i & @CRLF) DllCall("user32.dll", "int", "SendMessage", "hwnd", $fontlistgne, "int", $CB_ADDSTRING, "int", 0, "str", $i) Next GUISetState(@SW_SHOW) ;_ChooseFont() _SendMessage ($richedit, $EM_AUTOURLDETECT, True, 0) For $i = 0 To 1 _addtext() Next _richedit_seteventmask ($richedit, BitOR($ENM_SCROLL, $ENM_CHANGE)) ; ;#include "DllCallBack.au3" Global Const $EM_STREAMOUT = $WM_USER + 74 Global Const $EM_STREAMIN = $WM_USER + 73 Global Const $SF_TEXT = 1 Global Const $SF_RTF = 2 Global Const $SF_UNICODE = 0x10 Global Const $SF_UTEXT = 0x11 Global Const $SF_PWI = 0x10802 $dwThread = DllCall("kernel32.dll", "dword", "GetCurrentThreadId") $dwThread = $dwThread[0] Global $handle_file, $pStub_em_stream_out,$pStub_em_stream_in,$SaveToFile,$LoadFromFile,$ByteRead,$ByteWritten,$tEditStreamCallback Func _save() $SaveToFile = FileSaveDialog("Save to", @ScriptDir, "All (*.*)") ;$SaveToFile = "test2.rtf" While 1 $pStub_em_stream_out = DllCallbackRegister ("_EditStreamCallbackStreamOut","dword", "ptr;ptr;long;ptr") If @error Then msgbox(0,"1",@error) $tEditStreamCallback = DllStructCreate("dword dwCookie;dword dwError;ptr pfnCallback") If @error Then msgbox(0,"2",@error) $handle_file = _WinAPI_CreateFile ($SaveToFile, 4,4,4) If @error Then msgbox(0,"3",@error) $tfile = DllStructCreate("hwnd file") DllStructSetData($tfile, "file", $handle_file) $hFile = DllStructGetPtr($tfile) ConsoleWrite("$handle = " & $handle_file & @CRLF) DllStructSetData($tEditStreamCallback, "dwCookie", $hFile) DllStructSetData($tEditStreamCallback, "pfnCallback", DllCallbackGetPtr($pStub_em_stream_out)) _SendMessage ($richedit, $EM_STREAMOUT, $SF_RTF, DllStructGetPtr($tEditStreamCallback)) _WinAPI_CloseHandle ($handle_file) ;MsgBox(0,"","File successfully saved to " & $SaveToFile ) ExitLoop WEnd DllCallBackFree ($pStub_em_stream_out) EndFunc ;==>_save Func _load() $LoadFromFile = FileOpenDialog("Load From ", @ScriptDir, "All (*.*)") While 1 $tEditStreamCallback = DllStructCreate("dword dwCookie;dword dwError;ptr pfnCallback") If @error Then msgbox(0,"1",@error) $pStub_em_stream_in = DllCallbackRegister ("_EditStreamCallbackStreamIn", "dword","ptr;ptr;long;ptr") If @error Then msgbox(0,"2",@error) $handle_file = _WinAPI_CreateFile ($LoadFromFile, 2, 2, 2) If @error Then msgbox(0,"3",@error) $tfile = DllStructCreate("hwnd file") DllStructSetData($tfile, "file", $handle_file) $hFile = DllStructGetPtr($tfile) ConsoleWrite("$handle = " & $handle_file & @CRLF) DllStructSetData($tEditStreamCallback, "dwCookie", $hFile) DllStructSetData($tEditStreamCallback, "dwError", False) DllStructSetData($tEditStreamCallback, "pfnCallback", DllCallbackGetPtr($pStub_em_stream_in)) _SendMessage ($richedit, $EM_STREAMIN, $SF_RTF, DllStructGetPtr($tEditStreamCallback), "dword", "ptr") _WinAPI_CloseHandle ($handle_file) ;MsgBox(0,"","File successfully load from " & $SaveToFile ) ExitLoop WEnd DllCallBackFree ($pStub_em_stream_in) EndFunc ;==>_save ;DllStructSetData($tEditStreamCallback,"dwError","???") ;DllCall("kernel32","none","DebugBreak") Func _EditStreamCallbackStreamOut($dwCookie, $pbBuff, $cb, $pcb) _WinAPI_WriteFile ($dwCookie, $pbBuff, $cb, $ByteWritten) $aResult = DllCall("Kernel32.dll", "int", "WriteFile", "hwnd", $handle_file, "ptr", $pbBuff, "uint", $cb, "ptr", $pcb, "ptr", 0) Return $aResult[0] = 0 EndFunc ;==>_EditStreamCallbackStreamOut Func _EditStreamCallbackStreamIn($dwCookie, $pbBuff, $cb, $pcb) $aResult = DllCall("Kernel32.dll", "int", "ReadFile", "hwnd", $handle_file, "ptr", $pbBuff, "int", $cb, "ptr", $pcb, "ptr", 0) Return $aResult[0] = 0 EndFunc ;==>_EditStreamCallbackStreamOut ;_richedit_seteventmask($richedit,$ENM_SCROLL) While 1 $iGUIH = _WinAPI_GetClientHeight ($Form1) $iGUIW = _WinAPI_GetClientWidth ($Form1) $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $findbutton _findtext() Case $addbutton _addtext() Case $gettext _getseltext() Case $getlinecount _getlinecount() Case $getscrollpos _getscrollpos() Case $limittext _limittext() Case $setpassword _setpasswordchar() Case $setreadonly _setreadonly() Case $randomselect _randomselect() Case $increasefontsize _increasefontsize() Case $decreasefontsize _decreasefontsize() Case $getcharformat _chargetformat() Case $setrandomcolor _setrandomcolor() Case $demo _demo() EndSwitch Sleep(10) WEnd Func _exit() Exit EndFunc ;==>_exit Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) ;ConsoleWrite("hWnd " & $hWnd & @CRLF & "$iMsg " & $iMsg & @CRLF & "$iwParam " & $iwParam & @CRLF & "$ilParam " & $ilParam & @CRLF) Switch _WinApi_LoWord ($iwParam) Case $idNew _ConsoleWrite ("New") Case $idOpen _ConsoleWrite ("Open") _load() Case $idSave _ConsoleWrite ("Save") _save() Case $idExit Exit Case $idCut _ConsoleWrite ("Cut") Case $idCopy _ConsoleWrite ("Copy") Case $idPaste _ConsoleWrite ("Paste") Case $idAbout _ConsoleWrite ("About") Case 2001 _ConsoleWrite ("Bold") _setbold() Case 2002 _ConsoleWrite ("Italic") _setitalic() Case 2003 _ConsoleWrite ("Underline") _setunderline() Case 2004 _ConsoleWrite ("Police") EndSwitch Switch $ilParam Case $policelist _ConsoleWrite ("Combo Box") Switch _WinApi_HiWord ($iwParam) Case $CBN_CLOSEUP _ConsoleWrite ("CBN_CLOSEUP") Case $CBN_DROPDOWN _ConsoleWrite ("CBN_DROPDOWN") Case $CBN_SELCHANGE _ConsoleWrite ("CBN_SELCHANGE") _setpolice() EndSwitch Case $fontlistgne _ConsoleWrite ("Combo Box") Switch _WinApi_HiWord ($iwParam) Case $CBN_CLOSEUP _ConsoleWrite ("CBN_CLOSEUP") Case $CBN_DROPDOWN _ConsoleWrite ("CBN_DROPDOWN") Case $CBN_SELCHANGE _ConsoleWrite ("CBN_SELCHANGE") _setfontsize() EndSwitch Case $richedit _ConsoleWrite ("Rich Edit") Switch _WinApi_HiWord ($iwParam) Case $EN_HSCROLL _ConsoleWrite ("HSCROLL") Case $EN_VSCROLL _ConsoleWrite ("VSCROLL") Case $EN_CHANGE _ConsoleWrite ("EN_CHANGE") _autosyntax() EndSwitch EndSwitch ;If $hWnd = $library Then;RichEdit Events Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _addtext() _RichEdit_AddLine ($richedit, "essai") EndFunc ;==>_addtext func _ConsoleWrite($Data) ConsoleWrite($Data & @crlf) EndFunc Func _findtext() $find = InputBox("Find", "") $findtext = __tagFINDTEXT () $CHARRANGE = __tagCHARRANGE () DllStructSetData($CHARRANGE, "cpMin", "") DllStructSetData($CHARRANGE, "cpMax", "") $tfind = DllStructCreate("char[4096]") $pfind = DllStructGetPtr($tfind) DllStructSetData($tfind, 1, $find) DllStructSetData($findtext, "lpstrText", $pfind) DllStructSetData($findtext, "CHARRANGE", DllStructGetPtr($CHARRANGE)) ConsoleWrite(_SendMessage ($richedit, $EM_FINDTEXT, True, 0)) EndFunc ;==>_findtext Func _getseltext() Local $icount $tData = DllStructCreate("char Text[4096]") $pText = DllStructGetPtr($tData) $return = _SendMessage ($richedit, $EM_GETSELTEXT, 0, $pText) $iText = DllStructGetData($tData, "Text") $iText = _WinAPI_WideCharToMultiByte($iText) MsgBox(0, $return & " Characters copied", $iText, 3) EndFunc ;==>_getseltext Func _getlinecount() MsgBox(0, "Number of lines", _RichEdit_GetLineCount ($richedit), 3) EndFunc ;==>_getlinecount Func _limittext() $number = InputBox("Limit text to N characters", "Enter the limit " & _ "and try to insert more characters" & @CRLF & "Be careful of the empty lines (cost one character)") If Not @error Then _RichEdit_LimitText ($richedit, $number) EndFunc ;==>_limittext Func _setpasswordchar() $tData = DllStructCreate("ushort") DllStructSetData($tData, 1, "X") $pText = DllStructGetPtr($tData, 1) ConsoleWrite("set password X" & $pText & $tData & @CRLF) _SendMessage ($richedit, $EM_SETPASSWORDCHAR, $pText, 0) EndFunc ;==>_setpasswordchar Func _getscrollpos() $tPoint = DllStructCreate($tagPOINT) $pPoint = DllStructGetPtr($tPoint) $return = _SendMessage ($richedit, $EM_GETSCROLLPOS, 0, $pPoint) MsgBox(0, "Get scroll pos", "x : " & DllStructGetData($tPoint, "X") & @CRLF & "y : " & DllStructGetData($tPoint, "Y"), 3) EndFunc ;==>_getscrollpos Func _setreadonly() If $toggle = 0 Then $return = _RichEdit_SetReadOnly ($richedit, True) $toggle = 1 GUICtrlSetData($setreadonly, "Read Only ON") Else $return = _RichEdit_SetReadOnly ($richedit, False) GUICtrlSetData($setreadonly, "Read Only OFF") $toggle = 0 EndIf EndFunc ;==>_setreadonly Func _randomselect() $textlengh = _SendMessage ($richedit, $WM_GETTEXTLENGTH, 0, 0) $min = Random(0, $textlengh, 1) $max = Random($min, $textlengh, 1) _RichEdit_SetSel ($richedit, $min, $max) EndFunc ;==>_randomselect Func _increasefontsize() _RichEdit_IncreaseFontSize ($richedit, True, 1) EndFunc ;==>_increasefontsize Func _decreasefontsize() _RichEdit_DecreaseFontSize ($richedit, True, -1) EndFunc ;==>_decreasefontsize Func _chargetformat() Local $tcharformat = "", $pCHARFORMAT = "" $tcharformat = _tagCHARFORMAT2 () DllStructSetData($tcharformat, "cbSize", DllStructGetSize($tcharformat)) $pCHARFORMAT = DllStructGetPtr($tcharformat) _SendMessage ($richedit, $EM_GETCHARFORMAT, $SCF_SELECTION, $pCHARFORMAT) MsgBox(0, "Information", "$cbSize => " & DllStructGetData($tcharformat, "cbSize") & @CRLF & _ "$dwMask => " & DllStructGetData($tcharformat, "dwMask") & @CRLF & _ "$dwEffects => " & DllStructGetData($tcharformat, "dwEffects") & @CRLF & _ "$yHeight => " & DllStructGetData($tcharformat, "yHeight") & @CRLF & _ "$yOffset => " & DllStructGetData($tcharformat, "yOffset") & @CRLF & _ "$crTextColor => " & DllStructGetData($tcharformat, "crTextColor") & @CRLF & _ "$bCharSet => " & DllStructGetData($tcharformat, "bCharSet") & @CRLF & _ "$bPitchAndFamily => " & DllStructGetData($tcharformat, "bPitchAndFamily") & @CRLF & _ "$szFaceName => " & DllStructGetData($tcharformat, "szFaceName") & @CRLF & _ "$wWeight => " & DllStructGetData($tcharformat, "wWeight") & @CRLF & _ "$sSpacing => " & DllStructGetData($tcharformat, "sSpacing") & @CRLF & _ "$crBackColor => " & Hex(DllStructGetData($tcharformat, "crBackColor")) & @CRLF & _ "$lcid => " & DllStructGetData($tcharformat, "lcid") & @CRLF & _ "$dwReserved => " & DllStructGetData($tcharformat, "dwReserved") & @CRLF & _ "$sStyle => " & DllStructGetData($tcharformat, "sStyle") & @CRLF & _ "$wKerning => " & DllStructGetData($tcharformat, "wKerning") & @CRLF & _ "$bUnderlineType => " & DllStructGetData($tcharformat, "bUnderlineType") & @CRLF & _ "$bAnimation => " & DllStructGetData($tcharformat, "bAnimation") & @CRLF & _ "$bRevAuthor => " & DllStructGetData($tcharformat, "bRevAuthor") & @CRLF & _ "$bReserved1 => " & DllStructGetData($tcharformat, "bReserved1")) MsgBox(0, "", "Bold => " & BitAND(DllStructGetData($tcharformat, "dwEffects"), $CFE_BOLD) & @CRLF & _ "Italic => " & BitAND(DllStructGetData($tcharformat, "dwEffects"), $CFE_ITALIC) & @CRLF & _ "Underline => " & BitAND(DllStructGetData($tcharformat, "dwEffects"), $CFE_Underline)) EndFunc ;==>_chargetformat Func _setrandomcolor() For $i = 0 To 10 _richedit_setcolor ($richedit, Random(0x00AA00, 0x00FF00), 4) _richedit_setbkcolor ($richedit, Random(0x00AA00, 0x00FF00), 4) _richedit_setFontName ($richedit, "Lucida Console", 4) _RichEdit_SetBold ($richedit, Random(0, 1, 1), 4) _RichEdit_SetItalic ($richedit, Random(0, 1, 1), 4) _RichEdit_SetUnderline ($richedit, Random(0, 1, 1), 4) Sleep(100) Next $colorvalue = $CLR_BLUE ;while 1 _richedit_setbkcolor ($richedit, $colorvalue, 4) ; $colorvalue+=0x11000000 ; ToolTip($colorvalue) ; sleep(700) ;WEnd EndFunc ;==>_setrandomcolor Func _setbold() Local $tcharformat = "", $pCHARFORMAT = "" $tcharformat = _tagCHARFORMAT2 () DllStructSetData($tcharformat, "cbSize", DllStructGetSize($tcharformat)) $pCHARFORMAT = DllStructGetPtr($tcharformat) _SendMessage ($richedit, $EM_GETCHARFORMAT, $SCF_SELECTION, $pCHARFORMAT) If BitAND(DllStructGetData($tcharformat, "dwEffects"), $CFE_BOLD) Then _RichEdit_SetBold ($richedit, False) Else _RichEdit_SetBold ($richedit, True) EndIf EndFunc ;==>_setbold Func _setitalic() Local $tcharformat = "", $pCHARFORMAT = "" $tcharformat = _tagCHARFORMAT2 () DllStructSetData($tcharformat, "cbSize", DllStructGetSize($tcharformat)) $pCHARFORMAT = DllStructGetPtr($tcharformat) _SendMessage ($richedit, $EM_GETCHARFORMAT, $SCF_SELECTION, $pCHARFORMAT) If BitAND(DllStructGetData($tcharformat, "dwEffects"), $CFE_ITALIC) Then _RichEdit_Setitalic ($richedit, False) Else _RichEdit_Setitalic ($richedit, True) EndIf EndFunc ;==>_setitalic Func _setunderline() Local $tcharformat = "", $pCHARFORMAT = "" $tcharformat = _tagCHARFORMAT2 () DllStructSetData($tcharformat, "cbSize", DllStructGetSize($tcharformat)) $pCHARFORMAT = DllStructGetPtr($tcharformat) _SendMessage ($richedit, $EM_GETCHARFORMAT, $SCF_SELECTION, $pCHARFORMAT) If BitAND(DllStructGetData($tcharformat, "dwEffects"), $CFE_Underline) Then _RichEdit_Setunderline ($richedit, False) Else _RichEdit_Setunderline ($richedit, True) EndIf EndFunc ;==>_setunderline Func _setpolice() Local $i_index, $s_text $cursel = _SendMessage ($policelist, $CB_GETCURSEL, 0, 0) Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $policelist, "int", $CB_GETLBTEXTLEN, "int", $cursel, "int", 0) $len = $a_ret[0] $s_text = "" Local $p, $ret $p = DllStructCreate("char[" & $len + 1 & "]") Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $policelist, "int", $CB_GETLBTEXT, "int", $cursel, "ptr", DllStructGetPtr($p)) If ($a_ret[0] == $CB_ERR) Then Return SetError($CB_ERR, $CB_ERR, $CB_ERR) $s_text = DllStructGetData($p, 1) ConsoleWrite("Font Name " & $s_text & @CRLF) _richedit_setFontName ($richedit, $s_text) EndFunc ;==>_setpolice Func _setfontsize() Local $i_index, $s_text $cursel = _SendMessage ($fontlistgne, $CB_GETCURSEL, 0, 0) Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $fontlistgne, "int", $CB_GETLBTEXTLEN, "int", $cursel, "int", 0) $len = $a_ret[0] $s_text = "" Local $p, $ret $p = DllStructCreate("char[" & $len + 1 & "]") Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $fontlistgne, "int", $CB_GETLBTEXT, "int", $cursel, "ptr", DllStructGetPtr($p)) If ($a_ret[0] == $CB_ERR) Then Return SetError($CB_ERR, $CB_ERR, $CB_ERR) $s_text = DllStructGetData($p, 1) ConsoleWrite("Font Name " & $s_text & @CRLF) _RichEdit_setfontsize ($richedit, $s_text) EndFunc ;==>_setfontsize Func _demo() _RichEdit_AddLine ($richedit, "This is the demo that shows how richedit controls works") Sleep(2000) _RichEdit_AddLine ($richedit, "It will only shows how charformat works and how to use the functions") Sleep(2000) _RichEdit_AddLine ($richedit, "Now we change the color for the next characters") _RichEdit_AddLine ($richedit, "Set Black Background & Green Text") Sleep(2000) _richedit_setcolor ($richedit, 0x00FF00) _richedit_setbkcolor ($richedit, 0x000000) _RichEdit_AddLine ($richedit, "And we write some text (useful for console applications)") _richedit_setcolor ($richedit, 0xCCCCCC) _richedit_setbkcolor ($richedit, 0xffffffff) Sleep(2000) _RichEdit_AddLine ($richedit, "Or maybe you prefer this one") _richedit_setcolor ($richedit, 0x00FF00) _richedit_setbkcolor ($richedit, 0x000000) Sleep(2000) _RichEdit_AddLine ($richedit, "Now we restore the full text to default color") _richedit_setcolor ($richedit, 0xFFFFFF, 1) _richedit_setbkcolor ($richedit, 0x000000, 1) _RichEdit_AddLine ($richedit, "oups") _richedit_setcolor ($richedit, 0xFFFFFF, 1) _richedit_setbkcolor ($richedit, 0, 1) _RichEdit_AddLine ($richedit, "New ! let's set the text font size") _RichEdit_setfontsize ($richedit, 14) _RichEdit_AddLine ($richedit, "Tadaaaa ....") _RichEdit_setfontsize ($richedit, 10) _RichEdit_AddLine ($richedit, "Now more complex, let's start select the last line and make it strike out") EndFunc ;==>_demo Func _test() ConsoleWrite("ok scroll") EndFunc ;==>_test ;=============================================================================== ; Function Name: _FontGetList() ; Description: Returns an array with a list of all fonts currently installed on the system. ; Parameter(s): $i_opt - An Integer, 0 or 1. 0 will create a 1D array with font names only. ; 1 will create a 2d array with font names in the first column, font file names in the second ; Requirement(s): None ; Return Value(s): 1D-2D Array = [0] or [0][0] Contains total number of fonts. ; Author(s): Simucal <simucal@gmail.com> ; Revision: 20060501A ; ;=============================================================================== Func _FontGetList($i_opt = 0) Dim $a_FontNames[1], $a_FontNamesFiles[1][1], $i = 1 If @OSTYPE = "WIN32_NT" Then $regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" If @OSTYPE = "WIN32_WINDOWS" Then $regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts" While 1 $s_temp = RegEnumVal($regkey, $i) If @error <> 0 Then ExitLoop $s_temp2 = RegRead($regkey, $s_temp) $s_temp = StringRegExpReplace($s_temp, "\s\(.*?\)(\s*)?", "") If $i_opt = 0 Then ReDim $a_FontNames[ ($i + 1) ] $a_FontNames[$i] = $s_temp ElseIf $i_opt = 1 Then ReDim $a_FontNames[ ($i + 1) ] $a_FontNames[$i] = $s_temp & "|" & $s_temp2 EndIf $i = $i + 1 WEnd If $i_opt = 0 Then _ArraySort($a_FontNames) $a_FontNames[0]= (UBound($a_FontNames) - 1) Return ($a_FontNames) ElseIf $i_opt = 1 Then _ArraySort($a_FontNames) ; Sort with font names and files as a single array For $i = 1 To (UBound($a_FontNames) - 1) ; then split it up into 2D, so they will be alphabatized together. $s_fontsplit = StringSplit($a_FontNames[$i], "|") If IsArray($s_fontsplit) = 1 Then ReDim $a_FontNamesFiles[ ($i + 1) ][2] $a_FontNamesFiles[$i][0] = $s_fontsplit[1] $a_FontNamesFiles[$i][1] = $s_fontsplit[2] EndIf Next $a_FontNamesFiles[0][0] = (UBound($a_FontNamesFiles) - 1) Return ($a_FontNamesFiles) EndIf EndFunc ;==>_FontGetList Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) Local $iNewH, $iNewW, $iDltH, $iDltW, $iConH, $iConW ; Get the new GUI size $iNewW = _WinApi_LoWord ($ilParam) $iNewH = _WinApi_HiWord ($ilParam) ; Get the delta change in the GUI size $iDltW = $iNewW - $iGUIW $iDltH = $iNewH - $iGUIH ; Resize the control $iConW = _WinAPI_GetWindowWidth ($richedit) + $iDltW $iConH = _WinAPI_GetWindowHeight ($richedit) + $iDltH _WinAPI_SetWindowPos ($richedit, 0, 0, 0, $iConW, $iConH, BitOR($SWP_NOMOVE, $SWP_NOZORDER)) ; Update GUI size variables $iGUIW = $iNewW $iGUIH = $iNewH ; Make sure we let AutoIt receive the message too Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func _autosyntax() Local $lStart = 0 Local $lEnd = 0 $tlStart = DllStructCreate("int") $tlEnd = DllStructCreate("int") $plstart = DllStructGetPtr($tlStart, 1) $plend = DllStructGetPtr($tlEnd, 1) $curcar = _SendMessage ($richedit, $EM_GETSEL, $plstart, $plend) $nCharPosition = DllStructGetData($tlStart, 1) ConsoleWrite("$nCharPosition " & $nCharPosition & @CRLF) Local $lCharFromLineStart, $lCharStart $lCharStart = _SendMessage ($richedit, $EM_LINEINDEX, -1, 0);// Retrieves the character index of the current line (the line that contains the caret) ConsoleWrite("$lCharStart " & $lCharStart & @CRLF) $lCharFromLineStart = $nCharPosition - $lCharStart; ConsoleWrite("$lCharFromLineStart " & $lCharFromLineStart & @CRLF) $nLineIndex = _SendMessage ($richedit, $EM_LINEFROMCHAR, $lCharStart, 0); ConsoleWrite("$nLineIndex " & $nLineIndex & @CRLF) $nFindWorkBreak = _SendMessage ($richedit, $EM_FINDWORDBREAK, $WB_RIGHT, $lCharFromLineStart); ConsoleWrite("$nFindWorkBreak " & $nFindWorkBreak & @CRLF) $tcharrange = __tagCHARRANGE () ;DllStructSetData($tcharrange,"cpMin",$nFindWorkBreak) ;DllStructSetData($tcharrange,"cpMax",$nCharPosition) ;$pcharrange= DllStructgetptr($tcharrange) $ttext = DllStructCreate("char[4096]") $pText = DllStructGetPtr($ttext) $ttextrange = __tagTEXTRANGE () $pTextRange = DllStructGetPtr($ttextrange) DllStructSetData($ttextrange, "Min", $nFindWorkBreak) DllStructSetData($ttextrange, "Max", $nCharPosition) DllStructSetData($ttextrange, "Text", $pText) $return = _SendMessage ($richedit, $EM_GETTEXTRANGE, 0, $pTextRange) $iText = _WinAPI_WideCharToMultiByte ($ttext) ConsoleWrite("$iText " & $iText & @CRLF) EndFunc ;==>_autosyntax Func _colorblue() EndFunc ;==>_colorblue Func _colorred() EndFunc ;==>_colorred Func _colorgreen() EndFunc ;==>_colorgreenA3LRichEditexpandcollapse popup#include-once #include <WinApi.au3> Opt("MustDeclareVars", 1) ; ==================================================================================================== ; Description ...: Rich Edit 4.1 management module ; Author ........: Yoan Roblet (Arcker) ; Notes .........: ; ==================================================================================================== ; ==================================================================================================== ; *** *** *** *** *** *** *** *** *** *** *** Constants *** *** *** *** *** *** *** *** *** *** *** ; ==================================================================================================== ; Please do not remove these constants from this file. If you need to use these constants, please copy ; them to your own UDF and RENAME THEM so that they do not collide with the Auto3Lib names. ; ==================================================================================================== ;events mask Global Const $ENM_CHANGE = 0x1 Global Const $ENM_SCROLL = 0x4 Global Const $ENM_MOUSEEVENTS = 0x20000 ;notification messages ;Global Const $EN_CHANGE = 0x300 ;Global Const $EN_HSCROLL = 0x601 ;Global Const $EN_VSCROLL = 0x602 Global Const $EM_AUTOURLDETECT = $WM_USER + 91 Global Const $EM_FINDTEXT = $WM_USER + 56 ;Global Const $EM_GETLINE = 0xC4 ;global Const $EM_GETLINECOUNT = 0xBA ;global Const $EM_GETSEL = 0xB0 Global Const $EM_GETSELTEXT = $WM_USER + 62 Global Const $EM_GETTEXTEX = $WM_USER + 94 Global Const $EM_GETTEXTLENGTHEX = $WM_USER + 95 Global Const $EM_GETTEXTMODE = $WM_USER + 90 Global Const $EM_GETTEXTRANGE = $WM_USER + 75 Global Const $EM_GETSCROLLPOS = $WM_USER + 221 ;Global Const $EM_LIMITTEXT = 0xC5 Global Const $EM_SETPASSWORDCHAR = 0xCC Global Const $EM_SETFONTSIZE = $WM_USER + 223 Global Const $EM_GETCHARFORMAT = 1082 Global Const $EM_SETCHARFORMAT = 1092 global Const $EM_FINDWORDBREAK = $WM_USER + 76 ;global const $EM_LINEINDEX = 0xBB ;global Const $EM_LINEFROMCHAR = 0xC9 ;Global Const $EM_UNDO = 0xC7 ;Const $EM_SETSEL = 0xB1 ;Const $EM_SETREADONLY = 0xCF Global Const $SCF_SELECTION = 0x01 Global Const $SCF_WORD = 0x0002 ;constants for the CHARFORMAT2 Global Const $CFM_BOLD = 0x00000001 Global Const $CFM_ITALIC = 0x00000002 Global Const $CFM_UNDERLINE = 0x00000004 Global Const $CFM_STRIKEOUT = 0x00000008 Global Const $CFM_PROTECTED = 0x00000010 Global Const $CFM_LINK = 0x00000020 ;/ * Exchange hyperlink extension * / Global Const $CFM_SIZE = 0x80000000 Global Const $CFM_COLOR = 0x40000000 Global Const $CFM_FACE = 0x20000000 Global Const $CFM_OFFSET = 0x10000000 Global Const $CFM_CHARSET = 0x08000000 Global Const $CFM_WEIGHT = 0x00400000 Global Const $CFM_BACKCOLOR = 0x04000000 ; CHARFORMAT effects */ Global Const $CFE_BOLD = 0x0001 Global Const $CFE_ITALIC = 0x0002 Global Const $CFE_UNDERLINE = 0x0004 Global Const $CFE_STRIKEOUT = 0x0008 Global Const $CFE_PROTECTED = 0x0010 Global Const $CFE_LINK = 0x0020 Global Const $CFE_AUTOCOLOR = 0x40000000 Global Const $EM_SETEVENTMASK = $WM_USER + 69 ; global Const $WB_CLASSIFY = 3 global Const $WB_ISDELIMITER = 2 global Const $WB_LEFT = 0 global Const $WB_LEFTBREAK = 6 global Const $WB_MOVEWORDLEFT = 4 global Const $WB_MOVEWORDNEXT = 5 global Const $WB_MOVEWORDPREV = 4 global Const $WB_MOVEWORDRIGHT = 5 global Const $WB_NEXTBREAK = 7 global Const $WB_PREVBREAK = 6 global Const $WB_RIGHT = 1 global Const $WB_RIGHTBREAK = 7 ; ==================================================================================================== ; Description ..: Append some text to the control ; Parameters ...: $hWnd - Handle to the control ; $iText - Text to append ; $hLine - insert the @crlf at the end (default = True) ; Return values : ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_AddLine($hWnd, $iText, $hLine = True, $i_bool = True) Local $hTextLengh $hTextLengh = _SendMessage ($hWnd, $WM_GETTEXTLENGTH, 0, 0); _SendMessage ($hWnd, $EM_SETSEL, $hTextLengh, $hTextLengh); If $hLine Then DllCall("user32.dll", "none", "SendMessage", "hwnd", $hWnd, "int", $EM_REPLACESEL, "int", $i_bool, "str", $iText & @CRLF) Else DllCall("user32.dll", "none", "SendMessage", "hwnd", $hWnd, "int", $EM_REPLACESEL, "int", $i_bool, "str", $iText) EndIf EndFunc ;==>_RichEdit_AddLine ; ==================================================================================================== ; Description ..: Decrease the font size ; Parameters ...: $hWnd - Handle to the control ; $iSelec - Selected Text (Default) or Entire text ; $hDelta - Value of incrementation ; Return values : Returns 1 if success, otherwise false ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_DecreaseFontSize($hWnd, $iSelec = True, $hDelta = -1) Return _SendMessage ($hWnd, $EM_SETFONTSIZE, $iSelec, $hDelta) EndFunc ;==>_RichEdit_DecreaseFontSize ; ==================================================================================================== ; Description ..: Get the Line Count for the Control ; Parameters ...: $hWnd - Handle to the control ; Return values : Returns 1 if success, otherwise false ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_GetLineCount($hWnd) Return _SendMessage ($hWnd, $EM_GETLINECOUNT, 0, 0) EndFunc ;==>_RichEdit_GetLineCount ; ==================================================================================================== ; Description ..: Increase the font size ; Parameters ...: $hWnd - Handle to the control ; $iSelec - Selected Text (Default) or Entire text ; $hDelta - Value of incrementation ; Return values : Returns line count if success ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_IncreaseFontSize($hWnd, $iSelec = True, $hDelta = 1) Return _SendMessage ($hWnd, $EM_SETFONTSIZE, $iSelec, $hDelta) EndFunc ;==>_RichEdit_IncreaseFontSize ; ==================================================================================================== ; Description ..: Limit the control to N chararacters ; Parameters ...: $hWnd - Handle to the control ; $hLimitTo - Number of characters ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: Set 0 to disable the limit ; ==================================================================================================== Func _RichEdit_LimitText($hWnd, $hLimitTo) Return _SendMessage ($hWnd, $EM_LIMITTEXT, $hLimitTo, 0) EndFunc ;==>_RichEdit_LimitText ; ==================================================================================================== ; Description ..: Select the Background text color ; Parameters ...: $hWnd - Handle to the control ; $hMin - Color value ; $hMax - Color entire text or selection (default) ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetBkColor($hWnd, $hColor, $iSelec = True) Local $tcharformat, $pCHARFORMAT $tcharformat = _tagCHARFORMAT2() dllstructsetdata ($tcharformat, "cbSize", dllstructgetsize ($tcharformat)) dllstructsetdata ($tcharformat, "dwMask", $CFM_BACKCOLOR) dllstructsetdata ($tcharformat, "crBackColor", $hColor) $pCHARFORMAT = dllstructgetptr ($tcharformat) Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT) EndFunc ;==>_RichEdit_SetBkColor ; ==================================================================================================== ; Description ..: Toggle the Bold effect ; Parameters ...: $hWnd - Handle to the control ; $hFontName - Name of the Font ; $iSelec - Modify entire text or selection (default) ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetBold($hWnd, $hBold = False, $iSelec = 0x01) Local $tcharformat, $pCHARFORMAT $tcharformat = _tagCHARFORMAT2() dllstructsetdata ($tcharformat, "cbSize", dllstructgetsize ($tcharformat)) dllstructsetdata ($tcharformat, "dwMask", $CFM_BOLD) If $hBold Then dllstructsetdata ($tcharformat, "dwEffects", $CFE_BOLD) Else dllstructsetdata ($tcharformat, "dwEffects", 0) EndIf $pCHARFORMAT = dllstructgetptr ($tcharformat) Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT) EndFunc ;==>_RichEdit_SetBold ; ==================================================================================================== ; Description ..: Select the text color ; Parameters ...: $hWnd - Handle to the control ; $hMin - Color value ; $hMax - Color entire text or selection (default) ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetColor($hWnd, $hColor, $iSelec = True) Local $tcharformat, $pCHARFORMAT $tcharformat = _tagCHARFORMAT2() dllstructsetdata ($tcharformat, "cbSize", dllstructgetsize ($tcharformat)) dllstructsetdata ($tcharformat, "dwMask", $CFM_COLOR) dllstructsetdata ($tcharformat, "crTextColor", $hColor) $pCHARFORMAT = dllstructgetptr ($tcharformat) Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT) EndFunc ;==>_RichEdit_SetColor ; ==================================================================================================== ; Description ..: Set the text font size ; Parameters ...: $hWnd - Handle to the control ; $hMin - Color value ; $hMax - Color entire text or selection (default) ; Return values : True on success, otherwise False ; Author .......: grham, edited by Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetFontSize($hWnd, $Size , $iSelec = True) Local $tcharformat, $pCHARFORMAT $tcharformat = _tagCHARFORMAT2() dllstructsetdata ($tcharformat, "cbSize", DllStructGetSize ($tcharformat)) dllstructsetdata ($tcharformat, "dwMask", $CFM_SIZE) dllstructsetdata ($tcharformat, "yHeight", $Size*20) $pCHARFORMAT = DllStructGetPtr($tcharformat) Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT) EndFunc ; ==================================================================================================== ; Description ..: Set the text striked out ; Parameters ...: $hWnd - Handle to the control ; $hMin - Color value ; $hMax - Color entire text or selection (default) ; Return values : True on success, otherwise False ; Author .......: grham, edited by Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetStrikeOut($hWnd, $hBold = False, $iSelec = 0x01) Local $tcharformat, $pCHARFORMAT $tcharformat = _tagCHARFORMAT2() DllStructSetData ($tcharformat, "cbSize", DllStructGetSize($tcharformat)) DllStructSetData($tcharformat, "dwMask", $CFM_STRIKEOUT) If $hBold Then DllStructSetData ($tcharformat, "dwEffects", $CFE_STRIKEOUT) Else DllStructSetData ($tcharformat, "dwEffects", 0) EndIf $pCHARFORMAT = DllStructGetPtr($tcharformat) Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT) EndFunc ; ==================================================================================================== ; Description ..: The EM_SETEVENTMASK message sets the event mask for a rich edit control. ; The event mask specifies which notification messages the control sends to its parent window ; Parameters ...: $hWnd - Handle to the control ; ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetEventMask($hWnd, $hFunction) Return _SendMessage ($hWnd, $EM_SETEVENTMASK, 0, $hFunction) EndFunc ;==>_RichEdit_SetEventMask ; ==================================================================================================== ; Description ..: Select the Font Name ; Parameters ...: $hWnd - Handle to the control ; $hColor - Name of the Font ; $hSelec - Modify entire text or selection (default) ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetFontName($hWnd, $hFontName, $iSelec = True) Local $tcharformat, $pCHARFORMAT $tcharformat = _tagCHARFORMAT2() dllstructsetdata ($tcharformat, "cbSize", dllstructgetsize ($tcharformat)) dllstructsetdata ($tcharformat, "dwMask", $CFM_FACE) dllstructsetdata ($tcharformat, "szFaceName", $hFontName) $pCHARFORMAT = dllstructgetptr ($tcharformat) Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT) EndFunc ;==>_RichEdit_SetFontName ; ==================================================================================================== ; Description ..: Toggle the Italic effect ; Parameters ...: $hWnd - Handle to the control ; $hFontName - Name of the Font ; $iSelec - Modify entire text or selection (default) ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetItalic($hWnd, $hBold = False, $iSelec = 0x01) Local $tcharformat, $pCHARFORMAT $tcharformat = _tagCHARFORMAT2() dllstructsetdata ($tcharformat, "cbSize", dllstructgetsize ($tcharformat)) dllstructsetdata ($tcharformat, "dwMask", $CFM_ITALIC) If $hBold Then dllstructsetdata ($tcharformat, "dwEffects", $CFE_ITALIC) Else dllstructsetdata ($tcharformat, "dwEffects", 0) EndIf $pCHARFORMAT = dllstructgetptr ($tcharformat) Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT) EndFunc ;==>_RichEdit_SetItalic ; ==================================================================================================== ; Description ..: Set the control in ReadOnly Mode ; Parameters ...: $hWnd - Handle to the control ; $hBool - True = Enabled, False = Disabled ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetReadOnly($hWnd, $hBool = True) Return _SendMessage ($hWnd, $EM_SETREADONLY, $hBool, 0) EndFunc ;==>_RichEdit_SetReadOnly ; ==================================================================================================== ; Description ..: Select some text ; Parameters ...: $hWnd - Handle to the control ; $hMin - Character Number start ; $hMax - Character Number stop ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetSel($hWnd, $hMin, $hMax) Return _SendMessage ($hWnd, $EM_SETSEL, $hMin, $hMax) EndFunc ;==>_RichEdit_SetSel ; ==================================================================================================== ; Description ..: Toggle the Underline effect ; Parameters ...: $hWnd - Handle to the control ; $hFontName - Name of the Font ; $iSelec - Modify entire text or selection (default) ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_SetUnderline($hWnd, $hBold = False, $iSelec = 0x01) Local $tcharformat, $pCHARFORMAT $tcharformat = _tagCHARFORMAT2() dllstructsetdata ($tcharformat, "cbSize", dllstructgetsize ($tcharformat)) dllstructsetdata ($tcharformat, "dwMask", $CFM_UNDERLINE) If $hBold Then dllstructsetdata ($tcharformat, "dwEffects", $CFE_UNDERLINE) Else dllstructsetdata ($tcharformat, "dwEffects", 0) EndIf $pCHARFORMAT = dllstructgetptr ($tcharformat) Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT) EndFunc ;==>_RichEdit_SetUnderline ; ==================================================================================================== ; Description ..: Undo ; Parameters ...: $hWnd - Handle to the control ; $hMin - Character Number start ; $hMax - Character Number stop ; Return values : True on success, otherwise False ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_Undo($hWnd) Return _SendMessage ($hWnd, $EM_UNDO, 0, 0) EndFunc ;==>_RichEdit_Undo ; ==================================================================================================== ; *** *** *** *** *** *** *** *** *** *** *** Structures *** *** *** *** *** *** *** *** *** *** *** ; ==================================================================================================== ; ==================================================================================================== ; Description ..: (specifies a range of characters in a rich edit control) ; Parameters ...: $pPointer - If supplied, the structure will be mapped over this pointer ; Return values : Array formatted as follows: ; $aTag[0] - Tag prefix identifier ; $aTag[1] - Tag structure ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func __tagCHARRANGE() Return DllStructCreate("long cpMin;long cpMax ") EndFunc ;==>__tagCHARRANGE ; ==================================================================================================== ; Description ..: (contains information about a search operation in a rich edit control) ; Parameters ...: $pPointer - If supplied, the structure will be mapped over this pointer ; Return values : Array formatted as follows: ; $aTag[0] - Tag prefix identifier ; $aTag[1] - Tag structure ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func __tagFINDTEXT() Return DllStructCreate("ptr CHARRANGE;str lpstrText") EndFunc ;==>__tagFINDTEXT ; ==================================================================================================== ; Description ..: (contains information about character formatting in a rich edit control) ; Parameters ...: $pPointer - If supplied, the structure will be mapped over this pointer ; Return values : Array formatted as follows: ; $aTag[0] - Tag prefix identifier ; $aTag[1] - Tag structure ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _tagCHARFORMAT2($pPointer = 0) ;Global Const $tagCHARFORMAT2 = "uint;int;dword;long;long;dword;byte;byte;char[32];short;short;long;long;long;short;short;byte;byte;byte;byte" Return DllStructCreate ("uint cbSize;int dwMask;dword dwEffects;long yHeight;long yOffset;uint crTextColor;" _ & "byte bCharSet;byte bPitchAndFamily;char szFaceName[32];ushort wWeight;short sSpacing;uint crBackColor;uint lcid;dword dwReserved;short sStyle;ushort wKerning" _ & ";byte bUnderlineType;byte bAnimation;byte bRevAuthor;byte bReserved1") EndFunc ;==>_tagCHARFORMAT2 ; ==================================================================================================== ; Description ..: (Size, Flags, hCursor, X, Y) ; Parameters ...: $pPointer - If supplied, the structure will be mapped over this pointer ; Return values : Array formatted as follows: ; $aTag[0] - Tag prefix identifier ; $aTag[1] - Tag structure ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _tagLOGFONT($pPointer = 0) Return DllStructCreate ($tagLOGFONT) ;Local $aTag[2] = ["tagLOGFONT_", __tagStruct ($sStruct, $pPointer) ] ;Return __tagBuild ($aTag, "lfHeight, lfWidth, lfEscapement, lfOrientation, lfWeight, lfItalic, " & _ ; "lfUnderline, lfStrikeOut, lfCharset, lfOutPrecision, lfClipPrecision, lfQuality, lfPitchAndFamily, lfFaceName") EndFunc ;==>_tagLOGFONT ; ==================================================================================================== ; Description ..: (Size, Flags, hCursor, X, Y) ; Parameters ...: $pPointer - If supplied, the structure will be mapped over this pointer ; Return values : Array formatted as follows: ; $aTag[0] - Tag prefix identifier ; $aTag[1] - Tag structure ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func __tagTEXTRANGE($pPointer = 0) Return DllStructCreate ("long Min;long Max;ptr Text") ;Local $aTag[2] = ["tagTEXTRANGE_", __tagStruct ($sStruct, $pPointer) ] ;Return __tagBuild ($aTag, "Min, Max, Text") EndFunc Opt("MustDeclareVars", 0) Edited December 17, 2007 by arcker -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
A. Percy Posted February 6, 2007 Share Posted February 6, 2007 A sugestion: put it in a zip file Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator VW Bug user Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral Link to comment Share on other sites More sharing options...
lod3n Posted February 7, 2007 Share Posted February 7, 2007 I can't find A3LRichEdit.au3 anywhere, and I've looked. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Achilles Posted February 7, 2007 Share Posted February 7, 2007 (edited) I can't find A3LRichEdit.au3 anywhere, and I've looked.Copy the second part of his code and name it "A3RichEdit.au3"EDIT: Yay, 200 posts Edited February 7, 2007 by Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Somerset Posted February 7, 2007 Share Posted February 7, 2007 A sugestion: put it in a zip filejust putting it into a zip only is frowned at.... arcker did the right thing... so if you don't know how to copy and paste you really shouldn't be here A. Percy. lod3n arcker posted that as well.... Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted February 7, 2007 Share Posted February 7, 2007 just putting it into a zip only is frowned at.... arcker did the right thing... so if you don't know how to copy and paste you really shouldn't be here A. Percy. lod3n arcker posted that as well....if you use the 'save selected text' firefox extenion it makes life easier.. but i prefer zipped files, just as long as they exists.. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
AU3Newbie Posted February 7, 2007 Share Posted February 7, 2007 too many files to include which cannot be found.C:\Documents and Settings\Administrator\桌面\code\A3LRichEdit.au3(3,10) : ERROR: can't open include file <A3LWinApi.au3> #include <A3LWinApi.au3> ~~~~~~~~~^ C:\Documents and Settings\Administrator\桌面\code\A3LRichEdit.au3(29,43) : WARNING: $WM_USER: possibly used before declaration. Global Const $EM_AUTOURLDETECT = $WM_USER + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ ^^^^^^^^ Link to comment Share on other sites More sharing options...
arcker Posted February 7, 2007 Author Share Posted February 7, 2007 ok ok ok as i've said, it's an alpha version i don't know because i use a proxy or what, but i CANT post anything i'll try to make the first post easier, and copy some images sry for the inconvenience -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
Uten Posted February 7, 2007 Share Posted February 7, 2007 Hi @arcker,I have not tried your script, but would like to say that most of it looks reasonably designed and documented...I have had some problems with posting attachments to and I'm not behind a restrictive firewall. May I suggest two things to overcome this. Wrap the code in both the codebox and the autoit tag. Your entire post will be easier to read and each file easier to locate. The biggest problem with this approach is that it can be a bit hard to mark the code for copying. Also, if you compile and decompile your script all the necessary include files will be there. Post all of that in a [ codebox ] [ autoit ] wrapped block.Happy Scripting Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
A. Percy Posted February 7, 2007 Share Posted February 7, 2007 First: I know how copy and paste, if this makes you happy. In case that not, tell the moderators.Second: I do not question the fact to have shown the code. But if included a zip file is more comfortable to download directly. Something against?just putting it into a zip only is frowned at.... arcker did the right thing... so if you don't know how to copy and paste you really shouldn't be here A. Percy. lod3n arcker posted that as well.... Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator VW Bug user Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral Link to comment Share on other sites More sharing options...
Somerset Posted February 7, 2007 Share Posted February 7, 2007 First: I know how copy and paste, if this makes you happy. In case that not, tell the moderators.Second: I do not question the fact to have shown the code. But if included a zip file is more comfortable to download directly. Something against?no silly. just having a zip is bad.. you showed the code being used.... some persons just say here is my exe or zip without showing code... makes them seem suspcious is all.... Link to comment Share on other sites More sharing options...
A. Percy Posted February 7, 2007 Share Posted February 7, 2007 Yes, suspicious, but I agree to the case of exe, but not of zip fileno silly. just having a zip is bad.. you showed the code being used.... some persons just say here is my exe or zip without showing code... makes them seem suspcious is all.... Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator VW Bug user Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral Link to comment Share on other sites More sharing options...
i542 Posted February 9, 2007 Share Posted February 9, 2007 Wow this is great! i542 I can do signature me. Link to comment Share on other sites More sharing options...
Michel Claveau Posted February 9, 2007 Share Posted February 9, 2007 (edited) Hi! Very interesting script. Congratulations, and... continue! For guys who have problem for select the source-code: 4 clics, then copy. Edited February 9, 2007 by Michel Claveau Link to comment Share on other sites More sharing options...
arcker Posted February 11, 2007 Author Share Posted February 11, 2007 thx for the feedback i'm working on the auto highlighting function but i've some problem with the getwordbreak function, but it was unexpected (it take tome time to get the last word break ( space or CR) so the current word is not returned, but two to three of them.....erf :/ i'm making some debugs more and i'll post the new, when it's done... it's really hard with such a control like this i need some ideas to make it really interesting i've looked to enables tables, but, as usual, it's really hard, and i've just found one little piece of code that did it :/ -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
DjDeep00 Posted April 18, 2007 Share Posted April 18, 2007 Can you please zip all the required files needed for this? The download link above doesnt work. Link to comment Share on other sites More sharing options...
DjDeep00 Posted April 22, 2007 Share Posted April 22, 2007 Bump...arcker?? Link to comment Share on other sites More sharing options...
James Posted April 23, 2007 Share Posted April 23, 2007 Hey Archer, take a look at BetaPad and take some ideas! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
grham Posted July 6, 2007 Share Posted July 6, 2007 Hi! It looks very interesting. I have been looking for a way to make an input (or an edit) with different fontsizes and styles (underlined ...) . Since this is not possible (till now?), I found in your script a workarround. Waw I can't prove the Betapad (looks good in the screenshot) for the reason that I don't use MSOFFICE (this is at least what I understood from that thread). There's only to find out how to set the font size (directly - not increase or decrease) and ... voilà. Thanks and good luck by developping it. PD: Some functions don't do the expected (like fontsizedecrease ...) but I know - it's a Beta. Link to comment Share on other sites More sharing options...
grham Posted July 16, 2007 Share Posted July 16, 2007 Hello,are you still workig on it?I have been playing with the code and I added:_RichEdit_SetFontSize and _RichEdit_SetStrikeOutand in combination with GaFrost's RichEdit you can read it as plane text.So now you have a "pseudo Input" or Edit with formated text (italic, underlined, fot size change.......).Now I don't know yet how to read it as formated text and save it as rtf.So .............. 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