カスタム .NET ref クラスを使用してボタン システムを制御しようとしています。親フォームに追加されるクラス内の PictureBox で構成されます。クリックを検出すると、親クラス内のメソッドであるコンストラクターで指定された関数を呼び出す必要があります。
例えば:
//in the custom class file
public ref class CButton {
private: void (*callingproc)(void);
public:
CButton(void (*cproc)(void)) {
callingproc = cproc;
}
button_dowork() {
//do our code to detect if the click was in the right place and call our proc
callingproc();
}
};
//in the form.h
void cp(void) {
//do our form work
}
void Form_CreateCButton() {
CButton^ t = gcnew CButtom(cp);
}
上記の場合、「 &ns::form::cp を使用してメンバーへのポインターを作成する」という行に沿ってエラーが発生し、その後に「ポインターからメンバーへのポインターがマネージド クラスに対して無効です」というエラーが発生します。何か案は?