⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faq4.htm

📁 C++builder学习资料C++builder
💻 HTM
字号:


<HTML>

<HEAD>

   <TITLE>Hide the application's taskbar icon</TITLE>

   <META NAME="Author" CONTENT="Harold Howe">

</HEAD>

<BODY BGCOLOR="WHITE">



<CENTER>

<TABLE  BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="640">



<TR>

<TD>









<H3>

Hide the application's taskbar icon<BR>

</H3>

<BR>



<P>

First, let's get some terminology straight. The system tray is the little box

in the corner of the task bar where programs can display small icons. Some examples include

the SysAgent icon, and the Outlook icon when you get new mail. The taskbar is the toolbar that

stretches across the screen. This is where program icons are located. To hide a program's taskbar

icon, you call the <TT>ShowWindow</TT> function and pass the <TT>Application-&gt;Handle</TT>

window handle.</P>

<pre>

ShowWindow<b>(</b>Application<b>-></b>Handle<b>,</b> SW_HIDE<b>)</b><b>;</b>

</pre>

<P>

To make the taskbar icon re-appear, simply change <TT>SW_HIDE</TT> to <TT>SW_SHOW</TT>.

</P>

<pre>

ShowWindow<b>(</b>Application<b>-></b>Handle<b>,</b> SW_SHOW<b>)</b><b>;</b>

</pre>

<P>

<B>Note:</B> You can hide the main form by setting its <TT>Visible</TT> property to false.

</P>

<P>

<B>Note:</B> Hiding the form's taskbar icon with <TT>ShowWindow</TT> is not permanent. Certain actions will cause the

taskbar icon to reappear. You can remove a program's taskbar icon and prevent it from ever appearing again by making

the hidden application window a tool window. Tool windows never have a taskbar icon. Making the application window a tool

window has the side effect of removing the program from the list of programs that appear when the user presses ALT-TAB.

You can make the application window a tool window by calling the API <TT>GetWindowLong</TT> and <TT>SetWindowLong</TT>

functions.

</P>

<pre>

WINAPI WinMain<b>(</b>HINSTANCE<b>,</b> HINSTANCE<b>,</b> LPSTR<b>,</b> <b>int</b><b>)</b>

<b>{</b>

    DWORD dwExStyle <b>=</b> GetWindowLong<b>(</b>Application<b>-></b>Handle<b>,</b> GWL_EXSTYLE<b>)</b><b>;</b>

    dwExStyle <b>|=</b> WS_EX_TOOLWINDOW<b>;</b>

    SetWindowLong<b>(</b>Application<b>-></b>Handle<b>,</b> GWL_EXSTYLE<b>,</b> dwExStyle<b>)</b><b>;</b>



    <b>try</b>

    <b>{</b>

         Application<b>-></b>Initialize<b>(</b><b>)</b><b>;</b>

         Application<b>-></b>CreateForm<b>(</b><b>__classid</b><b>(</b>TForm1<b>)</b><b>,</b> <b>&</b>Form1<b>)</b><b>;</b>

         Application<b>-></b>Run<b>(</b><b>)</b><b>;</b>

    <b>}</b>

    <b>catch</b> <b>(</b>Exception <b>&</b>exception<b>)</b>

    <b>{</b>

         Application<b>-></b>ShowException<b>(</b><b>&</b>exception<b>)</b><b>;</b>

    <b>}</b>

    <b>return</b> <font color="blue">0</font><b>;</b>

<b>}</b>

</pre>





</TD> </TR>



</TABLE>

</CENTER>

</BODY>

</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -