 |
|
 |
Great work but how to use it in a dialog-based app?
|
|
|
|
 |
|
 |
Does this apply to CFormView as well? I can't seem to work it out with CFOrmView. It keeps on flickering when i resize the window. Please do help.
|
|
|
|
 |
|
 |
Thought I would comment that I found a potential memory leak in this class in the function CBufferMemDC::SetSizeBuffer. The section
m_pBitmap = new CBitmap;
if (!m_pBitmap->CreateCompatibleBitmap(pDC, m_SizeBitmap.Width(), m_SizeBitmap.Height())){
AfxMessageBox("...");
m_pBitmap = NULL;
}
should instead read
m_pBitmap = new CBitmap;
if (!m_pBitmap->CreateCompatibleBitmap(pDC, m_SizeBitmap.Width(), m_SizeBitmap.Height())){
AfxMessageBox("...");
delete m_pBitmap;
m_pBitmap = NULL;
}
Otherwise there will be a memory leak if the call to CreateCompatibleBitmap fails.
Regards,
shettelbus
|
|
|
|
 |
|
 |
Hello,
the function of your class is good, but when i exit my programm i get this messages:
Detected Memory Leaks!
(A lot of CBitmap-Object)
|
|
|
|
 |
|
 |
Hello,
the error was in my own code, in the dialog where i have created a member-variable of your classes.
There are no memory leaks in your classes!
Sorry!
|
|
|
|
 |
|
 |
cool,but it is too slow.
Regards
http://www.ucancode.net/
|
|
|
|
 |
|
 |
How to code "OnRedraw()"?
Give me Example source plz (Anybody...)
PS, Sorry i can't english well... T.T
|
|
|
|
 |
 | CMemDC  |  | Anonymous | 22:27 19 Aug '01 |
|
 |
>...CMemDC did not call the functions of CPreviewDC
Why would you use CMemDC or CBufferMemDC when printing?
CMyView::OnDraw(CDC*pDC)
{
CMemDC* pMemDC = NULL;
if (!pDC->IsPrinting())
{
pDC = pMemDC = new CMemDC(pDC);
}
...draw using pDC
delete pMemDC;
}
|
|
|
|
 |
|
 |
hi!
I am using these classes in my application. When i used these classes, the background becomes Black.
What may be the problem??
Hoping to hear from u soon.
regards'
Hassan
Hassan
|
|
|
|
 |
|
 |
HI,
If any one found remedx of this problem, please do post.
Thanks.
Jabran
|
|
|
|
 |
|
 |
I do believe I have a solution to this problem if you still need it.
What I did was fill the buffer (CBufferMemDC) with everything that should be drawn on the screen first. Then you can do whatever you want with it.
|
|
|
|
 |
|
 |
I get these 2 classes to works great with a normal CView class (many thanks to the author). But when I use it with CSCrollView it gives problems.
The screen is redrawn incorrectly when the screen is scrolled and then resized.
Any idea how to fix this?
Richar
|
|
|
|
 |
|
 |
Hi Richard,
You could use the following piece of code in your CScrollView-derived class's OnDraw()
CYourCSView::OnDraw(CDC* pDC)
{
// initalize your MemDC object
...
// add following piece of code
CPoint point;
point = GetScrollPosition();// this is CScrollView's fxn that returns the point scrolled
if( memDC.GetWindowOrigin() != point )
{
memDC.SetWindowOrigin(point);
}
...
// your drawing code here
}
// declarations of Set and Get functions used above in the memDC class's .h file
private:
CPoint m_ptOrigin;
...
public:
CPoint GetWindowOrigin();
void SetWindowOrigin(CPoint ptOrg);
...
// definitions of Set and Get functions used above in the memDC class's .cpp file
void CMemDC::SetWindowOrigin(CPoint ptOrg)
{
if ( m_bMemDC )
{
m_ptOrigin = ptOrg;
SetWindowOrg(m_ptOrigin.x, m_ptOrigin.y);
SetBrushOrg(m_ptOrigin.x % 8, m_ptOrigin.y % 8);
}
}
CPoint CMemDC::GetWindowOrigin()
{
return m_ptOrigin;
}
///////////////////////////////////////////////////////////////////////
Hope this helps.
Regards,
Ashutosh
|
|
|
|
 |
|
 |
I tried using this code, it workrd fine with one buffer
(ofcourse I did not get any speed increase).
But when I added another buffer I could not copy the data
from the background buffer to the current buffer.
Can you please Emai/post a simple 2 buffer running demo
|
|
|
|
 |
|
 |
I wrote this classes some time ago as helper classes for a big application. I didn't have problems with
them and so i don't have a simple demo example. I now don't have the time to write such an example
and i am not very interested in such code because i now don't work on Microsoft Windows any more
because the future is not based on Microsoft any more..
If you have a simple example which does not work i can look where the error is and then we can publish
it here
|
|
|
|
 |
|
 |
If you change the code in
BOOL CBufferMemDC::SetSizeBuffer( CDC *pDC, CRect rect )
to read
if ( (m_SizeBitmap.Width() < rect.Width() ) | (m_SizeBitmap.Height() < rect.Height() ))
Reset();
instead of
if (m_SizeBitmap != rect)
Reset();
The buffer is only re-allocated when it is too small for the current view.
|
|
|
|
 |
|
 |
I have tried it. I am pleased to mention that there is no more flickering in my drawing. But there is a problem, now the drawing becomes pretty slow.
I am drawing various maps on the screen. Whenever i resize or drag some custom figure (i.e. rectangle, triangle etc.), drawing becomes pretty slow.
Can any one suggest any idea of improving the speed of drawing?
Thanx in advance.
Hassan Zia
|
|
|
|
 |
|
 |
Good Solution, but don't forget to override
OnEraseBkgnd(CDC* pDC)
BOOL CMyView::OnEraseBkgnd(CDC* pDC)
{
return FALSE;
}
this stops MFC from clearing the background during sizing etc
|
|
|
|
 |
|
|
 |