Solved

CEdit ---> BitMap

Posted on 2000-05-08
4
481 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 31

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 31

Expert Comment

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

have a nice day,

regards,

ZOPPO
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

861 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

24 Experts available now in Live!

Get 1:1 Help Now