|
-
Mar 17th, 2001, 11:08 PM
#1
Thread Starter
Addicted Member
Why doesn't the image get BitBlted to the form I've made sure there is an image but it still doesn't work.
PHP Code:
int LoadPicture(HWND hwnd,HDC winHDC,double Width,double Height){
HDC ImagehDC;
LPCTSTR File;
int checkError;
File=(LPCTSTR)GlobalAlloc(GMEM_FIXED,50);
File= "C:\\Bells\\Vb6Sbs\\Less09\\Bld-up.bmp";
ImagehDC=(HDC)LoadImage(appInstance,File,IMAGE_BITMAP,Width,Height,LR_LOADFROMFILE);
if(ImagehDC==NULL){
MessageBox(hwnd,"Darn no image","Msg",MB_OK);
}
checkError=BitBlt(winHDC,0,0,Width,Height,ImagehDC,0,0,SRCCOPY);
if(checkError==0){
MessageBox(hwnd,"Darn didn't paste too form","Msg",MB_OK);
}
return 1;
}
-
Mar 17th, 2001, 11:41 PM
#2
Lively Member
I think you have to put 2 backslashes when specifying a pathname. So change your "File" variable to "C:\\Bells\\Vb6Sbs\\Less09\\Bld-up.bmp"
-
Mar 17th, 2001, 11:50 PM
#3
Thread Starter
Addicted Member
The File variable does have two back slashes but the vb-world software takes out the second backslash
-
Mar 18th, 2001, 12:02 AM
#4
Lively Member
You are passing "Width" and "Height" as doubles when they are supposed to be integers. Does that help?
-
Mar 18th, 2001, 12:13 AM
#5
Thread Starter
Addicted Member
-
Mar 18th, 2001, 12:18 AM
#6
Thread Starter
Addicted Member
Just too make sure you know everthing.
BitBlt comes back with the number 0.
-
Mar 18th, 2001, 03:40 AM
#7
Thread Starter
Addicted Member
Sigh Looking at the api's i have too get the HDC of the BitMap for BitBlt.
Which i can't do so i have to use the SelectObject api,
But i need some help on converting the BitMap from the LoadImage api to one that is Compatible with the SelectObject api.
-
Mar 18th, 2001, 04:17 AM
#8
Monday Morning Lunatic
You have to create a DC that's compatible with the window you have, using CreateCompatibleDC.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Mar 19th, 2001, 11:05 AM
#9
Frenzied Member
Try this:
PHP Code:
int LoadPicture(HWND hwnd,HDC winHDC,double Width,double Height){
HDC ImagehDC;
LPCTSTR File;
int checkError;
ImagehDC = CreateCompatibleDC(NULL); //Setup The DC
File=(LPCTSTR)GlobalAlloc(GMEM_FIXED,50);
File= "C:\Bells\Vb6Sbs\Less09\Bld-up.bmp";
SelectObject(ImagehDC,LoadImage(appInstance,File,IMAGE_BITMAP,Width,Height,LR_LOADFROMFILE)); //Put The Bitmap In The DC
//ImagehDC=(HDC)LoadImage(appInstance,File,IMAGE_BITMAP,Width,Height,LR_LOADFROMFILE);
if(ImagehDC==NULL){
MessageBox(hwnd,"Darn no image","Msg",MB_OK);
}
checkError=BitBlt(winHDC,0,0,Width,Height,ImagehDC,0,0,SRCCOPY);
if(checkError==0){
MessageBox(hwnd,"Darn didn't paste too form","Msg",MB_OK);
}
return 1;
}
Remeber to destory your DCs when you are done with DeleteDC(yourHDC);
Also remember the BitBlt does not "really" put the image there, so when ever there is a redraw, WM_PAINT, etc. the image will disappear unless you fix it to be painted when those happen. So if your image is still not being BitBlt, make sure something is not redrawing your window after you have done it.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Mar 19th, 2001, 02:53 PM
#10
Thread Starter
Addicted Member
Thanks a million it worked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|