I need your help. What is the trick to creating transparent bitmaps in Developer Studio? I would like to create bitmaps that blend in to the gray color of the dialog box that contains them.
I don't think you can create transparent bitmaps, but you can give a try of creating an icon of custom size; never tried it myself though.
I had read that the color you used for the upper left corner pixel was made "transparent" in icons, but I have never been able to get this to work myself. There must be something else I missed...
You can draw a transparent bitmap by creating a mask for the bitmap which you want to display with a transparent background. Attached is an example of the code for displaying the bitmap.
use dfwinainteger*4 hDCBitMap,hbmBullseye,hbmBullseyeMaksinteger*4 hDC,iHPosition,iVPosition
hbmBullseye = LoadBitmap(ghModule,IDB_BULLSEYE)hbmBullseyeMask = LoadBitmap(ghModule,IDB_BULLSEYE_MASK)hDCBitMap = CreateCompatibleDC(hDC)ret = SelectObject(hDCBitMap,hbmBullseyeMask)ret = BitBlt (hDC, iHPosition, iVPosition, 15, & 15,hDCBitMap, 0, 0, SRCAND) ret = SelectObject(hDCBitMap,hbmBullseye)ret = BitBlt (hDC, iHPosition, iVPosition, 15, & 15,hDCBitMap, 0, 0, SRCPAINT) ret = DeleteDC(hDCBitMap)
You need to initialize iHPosition and iVPosition according to where you want the bitmap to be displayed. I don't know if this is what you are looking for, but you should be able to modify it for your dialog boxes. This particular bit of code was used to paint a bullseye bitmap on a graph in the main window.
Unfortunately, for some reason, I am not able to attach files to this message, otherwise, I would attach the sample bitmap and mask.
If you want to attach a file of a type not accepted by the forum, put it in a ZIP archive and attach that.
Here are the bitmaps that go with my reply.
Regarding the Icon Editor in Visual Studio, the bit of the in-line help regarding this says
Choosing an Opaque or Transparent BackgroundHome Page (Graphics Editor) | Overview | How Do I ... Topics
When you move or copy a selection from a cursor or icon, any pixels in the selection that match the current background color are, by default, transparent: they do not obscure pixels in the target location. A custom brush behaves in the same way.
To toggle the background-color transparency
In the Graphics toolbar option selector, click the appropriate button:Opaque background: existing image is obscured by all parts of the selection.
Transparent background: existing image shows through parts of the selection that match the current background color. You can change the background color while a selection is already in effect to change which parts of the image are transparent.
I think that the background colour is set within the "Colors" toolbar where there are two small "terminal screen" icons (green or pink). In addition when in the Icon Editor, there is an "Image" menu on the main toolbar containing a "draw opaque" option which I think is what controls whether the background is counted as transparent or not when finally drawn within a toolbar.