Skip to content

Instantly share code, notes, and snippets.

@Kogarasi
Last active June 27, 2018 03:07
Show Gist options
  • Save Kogarasi/5e71636e38d21203210ad6316d82d537 to your computer and use it in GitHub Desktop.
Save Kogarasi/5e71636e38d21203210ad6316d82d537 to your computer and use it in GitHub Desktop.
make_c_function
#include <functional>
#include <windows.>
template <typename F> struct c_function {
static void called( HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ){
destFunction( hMidiIn, wMsg, dwInstance, dwParam1, dwParam2 );
}
static F destFunction;
};
template <typename F> F c_function<F>::destFunction;
template <typename Function, typename F> Function make_c_function( F func ){
c_function<F>::destFunction = func;
return &c_function<F>::called;
}
int main(){
auto MidiInProc = make_c_function<void(*)(HMIDIIN, UINT, DWORD, DWORD, DWORD)>(
std::function<void(HMIDIIN,UINT,DWORD,DWORD,DWORD)>(
std::bind(
&AppMA::MidiInProc,
/* AppMAインスタンスへのポインタ*/,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3,
std::placeholders::_4,
std::placeholders::_5
)
)
);
//midiInOpen(&hMidiIn, wSelDev, (DWORD)MidiInProc, NULL, CALLBACK_FUNCTION)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment