【问题标题】:RestoreCapture FMX - Win32恢复捕获 FMX - Win32
【发布时间】:2018-12-09 01:32:58
【问题描述】:

我以this example 对表单的 HWND 进行子类化作为起点,然后添加了来自 from here 的 jrohde 代码,该代码旨在让您通过单击表单的任意位置(而不是标题栏上)来拖动表单。此代码在 ReleaseCapture()line 上失败,并显示以下消息:E2283 Use . or -> to call '_fastcall TCommonCustomForm::ReleaseCapture()

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

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

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

谢谢,拉斯

【问题讨论】:

    标签: firemonkey c++builder


    【解决方案1】:

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

    【讨论】:

    • 就是这样。谢谢克劳斯。我曾以为我需要一个完全限定的命名空间,但我不知道它会是什么。是否有一些文档描述了前缀 :: 在像这样单独使用时正在做什么?
    • :: 左边没有任何标识符,指的是全局命名空间。
    • 而且Win32 API是基于C的API,不是基于C++的API,所以它根本不使用命名空间,一切都在C++的全局命名空间中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-06
    • 2019-07-03
    • 2019-05-20
    • 1970-01-01
    • 1970-01-01
    • 2019-05-03
    • 1970-01-01
    相关资源
    最近更新 更多