CFormView and scrolling

Hi,

I am developping on pocket pc an application with  some views deriving 
from CFormView.
On this platform you cannot resize your MainFrame because it's always 
maximized.
So let's say I have a CAboutView and inside it I am putting some 
controls outside the client rect, for now here is what I am doing to 
have the scrollbar appeared :


void CAboutView::OnWindowPosChanged( WINDOWPOS* lpwndpos )
if ( rcItem.bottom > rc.bottom ) {
		// Scroll bar info
		SetScrolling( TRUE );
		SetScrollPos( SB_VERT, 0 );
		SetScrollSizes( MM_TEXT, CSize( rc.Width(), rcItem.bottom + 2) );
		
	}
	else {
		// Scroll bar info
		SetScrollSizes( MM_TEXT, rc.Size() );
	}
}

So basically I am taking the last controls and I resize my scrollbars.

But I am not very satisfied by this solution, do you have a better idea ?
0
7/20/2007 9:11:59 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1092 Views

Similar Articles

[PageSpeed] 22

What is it that you are trying to do?  That's not very clear in your post.

AliR.


"mosfet" <john.doe@anonymous.org> wrote in message 
news:46a07c5f$0$9922$426a74cc@news.free.fr...
> Hi,
>
> I am developping on pocket pc an application with  some views deriving 
> from CFormView.
> On this platform you cannot resize your MainFrame because it's always 
> maximized.
> So let's say I have a CAboutView and inside it I am putting some controls 
> outside the client rect, for now here is what I am doing to have the 
> scrollbar appeared :
>
>
> void CAboutView::OnWindowPosChanged( WINDOWPOS* lpwndpos )
> if ( rcItem.bottom > rc.bottom ) {
> // Scroll bar info
> SetScrolling( TRUE );
> SetScrollPos( SB_VERT, 0 );
> SetScrollSizes( MM_TEXT, CSize( rc.Width(), rcItem.bottom + 2) );
>
> }
> else {
> // Scroll bar info
> SetScrollSizes( MM_TEXT, rc.Size() );
> }
> }
>
> So basically I am taking the last controls and I resize my scrollbars.
>
> But I am not very satisfied by this solution, do you have a better idea ? 


0
AliR3470 (3236)
7/20/2007 2:53:11 PM
AliR (VC++ MVP) a �crit :
> What is it that you are trying to do?  That's not very clear in your post.
> 
> AliR.
> 
> 
> "mosfet" <john.doe@anonymous.org> wrote in message 
> news:46a07c5f$0$9922$426a74cc@news.free.fr...
>> Hi,
>>
>> I am developping on pocket pc an application with  some views deriving 
>> from CFormView.
>> On this platform you cannot resize your MainFrame because it's always 
>> maximized.
>> So let's say I have a CAboutView and inside it I am putting some controls 
>> outside the client rect, for now here is what I am doing to have the 
>> scrollbar appeared :
>>
>>
>> void CAboutView::OnWindowPosChanged( WINDOWPOS* lpwndpos )
>> if ( rcItem.bottom > rc.bottom ) {
>> // Scroll bar info
>> SetScrolling( TRUE );
>> SetScrollPos( SB_VERT, 0 );
>> SetScrollSizes( MM_TEXT, CSize( rc.Width(), rcItem.bottom + 2) );
>>
>> }
>> else {
>> // Scroll bar info
>> SetScrollSizes( MM_TEXT, rc.Size() );
>> }
>> }
>>
>> So basically I am taking the last controls and I resize my scrollbars.
>>
>> But I am not very satisfied by this solution, do you have a better idea ? 
> 
> 

Ok What I want to do is to be able to scroll a view deriving from a 
CFormView on a smartphone knowing that on this platform you cannot move
scollbars "by hand". For that you have to use keypad.
The problem is usually a WM_KEYDOWN is eaten in the PreTranslateMessage.

