Print Page | Close Window

CFormView and ScrollBars

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=699
Printed Date: 17 June 2025 at 10:34pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CFormView and ScrollBars
Posted By: AliRafiee
Subject: CFormView and ScrollBars
Date Posted: 06 May 2004 at 4:10pm

Hi,

I have an MDI application, trying to use Office2003 theme.  The application's View is a CXTTabView, and in the OnInitialUpdate I add a couple of views (CFormView) to the CXTTabView.  If I resize the view so that the scrollbars show up, they flicker between gray and blue scrollbars, once I stop it displays the gray ones until I click on each part of the scroll bars, and at that point it redraws them in blue.

What am I doing wrong here?

Thanks

Ali




Replies:
Posted By: LarryWaugh
Date Posted: 18 November 2004 at 3:52pm
This is a very ANNOYING problem. Does CodeJock have any input on this situation??


Posted By: Oleg
Date Posted: 18 November 2004 at 11:32pm

it is OS xp bug. Remove scrollbars:

void CSimpleForm::OnInitialUpdate()
{
 CFormView::OnInitialUpdate();
 
 SetScaleToFitSize(CSize(0));
 
}



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: LarryWaugh
Date Posted: 19 November 2004 at 8:26am

Adding SetScaleToFitSize(CSize(0)); causes a Debug Assertion Failed in wingdi.cpp at line 454.

This is a CXTResizeFormView derived class in a CXTSplitterWnd.



Posted By: AliRafiee
Date Posted: 19 November 2004 at 10:05am

Larry

Change the line to

SetScaleToFitSize(CSize(1,1));

to get rid of the asserts, but doesn't solve the problem, it looks like a microsoft bug!

 

Oleg,

For me that doesn't solve the problem, it just simply hids the scrollbar.

 



Posted By: robin_l
Date Posted: 05 May 2007 at 9:44am
I've struggled with this for a long time and have come up with a solution that others might find useful. It seems that if you set the WS_VSCROLL and WS_HSCROLL styles then this ensures the themed scrollbars are used. However, you need to then ensure that these flags are restored to the original values (or resizing doesn't work properly).  In your OnInitialUpdate code add the following before you do anything else:
 
BOOL bisV = (GetStyle() & WS_VSCROLL)!= 0;
BOOL bisH = (GetStyle() & WS_HSCROLL)!= 0;
// add scroll bars to ensure that themed ones are used later
// overcomes windows bug (XP)
ModifyStyle( 0, WS_HSCROLL | WS_VSCROLL );

// remove / put them back correctly
ModifyStyle( WS_HSCROLL | WS_VSCROLL, (bisH ? WS_HSCROLL : 0) | (bisV ? WS_VSCROLL : 0) );
 
ModifyStyle(0, WS_CLIPCHILDREN|WS_CLIPSIBLINGS);


Posted By: countersa08
Date Posted: 23 June 2007 at 11:12pm
Thank you for this solution.  It fixed my problem too!


Posted By: tomay3000
Date Posted: 31 October 2013 at 9:58pm
nice trick ;)

this also could work:

DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
::SetWindowLong(m_hWnd, GWL_STYLE, WS_HSCROLL | WS_VSCROLL);
::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);


-------------
Product: Codejock ToolkitPro MFC v16.2.0
Platform: Microsoft Windows 8 Pro (64-bit)

Language: Microsoft Visual C++ v6.0 (MFC)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net