I have created a dialog box with a button which has a bitmap skin but the

problem is that the bitmap dosent seem to fit the butttons size how can i

make the bitmap either stretch or shrink according to my requirements???
Posted on 2003-04-26 09:59:38 by telophase
well as far as i know there is no diference between a window made on a RC file or
by CreateWindowexA .


both got ID and Handles so o got all to skin a bitmap must be BS_OWNERDRAW

i think in RC

you can also use in the initdilaog section and make the buttons with CreateWindow


1 - CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.


call CreateCompatibleDC,
mov ,eax

2-SelectObject function selects an object into the specified device context. The new object replaces the previous object of the same type.

call SelectObject ,,



3- The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. Windows stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.

BOOL StretchBlt(

HDC hdcDest, // handle of destination device context
int nXOriginDest, // x-coordinate of upper-left corner of dest. rect.
int nYOriginDest, // y-coordinate of upper-left corner of dest. rect.
int nWidthDest, // width of destination rectangle
int nHeightDest, // height of destination rectangle
HDC hdcSrc, // handle of source device context
int nXOriginSrc, // x-coordinate of upper-left corner of source rectangle
int nYOriginSrc, // y-coordinate of upper-left corner of source rectangle
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
DWORD dwRop // raster operation code
);


well i hope i help you some thing ... :(
Posted on 2003-04-26 12:32:04 by Nguga
But there are so many complications like to give height and width of the new button etc...
Can u suggest a simple way?
Posted on 2003-04-28 02:31:48 by telophase

well as far as i know there is no diference between a window made on a RC file or
by CreateWindowexA .

There's one particular quirk... RC files work with Dialog Units, while CreateWindow uses pixels. Especially the difference between "small fonts" and "large fonts" display settings make this difference important.
Posted on 2003-04-28 02:52:24 by f0dder
If you use a resource editor it will does the dialog unit to pixel conversions for you and will save you a trip through dialog unit hell. Generally a dialog unit is calculated as follows :

Use GetDialogBaseUnits to obtain the base unit multiplier, the low word of the return is baseunitX and the high word is baseunitY, then the following formula :

templateunitX = (pixelX * 4) / baseunitX
templateunitY = (pixelY * 8) / baseunitY

If you're calculating an actual dialog and not just a control, that's where hell comes in. You must process the frame flags and add those as well. If you set the font in the resource then you must use GetTextMetric to obtain you base units for that font.

Best thing to do is to just use a dialog editor and let somebody else do the work for you.
Posted on 2003-04-28 07:50:22 by donkey