CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    What's a device context?

    Could you tell me in human terms what we are talking about when we refer to a device context/display context.

    Thanks

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: What's a device context?

    Quote Originally Posted by TpOreilly View Post
    Could you tell me in human terms what we are talking about when we refer to a device context/display context.

    Thanks
    When you display output, it has to display on something -- that "something" is the device context. It could be a particular window, a printer, etc.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: What's a device context?

    HDC handleDeviceContext;
    PAINTSTRUCT PaintSt;
    handleDeviceContext= BeginPaint(hWnd, &PaintSt);

    "HDC handleDeviceContext;" - Here we are creating a variable which will be a handle to a device context.

    "PAINTSTRUCT PaintSt;" - Not 100% sure what is stored in here?

    "handleDeviceContext= BeginPaint(hWnd, &PaintSt);" - This is where the device context actually comes from. This function returns a device context.

    So a device context is just a virtual area which we use to paint graphical output.

    Am i right in the above statements?

    Ive got the feeling im not quite right here, but thats why you nice people are willing to clear things up, i hope

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: What's a device context?

    Quote Originally Posted by TpOreilly View Post
    "PAINTSTRUCT PaintSt;" - Not 100% sure what is stored in here?
    Just look at MSDN as to what BeginPaint() does.
    So a device context is just a virtual area which we use to paint graphical output.
    Yes. In addition, see functions such as GetDeviceCaps() as an example. It takes a device context, and returns, given what you're asking for, information on that device context.

    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; April 4th, 2011 at 11:34 PM.

  5. #5
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: What's a device context?

    "PAINTSTRUCT PaintSt;" - Not 100% sure what is stored in here?
    Some years ago 2 guys created a revolution on the internet. It has to do with searching... they called themselves google. Learn to use it.

    PAINTSTRUCT

  6. #6
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: What's a device context?

    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  7. #7
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: What's a device context?

    Seeing as we dont modify the attributes of the PAINTSTRUCT variable, the must be default values. By default does this make the device context area the size of the whole client area?

    (This question is targeted at the rcPaint attribute of the structure)

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