okay, so I have a dialog box which is used as the main window for my app. for the dialog box's WM_INITDIALOG message I am creating a thread. the thread does some stuff, and then sends a message to a control on the dialog to adjust its font weight.
the problem seems to be that sometimes the message to adjust the font weight of the control is being sent before the WM_INITDIALOG message has been fully processed (before the dialog box appears). when this happens, the code to adjust the font weight doesn't work, I have to minimize and maximize the dialog box to see the change. this only happens sometimes, and depends on a number of factors, however I am 100% sure that this is the problem (I tried adding a MessageBox in the thread function before calling the function that adjusts the control's font weight, and found that the MessageBox sometimes appears before the dialog box does, and in these cases the font weight is not changed). the function that adjusts the control's font weight uses SendMessage, sending WM_SETFONT.
I've thought of adding a Sleep statement in my thread function, but that would be my last resort. basically I need a way to make sure that the function that changes the font weight is executed after the WM_INITDIALOG message has been fully processed, but I can't think of how I can do this.
any suggestions or advice here would be appreciated. thank you in advance.
This probably is not the proper way to do this, but you could have a SendMessage() at the very end up WM_INITDIALOG to go to some other message, so that way WM_INITDIALOG would finish by the time the other message is called. Just a thought, though.
That's the way I do it, except I use PostMessage to make sure it gets processed after WM_INITDIALOG, SendMessage will cause it to finish before WM_INITDIALOG finishes (since its an immediate process & return).