Results 1 to 10 of 10

Thread: BitBlt

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    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;

    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    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"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    The File variable does have two back slashes but the vb-world software takes out the second backslash
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  4. #4
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    You are passing "Width" and "Height" as doubles when they are supposed to be integers. Does that help?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    Nope.
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    Just too make sure you know everthing.
    BitBlt comes back with the number 0.
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    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.
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  9. #9
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154

    Smile

    Thanks a million it worked.
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width