Thread: design flaw

  1. #1
    Madly in anger with you
    Join Date
    Nov 2005
    Posts
    211

    design flaw

    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.
    Last edited by Bleech; 10-23-2007 at 03:23 PM.

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    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.

  3. #3
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    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).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Design flaw in C++?
    By @nthony in forum C++ Programming
    Replies: 24
    Last Post: 10-20-2008, 07:47 PM
  2. Implementing Inheritence into your design
    By bobthebullet990 in forum C++ Programming
    Replies: 6
    Last Post: 08-05-2006, 04:40 PM
  3. linked list of templates (or a design flaw?)
    By Ess in forum C++ Programming
    Replies: 3
    Last Post: 11-30-2002, 08:15 PM
  4. is this a design flaw
    By blight2c in forum C++ Programming
    Replies: 5
    Last Post: 03-20-2002, 12:33 AM