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;
}