Solved

CEdit ---> BitMap

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 133
mixString challenge 36 131
Perl Awk Need Help 3 128
mapBully challenge 6 152
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‚Ķ
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

828 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