恢复捕获 FMX - Win32

RestoreCapture FMX - Win32

我选择了 of subclassing a Form's HWND as a starting point and then added in jrohde's code from from here,它旨在让您通过单击表单上的任意位置(而不是标题栏)来拖动表单。此代码在 ReleaseCapture() 行失败并显示以下消息:E2283 Use . or -> to call '_fastcall TCommonCustomForm::ReleaseCapture()

如果我注释掉代码 运行s 并且我可以通过鼠标左键拖动来移动表格,但我不能放手。鼠标像粘蝇纸一样粘在窗体上。如果我用 ShowMessage 替换 ReleaseCapture() 我可以突破,但这显然不是要走的路...

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

下面是我添加到 switch(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;

谢谢,拉斯

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