有没有办法修改主窗口的类名? ( 积分: 100 )

  • 主题发起人 主题发起人 luckymanman
  • 开始时间 开始时间
L

luckymanman

Unregistered / Unconfirmed
GUEST, unregistred user!
delphi编写的程序窗口类名一般都是以T开头,有没有办法改为其它名称?<br>用CreateWindowEx是可以,但这样创建窗口比较麻烦,有没有比较简单的方法?
 
以T(Type)开头只是一个习惯而已,不知道LZ要作什么
 
我想随机改变窗口的类名和标题,不让别人那么容易修改我的程序。
 
type<br>&nbsp;&nbsp;TCustomEDoForm&nbsp;=&nbsp;class&nbsp;(TForm)<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SpecifyWinClassName(var&nbsp;WinClassName:&nbsp;string);&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CreateParams(var&nbsp;Params:&nbsp;TCreateParams);&nbsp;override;<br>&nbsp;&nbsp;end;<br><br>procedure&nbsp;TCustomEDoForm.CreateParams(var&nbsp;Params:&nbsp;TCreateParams);<br>var<br>&nbsp;&nbsp;clsName:&nbsp;string;<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;clsName&nbsp;:=&nbsp;Self.ClassName;<br>&nbsp;&nbsp;SpecifyWinClassName(clsName);<br>&nbsp;&nbsp;if&nbsp;Length(clsName)&nbsp;&gt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;StrLCopy(Params.WinClassName,&nbsp;PChar(clsName),&nbsp;SizeOf(Params.WinClassName)&nbsp;-&nbsp;1);<br>end;<br><br>procedure&nbsp;TCustomEDoForm.SpecifyWinClassName(var&nbsp;WinClassName:&nbsp;string);<br>var<br>&nbsp;&nbsp;fmText:&nbsp;string;<br>begin<br>&nbsp;&nbsp;{删除创建的窗体类名开头的字母T}<br>&nbsp;&nbsp;if&nbsp;(WinClassName&nbsp;&lt;&gt;&nbsp;'')&nbsp;and&nbsp;(UpperCase(WinClassName[1])&nbsp;=&nbsp;'T')&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Delete(WinClassName,&nbsp;1,&nbsp;1);<br>&nbsp;&nbsp;{删除创建的窗体类名开头的fm或者frm}<br>&nbsp;&nbsp;fmText&nbsp;:=&nbsp;LowerCase(Copy(WinClassName,&nbsp;1,&nbsp;3));<br>&nbsp;&nbsp;if&nbsp;fmText&nbsp;=&nbsp;'frm'&nbsp;then&nbsp;Delete(WinClassName,&nbsp;1,3)<br>&nbsp;&nbsp;else&nbsp;if&nbsp;Copy(fmText,&nbsp;1,&nbsp;2)&nbsp;=&nbsp;'fm'&nbsp;then&nbsp;Delete(WinClassName,&nbsp;1,&nbsp;2);<br>end;<br><br>仅供参考!
 
zqw0117的代码符合我的要求,谢谢,接分!<br><br><br><br>type<br>&nbsp;&nbsp;TForm1&nbsp;=&nbsp;class(TForm)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Private&nbsp;declarations&nbsp;}<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Public&nbsp;declarations&nbsp;}<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CreateParams(var&nbsp;Params:&nbsp;TCreateParams);&nbsp;override;<br>&nbsp;&nbsp;end;<br><br>var<br>&nbsp;&nbsp;Form1:&nbsp;TForm1;<br>implementation<br>{$R&nbsp;*.dfm}<br><br>procedure&nbsp;TForm1.CreateParams(var&nbsp;Params:&nbsp;TCreateParams);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;Params.WinClassName:='自定义类名';<br>end;
 
后退
顶部