简体   繁体   中英

How can I draw an image in a static area in an MFC dialog?

In an MFC dialog I have a static area and assigned an id: IDC_STATIC . How can I connect this IDC_STATIC id with the handler ( HWND ) such that my image will draw inside the static text area?

HWND   g_hWnd3      = NULL;
HDC    g_hDC3       = NULL;

g_hDC3 = ::GetDC( g_hWnd3 );

How can I pass the static text id as a GetDC() argument?

You should consider deriving your own class from CStatic. The advantage to this approach is that you can control all of the rendering to the control from one self contained class. In particular, if you define the static control with the SS_OWNERDRAW style, you will be able to handle its rendering in CStatic::DrawItem . When DrawItem is called, you will receive a pointer to the DrawItemStruct, which has embedded in it, a handle to the control's DC that you can use to render into the control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM