example of embarcadero WindowHandleToPlatform c++

前端 未结 1 1163
轮回少年
轮回少年 2021-01-26 01:57

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 Wi

相关标签:
1条回答
  • 2021-01-26 02:16

    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.

    0 讨论(0)
提交回复
热议问题