How to hide an application's taskbar icon

Source: Internet
Author: User

First, take a look at these terms. The system tray is a small box in the right corner of the taskbar, where the application can display small icons in the tray. The taskbar is a toolbar that you can stretch on your screen. This is where the program icon is located. To hide the taskbar icon for the program, you can apply the ShowWindow function and pass it to the Application->handle window handle.

ShowWindow (Application->handle, sw_hide);

To make the taskbar icon appear again, simply change the sw_hide to Sw_show.

ShowWindow (Application->handle, sw_show);

Note: You can hide it by setting the Visible property of the main window to false.

Note: The taskbar icon that hides the window through ShowWindow is not persistent. Some actions cause the taskbar icon to reappear. You can set the Hidden application window to tool window to remove the taskbar icon from the program and prevent it from appearing again. Tool windows will never have taskbar icons. Making the application window a tool windows has a side effect: it will not appear in the list of programs when the user presses the alt-tab. You can invoke API functions GetWindowLong and SetWindowLong to make the application window a tool windows.

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
     DWORD dwExStyle = GetWindowLong(Application->Handle, GWL_EXSTYLE);
     dwExStyle |= WS_EX_TOOLWINDOW;
     SetWindowLong(Application->Handle, GWL_EXSTYLE, dwExStyle);
     try
     {
        Application->Initialize();
        Application->CreateForm(__classid(TForm1), &Form1);
        Application->Run();
     }
     catch (Exception &exception)
     {
        Application->ShowException(&exception);
     }
     return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.