So when I have a CFormView with some controls(listboxes for instance) on 
it, a WM_KEYDOWN is receive in the PreTranslate and after the 
shell/OS/framework(I don't know who exactly) move the focus from one 
control to another.

Now consider the case :

We have a view with one vertical scrollbar and one static control to 
display some text and a CStaticlink(CButton) to open a URL when clicking 
on it.

If I want to be able to move my scrollbar I do the following

UINT CBaseView::OnGetDlgCode()
{
if (m_nScrollPolicy == 0)
	return (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS | 
DLGC_WANTALLKEYS);
	else
	return ( CFormView::OnGetDlgCode() );
}


I receive the WM_GETDLGCODE and I say that my view wants to receive 
WM_KEYDOWN.
When I receive the WM_KEYDOWN I call OnVScroll to move my view BUT the 
problem is if I do that my CStaticlink cannot get focus and I cannot
click on it.

void CBaseView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	...
	switch (nChar)
	{
	case VK_UP:
		nVPos = ((nVPos - 15) < 0)  ? 0 : nVPos - 15;
		OnVScroll(SB_THUMBTRACK, nVPos,NULL);
		break;
	case VK_DOWN:
		OnVScroll(SB_THUMBTRACK,nVPos + 15,NULL);
		break;
	case VK_LEFT:
		nHPos = ((nHPos - 15) < 0)  ? 0 : nHPos - 15;
		OnHScroll(SB_THUMBTRACK,nHPos,NULL);
		break;
	case VK_RIGHT:
		nHPos += 15;
		OnHScroll(SB_THUMBTRACK,nHPos,NULL);
		break;
	}
}

So to fix it I would need inside the OnKeyDown to check if the next tab 
control is on screen and in this case instead of calling OnVScroll maybe 
  I should set focus to my CStaticlink.
And what if a ClistView get the focus, normally each call to WM_KEYDOWN 
should move the item and not the focus.


ANOTHER problem is that this first case relies on the fact that I 
receive the WM_GETDLGCODE and it's not always the case. it works ONLY if 
my view doesn't have a focus on a control.

































0
7/20/2007 3:36:35 PM
If you ask me this is going to be a never ending battle between the controls 
and the scrollbar.

But here are some pointers.
You can obviously get the scroll position which will give you the visible 
area of the FormView.
You can call GetNextDlgTabItem to get the next or previous item in the tab 
order.  And you can get its rectangle
Now you can compare the two rectangles to see if the next item in the tab 
order is visible or not.

Why don't you catch the WM_KEYDOWN message in the PreTranslateMessage 
anyway, and do your processing there instead of OnKeyDown.

Hope this helps.
AliR.


