Graphics.FromHWND method

Applies to: desktop apps only

The Graphics::FromHWND method creates a Graphics object that is associated with a specified window.

Syntax

static Graphics* FromHWND(
  [in]  HWND hWnd,
  [in]  BOOL icm
);

Parameters

hWnd [in]

Type: HWND

Handle to the window that will be associated with the new Graphics object.

icm [in]

Type: BOOL

Optional. Boolean value that specifies whether the new Graphics object applies color adjustment according to the ICC profile associated with the display device. TRUE specifies that color adjustment is applied, and FALSE specifies that color adjustment is not applied. The default value is FALSE.

Return value

Type:

Type: Graphics*

This method returns a pointer to the new Graphics object.

Examples

The following function calls Graphics::FromHWND to create a Graphics object that is associated with a window. The call to the Graphics::DrawLine method of that Graphics object draws a line in the window.


VOID Example_FromHWND(HWND hWnd)
{
   Graphics* graphics = Graphics::FromHWND(hWnd);
   Pen pen(Color(255, 0, 0, 255));
   graphics->DrawLine(&pen, 0, 0, 200, 100);
   delete graphics;
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusgraphics.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Graphics
Graphics::GetHDC
FromHDC Methods
Graphics::FromImage
Graphics Constructors
Changes in the Programming Model

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show: