I'm with a little problem when trying to show more than one form on taskbar on the same time. I found I need to use the following:
WS_EX_APPWINDOW
So I search a little bit more about and then found it:
class TForm2 : public TForm
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TForm2(TComponent* Owner);
void __fastcall CreateParams(Controls::TCreateParams &Params);
};
void __fastcall TForm2::CreateParams(Controls::TCreateParams &Params)
{
TForm::CreateParams(Params);
Params.ExStyle = Params.ExStyle | WS_EX_APPWINDOW;
Params.WndParent = ParentWindow;
}
However that function works just with VCL (TCreateParams is not a member of Fmx::Controls).
So, I search a little bit more again and found it (This function goes at OnCreate form function):
SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
But I got something wrong saying the following:
[bcc32 Error] Codigo.cpp(19): E2034 Cannot convert 'TWindowHandle * const' to 'HWND__ *'
Full parser context
Codigo.cpp(18): parsing: void _fastcall TfrmCodigo::FormCreate(TObject *)
[bcc32 Error] Codigo.cpp(19): E2342 Type mismatch in parameter 'hWnd' (wanted 'HWND__ *', got 'TWindowHandle *')
Full parser context
Codigo.cpp(18): parsing: void _fastcall TfrmCodigo::FormCreate(TObject *)
Do you know any other alternative to do this? If you can help me or not, since now, thanks A LOT!
The code snippets you have shown are for VCL only.
FireMonkey does not allow you to customize the creation of a Form's HWND like VCL does. The HWND creation is hidden behind a private interface that FireMonkey uses internally ( TPlatformWin.CreateWindow()
). That is why there is no CreateParams
in FireMonkey.
However, you can still access the HWND, but only after it has been created. There is a WindowHandleToPlatform()
function (which replaces the older FmxHandleToHWND()
function), and a FormToHWND
function (which uses WindowHandleToPlatform()
internally). All of these functions are Windows-specific, so you have to wrap them with an #ifdef
if you are writing FireMonkey code that runs on multiple platforms.
Try this:
#ifdef _Windows
#include <FMX.Platform.Win.hpp>
#endif
...
#ifdef _Windows
//HWND hWnd = FmxHandleToHWND(Form2->Handle);
//HWND hWnd = WindowHandleToPlatform(Form2->Handle)->Wnd;
HWND hWnd = FormToHWND(Form2);
if (hWnd != NULL)
{
LONG Style = GetWindowLong(hWnd, GWL_EXSTYLE); // <-- don't forget this step!
SetWindowLong(hWnd, GWL_EXSTYLE, Style | WS_EX_APPWINDOW);
}
#endif
Also see:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.