A strange WTL-app debug/release problem [modified]
-
I encountered strange problem with WTL program I'm trying to make (please bear with me because I'm not a pro, programming is just my hobby). I'm trying to make a program to view any image directly from zip (something like CDisplay, but with FreeImage and ZipUtils). I reused code of a WTL Bitmap viewer example (from original WTL package). I'm switching 2 views in SDI application (see http://www.codeproject.com/KB/wtl/switchviews\_wtl.aspx), one flicker-free image display (generic view) and a CListViewCtrl thumbnails list (not a control in client, I use whole view#2 window). I build with VC8ExpressSP1 + Platform SDK2003R2 + WTL latest version. Essential code:
class CMainFrame : public CFrameWindowImpl<CMainFrame >, public CUpdateUI<CMainFrame >,public CMessageFilter, public CIdleHandler, public C_ImgArchive { public: DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME) CIAVView m_view; CThumbView m_thumbview; BEGIN_UPDATE_UI_MAP(CMainFrame) END_UPDATE_UI_MAP() BEGIN_MSG_MAP(CMainFrame) MESSAGE_HANDLER(WM_CREATE, OnCreate) ..... CHAIN_MSG_MAP(CUpdateUI) CHAIN_MSG_MAP(CFrameWindowImpl) END_MSG_MAP() ....} // LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { //create view#1 m_hWndClient=m_thumbview.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LVS_ICON | LVS_SINGLESEL | WS_EX_COMPOSITED); //create view#2 m_view_hWnd=m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); //add thumbnail-list images here, or later, it's not important .... } class CIAVView : public CScrollWindowImpl<CIAVView > { public: DECLARE_WND_CLASS_EX(NULL, CS_HREDRAW | CS_VREDRAW, -1) BEGIN_MSG_MAP(CIAVView) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) ... CHAIN_MSG_MAP(CScrollWindowImpl) END_MSG_MAP() void DoPaint(CDCHandle dc); //I implement flicker-free draw here ... } class CThumbView: public CDoubleBufferWindowImpl<CThumbView, CListViewCtrl> public: DECLARE_WND_SUPERCLASS(NULL, CListViewCtrl::GetWndClassName()) CImageList m_ImageListThumb; BEGIN_MSG_MAP(CThumbView) ... END_MSG_MAP() ... }
The problem is: in debug version all is fine with window redrawing but in release version my flicker-free window is never updated, even when it is -
I encountered strange problem with WTL program I'm trying to make (please bear with me because I'm not a pro, programming is just my hobby). I'm trying to make a program to view any image directly from zip (something like CDisplay, but with FreeImage and ZipUtils). I reused code of a WTL Bitmap viewer example (from original WTL package). I'm switching 2 views in SDI application (see http://www.codeproject.com/KB/wtl/switchviews\_wtl.aspx), one flicker-free image display (generic view) and a CListViewCtrl thumbnails list (not a control in client, I use whole view#2 window). I build with VC8ExpressSP1 + Platform SDK2003R2 + WTL latest version. Essential code:
class CMainFrame : public CFrameWindowImpl<CMainFrame >, public CUpdateUI<CMainFrame >,public CMessageFilter, public CIdleHandler, public C_ImgArchive { public: DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME) CIAVView m_view; CThumbView m_thumbview; BEGIN_UPDATE_UI_MAP(CMainFrame) END_UPDATE_UI_MAP() BEGIN_MSG_MAP(CMainFrame) MESSAGE_HANDLER(WM_CREATE, OnCreate) ..... CHAIN_MSG_MAP(CUpdateUI) CHAIN_MSG_MAP(CFrameWindowImpl) END_MSG_MAP() ....} // LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { //create view#1 m_hWndClient=m_thumbview.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LVS_ICON | LVS_SINGLESEL | WS_EX_COMPOSITED); //create view#2 m_view_hWnd=m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); //add thumbnail-list images here, or later, it's not important .... } class CIAVView : public CScrollWindowImpl<CIAVView > { public: DECLARE_WND_CLASS_EX(NULL, CS_HREDRAW | CS_VREDRAW, -1) BEGIN_MSG_MAP(CIAVView) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) ... CHAIN_MSG_MAP(CScrollWindowImpl) END_MSG_MAP() void DoPaint(CDCHandle dc); //I implement flicker-free draw here ... } class CThumbView: public CDoubleBufferWindowImpl<CThumbView, CListViewCtrl> public: DECLARE_WND_SUPERCLASS(NULL, CListViewCtrl::GetWndClassName()) CImageList m_ImageListThumb; BEGIN_MSG_MAP(CThumbView) ... END_MSG_MAP() ... }
The problem is: in debug version all is fine with window redrawing but in release version my flicker-free window is never updated, even when it isHave a look at http://www.flounder.com/debug_release.htm[^] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]