tags:

views:

41

answers:

2

I have some C++ Win32 code that I want to call from Ruby. But the code needs to be set up like this

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)

otherwise things don't work right when I try creating windows and stuff. I don't know how to do that with a Ruby extension.

What can I do? Is there some routine I can call from main() to set up the process so my win32 api calls work right?

Edit: (mostly) solved. see my answer.

A: 

I changed the nShowCmd parameter to 10 in the various window-related functions.

Now stuff works just fine... I had just given up when fiddling with hInstance wasn't enough to get it to work.

I can't find much info on nShowCmd though. Why do windows not work when it's 0?

Steven Lu
A: 

ShowWindow() takes an nShowCmd parameter, where 0 means SW_HIDE, ie to hide the window:

http://msdn.microsoft.com/en-us/library/ms633548(VS.85).aspx

Saxon Druce