X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b95edd4708105589d03267b5932f3a42e89b0d06..ee3510132b8b4160f848bd4f502a6f5315f90dbc:/src/msw/dc.cpp?ds=inline diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 0a75fced54..09d21ad3d0 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1923,8 +1923,30 @@ void wxDC::DoGetSizeMM(int *w, int *h) const if (!GetHDC()) return; #endif - if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZSIZE); - if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTSIZE); + // if we implement it in terms of DoGetSize() instead of directly using the + // results returned by GetDeviceCaps(HORZ/VERTSIZE) as was done before, it + // will also work for wxWindowDC and wxClientDC even though their size is + // not the same as the total size of the screen + int wPixels, hPixels; + DoGetSize(&wPixels, &hPixels); + + if ( w ) + { + int wTotal = ::GetDeviceCaps(GetHdc(), HORZRES); + + wxCHECK_RET( wTotal, _T("0 width device?") ); + + *w = (wPixels * ::GetDeviceCaps(GetHdc(), HORZSIZE)) / wTotal; + } + + if ( h ) + { + int hTotal = ::GetDeviceCaps(GetHdc(), VERTRES); + + wxCHECK_RET( hTotal, _T("0 height device?") ); + + *h = (hPixels * ::GetDeviceCaps(GetHdc(), VERTSIZE)) / hTotal; + } } wxSize wxDC::GetPPI() const