Creating a window inside a dll

Started by
7 comments, last by Red_falcon 18 years, 3 months ago
Hi, As the topic says, I'm trying to create a directX window inside a dll, but it isn't working as I want it to. I´m not sure if it is a directX issue, but when I put the same code in a exe project it works. This is what happens, I create the window and a d3d device and start the message loop which looks like this:

MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
        if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
        {
	  TranslateMessage( &msg );
	  DispatchMessage( &msg );
	}
	else
	{
	  RenderFrame();
	}
}

The PeekMessage seems to always return true, but not in the exe-project? I've searched these forums and found articles about dll renderer, but it didn't solve my problem. Help anyone?
Advertisement
Had same problem, it is not a direct3d issue. Create App class outside of render dll and place window creation and message loop in it ( this is the way most render engines are written - as far as i know ). Inside App class you should call render functions exposed by dll. Hope this helps. As for the reason why it doesn't work from dll, i am not shure ( i guess it has something to do with the way dll works. )
Ok, thanks for the info!
My engine is in a dll and window creation is within too
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish
could you post some code? or care to explain? :)
Quote:Original post by Red_falcon
My engine is in a dll and window creation is within too


What about message loop function?
Message loop is of course in the main.cpp of my appication, which uses the engine dll. There is no other way around, cause every application has its own specific loop requirements

edit: Tell me which part of code, cause i must get it from my laptop first
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish
Ok, I thought you created everything in the dll. I got it working with the messageloop and wndproc callback in a dll. It's not just a renderer, I'm working on a gameengine. I just had to create the Window in main application.. it's a bit ugly cause I export the WndProc so when I create the windowclass I have to do this Engine::WndProc to get adress... I'll see when I find a better solution. Just tired of this issue right now :P
My engine is compiled in a dll, but i use singleton classes for window and renderer(opengl), cause the advantage to modify from every point of the app or engine, secondly i dont need more windows if i go fullscreen. So i mustn't create window all time as i start new projects.

I use something like that for creation:

engWindow *win 0 new engWindow("Test",0,0,640,480,hInst);
win->Create();
win->Show(true);

also is the initialization of the renderer in this style, so i get off the work to write it allways new.
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish

This topic is closed to new replies.

Advertisement