c++ - Windows api get client dc bitmap size -
i use following code size of bitmap bound windows mfc view window's client area dc:
void cview::ondraw(cdc* ) { cdc *pdc = getdc(); bitmap bmpheader; memset( &bmpheader, 0, sizeof(bitmap)); hgdiobj hbmp = getcurrentobject(pdc->m_hdc, obj_bitmap); getobject(hbmp,sizeof(bitmap), &bmpheader); int bmpwidth = bmpheader.bmwidth; int bmpheight = bmpheader.bmheight; ... }
according msdn getdc() gets client area dc:
retrieves pointer common, class, or private device context client area depending on class style specified cwnd
so suppose bmpwidth , bmpheight should same size client area rect. isn't. appears size of entire window including toolbar area , menu area. doing wrong here?
there no bitmap in there. use getclientrect
find , height of client area. use cdc* provided, or else try cclientdc dc(this)
. in case drawing should this:
void cmyview::ondraw(cdc* dc) { crect rc; getclientrect(&rc); dc->fillsolidrect(rc, rgb(0, 0, 255)); }
bitmap object not return information window. use window functions information windows.
most window functions have equivalent in mfc. example,
in winapi: getclientrect(hwnd hwnd, lprect rc);
in mfc: cwnd::getclientrect(lprect rc);
Comments
Post a Comment