mIRC Home    About    Download    Register    News    Help

Print Thread
Calling Bitmap Resources from a DLL File #57618 26/10/03 01:01 PM
Joined: Dec 2002
Posts: 43
C
Cypris Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Dec 2002
Posts: 43
I need help on callling a .bmp fiile from a dll's Resource.
I have alreafdy figured out how to Make a DLL that has ICONS that you can call, that was simple, and adding the BMP Files into the Resouurce list was easy too, Visual C++ 6 made that part simple, but the only thing i cant (and that i desperately need) is a way of Calling bitmaps... im sure it can be done. Anyone have any ideas?


-Cypris
Re: Calling Bitmap Resources from a DLL File #57619 27/10/03 06:26 AM
Joined: Oct 2003
Posts: 38
T
TheXenocide Offline
Ameglian cow
Offline
Ameglian cow
T
Joined: Oct 2003
Posts: 38
the LoadImage() API can load resource BMPs (it returns a handle to the file in memory)

You can use that handle in a number of ways :P


-TheXenocide
ParseMPopup
Re: Calling Bitmap Resources from a DLL File #57620 28/10/03 12:30 PM
Joined: Dec 2002
Posts: 43
C
Cypris Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Dec 2002
Posts: 43
How could i use that handle in mIRC? say forinstance how when you load an icon lmage for a dialog control' icon', and the ID is 37, the dialog is file.sharing:

/did -g file.sharing 37 0 $mircdirimages.dll

this will set the first icon in the list.. anything i can do similar what what u mentioned?
(say if my last image is 4, can i make the bmp be 5?)


-Cypris
Re: Calling Bitmap Resources from a DLL File #57621 28/10/03 08:18 PM
Joined: Jun 2003
Posts: 195
N
Narusegawa_Naru Offline
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
it really depends on what you intend to do with the image itself. Many functions that handle drawing require a handle to the image in this case an HBITMAP. For a bitmap with multiple images i would suggest an image list (look into the ImageList_Create macro). it has functions that allow you to load a bitmap in sections based on the cx and cy (width and height) of the image list. for example if you specify a 32x32 image list then load a 320x32 bitmap into it you will end up with 10 images in the list. You can also use the image list for drawing (look into the ImageList_Draw and ImageList_DrawIcon functions). The most common way to draw a bitmap would be first obtain the dc (device context) to the window you wish to draw in. then create a similar dc (CreateCompatibleDC) then load the bitmap into the new dc (SelectObject). then call the BitBlt function specifying the new dc as HdcSrc and the windows dc as HdcDest. Note however that the next time the window recieves a WM_PAINT message (more importantly a WM_ERASEBKGND msg) what you have draw MUST be redrawn otherwise it will be overdrawn.

Depending on how you wish to display the image determines wich function to call. to specify that an image be drawn with its normal size or in a particular rectangle of the window BitBlt will do. to stretch the image look into StretchBlt. You could also use the CreatePatternBrush function if you wish to tile the image. You can of course use a combination of these functions to produce whatever affect you need. (note that the image list functions are much faster and offer alot of abilities and are typically easier for newer people to use).

I would suggest performing all of your drawing at once into the compatible dc BEFORE blit'ing it over this will reduce flicker (in most cases to nothing).


Have Fun smile
Re: Calling Bitmap Resources from a DLL File #57622 29/10/03 05:53 AM
Joined: Oct 2003
Posts: 38
T
TheXenocide Offline
Ameglian cow
Offline
Ameglian cow
T
Joined: Oct 2003
Posts: 38
Also, if you keep the "Compatible" DC loaded (like making it a global variable, rather than local to your function) then after you load the bitmap to it, you will not have to reload the bitmap, you will only need to capture the WM_PAINT and WM_ERASEBKGND messages and BitBlt the image back to the windows DC. If you capture these messages through an overridden WndProc then you will want to use CallWndProc FIRST and THEN re-BitBlt your Bmp over.


-TheXenocide
ParseMPopup