CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2001
    Posts
    391

    Question Possible to Draw A Standard Control Into a DC?

    Just wondering, is there a way to draw a standard control (such as a button, a group box, a radio button) into an arbitrary memory DC? In other words, if i call this certain API Windows will draw all the required visual appearance for that standard control into my provided device context. I could have sworn i saw an api that did this but i cant find it anymore

    Thanks in advance

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: Possible to Draw A Standard Control Into a DC?

    yes you can do it, and the api is still live and kicking
    DrawFrameControl(..)

    Cheers
    Last edited by golanshahar; August 13th, 2005 at 11:12 AM.
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    Dec 2001
    Posts
    391

    Question Re: Possible to Draw A Standard Control Into a DC?

    Hi golanshahar, thanks for the quick reply. I did see this api but was a little concerned that it didnt have a feature to draw group boxes. Baffling as that may be. Can you tell me is there such an api that can draw group boxes too, as DrawFrameControl(..) seems to draw everything else but htat.

    Thanks again

  4. #4
    Join Date
    May 2005
    Posts
    4,954

    Re: Possible to Draw A Standard Control Into a DC?

    well i dont know of other function however its pretty easy to draw it yourself here i made you a function that draw GroupBox ( just for you ) it looks the same i checked it out.

    Code:
    void DrawGroupBox ( HWND hWnd, const RECT &rc )
    {
      HDC dc = ::GetDC(hWnd);
      HBRUSH hBrush = ::CreateSolidBrush(RGB(255,255,255));
      ::FrameRect(dc,&rc,hBrush);
      RECT rcTmp = rc;
      ::InflateRect(&rcTmp,1,1);
      ::FrameRect(dc,&rcTmp,hBrush);
    
    
      ::DeleteObject(hBrush);
       hBrush = ::CreateSolidBrush(RGB(128,128,128));
      ::InflateRect(&rcTmp,-1,-1);
      rcTmp.top-=1;
      rcTmp.left-=1;
       ::FrameRect(dc,&rcTmp,hBrush);
      ::DeleteObject(hBrush);
    
      ::ReleaseDC(hWnd, dc);
    }
    just send it the HWND of the window you want to draw it and the rect of the group box.
    hope it helps.

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  5. #5
    Join Date
    Dec 2001
    Posts
    391

    Re: Possible to Draw A Standard Control Into a DC?

    hahaha thanks a lot golanshahar. Ill rate ya!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured