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

C / C++ / MFC

 
AnswerRe: How to remove old VSS bind from project ? Pin
Anthony_Yio31-May-04 15:57
Anthony_Yio31-May-04 15:57 
GeneralMultithread- Urgent Requirement Pin
Billar31-May-04 3:09
Billar31-May-04 3:09 
GeneralRe: Multithread- Urgent Requirement Pin
Sumit Kapoor31-May-04 3:57
Sumit Kapoor31-May-04 3:57 
GeneralRe: Multithread- Urgent Requirement Pin
Billar31-May-04 4:33
Billar31-May-04 4:33 
GeneralRe: Multithread- Urgent Requirement Pin
Sumit Kapoor31-May-04 17:44
Sumit Kapoor31-May-04 17:44 
GeneralRe: Multithread- Urgent Requirement Pin
David Crow1-Jun-04 4:08
David Crow1-Jun-04 4:08 
GeneralRe: Multithread- Urgent Requirement Pin
Jörgen Sigvardsson31-May-04 5:28
Jörgen Sigvardsson31-May-04 5:28 
GeneralWhy this is happening? -- Why this is capturing screen image instead of ClientDC Pin
JHAKAS31-May-04 2:08
JHAKAS31-May-04 2:08 
Hi

Well i am drawing on my clientDc and then i am writing to MemDC.
This MemDc i am using for saving clientDc content to Image file.


 <br />
<br />
Class MyView<br />
{<br />
    CDC MemDC;<br />
    CBitmap m_MyBitmap;<br />
};<br />
<br />
Class MyView:rawDiag()<br />
{<br />
  CClientDC dc(this);<br />
      <br />
  ---------------<br />
       Drawing code goes here. With default mapping mode <br />
    ---------------<br />
  <br />
<br />
  m_MyBmp.DeleteObject ();<br />
  MemDC.CreateCompatibleDC (&ClientDC);<br />
  m_MyBmp.CreateCompatibleBitmap (&ClientDC, 860, 1100);<br />
  CBitmap *OldBitmap = MemDC.SelectObject (&m_MyBmp);<br />
  MemDC.PatBlt (0,0,860,1100,WHITENESS);<br />
<br />
   if(MemDC.StretchBlt(50, 0, 860, 1100, &ClientDC, 0, 0, 860,<br />
      1100, SRCCOPY) == FALSE)<br />
	AfxMessageBox("Failed to draw WFR diagram"); <br />
    <br />
    MemDC.SelectObject (OldBitmap);<br />
    ClientDC.SetMapMode(MM_LOENGLISH);<br />
}<br />
<br />
Function for saving dc to Bitmap file. This code i got from codeproject post<br />
<br />
Class MyView::SaveDCtoBMP()<br />
{<br />
  CString Filename;<br />
  CFileDialog dlgFile (false,"*.*",NULL, OFN_HIDEREADONLY,"BMP Files: (*.bmp)|*.bmp||");<br />
  dlgFile.m_ofn.lpstrTitle  = "Save As Image File";<br />
	<br />
  int ret = dlgFile.DoModal(); <br />
  if(IDOK == ret)<br />
  {<br />
     Filename = dlgFile.GetFileName ();	<br />
    // Create a temporary bitmap compatible with client DC<br />
    CClientDC clientDC(::AfxGetMainWnd());<br />
    clientDC.SetMapMode (MM_LOENGLISH);<br />
    <br />
    CBitmap TmpBitmap;<br />
    TmpBitmap.CreateCompatibleBitmap(&clientDC, 860, 1100);<br />
    // Replace the bitmap in the DC, even though the DC is const.<br />
    CDC& ncDC = const_cast<CDC&>(MemDC);<br />
    ncDC.SelectObject(TmpBitmap);<br />
    ncDC.SetMapMode (MM_LOENGLISH);<br />
<br />
   // Save the bitmap that is now deselected from the DC.<br />
   CDIBSectionLite	dib;<br />
   HBITMAP hnd = (HBITMAP)m_WfrBmp.GetSafeHandle (); <br />
   dib.SetBitmap (hnd);<br />
   dib.Save(Filename);	<br />
  // Select the bitmap in the DC again.<br />
   ncDC.SelectObject(m_WfrBmp); <br />
  // Done with the bitmap now delete that one.<br />
   TmpBitmap.DeleteObject ();<br />
   }<br />
}<br />
<br />


I get following image as bitmap file.
I want only the clientdc content but it seems that it provides screen capture


How to attach image file alongwith post?

Leave your mark wherever you go
GeneralRe: Why this is happening? -- Why this is capturing screen image instead of ClientDC Pin
JHAKAS31-May-04 22:33
JHAKAS31-May-04 22:33 
GeneralRe: Why this is happening? -- Why this is capturing screen image instead of ClientDC Pin
Anthony_Yio1-Jun-04 1:14
Anthony_Yio1-Jun-04 1:14 
GeneralRe: Why this is happening? -- Why this is capturing screen image instead of ClientDC Pin
Anonymous1-Jun-04 2:37
Anonymous1-Jun-04 2:37 
GeneralRe: Why this is happening? -- Why this is capturing screen image instead of ClientDC Pin
JHAKAS1-Jun-04 19:34
JHAKAS1-Jun-04 19:34 
GeneralOLE Pin
Aizaz31-May-04 2:04
Aizaz31-May-04 2:04 
GeneralRe: OLE Pin
f6431-May-04 8:32
f6431-May-04 8:32 
QuestionPlease help me. how to attach a dialog to a view? Pin
freehawk31-May-04 1:59
freehawk31-May-04 1:59 
AnswerRe: Please help me. how to attach a dialog to a view? Pin
JHAKAS31-May-04 2:10
JHAKAS31-May-04 2:10 
AnswerRe: Please help me. how to attach a dialog to a view? Pin
dart1331-May-04 3:51
dart1331-May-04 3:51 
GeneralCOM controls security Pin
Imtiaz Murtaza31-May-04 1:47
Imtiaz Murtaza31-May-04 1:47 
GeneralRe: COM controls security Pin
Sumit Kapoor31-May-04 4:05
Sumit Kapoor31-May-04 4:05 
GeneralMapViewOfFile() Pin
ricardo.padrela31-May-04 0:36
ricardo.padrela31-May-04 0:36 
GeneralRe: MapViewOfFile() Pin
Anthony_Yio31-May-04 1:30
Anthony_Yio31-May-04 1:30 
GeneralRe: MapViewOfFile() Pin
Roger Allen1-Jun-04 5:07
Roger Allen1-Jun-04 5:07 
QuestionWhy the PFA_JUSTIFY of Paragraph alignment is invalid in the RichEidt20(rich edit controls ver >3.0),Can you help me? Pin
lsm31-May-04 0:04
lsm31-May-04 0:04 
QuestionVector STL - insert class with private copy constructor and assignment operator? Pin
Indrawati30-May-04 21:33
Indrawati30-May-04 21:33 
AnswerRe: Vector STL - insert class with private copy constructor and assignment operator? Pin
markkuk30-May-04 21:53
markkuk30-May-04 21: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.