Thread: Saving bmps#2

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Kurunegala Colony, Sri Lanka, Sri Lanka

    Saving bmps#2

    My program gets a screen cap and displays that image on it's main dialog window. Then it lets the user to crop the image by drawing a square on the image. After the user releases the mouse after cropping, a child dialog window is opened to display the cropped image. Now i want to save this cropped image into the hard disk. i checked out the msdn article: Storing an Image and used the 2 functions found there to do this. Below is how i call those 2 function within the WM_LBUTTONUP msg handler of my main windows's dlgproc (the dlg that displays the uncropped screen cap).

    case WM_LBUTTONUP:
    		//user releases the mouse ending the crop
    			//get ending mouse coords
    			iEndXPos = GET_X_LPARAM(lParam); 
    			iEndYPos = GET_Y_LPARAM(lParam); 
    			HWND hwndTempCap = CreateDialog(hInst,MAKEINTRESOURCE(IDD_TEMPCAP),NULL,DlgProcTempCap); //open the child dlg which should display the croped img
    			g_hTempMemDC = GetDC(hwndTempCap); //get the dc for the child dlg
    				g_hMemDC,iStartXPos,iStartYPos,SRCCOPY); //copy the croped bitmap into the child dialogs' hdc
    			HBITMAP hbitmap = CreateCompatibleBitmap(g_hTempMemDC,200,200); // create a bmp for the child dlg
    			PBITMAPINFO bmpinfo = CreateBitmapInfoStruct(hwnd, hbitmap); // msdn function - initialize members within a BITMAPINFOHEADER structure
    			CreateBMPFile(hwnd,"test.bmp",bmpinfo,hbitmap,g_hTempMemDC); // msdn function - save the croped img to disk
    But after CreateBMPFile executes, what i get is a blank bitmap ("test.bmp") on the hard disk. CreateBitmapInfoStruct() and CreateBMPFile() cannot go wrong because i found them in msdn, so it's me somthing doing wrong. what's i'm doing wrong plase? Please help.
    Last edited by geek@02; 10-16-2006 at 09:52 PM.
    My amature IT Blog:
    My Flash games:

    (and, sorry for my amateur English)

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    New York
    Several things wrong. Very similar to a problem I had. Use this 'screenshot' function (thx to anonytmouse).


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to C++ problem saving files
    By wesm in forum C++ Programming
    Replies: 2
    Last Post: 11-02-2005, 02:00 PM
  2. Replies: 2
    Last Post: 06-16-2005, 10:03 AM
  3. saving a binary tree??
    By fayte in forum C++ Programming
    Replies: 9
    Last Post: 01-27-2005, 01:32 PM
  4. Saving vectors of structures problem
    By redeck in forum C++ Programming
    Replies: 4
    Last Post: 12-09-2004, 04:47 PM
  5. File saving problem in DevC++ pls help ???
    By intruder in forum C Programming
    Replies: 3
    Last Post: 12-17-2002, 01:17 AM