I faced a problem when resizing more than 60 controls it was simply too slow thus, I have implemented Andrey del pozo improvement (DeferWindowPos) and now the class rock and rolls. Thanks Guys,
ReplyFirst of all the class is great and very useful. Second, I bump into a problem when resizing for example 60 controls on a dialog. The function SetWindowPos consumes most of the time. It can take several seconds to resize the dialog! Can any one suggest a solution for the problem or a pointer where in the code I need to intervene? Thanks,
ReplyThis is a wonderful class. But I don't know how to use it in a CFormView. Does any one can help me with it? Thank you very much. I need it very urgent.
ReplyWith a little work the class worked like magic! Thanks... Jony Patal.
ReplyOriginally posted by: Standa K.
I really appreciate your job, it helped me much. I have just one question. In my dialog, I create to CView-class-derived objects (that I've drawn previously in resource editor) dynamically in OnInitDialog() using CView::Create(...), but they don't get redrawn.
Is there any way to solve it?
Any suggestion helps much.
Best regards,
Standa K.
Originally posted by: Roddy
You mention in your documentation, code needs to be inserted in the OnInitDialog. But if the controls are on a FormView, the formview doesn't have the OnInitDialog(), and therefore the controls can't be resized.
Where would you suggest the best place is to insert the code for a FormView?
Kind Regards,
Roddy.
ReplyOriginally posted by: andrey del pozo
void CResizer::MoveAndHideOverlapped() const{
//first this
You can use DeferWindowPos instead of setwindowpos, and remove SWP_NOCOPYBITS.
_ASSERTE(m_nSize == m_nCachedSize);
HDWP hdwp = ::BeginDeferWindowPos( 0 );
for(int i=0; i<m_nSize; i++){
CRectInfo &riSlave = m_vRectInfo[i];
for(int j=0; j<i; j++){
const CRectInfo &riMaster = m_vRectInfo[j];
if(riMaster.bVisible && riSlave.bVisible && !riSlave.bHide){
RECT rc;
::IntersectRect(&rc, &riMaster.rc, &riSlave.rc);
riSlave.bHide = !::IsRectEmpty(&rc);
}
}
HWND pCtl = GetDlgItem(riSlave.nID);
if(riSlave.bHide)
::SetRectEmpty(&riSlave.rc);
//instead of SetWindowPos
hdwp = ::DeferWindowPos( hdwp,pCtl, NULL, riSlave.rc.left, riSlave.rc.top,
riSlave.rc.right - riSlave.rc.left, riSlave.rc.bottom - riSlave.rc.top,
SWP_NOZORDER);
}
//and finally move them
::EndDeferWindowPos( hdwp );
}
Originally posted by: Dmitry Kochin
The easiest way is to set WS_CLIPCHILDREN style to a dialog. It will help significantly, however, some flikering will occur anyway. You can play with ::SetWindowPos at line 287 of resizer.cpp. For example, turn off SWP_NOCOPYBITS flag. It will remove flickering almost at all, but it will sometimes redraw incorrectly.
I don't know of other ways. You can experiment :)
Reply
Originally posted by: Tony Boon
This is one of the best classes I have gotten from Codeguru!
It moves, resizes, no pain at all. I only wish I could get rid of the flickering done when resizing/moving a bunch of controls!
Best wishes, Tony
ReplyOriginally posted by: Chris
Thank you for a really useful class.
Just one question: does the resizing class usually work correctly with group boxes? I find that, depending on the order of passing controls to Init(), either the group box or everything it overlaps is hidden when the containing dialog is resized. :-(
Obviously with a group box I would prefer everything including the box to remain visible even with the overlap. Unfortunately, I can't see any way I can achieve this with the current interface to the resizing class. Have I missed something?
Reply