0

I need an example of WindowHandleToPlatform for c++ builder I want to use the handle to do bitblt and other functions to a form I can do this using VCL and works great. Think WindowHandleToPlatform is the solution for firemonkey, but documentation is very poor

Thanks

manlio
  • 18,345
  • 14
  • 76
  • 126
  • Do you mean the TPlatformServices? and that you want to get to IFMXWindowService? – Huy Pham Nov 21 '13 at 07:26
  • No, I want to access The actual windows handle as the firemonkey handle does not support many things – user3016178 Nov 22 '13 at 08:00
  • Use WindowHandleToPlatform(Form1.Handle) will give you the actual Windows window handle. – Huy Pham Nov 22 '13 at 08:15
  • @HuyPham: that would be `Form1->Handle` in C++. And if the calling code is already inside of the `TForm1` class, then drop the `Form1->` portion and access the `Handle` via the implicit `this` pointer (`Self` in Delphi). – Remy Lebeau Dec 19 '13 at 02:13

1 Answers1

1

Try this:

#include <FMX.Platform.Win.hpp>

void __fastcall TMyForm::DoSomething()
{
    TWinWindowHandle *ThisHandle = WindowHandleToPlatform(this->Handle);
    if (ThisHandle != NULL)
    {
        HWND hWnd = ThisHandle->Wnd;
        if (ThisWnd != NULL)
        {
            // use ThisWnd as needed...
        }
    }
}

Or use FormToHWND() instead (which uses WindowHandleToPlatform() internally):

#include <FMX.Platform.Win.hpp>

void __fastcall TMyForm::DoSomething()
{
    HWND ThisWnd = FormToHWND(this);
    if (ThisWnd != NULL)
    {
        // use ThisWnd as needed...
    }
}

Either way, keep in mind that these functions are specific Windows. If you want something that is cross-platform, you will have to find another solution.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770