Which way should i draw a BMP/JPG

Which way is the simplest to show a BMP/JPG on the entire client area...BUT!, to keep the window drag-able from the client area, not not the title bar.

Thank's :)
closed account (3pj6b7Xj)
Lol that sounds like a Keygen program!

Anyway, just trap the WM_MOUSEMOVE with the WM_LBUTTONDOWN and insert your code to move the window along with the mouse co-ordinates, use MoveWindow() StretchRect() should help you out in resizing the image to the entire client area.

As for the loading of the BMP into memory, use loadimage() or write your own to load it, you'll have to write class or function that loads the bitmaps for you.
I can see where you're coming from with the keygen statement but, i think it'll be awfully sad if the only applications to use Image files and Drag-able windows were to be Keygens.

I happen to design my own GUI...i like eye-candy in my programs.


Thank you, the LoadImage seem's simple enough.
Here's a code to move your window, just add it in winproc.
1
2
3
4
5
6
// move our window 
case WM_LBUTTONDOWN:
   {
	PostMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION,0);
	break;
   }


Thank you for the dragging code :)

-----


I tried using the LoadImage to load a 32bit BitMap and with UpdateLayeredWindow to draw it on the window area...searched all over...just can't make it display anything :(

Any suggestions?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

HBITMAP bmp;
HDC hdc, image_dc;
HBITMAP old_hbitmap;
POINT ptSrc = {10, 10 };
SIZE sz = { 100, 100 };

COLORREF colour = RGB(255,555,255);
		case WM_CREATE:
			{

				bmp = (HBITMAP) LoadImage (NULL,"C:\\newbg.BMP", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
					 if(!bmp)
					 MessageBoxA(NULL, (LPCSTR)GetLastError(), NULL,MB_OK|MB_ICONERROR);
					 hdc = GetDC(hwnd);
					 image_dc = CreateCompatibleDC(hdc);
					 old_hbitmap = (HBITMAP)SelectObject(image_dc,bmp);
					
					
					BLENDFUNCTION blend;
						blend.BlendOp = AC_SRC_OVER;
						blend.BlendFlags = 0;
						blend.SourceConstantAlpha = 255;
						blend.AlphaFormat = AC_SRC_ALPHA;

						BOOL bRet= UpdateLayeredWindow(hwnd, NULL, NULL, &sz, image_dc, &ptSrc, colour, &blend,  ULW_COLORKEY);
			}

Load your bitmap in maybe winmain or WM_CREATE.
1
2
// load our bitmap
HBITMAP hSkinMBmp = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MSKIN));  


then draw in WM_PAINT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// draw our bitmap
case WM_PAINT: 
   {
	BITMAP bm;
	PAINTSTRUCT ps;
	HDC hdc = BeginPaint(hwnd, &ps);
	HDC dcSkin = CreateCompatibleDC(hdc); 
	GetObject(hSkinMBmp, sizeof(bm), &bm);
	SelectObject(dcSkin, hSkinMBmp);
	BitBlt(hdc, 0,0,bitmapWidth,bitmapHeight, dcSkin, 0, 0, SRCCOPY);
	DeleteDC(dcSkin);
	EndPaint(hwnd, &ps);
	break;
   } 


if you don't know one of these functions does just look it up at http://msdn.microsoft.com/library/default.aspx
Topic archived. No new replies allowed.