GaryFrost Posted April 4, 2006 Posted April 4, 2006 I've got a problem, if I want that the text "Table" is size 18 and I want that the text "other tables" is size 14, then I select The text "table", but then all the text is size 18. So is there a way to make the text "table" size 18 and the text "other tables" size 14?Kind Regards,PcExpertIn order to to that kind of text formatting on a gui you'll need to use a richedit control, gl. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
PcExpert Posted April 5, 2006 Author Posted April 5, 2006 (edited) OK, but how do I change the edit control into the activeX control? This is the code: #include <GuiConstants.au3>#Include <GuiStatusBar.au3>#include <Array.au3>#include "FileDialog.au3"Opt("MustDeclareVars", 1)_Main_EditControl()_Main_Into_Variable()_Main_Into_Array()Func _Main_EditControl() Local $file, $gui, $ctrl_Edit, $btn_file, $msg, $StatusBar1, $btn_save, $s_text Local $Caption = "Bestand Openen...", $Default_File = "" Local $Filter = "Documenten (*.pbw;*.rtf)" Local $Default_Index = 1 Local $Dialog = 0 ; show open Local $Flags = BitOR($cdlOFNExplorer, $cdlOFNFileMustExist, $cdlOFNLongNames, $cdlOFNPathMustExist, $cdlOFNNoChangeDir) Local $cmb_pnt Local $cmb_fnt $gui = GUICreate("PcBase Writer", 600, 600) $ctrl_Edit = GUICtrlCreateEdit("", 10, 70, 580, 500, -1, $WS_EX_CLIENTEDGE) $btn_file = GUICtrlCreateButton("Bestand Openen", 10, 10, 90, 20) $btn_save = GUICtrlCreateButton("Bestand Opslaan", 120, 10, 90, 20) $StatusBar1 = _GuiCtrlStatusBarCreate ($gui, -1, "") $cmb_pnt = GUICtrlCreateCombo("12", 230, 10) GUICtrlSetData($cmb_pnt, "6|8|10|12|14|16|18|20|22|24|26|28|30|32|34|36|38|30|42|44|46|48|50|", "12") $cmb_fnt = GUICtrlCreateCombo("Times New Roman", 340, 10, 140) GUICtrlSetData($cmb_fnt, "Comic Sans MS|Monotype Corsiva|Arial|Arial Black|Arial Unicode MS|Book Antiqua|Bookman Old Style|Century Gothic|Courier New|Estrangelo Edessa|Franklin Gothic Medium|Georgia|Lucida Sans Unicode|MV Boli|Tahoma|Trebuchet MS|Verdana|", "Times New Roman") GUICtrlSetFont($ctrl_Edit,"", "", "", GUICtrlRead($cmb_pnt)) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn_file $file = _FileDialog ($ctrl_Edit, $Caption, @ScriptDir, $Default_File, $Filter, $Default_Index, $Flags, $Dialog, 3) If @error Then _GuiCtrlStatusBarSetText ($StatusBar1, $DialogError.description, 0) Else _GuiCtrlStatusBarSetText ($StatusBar1, $file, 0) EndIf Case $msg = $btn_save $Flags = BitOR($cdlOFNExplorer, $cdlOFNOverwritePrompt, $cdlOFNLongNames, $cdlOFNPathMustExist, $cdlOFNNoChangeDir) $Dialog = 1 ; show save $s_text = GUICtrlRead($ctrl_Edit) $file = _FileDialog ($s_text, $Caption, @ScriptDir, $Default_File, $Filter, $Default_Index, $Flags, $Dialog) If @error Then _GuiCtrlStatusBarSetText ($StatusBar1, $DialogError.description, 0) Else _GuiCtrlStatusBarSetText ($StatusBar1, $file, 0) EndIf Case $msg = $cmb_pnt GUICtrlSetFont($ctrl_Edit, GUICtrlRead($cmb_pnt)) Case $msg = $cmb_fnt GUICtrlSetFont($ctrl_Edit, GUICtrlRead($cmb_pnt), "", "", GUICtrlRead($cmb_fnt)) Case Else ;;;;;;; EndSelect WEnd GUIDelete() EndFunc ;==>_Main_EditControlFunc _Main_Into_Variable() Local $file, $a_file Local $Caption = "Bestand Openen...", $Default_File = "" Local $Filter = "Documenten (*.pbw;*.rtf)" Local $Default_Index = 1, $Dialog = 0 Local $Flags = BitOR($cdlOFNExplorer, $cdlOFNFileMustExist, $cdlOFNLongNames, $cdlOFNPathMustExist, $cdlOFNNoChangeDir) $file = _FileDialog ($a_file, $Caption, @ScriptDir, $Default_File, $Filter, $Default_Index, $Flags, $Dialog, 1) If @error Then _DialogError() Else MsgBox(0, "File Read Into Variable In: " & $file, $a_file) EndIfEndFunc ;==>_Main_Into_VariableFunc _Main_Into_Array() Local $file, $a_file Local $Caption = "Bestand Openen...", $Default_File = "" Local $Filter = "Documenten (*.pbw;*.rtf)" Local $Default_Index = 1, $Dialog = 0 Local $Flags = BitOR($cdlOFNFileMustExist, $cdlOFNPathMustExist, $cdlOFNNoChangeDir, $cdlOFNAllowMultiselect) ; old style dialog $file = _FileDialog ($a_file, $Caption, @ScriptDir, $Default_File, $Filter, $Default_Index, $Flags, $Dialog, 2) If @error Then _DialogError() Else _ArrayDisplay($a_file, "File Read Into Array: " & $file) EndIfEndFunc ;==>_Main_Into_ArrayFunc _DialogError() MsgBox(0, "File Dialog", "Intercepted an Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $DialogError.description & @CRLF & _ "err.number is: " & @TAB & Hex($DialogError.number, 8) & @CRLF & _ "err.scriptline is: " & @TAB & $DialogError.scriptline & @CRLF)EndFunc ;==>_DialogErrorI have tried somethings, like changing the edit control into the ActiveX Control, but it still doesn't work. Please help Edited April 5, 2006 by PcExpert
PcExpert Posted April 5, 2006 Author Posted April 5, 2006 Please help, I'd really need some help. Because I can't figure out what to change.
GaryFrost Posted April 5, 2006 Posted April 5, 2006 quick and dirty, only changes text that is highlighted (selected) and anything new typed inyou'll need to ge the RTF Plugin by Lazycatexpandcollapse popup#include <GuiConstants.au3> #Include <GuiStatusBar.au3> #include <Array.au3> #include <Misc.au3> #include "FileDialog.au3" #include "RTF_writer.au3" #Compiler_PlugIn_Funcs=GUICtrlCreateRTFEdit,GUICtrlRTFSave,GUICtrlRTFSet, GUICtrlRTFGet Opt("MustDeclareVars", 1) _Main_RTFEditControl() Func _Main_RTFEditControl() Local $file, $gui, $ctrl_Edit, $btn_file, $msg, $StatusBar1, $btn_save, $s_text Local $Caption = "Bestand Openen...", $Default_File = "" Local $Filter = "Documenten (*.pbw;*.rtf)|*.pbw;*.rtf" Local $Default_Index = 1 Local $Dialog = 0; show open Local $Flags = BitOR($cdlOFNExplorer, $cdlOFNFileMustExist, $cdlOFNLongNames, $cdlOFNPathMustExist, $cdlOFNNoChangeDir) Local $cmb_pnt Local $cmb_fnt, $hPlug, $out, $a_font, $btn_font $hPlug = PluginOpen("rtfplugin.dll") $gui = GUICreate("PcBase Writer", 600, 600) $ctrl_Edit = GUICtrlCreateRTFEdit ($gui, 10, 70, 580, 500, -1, 0x20000) $btn_file = GUICtrlCreateButton("Bestand Openen", 10, 10, 90, 20) $btn_save = GUICtrlCreateButton("Bestand Opslaan", 120, 10, 90, 20) $StatusBar1 = _GuiCtrlStatusBarCreate ($gui, -1, "") $cmb_pnt = GUICtrlCreateCombo("12", 230, 10) GUICtrlSetData($cmb_pnt, "6|8|10|12|14|16|18|20|22|24|26|28|30|32|34|36|38|30|42|44|46|48|50|", "12") $cmb_fnt = GUICtrlCreateCombo("Times New Roman", 340, 10, 140) GUICtrlSetData($cmb_fnt, "Comic Sans MS|Monotype Corsiva|Arial|Arial Black|Arial Unicode MS|Book Antiqua|Bookman Old Style|Century Gothic|Courier New|Estrangelo Edessa|Franklin Gothic Medium|Georgia|Lucida Sans Unicode|MV Boli|Tahoma|Trebuchet MS|Verdana|", "Times New Roman") $btn_font = GUICtrlCreateButton("Font...", 340, 40, 90, 25) GUICtrlSetFont($ctrl_Edit, "", "", "", GUICtrlRead($cmb_pnt)) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn_file $Dialog = 0; show open $file = _FileDialog ($s_text, $Caption, @ScriptDir, $Default_File, $Filter, $Default_Index, $Flags, $Dialog, 1) If @error Then _GuiCtrlStatusBarSetText ($StatusBar1, $DialogError.description, 0) Else _GuiCtrlStatusBarSetText ($StatusBar1, $file, 0) $out = _RTFCreateDocument ("MS Sans Serif") $out = $s_text GUICtrlRTFSet ($ctrl_Edit, $out, 1) EndIf Case $msg = $btn_save $Dialog = 1; show save $s_text = _GetCtrlText($ctrl_Edit, 1) $file = _FileDialog ($s_text, $Caption, @ScriptDir, $Default_File, $Filter, $Default_Index, $Flags, $Dialog) If @error Then _GuiCtrlStatusBarSetText ($StatusBar1, $DialogError.description, 0) Else _GuiCtrlStatusBarSetText ($StatusBar1, $file, 0) EndIf Case $msg = $btn_font $a_font = _ChooseFont (GUICtrlRead($cmb_fnt), GUICtrlRead($cmb_pnt)) If Not @error Then $out = _RTFCreateDocument ("MS Sans Serif") $s_text = _GetCtrlText($ctrl_Edit, 0, 1) $out = _RTFAppendString ($out, $s_text, $a_font[7], $a_font[3], $a_font[1], $a_font[2]) GUICtrlRTFSet ($ctrl_Edit, $out, 1) EndIf Case $msg = $cmb_pnt $out = _RTFCreateDocument ("MS Sans Serif") $s_text = _GetCtrlText($ctrl_Edit, 0, 1) $out = _RTFAppendString ($out, $s_text, 0x000000, GUICtrlRead($cmb_pnt), 0, GUICtrlRead($cmb_fnt)) GUICtrlRTFSet ($ctrl_Edit, $out, 1) Case $msg = $cmb_fnt ;~ GUICtrlSetFont($ctrl_Edit, GUICtrlRead($cmb_pnt), "", "", GUICtrlRead($cmb_fnt)) $out = _RTFCreateDocument ("MS Sans Serif") $s_text = _GetCtrlText($ctrl_Edit, 0, 1) $out = _RTFAppendString ($out, $s_text, 0x000000, GUICtrlRead($cmb_pnt), 0, GUICtrlRead($cmb_fnt)) GUICtrlRTFSet ($ctrl_Edit, $out, 1) Case Else ;;;;;;; EndSelect WEnd GUIDelete() EndFunc ;==>_Main_RTFEditControl Func _DialogError() MsgBox(0, "File Dialog", "Intercepted an Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $DialogError.description & @CRLF & _ "err.number is: " & @TAB & Hex($DialogError.number, 8) & @CRLF & _ "err.scriptline is: " & @TAB & $DialogError.scriptline & @CRLF) EndFunc ;==>_DialogError Func _GetCtrlText($hEdit, $rtf = 0, $getsel = 0) If $rtf Then Return GUICtrlRTFGet ($hEdit) Else ;~ typedef struct _gettextex { ;~ DWORD cb; ;~ DWORD flags; ;~ UINT codepage; ;~ LPCSTR lpDefaultChar; ;~ LPBOOL lpUsedDefChar; ;~ } GETTEXTEX; Local Const $GT_DEFAULT = 0 Local Const $GT_USECRLF = 1 Local Const $GT_SELECTION = 2 Local Const $WM_USER = 0x400 Local Const $EM_GETTEXTEX = ($WM_USER + 94) Local $struct = DllStructCreate("dword;dword;int;char;int") DllStructSetData($struct, 1, 4095) If $getsel Then DllStructSetData($struct, 2, BitOR($GT_USECRLF, $GT_SELECTION)) Else DllStructSetData($struct, 2, $GT_USECRLF) EndIf Local $lResult = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hEdit, "int", $EM_GETTEXTEX, "ptr", DllStructGetPtr($struct), "str", "") If Not @error Then $lResult = $lResult[4] $struct = 0 Return $lResult EndIf EndIf EndFunc ;==>_GetCtrlText SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
PcExpert Posted April 6, 2006 Author Posted April 6, 2006 OK, thanks. But the following ERROR occured: ERROR CODE: C:\Program Files\AutoIt3\beta\Examples\Helpfile\pcbase writer 1.au3(98,37) : ERROR: GUICtrlRTFGet(): undefined function. Return GUICtrlRTFGet ($hEdit) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Program Files\AutoIt3\beta\Examples\Helpfile\pcbase writer 1.au3 - 1 error(s), 0 warning(s)
nfwu Posted April 6, 2006 Posted April 6, 2006 2 possible solutions: 1) The RTF plugin dll ("rtfplugin.dll") has to be in the same directory as the script. 2) Try compiling the script. #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
PcExpert Posted April 6, 2006 Author Posted April 6, 2006 THere's something wrong, I used the code that gafrost wrote, now it works, but if I try to change the size or font it displays this error: Line 0 (File "C:\Program Files\AutoIt3\beta\Examples\Helpfile\pcbase writer 1.exe"): $sRed = BitAnd(BitShift($nColor, 16), 0xff) ^ ERROR Error: Variable used without being declared.
GaryFrost Posted April 6, 2006 Posted April 6, 2006 THere's something wrong, I used the code that gafrost wrote, now it works, but if I try to change the size or font it displays this error: Line 0 (File "C:\Program Files\AutoIt3\beta\Examples\Helpfile\pcbase writer 1.exe"): $sRed = BitAnd(BitShift($nColor, 16), 0xff) ^ ERROR Error: Variable used without being declared. in the RTF_writer.au3 change: Func _RTFGetColor($nColor) $sRed = BitAnd(BitShift($nColor, 16), 0xff) $sGreen = BitAnd(BitShift($nColor, 8), 0xff) $sBlue = BitAnd($nColor, 0xff) Return("\red" & $sRed & "\green" & $sGreen & "\blue" & $sBlue) EndFunc TO: Func _RTFGetColor($nColor) Local $sRed = BitAnd(BitShift($nColor, 16), 0xff) Local $sGreen = BitAnd(BitShift($nColor, 8), 0xff) Local $sBlue = BitAnd($nColor, 0xff) Return("\red" & $sRed & "\green" & $sGreen & "\blue" & $sBlue) EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
PcExpert Posted April 6, 2006 Author Posted April 6, 2006 OK, now it works, but the size is still the same even if I change it to 72 it stays 12
GaryFrost Posted April 6, 2006 Posted April 6, 2006 OK, now it works, but the size is still the same even if I change it to 72 it stays 12only changes text that is highlighted (selected) and then anything new typed in SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
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