"mosfet" <john.doe@anonymous.org> wrote in message 
news:46a0d684$0$1616$426a34cc@news.free.fr...
> AliR (VC++ MVP) a �crit :
>> What is it that you are trying to do?  That's not very clear in your 
>> post.
>>
>> AliR.
>>
>>
>> "mosfet" <john.doe@anonymous.org> wrote in message 
>> news:46a07c5f$0$9922$426a74cc@news.free.fr...
>>> Hi,
>>>
>>> I am developping on pocket pc an application with  some views deriving 
>>> from CFormView.
>>> On this platform you cannot resize your MainFrame because it's always 
>>> maximized.
>>> So let's say I have a CAboutView and inside it I am putting some 
>>> controls outside the client rect, for now here is what I am doing to 
>>> have the scrollbar appeared :
>>>
>>>
>>> void CAboutView::OnWindowPosChanged( WINDOWPOS* lpwndpos )
>>> if ( rcItem.bottom > rc.bottom ) {
>>> // Scroll bar info
>>> SetScrolling( TRUE );
>>> SetScrollPos( SB_VERT, 0 );
>>> SetScrollSizes( MM_TEXT, CSize( rc.Width(), rcItem.bottom + 2) );
>>>
>>> }
>>> else {
>>> // Scroll bar info
>>> SetScrollSizes( MM_TEXT, rc.Size() );
>>> }
>>> }
>>>
>>> So basically I am taking the last controls and I resize my scrollbars.
>>>
>>> But I am not very satisfied by this solution, do you have a better idea 
>>> ?
>>
>>
>
> Ok What I want to do is to be able to scroll a view deriving from a 
> CFormView on a smartphone knowing that on this platform you cannot move
> scollbars "by hand". For that you have to use keypad.
> The problem is usually a WM_KEYDOWN is eaten in the PreTranslateMessage.
>
> So when I have a CFormView with some controls(listboxes for instance) on 
> it, a WM_KEYDOWN is receive in the PreTranslate and after the 
> shell/OS/framework(I don't know who exactly) move the focus from one 
> control to another.
>
> Now consider the case :
>
> We have a view with one vertical scrollbar and one static control to 
> display some text and a CStaticlink(CButton) to open a URL when clicking 
> on it.
>
> If I want to be able to move my scrollbar I do the following
>
> UINT CBaseView::OnGetDlgCode()
> {
> if (m_nScrollPolicy == 0)
> return (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS | 
> DLGC_WANTALLKEYS);
> else
> return ( CFormView::OnGetDlgCode() );
> }
>
>
> I receive the WM_GETDLGCODE and I say that my view wants to receive 
> WM_KEYDOWN.
> When I receive the WM_KEYDOWN I call OnVScroll to move my view BUT the 
> problem is if I do that my CStaticlink cannot get focus and I cannot
> click on it.
>
> void CBaseView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
> {
> ...
> switch (nChar)
> {
> case VK_UP:
> nVPos = ((nVPos - 15) < 0)  ? 0 : nVPos - 15;
> OnVScroll(SB_THUMBTRACK, nVPos,NULL);
> break;
> case VK_DOWN:
> OnVScroll(SB_THUMBTRACK,nVPos + 15,NULL);
> break;
> case VK_LEFT:
> nHPos = ((nHPos - 15) < 0)  ? 0 : nHPos - 15;
> OnHScroll(SB_THUMBTRACK,nHPos,NULL);
> break;
> case VK_RIGHT:
> nHPos += 15;
> OnHScroll(SB_THUMBTRACK,nHPos,NULL);
> break;
> }
> }
>
> So to fix it I would need inside the OnKeyDown to check if the next tab 
> control is on screen and in this case instead of calling OnVScroll maybe I 
> should set focus to my CStaticlink.
> And what if a ClistView get the focus, normally each call to WM_KEYDOWN 
> should move the item and not the focus.
>
>
> ANOTHER problem is that this first case relies on the fact that I receive 
> the WM_GETDLGCODE and it's not always the case. it works ONLY if my view 
> doesn't have a focus on a control.
>


0
AliR3470 (3236)
7/20/2007 3:54:26 PM
Reply:

Similar Artilces:

Panning and scrolling with tablet pen
Hi all, Is there a way to scroll and pan with the tablet pen? Like the 'hand' button that is found is many applications. Even suggestions for a way that it could be implemented programatically would be appreciated. Thanks, omega Omega wrote: > Is there a way to scroll and pan with the tablet pen? Like the 'hand' > button that is found is many applications. Even suggestions for a way > that it could be implemented programatically would be appreciated. There is no such feature. One can only use the scrollbars. Rainald Hi, Thanks for your repl...

Scrolling Window Issues
Query 1: "Scrolling Window Issues" During insertion a new line in the scrolling window, a duplicate line automatically inserted only in Scrolling window. But when click again on the new line inserted it vanishes. I have following settings: 1>It saves line item during insertion. 2>I have applied range on the table attached with the scrolling window How can I get rid of this duplicate record in the scrolling window which has no existance in the database? Query 2: "Field Locking Issue in Scrolling Window" How can I lock a certain line in the scrolling window? ...

Outlook vertical scrollbar slider
I have Outlook 2002 on Windows XP. When I move the vertical scrollbar slider in Contacts, Journal and Tasks, the entries don't move until I release the mouse button, then they jump to the final position. Is there a way to activate smooth scrolling? The slider sort of works in the e-mail Inbox - it does smooth scrolling but only on the second try. I seem to remember there was a registry fix for this problem in Word some years ago and wonder if there is one for Outlook. Any help will be appreciated. There is not a registry fix. What kind of a mouse do you have? Some mouse softwar...

Vertical Scroll Bar
Word 2003. I can see the left vertical scroll bar. I can not get the the top margin guide (indicator) to show on it unless I click View - Headers/Footers. When I close Headers/Footers the guide indictor is visible. I am in Print Layout View. I have checked "all" of Help. Any clue? Thank you for your help. Hi Barbara From File>PageSetup check the 'Top Margin' "Barbara" wrote: > Word 2003. > > I can see the left vertical scroll bar. I can not get the the top margin > guide (indicator) to show on it unless I click View -...

Is it possible to use the mouse wheel to scroll horizontally?
I have a large excel document, and I wish to know if it is possible to scroll using the mouse wheel horizontally across the page, instead of the default vertical down the page? You can using tilt wheel..Make sure from Control Panel you have enabled horizontal scrolling with tilt wheel . -- Jacob "Diabolo_Devil" wrote: > I have a large excel document, and I wish to know if it is possible to scroll > using the mouse wheel horizontally across the page, instead of the default > vertical down the page? ...

Excel Charts from pivot tables without scroll down bar?
Is there an easy way to copy/paste a pivot table chart into powerpoint without scroll down bars? If you hide them in Excel: On the PivotTable toolbar, choose PivotChart>Hide PivotChart Field Buttons they should also be hidden when you paste the chart into PowerPoint. Angel wrote: > Is there an easy way to copy/paste a pivot table chart into powerpoint > without scroll down bars? -- Debra Dalgleish Contextures http://www.contextures.com/tiptech.html ...

Freeze the side column/top row & scroll others
what is the function to set (lock in or freeze) the first column and / or top row of a spreadsheet, so the words and numbers remain in the same place as you scroll the other columns and rows. (so you can add more columns..yet keep the main information in the first column/row) Freeze Panes..... In older versions of Excel, it is under Window. In 2007 version of Excel, it is under View. You first select a cell, then activate the command. Excel uses the selected cell's upper left corner to define the freeze point. Play with it. You can also Unfreeze panes that were fro...

Scroll Bar question
This is kind of hard to explain, but here it goes. Let's say I start with a spreadsheet that has 10,000 rows of data. Then I decide to delete 3,000 of these rows. When I use the scroll bar to go to the bottom of the spreadsheet, it takes me to row 10,000. Or, if I use control + end, it goes to row 10,000 as well. Is there a way to "reset" the scroll bar to now know that the bottom of the data is row 7,000? I know I could just copy it into a new spreadsheet. But I am just curious. The same can be asked about deleted columns too. Thank you. Visit Debra Dalg...

Chart Zooming and scrolling
Please shoot me or somehow put me out of my misery! Try the following: (1) Create a dummy scatter chartsheet manually. Data is not important, chart can be completely blank for this test. (2) Zoom-in with 200 magnification on the chart. (3) Now WRITE a VBA macro to position the view to the upper right corner of the chart. Scrollbars movement don't seem to be functional within VBA at least on chart pages. Thanks in advance Ken Put the chart into a blank worksheet, and constrain the ScrollArea to the cells covered by the chart. Then you can use the ScrollRows and ScrollColumns, or the ...

Does Outlook have live scrolling and resizing on Vista?
Just wondering if this is a byproduct of using Outlook 2007 on a non- Vista operating system (Windows XP): 1) When scrolling the contacts window by clicking and dragging the "thumb" of the scroll bar, the list doesn't move until you let go of the mouse button. This happens in all of the contact views (Business Cards, Phone List, etc.). I also find this happens with mail folders which contain many messages (>200). 2) When resizing a message window, the message contents do not re-flow until you let go of the mouse button. These are steps backwards in usability compared to Out...

