Click here to Skip to main content
16,017,608 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionVC++ 6 -warpper Pin
Tal S.31-May-07 9:54
Tal S.31-May-07 9:54 
AnswerRe: VC++ 6 -warpper Pin
Matthew Faithfull31-May-07 10:06
Matthew Faithfull31-May-07 10:06 
AnswerRe: VC++ 6 -warpper Pin
Chris Losinger31-May-07 10:43
professionalChris Losinger31-May-07 10:43 
AnswerRe: VC++ 6 -warpper Pin
Hamid_RT31-May-07 18:27
Hamid_RT31-May-07 18:27 
Questionconverting from const char [] to 'LPWSTR' Pin
maizhiming31-May-07 9:28
maizhiming31-May-07 9:28 
AnswerRe: converting from const char [] to 'LPWSTR' Pin
Matthew Faithfull31-May-07 9:43
Matthew Faithfull31-May-07 9:43 
AnswerRe: converting from const char [] to 'LPWSTR' Pin
Xing Chen31-May-07 15:18
Xing Chen31-May-07 15:18 
QuestionGetDIBits() function call fails Pin
TheDelChop31-May-07 8:50
TheDelChop31-May-07 8:50 
Anybody see what the problem is with this code? GetDIBits fails, and when I call GetLastError(), it tells me that Windows "ERROR_FILE_NOT_FOUND".

<br />
<br />
GetClientRect(hDlg, &rc); // Get the rectangle dimensions of the Dialog Box<br />
      <br />
      hdc = GetDC(hDlg);  // Get a handle to the Drawing Context of the Dialog Box<br />
<br />
      rc.bottom -= (GetSystemMetrics(SM_CYHSCROLL)+GetSystemMetrics(SM_CYEDGE));<br />
      <br />
      hSavedXYContext = CreateCompatibleDC(hdc);  // Create a drawing context that is compatiable to <br />
                                                  // the drawing context on the screen<br />
      hSavedXYBitmap = CreateCompatibleBitmap(hdc, rc.right-rc.left,rc.bottom-rc.top);  <br />
<br />
      hTheDCsOriginalBitmap = (HBITMAP)SelectObject(hSavedXYContext, hSavedXYBitmap); <br />
<br />
      BitBlt(hSavedXYContext,0,0,rc.right-rc.left, rc.bottom-rc.top,hdc,0,0,SRCCOPY);<br />
      <br />
      hSavedXYBitmap = (HBITMAP)SelectObject(hSavedXYContext, hTheDCsOriginalBitmap);   <br />
<br />
<br />
      // As far as I can tell above code does exactly what it should.  It grabs a handle to the drawing<br />
      // context, along with the rectangular coordinates of the drawing context.  Then after creating<br />
      // a compatible bitmap, and selecting it into the saved drawing context, before blting it in.  <br />
<br />
<br />
      // Now we have the DC saved to hSavedContext, so we need to take it and create a <br />
      // bitmap file that we can open in Paint.  <br />
      // This involves creating a bmp structure then writing it to a file.<br />
      <br />
      GetObject(hSavedXYBitmap,sizeof(BITMAP),(LPSTR)(&bmp));<br />
      <br />
      cClrBits = (WORD)(bmp.bmPlanes*bmp.bmBitsPixel);<br />
      <br />
      cClrBits = 4;<br />
<br />
      pbmi = (PBITMAPINFO) LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER));<br />
      <br />
      // Initialize the fields in the BITMAPINFO structure.<br />
<br />
      pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);<br />
      pbmi->bmiHeader.biWidth = bmp.bmWidth;<br />
      pbmi->bmiHeader.biHeight = bmp.bmHeight;<br />
      pbmi->bmiHeader.biPlanes = bmp.bmPlanes;<br />
      pbmi->bmiHeader.biBitCount =4;<br />
<br />
      pbmi->bmiHeader.biCompression = BI_RGB;<br />
<br />
      pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 15)/16 <br />
                                      * pbmi->bmiHeader.biHeight * 4;<br />
<br />
      pbmi->bmiHeader.biClrImportant = 0;<br />
          <br />
      // Make sure to fill in the rest of the BITMAP info in the header.<br />
<br />
      pBitmapInfoHeader = (PBITMAPINFOHEADER)pbmi;<br />
<br />
      lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED,pbmi->bmiHeader.biSizeImage);<br />
           <br />
      test = GetDIBits(hdc,hSavedXYBitmap,0,(WORD) pbmi->bmiHeader.biHeight,<br />
                lpBits,pbmi,DIB_RGB_COLORS);<br />
<br />
      test = GetLastError();<br />


I would appreciate any feedback, as I am out of ideas.
AnswerRe: GetDIBits() function call fails Pin
John R. Shaw31-May-07 9:17
John R. Shaw31-May-07 9:17 
AnswerRe: GetDIBits() function call fails Pin
Mark Salsbery31-May-07 9:30
Mark Salsbery31-May-07 9:30 
QuestionNewbie Question Pin
joshp121731-May-07 8:45
joshp121731-May-07 8:45 
AnswerRe: Newbie Question Pin
David Crow31-May-07 10:31
David Crow31-May-07 10:31 
AnswerRe: Newbie Question Pin
Matthew Faithfull31-May-07 11:10
Matthew Faithfull31-May-07 11:10 
GeneralRe: Newbie Question Pin
joshp121731-May-07 11:15
joshp121731-May-07 11:15 
GeneralRe: Newbie Question Pin
Matthew Faithfull31-May-07 11:37
Matthew Faithfull31-May-07 11:37 
Question64 bit XP Pin
Monty231-May-07 7:40
Monty231-May-07 7:40 
AnswerSolution for those interested Pin
Monty231-May-07 22:41
Monty231-May-07 22:41 
GeneralRe: Solution for those interested Pin
Mark Salsbery1-Jun-07 6:22
Mark Salsbery1-Jun-07 6:22 
QuestionRegistry vs .Ini files. Pin
Anurag Gandhi31-May-07 7:37
professionalAnurag Gandhi31-May-07 7:37 
AnswerRe: Registry vs .Ini files. Pin
David Crow31-May-07 7:57
David Crow31-May-07 7:57 
GeneralRe: Registry vs .Ini files. Pin
Anurag Gandhi31-May-07 8:00
professionalAnurag Gandhi31-May-07 8:00 
QuestionRe: Registry vs .Ini files. Pin
David Crow31-May-07 8:15
David Crow31-May-07 8:15 
AnswerRe: Registry vs .Ini files. Pin
Anurag Gandhi31-May-07 8:17
professionalAnurag Gandhi31-May-07 8:17 
GeneralRe: Registry vs .Ini files. Pin
Maximilien31-May-07 8:45
Maximilien31-May-07 8:45 
GeneralRe: Registry vs .Ini files. Pin
David Crow31-May-07 8:45
David Crow31-May-07 8:45 

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.