Solved

CEdit ---> BitMap

Posted on 2000-05-08
4
479 Views
Last Modified: 2013-11-20
Hello,
This is not really a Q? more a need 4 help...
Since I'm very short in time and not very familiar with MFC I would be VERY happy if the answer can be an example / pointer to one.
I need to take the content of a CEdit and to translate it into a BitMap
(So the bitmap will show the text inside the CEdit).
If I'll get a good example(simple & clean) and not a pseudo code (although they are welcome too) I'll increase the points by 100...
Tnx allot in advance
Giligen,
0
Comment
Question by:giligen
  • 2
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
Zoppo earned 200 total points
ID: 2787738
Hi giligen,

try this code:


HBITMAP
GetEditBitmap( CWnd* pWnd )
{
 CRect rect;
 pWnd->GetClientRect( rect );
 CDC* pDC = pWnd->GetDC();
 CDC memDC;
 memDC.CreateCompatibleDC( pDC );
 CBitmap bitmap;
 bitmap.CreateCompatibleBitmap( pDC, rect.Width(), rect.Height() );
 CBitmap* pOldBmp = memDC.SelectObject( &bitmap );
 memDC.BitBlt( 0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY );
 memDC.SelectObject( pOldBmp );
 memDC.DeleteDC();
 return (HBITMAP)( bitmap.Detach() );
}

// usage i.e. like this
AnyFoo()
{
 ...
 CWnd* pEdit = GetDlgItem( IDC_EDIT1 );
 HBITMAP hBitmap = GetEditBitmap( pEdit );

 CStatic* pStatic = (CStatic*)GetDlgItem( IDC_STATIC_BMP );
 pStatic->SetBitmap( hBitmap );
}


hope that helps,

ZOPPO
0
 

Author Comment

by:giligen
ID: 2787891
Adjusted points from 100 to 200
0
 

Author Comment

by:giligen
ID: 2787892
Tnx ALLOT
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 2787895
you're welcome......

have a nice day,

regards,

ZOPPO
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now