Access 2007 scrolling with Left mouse button
Hi, all. I have an Access application written in Access 2003 that we are now testing with Access 2007. When using Access 2003, the users used to be able to scroll through records displayed on a form by positioning the cursor on top of a VCR button and holding down the left mouse button. People with external mice could also cause the same scrolling by using their mouse wheel. Neither of these behaviors happen when the application is run using Access 2007. After reading a number of posts about changing the behavior of the mouse WHEEL when using Access 2007 so it mimics the scrollin...

vertical scroll bars missing from text and memo fields in datasheet view
I must be going insane. For some reason, vertical scroll bars are missing from my text and memo fields! I even created a brand new db file (Access 2003), created a new table with a text field and a memo field. I typed a bunch of text into them. Then I created a new form, plopped the two fields on there. The vertical scroll bars appear just fine in Single Form view, but are missing from datasheet view. Am I going crazy? I've never had this problem before. I even have a previous database that I just opened, and these the scroll bars are working fine in that database. I am at a tota...

Scroll Wheel effecting a form
Is there any way to keep a mouse scroll wheel from having an effect on a form? This is a single form for data entry and if are part way thru the form and for what ever reasom use the scroll wheel all the fields on the form are effected (they dissapear - like going to the next new record). My suggestion to get a mouse without a scrool wheel was not met with enthusiasm. :) Any help here will be appreciated. Thanks in advance The scroll wheel is moving you through the records. Nothing except your view of the records is disappearing. The records are still there. I wouldn't think y...

Display Scroll bars
What is the best way to assure that when an Excel workbook is open it fills the entire screen, regardless of the user's display specs, and that both the horizontal and vertical scrollbars display. I've tried: Private Sub Workbook_Open() With Application .DisplayFullScreen = True .DisplayScrollBars = True .DisplayStatusBar = True End With End Sub And I've also tried: Private Sub Workbook_Open() Application.DisplayFullScreen = True ActiveWindow.DisplayHorizontalScrollBar = True End Sub The problem is the horizotal scrollbar does not appear. Ironically after ...

How to create a CEdit custom Scroll bar
Good morning developers. I am currently almost halfway developping a custom scroll bar for a CEdit control. My problem is that it almost works ok in Debug mode but it is unacceptable in release mode. Is there any trails I should look into on how to properly skin a CEdit control Scroll bar. The way I did it is I disabled the scroll bar in the MFC UI designer and I am painting a scroll bar in the NC Area. Is this the proper way to do It? I cought almost all the message to drag the thum, and the mouse wheel and auto moving the thumb if the view is scrolled when typing. Currently I am st...

