Thread: HDC of a child window

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    162

    HDC of a child window

    Hello

    My title may sound weird because I have no idea if there is such a thing like HDC of a child (static) window or the only HDC is available for main window.

    If yes how do I retrieve the handle I tried already

    Code:
    HDC hChildWindowDC;
    
    hChildWindowDC = GetDC(hWnd_ChildWindow);
    But this apparantly didnt work. Is there some other way?

    Why do I need this? Basically I need to put some text on the child static window but I dont want to create other child static windows so I need to retrieve the handle.
    If there is better how to solve this please tell me

    Thank you

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Explain "didn't work". Do you get a handle back, or a NULL-value. If you get a NULL, what does GetLastError() give?

    If it's not the above problem, describe what happens, and how that is different from what you expected.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The device context for a child window is usually that of its parent; this is definitely the case for a static control.

    Basically I need to put some text on the child static window
    Is there some reason why you can't use SetWindowText/WM_SETTEXT?
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    162
    Seems it works with the main Window (hDC). I must have missed that before.

    So the text is drawn where it is supposed to be but it keeps being overdrawn by the static window.
    How do I draw the text over the static window then?
    Last edited by Gordon; 05-29-2008 at 02:04 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My progress.. thnx to Cprogramming forumites
    By csonx_p in forum Windows Programming
    Replies: 6
    Last Post: 05-21-2008, 01:17 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  3. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM