How to save mouse?

This is a discussion on How to save mouse? within the Windows Programming forums, part of the Platform Specific Boards category; My English is poor,sorry. I copy screen into a file,and then I open the file, I couldn't see the mouse,why?How ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    50

    How to save mouse?

    My English is poor,sorry.
    I copy screen into a file,and then I open the file,
    I couldn't see the mouse,why?How to solve it?
    Look:
    Code:
    SetCursorPos(300,300);
    Sleep(3000);
    
    HDC hdc;
    hdc=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
    int cx,cy;
    cx=GetSystemMetrics(SM_CXSCREEN); 
    cy=GetSystemMetrics(SM_CYSCREEN); 
    
    HDC memhdc;
    memhdc=CreateCompatibleDC(hdc);
    HBITMAP hBitmap,holdBitmap;
    hBitmap=CreateCompatibleBitmap(hdc,cx,cy);
    
    holdBitmap=(HBITMAP)SelectObject(memhdc,hBitmap);
    BitBlt(memhdc,0,0,cx,cy,hdc,0,0,SRCCOPY);
    BITMAP bitmap;
    GetObject(hBitmap,sizeof(BITMAP),&bitmap);
    
    DWORD size=bitmap.bmWidthBytes*bitmap.bmHeight;
    HGLOBAL hMem =GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,size);
    LPSTR lpData = (LPSTR)GlobalLock(hMem);
    
    BITMAPINFOHEADER bih;
    bih.biSize=sizeof(BITMAPINFOHEADER);
    bih.biWidth=bitmap.bmWidth;
    bih.biHeight=bitmap.bmHeight;
    bih.biPlanes=1;
    bih.biBitCount=bitmap.bmBitsPixel;
    bih.biCompression=0;
    bih.biSizeImage=size;
    bih.biXPelsPerMeter=0;
    bih.biYPelsPerMeter=0;
    bih.biClrUsed=0;
    bih.biClrImportant=0;
    
    GetDIBits(memhdc,hBitmap,0,bih.biHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
    
    BITMAPFILEHEADER bfh;
    bfh.bfType=((WORD)('M'<< 8)|'B');
    bfh.bfSize=54+size;
    bfh.bfReserved1=bfh.bfReserved2=0;
    bfh.bfOffBits=54;
    
    CFile bf;
    if(bf.Open("D:\\wt.bmp",CFile::modeCreate|CFile::modeWrite))
    {
    bf.WriteHuge(&bfh,sizeof(BITMAPFILEHEADER));
    bf.WriteHuge(&bih,sizeof(BITMAPINFOHEADER));
    bf.WriteHuge(lpData,size);
    bf.Close();
    }
    
    GlobalUnlock(hMem);
    GlobalFree(hMem);
    hBitmap=(HBITMAP)SelectObject(memhdc,holdBitmap);
    DeleteObject(hBitmap);
    DeleteDC(memhdc);
    DeleteDC(hdc);

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    Draw you own crosshair on the mouse position

    Niara

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Identifying mouse used with Global mouse hooks
    By Chillance in forum Windows Programming
    Replies: 4
    Last Post: 02-15-2009, 08:42 AM
  2. Save vs Save As.... OPENFILENAME flags
    By csonx_p in forum Windows Programming
    Replies: 16
    Last Post: 06-01-2008, 03:42 PM
  3. save and save as functions
    By willc0de4food in forum Windows Programming
    Replies: 2
    Last Post: 06-29-2005, 03:49 AM
  4. save webpage? some save some not
    By kryptkat in forum Tech Board
    Replies: 3
    Last Post: 06-07-2005, 10:21 AM
  5. save yourself
    By kerick in forum Game Programming
    Replies: 1
    Last Post: 03-29-2002, 10:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21