How to show a disabled vertical scroll bar for CListView?
Hi there, I've created a View base on CListView, with "LVS_REPORT" report style. The view's required to show a disabled vertical scroll bar for the list view when the view does not contain enough items to scroll, just like we specify LBS_DISABLENOSCROLL style to a "CListBox" list box. I tried to put this line in CMyListView::OnInitialUpdate()... ModifyStyle(0, WS_VSCROLL ,0); But it's of no use. Any ideas? Thanks. Gordon Gordon Hsu wrote: >Hi there, > >I've created a View base on CListView, with "LVS_REPORT" report style. > &g...

Using mouse scroll wheel to create new records
I am finally working out the kinks in my DB. I have a button that creates a new record in a subform when the user selects it from a list in a main form. It keeps track of the main form id (which is stored in a variable on the subform as subpoenaID.) If i create a new form using this button, then my applications keeps track of the subpeonaID. BUT if I use the scroll when to create a new record, it loses track of the subpoenaID. (I don't allow this field to be blank so the user gets an error) I don't want to disable the mousewheel. Is there an easy way (or where is the control) for...

how do i mark range from A1 to DV5000 without scrolling?
Hi Is there a menu option to mark a range from A1 to some far off cell like DK4563 without scrolling all the way down and across? thanks Cricket :-) You can type the address, e.g., A1:DK4563, in the Name Box, which is to the left of the formula bar. This will select the specified range. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com <cricketunes@yahoo.com> wrote in message news:1134001998.341982.309400@g47g2000cwa.googlegroups.com... > Hi > Is there a menu option to mark a range from A1 to some far off > cell > l...

Spinners and Scroll bars
Hi i think i already sent this but anyway... I have 2 questions: 1)Create a spinner for the deposit =A30-=A3250 increments of=20 =A325 (Link cell here is the cell containing the deposit). 2)Create a scroll bar for the interest rate. Delete the=20 value you typed in for the interest rate and put in a=20 formula related to the link cell. I have no idea what any of this means and any help would=20 be greatly appreciated.=20 Thanking you in advance, Andy Here goes, Andy 1) There are two ways to get controls (a) from the Forms toolbar and (b) from the Controls toolbar. The former are simpler to u...

How can I force a vertical scroll to a line scroll in CRichEditCtr
-- maggie zhang ...

Stop scrolling
I have a worksheet where I want to limit how far a user can scroll down. For example, I want people to be able to scroll to row 27, but have the view stop there and not allow them to be able to scroll down passed that line. Even if I hide the rows under row 27, you can still keep scrolling down. I want to stop that from happening. Is there a way? Thanks. have a look in vba help index for scrollarea -- Don Guillett SalesAid Software donaldb@281.com "gottahavit" <gottahavit@discussions.microsoft.com> wrote in message news:6FB03B59-7681-4271-B37A-FDF1DF35EADF@microsoft.com.....

Scrolling list?
Isn't there a way to make a scrolling list of fields on a form? I only use Access occasionally and it used to be 2003 and now it's 2007. I used 2007 for a project last year too so it's not like I'm just in transition. But if I have a form of say people, and on that form I want an endless scrollable list of say appointments (which links to its own table), isn't there some way, maybe using a bound object frame or something, to set that up? I've found a video tutorial online about putting one form on another, the same effect I guess as using the subform item in for...

scroll a OLE object field
I am using a form to display the contents of a Word Doc in an Access 03 DB. The results are great but the page is too large to show with the form that I'm using. Is there a way to scroll the contents of the OLE field? Thank You! ...

scroll window
Hello! I read a book called programming Visual C++ says. "If you use the mouse to shrink the size of an ordinary window, the contents of the window remain anchored at the top of the window, and items at the bottom and/or the right of the window disappear. When you expand the window, the items reappear.You can correctly conclude that a window is larger then the viewport that you see on the screen. the viewport doesn't have to be anchored at the top left of the window area however. Through the use of the CWnd functions ScrollWindow and SetWindowOrg, the CscrollView class allows...

Scrolling issue in Version 9
Another employee and myself are coming across an issue in Dynamics Version 9 that I hope someone has some knowledge of. When in any inquiry screen occassionally (a couple times a day) when we use our mouse scroll button Dynamics continues scrolling even after we have ceased using the button. The scrolling continues and we are forced to do a hard exit and restart the program again. Does anyone know the cause and any specific remedies? This may be unrelated but also when I am in the bank recon module and marking cleared checks sometimes after I have used the mouse scroll to scroll dow...