CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2002
    Location
    India,bangalore
    Posts
    295

    GetClipBox & GetBoundsRect ?

    hi all,

    i need the width and height of the CDC object so i tried this

    CRect rc;
    CString str;

    m_MemDC.SetBoundsRect(&rc,DCB_SET|DCB_ENABLE);

    for ( int i = 0 ; i < 500 ; i+=10 )
    {
    str.Format("done -%d",i);
    m_MemDC.TextOut(0,i,str);
    }

    m_MemDC.GetBoundsRect(&rc,DCB_ACCUMULATE|DCB_ENABLE );

    m_MemDC.GetClipBox(&rc);

    i tried to User GetBoundsRect and GetClipBox of CDC but was not able to get the actual
    width and height of the CDC.

    -GetClipBox get only the ctrl width and height
    -GetBoundsREct gets the width and height only if it is less than ctrl width

    is there some way to get or it is not possible at all

    eagerly waiting for a solution

    thanks
    rajeev

  2. #2
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    182
    The width and the height you can get from the window. Obviously somewhere you wrote something like HDC hDC = ::GetDC(m_hWnd);
    Good luck

  3. #3
    Join Date
    Jun 2002
    Location
    India,bangalore
    Posts
    295
    hi Caprice,
    thanks for the reply

    Here i am talking about the MemoryDc area ( rectangle )not the window rectangle.

    thanks ahead
    rajeev

  4. #4
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815
    GetBoundsRect() and GetClipBox() both deal with the temporary clipping region, which changes as parts of the DC get validated or invalidated. A DC has no "size" as such, as it is a virtual drawing context which is either assigned to a physical device (like screen or printer), or an offscreen bitmap (in the case of a memory DC). In the first case, the "bounds" of the DC are the physical bounds of the device or the window bounds. In the second case, the "size" of the DC is determined by the size of the bitmap you select into it to do the offscreen drawing.

  5. #5
    Join Date
    Jun 2002
    Location
    India,bangalore
    Posts
    295
    hi gstercken,

    thanks for the reply.

    I Got it.


    cheers
    rajs

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