Mercurial > dwindows
diff os2/dw.c @ 1658:6fe1e91da477
Added DW_POINTER() macro for casting parameters to (void *)
Fixed issues with calculating buttons sizes with icons instead of bitmaps on OS/2 and Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 16 Apr 2012 15:43:43 +0000 |
parents | 3d4066aab4e0 |
children | fc135161f2b1 |
line wrap: on
line diff
--- a/os2/dw.c Tue Apr 10 21:19:11 2012 +0000 +++ b/os2/dw.c Mon Apr 16 15:43:43 2012 +0000 @@ -5002,20 +5002,41 @@ /* Handle bitmap buttons */ if(dw_window_get_data(handle, "_dw_bitmapbutton")) { - WNDPARAMS wp; - BTNCDATA bcd; - - wp.fsStatus = WPM_CTLDATA; - wp.cbCtlData = sizeof(BTNCDATA); - wp.pCtlData = &bcd; - - /* Query the button's bitmap */ - if(WinSendMsg(handle, WM_QUERYWINDOWPARAMS, (MPARAM)&wp, MPVOID) && bcd.hImage) + HPOINTER hpr = (HPOINTER)dw_window_get_data(handle, "_dw_button_icon"); + HBITMAP hbm = 0; + + /* Handle case of icon resource */ + if(hpr) + { + POINTERINFO pi; + + /* Get the internal HBITMAP handles */ + if(WinQueryPointerInfo(hpr, &pi)) + hbm = pi.hbmColor ? pi.hbmColor : pi.hbmPointer; + } + + /* If we didn't load it from the icon... */ + if(!hbm) + { + WNDPARAMS wp; + BTNCDATA bcd; + + wp.fsStatus = WPM_CTLDATA; + wp.cbCtlData = sizeof(BTNCDATA); + wp.pCtlData = &bcd; + + /* Query the button's bitmap */ + if(WinSendMsg(handle, WM_QUERYWINDOWPARAMS, (MPARAM)&wp, MPVOID) && bcd.hImage) + hbm = bcd.hImage; + } + + /* If we got a bitmap handle */ + if(hbm) { BITMAPINFOHEADER2 bmp; bmp.cbFix = sizeof(BITMAPINFOHEADER2); /* Get the parameters of the bitmap */ - if(GpiQueryBitmapInfoHeader(bcd.hImage, &bmp)) + if(GpiQueryBitmapInfoHeader(hbm, &bmp)) { thiswidth = bmp.cx; thisheight = bmp.cy;