Click here to Skip to main content
15,917,928 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMultiple Processes: Threads, Messages, Etc Pin
Eric Sanchez26-Sep-01 16:28
Eric Sanchez26-Sep-01 16:28 
GeneralRe: Multiple Processes: Threads, Messages, Etc Pin
Michael Dunn26-Sep-01 17:02
sitebuilderMichael Dunn26-Sep-01 17:02 
GeneralRe: Multiple Processes: Threads, Messages, Etc Pin
Eric Sanchez27-Sep-01 2:47
Eric Sanchez27-Sep-01 2:47 
GeneralBitmap Pin
26-Sep-01 15:16
suss26-Sep-01 15:16 
GeneralRe: Bitmap Pin
Christian Graus26-Sep-01 15:54
protectorChristian Graus26-Sep-01 15:54 
General2K and Tasks Pin
Christopher Lord26-Sep-01 15:15
Christopher Lord26-Sep-01 15:15 
GeneralRe: 2K and Tasks Pin
Tomasz Sowinski27-Sep-01 0:31
Tomasz Sowinski27-Sep-01 0:31 
GeneralRe: 2K and Tasks Pin
Christopher Lord27-Sep-01 0:40
Christopher Lord27-Sep-01 0:40 
GeneralRe: 2K and Tasks Pin
Tomasz Sowinski27-Sep-01 0:50
Tomasz Sowinski27-Sep-01 0:50 
GeneralRe: 2K and Tasks Pin
Christopher Lord27-Sep-01 0:53
Christopher Lord27-Sep-01 0:53 
GeneralRe: 2K and Tasks Pin
Anders Molin27-Sep-01 1:02
professionalAnders Molin27-Sep-01 1:02 
QuestionNeed help with d-heap analysis? Pin
26-Sep-01 11:29
suss26-Sep-01 11:29 
QuestionHow do I maximize a child frame in code? Pin
26-Sep-01 10:39
suss26-Sep-01 10:39 
AnswerRe: How do I maximize a child frame in code? Pin
26-Sep-01 10:45
suss26-Sep-01 10:45 
GeneralRe: How do I maximize a child frame in code? Pin
mspitzer26-Sep-01 11:00
mspitzer26-Sep-01 11:00 
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 

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.