Now it works.
However, if I add gMessage as one of the options, then the control dissappears.
Code: Select all
Message:
guicontrolget, myedit
msgbox, Contents %myedit%
return
Code: Select all
Message:
guicontrolget, myedit
msgbox, Contents %myedit%
return
Code: Select all
#NoEnv
SetBatchLines, -1
#include Class_RichEdit.ahk
appname := "SimpleRichEdit"
gosub, mainui
return
;------------------------------
mainui:
Gui, +Hwnd%appname%
MyRichEdit := new richedit(%appname%,"w75 vmyedit gMessage", false)
MyRichEdit.AlignText("RIGHT")
Gui, Show, h200 w300 center,%appname%
Return
;------------------------------
Message:
guicontrolget, myedit
ToolTip, My contents are %myedit%
return
;------------------------------
GuiClose:
ExitApp
Code: Select all
#NoEnv
SetBatchLines, -1
#include Class_RichEdit.ahk
appname := "SimpleRichEdit"
gosub, mainui
gosub, loadhotkeys
return
;------------------------------
mainui:
Gui, +Hwnd%appname%
MyRichEdit := new richedit(%appname%,"w250 vmyedit", true)
MyRichEdit.AlignText("RIGHT")
Gui, Show, h120 w270 center,%appname%
Return
;------------------------------
Message:
guicontrolget, myedit
ToolTip, My contents are %myedit%
settimer, removemessage, 1000
return
RemoveMessage:
settimer, removemessage, off
tooltip
return
;------------------------------
LoadHotkeys:
hotkey, IfWinActive, % "ahk_id " %appname% ; <------
hotkey, ^b, MakeBold
hotkey, ^+b, MakeBold_alt
hotkey, ^g, MakeColoured
hotkey, ^t, Message
hotkey, ^q, Clear
return
;------------------------------
;For syntax using the richtext tags:
;http://www.pindari.com/rtf1.html
;Demonstrate using the class' built-in ToggleFontStyle for the current selection
MakeBold:
MyRichEdit.ToggleFontStyle("B")
return
;Demonstrate setting of tag-styled text
MakeBold_alt:
MyRichEdit.SetText("{\rtf My Name is \b1 " . appname . "\b0}", ["SELECTION"])
return
MakeColoured:
colortable := "{\colortbl `;\red0\green176\blue80;\red0\green77\blue187`;\red255\green0\blue0`;}"
greentext := "\cf1 green text,\cf0"
bluetext := "\cf2 blue text,\cf0"
redtext := "\cf3 red text\cf0"
MyRichEdit.SetText("{\rtf " . colortable . "Colouized text: " . greentext . bluetext . redtext . ".}", ["SELECTION"])
return
Clear:
MyRichEdit.SetText("")
return
;------------------------------
GuiClose:
ExitApp
Code: Select all
hEdit1 := new richedit("mainui"," y0 w75 h24 vEdit1 gAction", false)
hEdit1.AlignText("RIGHT")
Control, ExStyle, -E0x200, , ahk_id %hEdit1%
Code: Select all
Control, ExStyle, ^0x200, , ahk_id %hEdit1%
Control, ExStyle, ^0x20000, , ahk_id %hEdit1%
Control, ExStyle, ^0x4000, , ahk_id %hEdit1%
EM_SETTEXTEXBGM wrote:Okay, I am right. The comment should read:
Replaces the whole content of the control.
This may be right, but it isn't done by the script, it's done by the control.When I use
hedit1.AlignText(2), it moves the text down by one pixel
in other words, without AlignText, the text is up one pixel
Code: Select all
loop, parse, whatstring
{
if(asc(a_loopfield) > 0xFF){
thischar := "\u" . asc(a_loopfield) . "?"
}else{
thischar := a_loopfield
}
newstring .= thischar
}
Return to “Scripts and Functions (v1)”
Users browsing this forum: TAC109 and 36 guests