mIRC Home    About    Download    Register    News    Help

Print Thread
#84494 29/05/04 10:31 AM
Joined: Jun 2003
Posts: 9
T
Theorem Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Jun 2003
Posts: 9
Hello there, I created a DLL that has a bitmap or two in it, and I want to load it into mIRC @Windows, but I can't figure out how to do it.
Anyone knows if it is possible?

#84495 29/05/04 05:23 PM
Joined: Jun 2003
Posts: 195
N
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
quite possible indeed.

First load the bitmap using LoadImage. Youll need to subclass the static face window of the @win. In its WM_PAINT case retrieve its device context. Create a compatible dc (CreateCompatibleDC) and then select your bitmap into the compatible dc (SelectObject). Use GetObject to get the dimentions of the bitmap and GetClientRect to get the dimensions of the window. Next call StretchBlt with the compatible dc as the source dc and the windows dc as the destination dc.

If you like you can create a brush from the bitmap and use FillRect instead to tile the bmp. for example

HBRUSH hBrush = CreatePatternBrush(hBmp);
FillRect(windoDC,&rcClient,hBrush);
DeleteObject(hBrush); //dont forget to free memory
ReleaseDC(hWnd,windowDC); //and release the dc so others can draw too.

Theres alot more support code youll need but this should get you well on your way. If you need any other help just let me know


Have Fun smile
#84496 31/05/04 07:53 PM
Joined: Jun 2003
Posts: 9
T
Theorem Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Jun 2003
Posts: 9
heh, thks grin
I've got the subclassing working, and I flooded myself with MessageBoxes in the WM_PAINT message, but I cant get the LoadImage thingy working =x

IDB_EXERCISING BITMAP "C:/My Projects/PA/tmps.bmp"

I've got this thing on my resource file... (#define IDB_EXERCISING 1) if you can give me a little tip of what to do now... or maybe a link, that would be nice ^^;

Thanks again, \o

#84497 31/05/04 09:31 PM
Joined: Jun 2003
Posts: 195
N
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
to load the bitmap from a resource you need 2 things. first the instance handle to your dll. you can get this from the DllMain function (this function also needs to be exported in your dll). second is the identifer of the resource. the following may help

HINSTANCE hInstDll;

BOOL WINAPI DllMain(HINSTANCE hInst,DWORD dwReason,LPVOID pUnused)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
hInstDll = hInst;
break;
return TRUE;
}


...meanwhile in a function near you...
HBITMAP bmp = (HBITMAP)LoadImage(hInstDll,MAKEINTRESOURCE(IDB_EXERCISING),IMAGE_BITMAP,0,0,LR_DEFAULTSIZE);

//use bmp in your drawing.
DeleteObject(bmp); //dont forget to delete it to avoid gdi memory leaking.


Have Fun smile
#84498 07/08/04 02:40 PM
Joined: Jun 2003
Posts: 9
T
Theorem Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Jun 2003
Posts: 9
Ok, I've now managed to draw the bmp on the @window, thanks you you :tongue:

but there's still a little problem... it seems that doing the drawing in the WM_PAINT message isn't enough.
If I have something on top of the @window, and then select it (becoming the @window active), it clears the image. Any special reason for this to happen?


Link Copied to Clipboard