Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CEdit ---> BitMap

Posted on 2000-05-08
4
Medium Priority
?
526 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 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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.
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

885 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