Results 1 to 6 of 6

Thread: GetDC

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Lightbulb

    Hi..

    Some API's require the
    DC of a device, and not
    the handle!
    Whats the difference
    between the two?
    What does GetDC do?

  2. #2
    Hyperactive Member schuurke28's Avatar
    Join Date
    Feb 2001
    Posts
    402
    don't know what it means but maybe this is useful for u:

    GetDC
    The GetDC function retrieves a handle to a display device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC.

    The GetDCEx function is an extension to GetDC, which gives an application more control over how and whether clipping occurs in the client area.

    HDC GetDC(
    HWND hWnd // handle to window
    );
    Parameters
    hWnd
    [in] Handle to the window whose DC is to be retrieved. If this value is NULL, GetDC retrieves the DC for the entire screen.
    Windows 98, Windows 2000: To get the DC for a specific display monitor, use the EnumDisplayMonitors and CreateDC functions.

    Return Values
    If the function succeeds, the return value is a handle to the DC for the specified window's client area.

    If the function fails, the return value is NULL.

    Windows NT/2000: To get extended error information, call GetLastError.

    Remarks
    The GetDC function retrieves a common, class, or private DC depending on the class style specified for the specified window. For common DCs, GetDC assigns default attributes to the DC each time it is retrieved. For class and private DCs, GetDC leaves the previously assigned attributes unchanged.

    Note that the handle to the DC can only be used by a single thread at any one time.

    After painting with a common DC, the ReleaseDC function must be called to release the DC. Class and private DCs do not have to be released. ReleaseDC must be called from the same thread that called GetDC. The number of DCs is limited only by available memory.

    Windows 95/98: There are only 5 common DCs available per thread, thus failure to release a DC can prevent other applications from accessing one

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    This may be wrong, but to me it seems to be reference to the client area of a form or window! I could be worng though.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Cool.I was right!

    If you dont know what the client area is, take a form and remove borders, menus, caption bars and toolbars and the client area is what's left.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Oh ok.

    So GetWindowRect would get the entire
    windows rect, And GetClientRect would
    get the CLient area of the window!!

    Neat.. Thanks!

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Exactly. Especially useful for taking screenshots of form without the caption bar.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

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