首页 文章

RestoreCapture FMX - Win32

提问于
浏览
0

我从from here中获取了this example的子类化Form 's HWND as a starting point and then added in jrohde' s代码,该代码旨在让您通过单击任何位置(而不是 Headers 栏)来拖动一个Form . 此代码在 ReleaseCapture() 行上失败并显示以下消息: E2283 Use . or -> to call '_fastcall TCommonCustomForm::ReleaseCapture()

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

我需要做什么才能让 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

1 回答

  • 2

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

相关问题