tko092397
asked on
How to draw into memDC, then show it
I would like to:
1. memDC.LineTo(60,60)
2. Determine the extension of memDC
3. draw memDC to my window screen
Is this possible without using bitmap?
If bitmap is needed to use, now I can
handle it but must first determine the
extension of bitmap first, then draw on
memDC. But I want to first draw on
memDC, then create a bitmap with the
correct needed extension, then draw
bitmap on window.
Please write sample code.
I use VisualStudio 6, MFC, c++
Thanks, Tomas
1. memDC.LineTo(60,60)
2. Determine the extension of memDC
3. draw memDC to my window screen
Is this possible without using bitmap?
If bitmap is needed to use, now I can
handle it but must first determine the
extension of bitmap first, then draw on
memDC. But I want to first draw on
memDC, then create a bitmap with the
correct needed extension, then draw
bitmap on window.
Please write sample code.
I use VisualStudio 6, MFC, c++
Thanks, Tomas
Hi!
You can not transwer data from one DC to another without bitmaps.
When you use memoryDC
You must before create bitmap with required dims. select it into thebmemory context? draw into the context, BitBlt from memory context to the destination context and then select memory context old bitmap back.
for example:
{
CDC dcDisplay;
dcDisplay.CreateIC("DISPLA Y", "", "", NULL)
CDC dcMem;
dcMem.CreateCompatibleDC(N ULL);
CBitmap bm;
bm.CreateCompatibleBitmap( &dcDisplay ,100,100 );
CBitmap* pbmOld = dcMem.SelectObject(&bm);
/* drawing routines here width using dcMem */
dcDest.BitBlt(...); //dcDest is the DC where to your image will be transfered
dcMem.SelectObject(pbmOld) ;
dcDisplay.DeleteDC();
}
You can not transwer data from one DC to another without bitmaps.
When you use memoryDC
You must before create bitmap with required dims. select it into thebmemory context? draw into the context, BitBlt from memory context to the destination context and then select memory context old bitmap back.
for example:
{
CDC dcDisplay;
dcDisplay.CreateIC("DISPLA
CDC dcMem;
dcMem.CreateCompatibleDC(N
CBitmap bm;
bm.CreateCompatibleBitmap(
CBitmap* pbmOld = dcMem.SelectObject(&bm);
/* drawing routines here width using dcMem */
dcDest.BitBlt(...); //dcDest is the DC where to your image will be transfered
dcMem.SelectObject(pbmOld)
dcDisplay.DeleteDC();
}
Hi tko,
perhaps you'd prefer drawing to a metafile in memory and than draw this metafile to your dc. For this see help for CreateMetaFile, CloseMetaFile and CDC::PlayMetaFile()
ZOPPO
perhaps you'd prefer drawing to a metafile in memory and than draw this metafile to your dc. For this see help for CreateMetaFile, CloseMetaFile and CDC::PlayMetaFile()
ZOPPO
A memory DC without a bitmap selected into it can't be used for drawing.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!!
Tomas
Tomas
ASKER