Click here to Skip to main content
15,903,201 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How do I maximize a child frame in code? Pin
Tomasz Sowinski27-Sep-01 0:34
Tomasz Sowinski27-Sep-01 0:34 
Generalseveral restarts when installing Windows Pin
Peter Molnar26-Sep-01 9:48
Peter Molnar26-Sep-01 9:48 
GeneralRe: several restarts when installing Windows Pin
Carlos Antollini26-Sep-01 10:06
Carlos Antollini26-Sep-01 10:06 
GeneralRe: several restarts when installing Windows Pin
Tim Smith26-Sep-01 10:37
Tim Smith26-Sep-01 10:37 
Generalseveral restarts when installing Windows Pin
Peter Molnar26-Sep-01 9:46
Peter Molnar26-Sep-01 9:46 
QuestionHow do IAdd MFC to Non-Atl snap-in? Pin
scoob26-Sep-01 9:40
scoob26-Sep-01 9:40 
GeneralMFC access to ffastun.ff* files Pin
Harold Bamford26-Sep-01 9:35
Harold Bamford26-Sep-01 9:35 
GeneralBitmaps, Clipboard, and Palettes, Oh My! Pin
#realJSOP26-Sep-01 9:33
professional#realJSOP26-Sep-01 9:33 
I'm writing a DLL that captures live video from a digital video camera. I have a buffer that contains the "image", and I need to copy this image to the clipboard as a DIB.

If I call "SetClipboardData(CF_BITMAP, hBmp)", I get the black rectangle. If I call "SetClipboardData(CF_DIB, hBmp)", I get an error that says the (bitmap?) handle is invalid.

Here's my code so far. When I paste the image into another app, all I get is a completely black rectangle. Can anyone help? Notice, there's no MFC here, and that's the way I'd like to keep it.


if (::OpenClipboard(NULL))
{
   ::EmptyClipboard();

   RECT rc;
   HBITMAP hBmp;
   HDC hDC;
   HDC cDC;
   HWND hWnd = myParmsPtr->liveHwnd;

   ::GetWindowRect(hWnd, &rc);
   long lStillWidth  = rc.right - rc.left;
   long lStillHeight = rc.bottom - rc.top;

   hDC = ::GetDC(hWnd);
   cDC = ::CreateCompatibleDC(hDC);

   hBmp = ::CreateCompatibleBitmap(cDC,lStillWidth,lStillHeight);
   HGDIOBJ oldBmp;
   oldBmp = ::SelectObject(cDC, &hBmp);

   PAINTSTRUCT ps;
   ::BeginPaint(hWnd, &ps);
   int prevMode = ::SetStretchBltMode(cDC, COLORONCOLOR);
   ::StretchDIBits(cDC,
                   0, 0, lStillWidth, lStillHeight,
                   0, 0, lStillWidth, lStillHeight,
                   cb.pBuffer, (BITMAPINFO*)(&cb.bih),
                   DIB_RGB_COLORS, SRCCOPY);
   ::SetStretchBltMode(cDC, prevMode);
   ::EndPaint(hWnd, &ps);

   if (!::SetClipboardData(CF_DIB, hBmp))
   //if (!::SetClipboardData(CF_BITMAP, hBmp))
   {
      LPVOID lpMsgBuf;
      FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                    NULL, GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, NULL);
      MessageBox(NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION);
      LocalFree(lpMsgBuf);
      MessageBeep(0);
   }
   ::CloseClipboard();

   ::SelectObject(hDC, oldBmp);
   ::DeleteObject(hBmp);
   ::DeleteDC(cDC);
   ::DeleteDC(hDC);
}

GeneralRe: Bitmaps, Clipboard, and Palettes, Oh My! Pin
Tomasz Sowinski26-Sep-01 9:52
Tomasz Sowinski26-Sep-01 9:52 
GeneralRe: Bitmaps, Clipboard, and Palettes, Oh My! Pin
#realJSOP26-Sep-01 10:01
professional#realJSOP26-Sep-01 10:01 
GeneralRe: Bitmaps, Clipboard, and Palettes, Oh My! Pin
Christian Graus26-Sep-01 12:58
protectorChristian Graus26-Sep-01 12:58 
GeneralMFC Toolbars Pin
26-Sep-01 8:59
suss26-Sep-01 8:59 
GeneralRe: MFC Toolbars Pin
Tomasz Sowinski26-Sep-01 9:06
Tomasz Sowinski26-Sep-01 9:06 
GeneralRe: MFC Toolbars Pin
26-Sep-01 10:27
suss26-Sep-01 10:27 
GeneralList Controls - how to edit Pin
john john mackey26-Sep-01 8:53
john john mackey26-Sep-01 8:53 
GeneralRe: List Controls - how to edit Pin
Michael Dunn26-Sep-01 9:08
sitebuilderMichael Dunn26-Sep-01 9:08 
GeneralRe: List Controls - how to edit Pin
john john mackey26-Sep-01 13:02
john john mackey26-Sep-01 13:02 
GeneralTabCtrl Pin
26-Sep-01 8:06
suss26-Sep-01 8:06 
GeneralRe: TabCtrl Pin
Michael Dunn26-Sep-01 8:34
sitebuilderMichael Dunn26-Sep-01 8:34 
GeneralRe: TabCtrl Pin
26-Sep-01 8:51
suss26-Sep-01 8:51 
GeneralRe: TabCtrl Pin
Michael Dunn26-Sep-01 15:51
sitebuilderMichael Dunn26-Sep-01 15:51 
QuestionHOWTO: Find owner of locked file? Pin
Matt Weagle26-Sep-01 8:00
Matt Weagle26-Sep-01 8:00 
GeneralDirectX Beginner Pin
Mr_Byte26-Sep-01 6:45
Mr_Byte26-Sep-01 6:45 
GeneralRe: DirectX Beginner Pin
26-Sep-01 6:47
suss26-Sep-01 6:47 
GeneralRe: DirectX Beginner Pin
Mr_Byte26-Sep-01 6:53
Mr_Byte26-Sep-01 6:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.