0

良い一日。
FireBreathでプラグインを書いています。C ++の知識が不足しているため、小さな問題が発生しました。以下のコードを参照してください。

なぜ関数FB::PluginWindowWin::getBrowserHWND()が返されるのか理解できませんが、関数は機能HWND したくないのです。HWNDGetWindowRect(hWnd, &rect)

コンパイラFBはから下線を引きFB::PluginWindowWin::getBrowserHWND()、「メンバーの非静的リンクはオブジェクトを設定するのではなく指定する必要がある」と言っています(これは私の翻訳です。メッセージはロシア語ですが、それでも同じ意味があると思います)

このエラーが発生しました:

Error C2352 FB::PluginWindowWin::getBrowserHWND:illegal call of non-static member function

コード:

TestPlugin.cpp
#include "Win/PluginWindowWin.h" 
#include "JSObject.h"
#include "variant_list.h"
#include "DOM/Document.h"
#include "global/config.h"
#include <Windows.h>
#include "TestPluginAPI.h"

///////My Functions////////

FB::variant PosTest()
{
RECT rect; 
HWND hWnd;
hWnd = FB::PluginWindowWin::getBrowserHWND();
if(GetWindowRect(hWnd, &rect))
    {

  int width = rect.right - rect.left;
  int height = rect.bottom - rect.top;
  int left = rect.left;
      return left;
    }
}


TestPlugin.h
#include "Win/PluginWindowWin.h"
#include <string>
#include <sstream>
#include <boost/weak_ptr.hpp>
#include "JSAPIAuto.h"
#include "BrowserHost.h"
#include "TestPlugin.h"
#include <Windows.h>

/////Declarations/////

//Rect
BOOL WINAPI GetWindowRect(HWND hWnd, LPRECT lpRect);

//Pos Test
FB::variant PosTest(); 
4

2 に答える 2

4

そのエラーは、それがメソッドでgetBrowserHWND()はないことを示しているstaticため、それを呼び出すにはオブジェクトインスタンスが必要です。

つまり、次のようなタイプのオブジェクトが必要です。次のFB::PluginWindowWinように呼び出すことができます。

hWnd = myPluginWindowWin.getBrowserHWND();
于 2013-03-26T18:11:33.403 に答える
1

このコードは私にとって非常にうまく機能します:

HWND myPluginAPI::getBrowserHwnd() {
    FB::PluginWindow* pluginWindow = getPlugin()->GetWindow();
    FB::PluginWindowWin* w = (FB::PluginWindowWin*)(pluginWindow);
    HWND hwndBrowser = GetAncestor( w->getHWND(), GA_ROOTOWNER );
    return hwndBrowser;
}
于 2013-03-27T09:48:28.550 に答える