I am having problems creating a window inside a thread. The thread is launched with a funtion from the main application. the LaunchThread() is in a DLL, the DLL also has a function for registering the window using RegisterWindow(), the WndProc and the ThreadProc are also in the DLL.
The thread is created using CreateThread and the ThreadProc calls CreateWindow to create the window, this window will be a user interface for operations that do not interfere with the main application, the window will be launching other threads and such threads will using functions defined in the DLL.
The only connection in between the main application and the DLL is the LaunchThread() function.
//-- Sample code
//-------main application
HANDLE hThread = LaunchThread();
// DLL
HANDLE DLLEXPORT LaunchThread()
{
// Create the theard
}
VOID ThreadProc(LPVOID lParam)
{
// Create the window using CreateWindow
// Message loop in here
}
2006-06-13
17:16:58
·
1 answers
·
asked by
gravit9
2
in
Computers & Internet
➔ Programming & Design
The HWND returned by CreateWindow() is NULL, but GetLastError() returns 0.
2006-06-13
17:39:04 ·
update #1
In the previous version of the software I am developing I was using MFC and I created the windows using AfxBeginThread.
I was also able to make it work using a dialog box, but I want to improve the GUI and MFC doesn't cut it, .NET is too much overhead so I opted for SDK.
The idea is that the main application has to process operations that take long , so I have to make the operations in a separate thread, there is a GUI for such operations, that's the reason why the window has to be in a different thread.
The window itself creates more threads from the WndProc, but this is outside the scope of this problem.
All this code goes into a DLL because the entire application is built in modules, so I want its module to have its own GUI.
I know I must be doing wrong and this thing doesn't have enough space to post code.
If I can find a different way to show more code I am willing to even email some code.
2006-06-14
15:29:06 ·
update #2