View previous topic :: View next topic |
Author |
Message |
stjepan
Joined: 11 Apr 2005 Posts: 22 Location: Croatia
|
Posted: Wed Apr 27, 2005 11:41 am Post subject: Background image for window on Windows |
|
|
I use: Code: | paintDelegate ~= delegate void(Component source, GContext gc) {
HBITMAP bmp = cast(HBITMAP)LoadImageA(null, "img/background.bmp", IMAGE_BITMAP, 0, 0, 0x10);
SelectObject(gc.peer, bmp);
BitBlt(gc.peer, 0, 0, 700, 700, GetDC(bmp), 0, 0, 0xCC0020);
gc.flush();
}; | It doesn't work. I don't know very much about WinAPI. _________________ I speak a little English. I am beginner in programming. I know C++, C# and D. |
|
Back to top |
|
|
BenHinkle
Joined: 27 Mar 2004 Posts: 76
|
Posted: Thu Apr 28, 2005 8:32 pm Post subject: |
|
|
Try something like
Code: |
paintDelegate ~= delegate void(Component source, GContext gc) {
HBITMAP bmp = cast(HBITMAP)LoadImageA(null, "img/background.bmp", IMAGE_BITMAP, 0, 0, 0x10);
HDC bmpdc = CreateCompatibleDC(gc.peer);
SelectObject(bmpdc, bmp);
BitBlt(gc.peer, 0, 0, 700, 700, bmpdc, 0, 0, 0xCC0020);
gc.flush();
DeleteDC(bmpdc);
DeleteObject(bmp);
};
|
Caching the handles so that they are create and deleted every time through the paint delegate would speed up the drawing if needed. |
|
Back to top |
|
|
stjepan
Joined: 11 Apr 2005 Posts: 22 Location: Croatia
|
Posted: Fri Apr 29, 2005 2:59 pm Post subject: |
|
|
Now it works, thanks. _________________ I speak a little English. I am beginner in programming. I know C++, C# and D. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|