Problems with WinAPI Drop-down List & Threads
category: code [glöplog]
So... I've been facing this issue for a week and I couldn't find the problem.
I'm creating a GUI library and there are some details of its implementation that may be important:
Every window has a different thread and there is this thing with the Windows message architecture... You cannot send/receive a message to/from another thread... Or something like that. To solve this problem (maybe partially, because I still cannot create a child window in the main process ), I used the AttachThreadInput function.
The problem is: When I click at the combobox to drop it down, the program stops... I can't understand why it is happening. Would someone try to help me? :(
Here's the code with both codeblocks and msvc projects:
www.silexars.com/GUI.zip
I'm creating a GUI library and there are some details of its implementation that may be important:
Every window has a different thread and there is this thing with the Windows message architecture... You cannot send/receive a message to/from another thread... Or something like that. To solve this problem (maybe partially, because I still cannot create a child window in the main process ), I used the AttachThreadInput function.
The problem is: When I click at the combobox to drop it down, the program stops... I can't understand why it is happening. Would someone try to help me? :(
Here's the code with both codeblocks and msvc projects:
www.silexars.com/GUI.zip
1.) there is no such file at the given URL :)
2.) You can use PostThreadMessage to send messages from one thread to another, you just need the thread id (you can offer such a function in your handling class so you do not need to handle with thread ids) -> maybe this might help: http://www.codeproject.com/Articles/225755/PostThreadMessage-Demystified
(maybe not, just a quick g00gl3)
3.) You have to start a "message pump" for each window/thread combination.
that might be the cause of your combobox problem (without seeing your code at all) !?
if this all doesn't help or meet your problem -> just ignore :P
2.) You can use PostThreadMessage to send messages from one thread to another, you just need the thread id (you can offer such a function in your handling class so you do not need to handle with thread ids) -> maybe this might help: http://www.codeproject.com/Articles/225755/PostThreadMessage-Demystified
(maybe not, just a quick g00gl3)
3.) You have to start a "message pump" for each window/thread combination.
that might be the cause of your combobox problem (without seeing your code at all) !?
if this all doesn't help or meet your problem -> just ignore :P
Quote:
(you can offer such a function in your handling class so you do not need to handle with thread ids)
argh :/ that sentence will visit my dreams tonight... raw semi-pseudo example:
Code:
class Window
{
private:
int threadId;
public:
bool sendMessage(UINT msg, WPARAM wParam, LPARAM lParam)
{
return (TRUE==PostThreadMessage(threadId, msg, wParam, lParam));
}
}
In general, I would advise avoiding any UI work outside of main thread as many UI win API methods are not truly thread safe.
Also, I normally only use message for worker thread to main thread synchronization, that's eliminates the need to create random message pumps everywhere.
But that's only me, I'm sure others will have a different ideas...
Also, I normally only use message for worker thread to main thread synchronization, that's eliminates the need to create random message pumps everywhere.
But that's only me, I'm sure others will have a different ideas...
My intention was to help Danguafer with his actual problem. Yours to point him in another direction. And believe me when I say: I second you :D
Oh, boy! Sorry xD I already fixed it. :)
I don't know why I didn't used this method, but maybe it was because mingw is lacking some winapi functions.
I don't know why I didn't used this method, but maybe it was because mingw is lacking some winapi functions.
And someone please mark this topic as residue. :P
I was just really annoyed with this stupid bug.
I was just really annoyed with this stupid bug.