📄 faq84.htm
字号:
<HTML>
<HEAD>
<TITLE>Change the window class name of a form</TITLE>
<META NAME="Author" CONTENT="Harold Howe">
</HEAD>
<BODY BGCOLOR="WHITE">
<CENTER>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="640">
<TR>
<TD>
<H3>
Change the window class name of a form
</H3>
<P>
Override the <TT>CreateParams</TT> method of your form, and copy your window class name into
the <TT>WinClassName</TT> member of the <TT>TCreateParams</TT> structure.
</P>
<pre>
<font color="navy">//---------------------------------------------------------------</font>
<font color="navy">// header file</font>
<b>private</b><b>:</b>
<b>virtual</b> <b>void</b> <b>__fastcall</b> CreateParams<b>(</b>TCreateParams <b>&</b> Params<b>)</b><b>;</b>
<font color="navy">//---------------------------------------------------------------</font>
<font color="navy">// cpp file</font>
<b>void</b> <b>__fastcall</b> TForm1<b>:</b><b>:</b>CreateParams<b>(</b>TCreateParams <b>&</b> Params<b>)</b>
<b>{</b>
TForm<b>:</b><b>:</b>CreateParams<b>(</b>Params<b>)</b><b>;</b>
strcpy<b>(</b>Params<b>.</b>WinClassName<b>,</b><font color="blue">"MotherPumpkin"</font><b>)</b><b>;</b>
<b>}</b>
</pre>
<P>
<B>Note: </B>The <TT>WinClassName</TT> member of the <TT>TCreateParams</TT> structure is an array of <TT>char</TT>. The
array size is 64. You need to copy your window class name into this variable using <TT>strcpy</TT>. Do not attempt
to assign the character string like this:
</P>
<pre>
<b>void</b> <b>__fastcall</b> TForm1<b>:</b><b>:</b>CreateParams<b>(</b>TCreateParams <b>&</b> Params<b>)</b>
<b>{</b>
TForm<b>:</b><b>:</b>CreateParams<b>(</b>Params<b>)</b><b>;</b>
Params<b>.</b>WinClassName <b>=</b> <font color="blue">"MotherPumpkin"</font><b>;</b> <font color="navy">// Error!</font>
<b>}</b>
</pre>
<P>
<B>Note: </B> The <TT>TCreateParams</TT> structure also contains a <TT>WindowClass</TT> member. This member is the
<TT>WNDCLASS</TT> structure that you would normally see in an API program. The <TT>WNDCLASS</TT> structure contains a
member called <TT>lpszClassName</TT> that would normally contain the class name in a standard API program. However, in
the VCL, <TT>lpszClassName</TT> conflicts with the <TT>WinClassName</TT> character array. I tried to use
<TT>lpszClassName</TT> to assign the class name, but it didn't have any effect. I recommend that you use
<TT>WinClassName</TT> instead.
</P>
</TD> </TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -