-1
如果您在默認情況下創建Delphi VCL應用程序,您將擁有一個VCL表單,如果您運行應用程序,則任務欄上只有一個圖標。之後,如果添加一個FMX表單,你可以同時使用兩種表單並使用它們。但是在應用程序運行時在任務欄中有兩個圖標。無論如何刪除它的標題是項目名稱,並保留另一個是你的主要形式?當我同時使用VCL和FMX時,如何刪除任務欄上的附加圖標?
我正在使用delphi XE8。
如果您在默認情況下創建Delphi VCL應用程序,您將擁有一個VCL表單,如果您運行應用程序,則任務欄上只有一個圖標。之後,如果添加一個FMX表單,你可以同時使用兩種表單並使用它們。但是在應用程序運行時在任務欄中有兩個圖標。無論如何刪除它的標題是項目名稱,並保留另一個是你的主要形式?當我同時使用VCL和FMX時,如何刪除任務欄上的附加圖標?
我正在使用delphi XE8。
我找到了答案。這很有趣。大約2天,我正在尋找,但沒有成功,我發佈了我的問題後找到答案。我自己回答可能對另一個人有用。
我發現這個代碼,這個頁面 https://github.com/vintagedave/firemonkey-container/blob/master/Parnassus.FMXContainer.pas
function EnumWindowCallback(hWnd: HWND; lParam: LPARAM): BOOL; stdcall;
const
FMXClassName = 'TFMAppClass';
var
ProcessID : DWORD;
ClassName : string;
ClassNameLength : NativeInt;
begin
// XE4 (possibly others) show a phantom TFMAppClass window on the taskbar. Hide it.
// Ensure the one we hide belongs to this thread/process - don't damage other FMX apps
if (GetWindowThreadProcessId(hWnd, ProcessID) = GetCurrentThreadId) and (ProcessID = GetCurrentProcessId) then begin
// Thanks to the ubiquitous David Heffernan... http://stackoverflow.com/questions/7096542/collect-all-active-window-class-names
SetLength(ClassName, 256);
ClassNameLength := GetClassName(hWnd, PChar(ClassName), Length(ClassName));
if ClassNameLength = 0 then RaiseLastOSError;
SetLength(ClassName, ClassNameLength);
if ClassName = FMXClassName then begin
// Found. Hide it, and return false to stop enumerating
ShowWindow(hWnd, SW_HIDE);
Exit(False);
end;
end;
Result := True; // Fallthrough, keep iterating
end;
如果使用下面的代碼使用它,在任務欄上的其他圖標將被隱藏
既然你正在尋找上在特定線程中的窗口,應該使用['EnumThreadWindows()'](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633495.aspx)而不是'EnumWindows()'。或者使用'FindWindow()'代替。 –