关于delphi tmemo的问题。 如何让利用opendialog打开的txt显示在memo里面
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于delphi tmemo的问题。 如何让利用opendialog打开的txt显示在memo里面相关的知识,希望对你有一定的参考价值。
还是不行,我说详细点好了,我想利用button控件实行打开命令。。。。然后就是接下来的,类似于最简单的记事本那种。。。
先添加一个OpenDialog控件,然后添加命令procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
end;
end; 参考技术A 对补充的说明还是未明白,楼上的2位按理是解决了才是
除非是你用timer控制按钮的点击事件,并且将所需要打开的文件路径指定好,这样就可以达到实时的显示最新的txt数据 参考技术B If OpenDialog1.Execute then Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
关于Delphi的TMemo控件
最近在看delphi的VCL源码时,发现TMemo的Text属性不知是哪继承来的,往上只追到
TCustomEdit里public属性的Text,但却没有读写方法
TCustomEdit = class(TWinControl)
public
...
property Text;
end;
再往上是TWinControl根本就没有Text这个属性,所以比较困惑的是,当我们给Memo的Text赋值时它是怎么传递的,一般的property(属性)都有读写方法一看就知道内部是怎么变的,这个TMemo的Text有什么特殊,望高手指点,哪位说明白了,加分
TCustomEdit的属性列表如下:
StdCtrls.TCustomEdit PropertiesFrom RAD Studio VCL Referencer
Up to Parent: TCustomEdit
Alignment Determines how the text is aligned within the text edit control.
AutoSelect Determines whether all the text in the edit control is automatically selected when the control gets focus.
AutoSize Determines whether the height of the edit control automatically resizes to accommodate the text.
BorderStyle Determines whether the edit control has a single line border around the client area.
CanUndo Indicates whether the edit control contains changes that can be backed out.
CharCase Determines the case of the text within the edit control.
HideSelection Determines whether the visual indication of the selected text remains when focus shifts to another control.
MaxLength Specifies the maximum number of characters the user can enter into the edit control.
Modified Indicates whether the user edited the text of the edit control.
NumbersOnly Allows only numbers to be typed into the text edit.
OEMConvert Determines whether characters typed in the edit control are converted from ANSI to OEM and then back to ANSI.
ParentColor
PasswordChar Indicates the character, if any, to display in place of the actual characters typed in the control.
ReadOnly Determines whether the user can change the text of the edit control.
SelLength Specifies the number of characters (bytes) that are selected.
SelStart Specifies the position of the first selected character in the text.
SelText Specifies the selected portion of the edit control's text.
TabStop
Text
TextHint A hint or message to be displayed when the Text property is empty.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
text在delphi中的描述为:
StdCtrls.TCustomEdit.Text inherits from Controls.TControl.Text. All content below this line refers to Controls.TControl.Text.
Contains a text string associated with the control.
Use the Text property to read the Text of the control or to specify a new string for the Text value. By default, Text is the control name. For edit controls and memos, the Text appears within the control. For combo boxes, the Text is the content of the edit control portion of the combo box.
Note: Controls that display text use either the Caption property or the Text property to specify the text value. Which property is used depends on the type of control. In general, Caption is used for text that appears as a window title or label, while Text is used for text that appears as the content of a control. 参考技术A 在TControl这个类里面,修饰为
protected
property Text: TCaption read GetText write SetText;
在TWinControl类里面写
public
property Text;
使用public修饰更改text属性, 使该属性可被访问。
实际访问的就是Tcoltrol的Text属性追问
再请问下,TControl里的Text读写方法都是在私用域,怎么取TMemo的Text属性的读写地址呢(PS:有个软件是Delphi编的,我要取TMemo的内容,已经可以成功注入,但TMemo的TEXT内存地址一直找不到,想从TMemo的具体实现上找方法)
另外我用的是D7,TWinControl里并没有property Text; 是不是版本问题,还是这个属性可以跨级继承TControl里的protected域里的Text属性
以上是关于关于delphi tmemo的问题。 如何让利用opendialog打开的txt显示在memo里面的主要内容,如果未能解决你的问题,请参考以下文章