IRR in Windows Form

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
yellowfever13
Posts: 34
Joined: Thu Aug 17, 2006 10:32 pm

IRR in Windows Form

Post by yellowfever13 »

I have searched irrlicht forums and google for a couple days now. I have tried numerous solutions.

My problem is getting mouse input for irrlicht when in a windows form. I am NOT using irrlicht.net. This is a C++ project.

I am starting the irrlicht loop with this:

Code: Select all

private: System::Void dialog_Load(System::Object^  sender, System::EventArgs^  e) 
			 {
				Manager^ Mgr;
				parenthWnd = (HWND)this->Handle.ToPointer();
				Threading::Thread^ dThread;
				Mgr = gcnew Manager;

				dThread = gcnew Thread( gcnew ThreadStart( Mgr, &Manager::run_main ));
				dThread->Start();
			 }
I have tried putting irrlicht in the parent form, in its own window and in a picture box. And no matter what I do I cannot get mouse inputs. I have attempted to write my own wndproc:

Code: Select all

virtual void WndProc( Message% m ) override
		{
			irr::SEvent irr_event;
			
			switch( m.Msg )
			{
			case WM_MOUSEMOVE:
				{
					irr_event.MouseInput.X = (short)LOWORD( &m.LParam );
					irr_event.MouseInput.Y = (short)HIWORD( &m.LParam );
					irr_event.EventType = irr::EET_MOUSE_INPUT_EVENT;
					device->postEventFromUser( irr_event );
					break;
				}
			case WM_LBUTTONDOWN:
				{
					irr_event.MouseInput.X = (short)LOWORD( &m.LParam );
					irr_event.MouseInput.Y = (short)HIWORD( &m.LParam );
					irr_event.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
					irr_event.EventType = irr::EET_MOUSE_INPUT_EVENT;
					device->postEventFromUser( irr_event );
					break;
				}
			case WM_LBUTTONUP:
				{
					irr_event.MouseInput.X = (short)LOWORD( &m.LParam );
					irr_event.MouseInput.Y = (short)HIWORD( &m.LParam );
					irr_event.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
					irr_event.EventType = irr::EET_MOUSE_INPUT_EVENT;
					device->postEventFromUser( irr_event );
					break;
				}
			case WM_RBUTTONDOWN:
				{
					irr_event.MouseInput.X = (short)LOWORD( &m.LParam );
					irr_event.MouseInput.Y = (short)HIWORD( &m.LParam );
					irr_event.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN;
					irr_event.EventType = irr::EET_MOUSE_INPUT_EVENT;
					device->postEventFromUser( irr_event );
					break;
				}
			case WM_RBUTTONUP:
				{
					irr_event.MouseInput.X = (short)LOWORD( &m.LParam );
					irr_event.MouseInput.Y = (short)HIWORD( &m.LParam );
					irr_event.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;
					irr_event.EventType = irr::EET_MOUSE_INPUT_EVENT;
					device->postEventFromUser( irr_event );
					break;
				}
			}
			Form::WndProc( m );
		}
I have seen many people ask this question, but I never saw any answers in the threads...so is this impossible?

Thanks!
Fashizzle
Post Reply