RestoreCapture FMX - Win32

问题描述 投票:0回答:1

我把一个Form的HWND子类化的this example作为起点,然后在from here的jrohde代码中添加,该代码旨在让你通过点击它上面的任何地方(而不是标题栏)来拖动一个Form。此代码在ReleaseCapture()line上失败,显示以下消息:E2283 Use . or -> to call '_fastcall TCommonCustomForm::ReleaseCapture()

如果我评论该行代码运行,我可以通过左鼠标移动窗体并拖动,但我不能放过它。鼠标像飞纸一样粘在表格上。如果我用ReleaseCapture()替换ShowMessage我可以爆发,但这显然不是要走的路......

我需要做什么让RestoreCapture()运行?这是Win32应用程序。

以下是我添加到the original开关(uMsg)块的代码:

    // two int's defined above the switch statement
    static int xClick;
    static int yClick;


    // new case added to the switch
    case WM_LBUTTONDOWN:
    SetCapture(hWnd);
    xClick = LOWORD(lParam);
    yClick = HIWORD(lParam);
    break;

    case WM_LBUTTONUP:
    //ReleaseCapture();  // This is the problem spot <------------------------
    ShowMessage("Up");
    break;

    case WM_MOUSEMOVE:
    {
    if (GetCapture() == hWnd)  //Check if this window has mouse input
    {
    RECT rcWindow;
    GetWindowRect(hWnd,&rcWindow);
    int xMouse = LOWORD(lParam);
    int yMouse = HIWORD(lParam);
    int xWindow = rcWindow.left + xMouse - xClick;
    int yWindow = rcWindow.top + yMouse - yClick;
    SetWindowPos(hWnd,NULL,xWindow,yWindow,0,0,SWP_NOSIZE|SWP_NOZORDER);
    }
    break;

谢谢,russ

firemonkey c++builder
1个回答
1
投票

从错误消息中,您可以推导出编译器将函数ReleaseCapture()解析为TCommonCustomForm :: ReleaseCapture()。但是你想调用Win32 API函数ReleaseCapture()。使用::ReleaseCapture();而不是ReleaseCapture();来强制执行此操作。

© www.soinside.com 2019 - 2024. All rights reserved.