I want to be able to remove my Win32 application's button from the Taskbar. I also want to be able to add it back later. How can this be done? I found this approach, but it is written in Delphi, and I'm using C++ instead.
I tried modifying this code by changing one line of Remy's code from:
SetWindowLong(hWnd, GWL_EXSTYLE, Style | WS_EX_APPWINDOW);
to
SetWindowLong(hWnd, GWL_EXSTYLE, Style | WS_EX_TOOLWINDOW);
But this doesn't work, the button is still on the Taskbar.
UPDATE: the code I'm using (that originated from Remy of course):
void __fastcall TForm1::CreateHandle() // this is code from Remy i added to help me trap screen lock
{
TForm::CreateHandle();
HWND hWnd = Fmx::Platform::Win::FormToHWND(this);
if (SetWindowSubclass(hWnd, &SubclassWndProc, 1, reinterpret_cast<DWORD_PTR>(this)))
{
MonitoringWTS = WTSRegisterSessionNotification(hWnd, NOTIFY_FOR_THIS_SESSION);
if (!MonitoringWTS)
RemoveWindowSubclass(hWnd, &SubclassWndProc, 1);
}
else {
MonitoringWTS = false;
}
if (hWnd != NULL) // this code added from https://stackoverflow.com/questions/28929163/how-to-show-a-secondary-form-on-taskbar-using-fmx-c
{
LONG Style = GetWindowLong(hWnd, GWL_EXSTYLE); // <-- don't forget this step!
SetWindowLong(hWnd, GWL_EXSTYLE, Style | WS_EX_APPWINDOW);
}
}
Using C++Builder 10.2 Version 25.0.31059.3231.