I'm not sure what you're after here, your post isn't worded particularly clearly. But if I understand correctly, and from looking at your code, I think you may have got things a little mixed up here.
The OnButtonStart() function is definitely a C++ function. So no real problems there (other than the use of printf!). But the JNIEXPORT line defines a C++ function which can only be called from Java using JNI (at least as far as I can tell! I could be wrong!).
So are you saying you want to be able to call the C++/JNI function from OnButtonStart(), rather than calling it from Java? If so you might want to consider moving/refactoring the C++ code in the JNI function into a new function and then calling that in the JNI function AND in OnButtonStart.
e.g.
// make this a public static member of
// whatever class m_DeviceID is a member of
void yourclass::SetDeviceID()
{
m_DeviceID = StartUp( GetConsoleHwnd2(), WM_VX);
}
Then in your dialog code:
void CVentanasDlg::OnButtonStart(){
std::cout << "OnButtonStart");
yourclass::SetDeviceID(); // call your new function here!
}
And likewise in the JNI function:
JNIEXPORT void JNICALL Java_JniComm_openDevice(JNIEnv *env, jobject obj){
yourclass::SetDeviceID(); // Call the new function here...
}
This would allow the functionality inside the SetDeviceID() function to be called from Java via the JNI function and directly from OnButtonStart.
BTW: The above snippets assume that the new function is a public static function in an external class called yourclass. …