How to set initial scroll position?

I have a CScrollView-derived view class with fixed height. I am setting the
vertical scroll size based on this known height in OnInitialUpdate(). I also
want to set the initial scroll position to the middle of the scroll range.
But I cannot do it within OnInitialUpdate() as OnInitialUpdate() is called
before the view window is displayed. So the height of the view is 0 and
ScrollToPosition() has no effect.

Where should the function ScrollToPosition() called?

A hack would be to use a BOOL and call it in OnDraw(), but IMO, this is not
the right way.

Thanks for any help.


0
7/6/2003 10:22:48 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
896 Views

Similar Articles

[PageSpeed] 46

Scott

Thanks for replying.

I tried using CRect rect; GetClientRect(&rect) and GetWindowRect(&rect), but
both are returning a rectangle of height 0 in rect.

Does it have anything to do with the splitter windows? The view I am talking
about is created within a static splitter window pane.

Thanks
Abhijit

"Scott McPhillips" <scottmcp@mvps.org> wrote in message
news:3F08CA98.5EB8AA2C@mvps.org...
> Abhijit wrote:
> >
> > I have a CScrollView-derived view class with fixed height. I am setting
the
> > vertical scroll size based on this known height in OnInitialUpdate(). I
also
> > want to set the initial scroll position to the middle of the scroll
range.
> > But I cannot do it within OnInitialUpdate() as OnInitialUpdate() is
called
> > before the view window is displayed. So the height of the view is 0 and
> > ScrollToPosition() has no effect.
> >
> > Where should the function ScrollToPosition() called?
> >
> > A hack would be to use a BOOL and call it in OnDraw(), but IMO, this is
not
> > the right way.
> >
> > Thanks for any help.
>
> I don't know how you got a height of 0.  When I try GetWindowRect in
> OnInitialUpdate it gets the correct size.
>
> A small improvement on your hack would be to use a BOOL and call
> ScrollToPosition in OnSize.  OnSize is passed the window size whenever
> it changes.
>
> --
> Scott McPhillips [VC++ MVP]


0
7/7/2003 7:22:49 AM
Abhijit wrote:
> 
> Scott
> 
> Thanks for replying.
> 
> I tried using CRect rect; GetClientRect(&rect) and GetWindowRect(&rect), but
> both are returning a rectangle of height 0 in rect.
> 
> Does it have anything to do with the splitter windows? The view I am talking
> about is created within a static splitter window pane.
> 
> Thanks
> Abhijit

Yes, that could be the cause.  I've seen cases with splitters where the
view was resized several times (OnSize) before finally receiving its
final size.  You may want to consider putting a new function in your
view to set the initial scroll position.  Call it from the CMainFrame
after the splitter RecalcLayout has finished.

--
Scott McPhillips [VC++ MVP]
0
scottmcp (342)
7/7/2003 12:32:53 PM
Reply:

Similar Artilces:

In Excel 2000, how do I add a vertical scroll bar to a split scre.
When I split my worksheet screen, I get an additional horizontal scroll bar but not a vertical. How do I rectify this? If it helps, what I am trying to do is lock two colums so that they don't scroll when other columns do, so that they always remain visible. Lisa Split won't allow that. Take the Split off and then Window>New Window to get two windows. Now Window>Arrange>Vertical to get them side by side. Resize the two column window. If you tire of this configuation, close one of the windows then save. Gord Dibben Excel MVP On Thu, 13 Jan 2005 12:37:03 -0800, &qu...

Setting Up Hotmail w/ Outlook
I am trying to set outlook 2000 to check a hotmail account. Someone told me that this is not possible. How do I set up outlook to automatically check hotmail? http://support.microsoft.com/default.aspx?scid=kb;en-us;287424&Product=ol2002 "LunaBalthazar@hotmail.com" <anonymous@discussions.microsoft.com> wrote in message news:18a7301c41b5a$5a885ff0$a401280a@phx.gbl... > I am trying to set outlook 2000 to check a hotmail > account. Someone told me that this is not possible. How > do I set up outlook to automatically check hotmail? Outlook 2000 does not sup...

How to set plot area back to automatic?
Hi, how do I set the chart plot area back to automatic, and make it stay there? While opening new workbook and making a chart, the plot area is set to some colour and I prefer it to keep automatic, and white. How? "KeepItSimple" <KeepItSimple@discussions.microsoft.com> wrote in message news:E7F9B001-56FD-48E6-B1B0-1056F51FE94C@microsoft.com... > Hi, > how do I set the chart plot area back to automatic, and make it stay > there? > While opening new workbook and making a chart, the plot area is set to > some > colour and I prefer it to keep automatic, and ...

set up new indentity in outlook express 6
I tried to set up my identity in our computer because I want to have my own email account from charter (ISP). But I can't receive email but i can send. The server keep on denying my username and password. What should I do? DO i need to call charter to set it up for me? "glenn lawrence" <galawrence@charter.net> wrote in message news:#GFWtMuCKHA.3732@TK2MSFTNGP02.phx.gbl... > I tried to set up my identity in our computer because I want to have my > own email account from charter (ISP). But I can't receive email but i can > send. The server keep on deny...

Unauthorized access to OWA if account set to change password on lo
Good day, We recently upgraded from Exchange 2000 to Exchange 2003 SP2 Our OWA was previously configured to allow users to change their password. If I configure a user account to "Prompt for the user to change password at next logon", the following page is displayed when they access OWA "You are not authorized to view this page" If I deselect the option that users are required to change their password at next logon, they can login to OWA properly and even change their passwords using the Options section. I'm thinking that there is probably an issue with access ...

Files and Settings Transfer Wizard #2
Hello, I recently did a clean install on my parents computer, which is part of my annual maintenance routine. I have used the Files and Settings Transfer Wizard several times on several machines to successfully restore data after this procedure. Unfortunately, when I did this on my parents machine, it lost all data in Outlook 2003 - contacts, emails, account settings, everything. It attempted to restore some settings in Outlook Express, but without any success. Once I reinstalled the OS and all the apps, I ran Windows Update and installed every hotfix, which gave me an identical environment ...

How can I set up a program 8 by 11 folding the sheet in quarters
I am trying to print a church progam with one sheet of paper making four pages by folding the sheet in quarters. I have not figured out how to set this up with pubisher. -- Imanuker Imanuker wrote: > I am trying to print a church progam with one sheet of > paper making four pages by folding the sheet in quarters. > I have not figured out how to set this up with pubisher. ================================ This may be what you are seeking. Go to...Blank Publications / Side Fold Card or Top Fold Card. -- ******John Inzer******** **MS Picture It! MVP** *****Digital Image****** H...

Sales Tax set-up question
I have a tax set up problem with RMS. I am using the "per customer" tax configuration because we ship products out of state and out of country. Here is the situation: Ontario (local) customers pay GST (federal) and PST (state/provincial) Rest of Canada pay GST only Outside Canada pay no tax However, in Ontario some products are still non-taxable (which is no problem) and some are GST only (which is a problem). Is there a way to accommodate all of this? Also, if I have a customer who is from out of province (with an out of province address in RMS) but who visits my store in Ont...

Setting up two users in Outlook
How do you set up multiple users in Outlook (I don't want to share the calendar or contacts). I tried creating a new .pst file, but when I opened it my contacts and calendar information appeared also on the new file. When I deleted a contact, it deleted it in my .pst file as well as the new one. Thanks. What version of Outlook are you using, and if 98 or 2000, what mail support mode? If you're not sure, look at the second line of Help | About Microsoft Outlook -- it should say "Internet Mail Only" or "Corporate/Workgroup". (Outlook 97, 2002, and 2003 don'...

Scoll window settings
I'm not sure if the following is possible in dex but I have the need to change either the font, color or shading of a line in a scoll window based on an attribute of the data in the line. It would even be acceptable to display a icon on the line. I need to draw the users attention to the line(s) when a certain condition exists. I have not found an easy way to do this in Dexterity for GP 10. Any suggestions would be appreciated. -Mark Hi Mark You need to add code into your fill script and your pre script to make the changes you want. You can use a visual switch to hide and show or...

setting workbook read only except for one user
I have a sheet that I want to share with co-workers but I only want them to have read only access. If I put the file on the public server it will give the frist perons to open it full access and readonly to everyone there after. What is the best way to go about this? <scott.streit@gmail.com> wrote... >I have a sheet that I want to share with co-workers but I only want >them to have read only access. > >If I put the file on the public server it will give the frist perons to >open it full access and readonly to everyone there after. > >What is the best way to go ab...

finding hidden tab settings
I appear to have some hidden tab settings from text that I have imported from WordPerfect. How do I find and delete them? I am accustomed to using "Reveal Codes" and am totally lost. I did save the text as text only, but it appears that the tabs came over with the text. ...

Setting up online services for multiple accounts at same bank
I'm having trouble establishing automatic updates for multiple accounts at the same bank. Specifically, I can't seem to automatically download transactions for my credit and my wife's credit both held with MBNA. I can set one up just fine, but Money doesn't seem to let me set the second one up. At least not intuitively. Any ideas? Thanks In microsoft.public.money, phudrick wrote: >I'm having trouble establishing automatic updates for multiple accounts at >the same bank. Specifically, I can't seem to automatically download >transactions for my cred...

How do I chart two separate sets of x and corresponding y values .
I would like to chart two sets of x and y values with each set of x values corresponding to its own set of dependant y values. The two sets of x values for the ordinate are entirely different. It seems like I can only chart two sets of data on the same graph with the same values for x and two separate sets of dependant values for y. Is there any way possible to get around this problem? Select your first set of X&Y data, Insert/ Chart (Chart type XY, & choose an appropriate sub-type)/ other options as appropriate. Now select your second set of X&Y data, Copy, select your c...

Same setting not working
I have two accounts, mine (admin), and a guest account. I set up a mail account on the admin and it works fine, retrieves the mail from the comcast servers to my inbox, on start up. But if I set it up the same way on the guest account, it doesn't work at all, nothing is retrieved and it can't be viewed. Why is the guest account not working? Anyone? >-----Original Message----- >I have two accounts, mine (admin), and a guest account. I >set up a mail account on the admin and it works fine, >retrieves the mail from the comcast servers to my inbox, >on start up. B...

Scroll Bar's bubble identifier
In Excel 2000, when u have a huge worksheet and u drag the scroll bar to jump into a specific row/column, it will show you an identifier in which row/column u have scrolled in to. But in Excel 2003, this feature seems to be taken out. Is there a way to enable it back or was it really taken out permanently? regards, Obrien >>But in Excel 2003, this feature seems to be taken out. Actually it disappeared in Excel 2002. The reason it was removed is that in Excel 2002+ the worksheet actually scrolls real-time as you drag the scroll bars. So it's not needed as you can see where...

Project settings for final release
Could I get some advice on exactly which setting I should change for my Release build in Project Settings? Up until now, I have enabled browsing and debugging, but at this final stage, I would like to strip out everything possible. What should Optimizations be set to? Should I set Debug Info to none? What else should I consider? Typically, when you create a new project the settingsf or debug and release are created automatically and I've found the defaults to be pretty good. I usually just add the non-debug versions of any libraries I've added. Typcially Optimization is dis...

Pivot table field settings--ghosted out
I'm MS-Excel 2003 pivot tables which connect to an OLAP database. I a trying to set my subtotals in the pivot table to "AVERAGE". Currently they're defaulting to the "SUM" setting. I right click on the cell (I do this for both the cell and the cel heading...same result) and select "FIELD SETTINGS". This brings up th Pivot table field window. The only options that I have that are no ghosted out are "AUTOMATIC" and "NONE". I understand that I need to tick the CUSTOM radio button under th Subtotal heading, but i am unable to do so...

How can i set incoming and outgoing limit size?
Hell I'm wondering how can i set incoming and outgoing mail limit size for distribution list in exchange 5.5? Is there somekind of script or maybe a tool (like header for exporting and importing columns)? Please help me out!! Thanks a lo Goran On your connection in configuration. Open the live connection and on "Generatl" tab you can define the message size. >-----Original Message----- >Hello > >I'm wondering how can i set incoming and outgoing mail limit size for distribution list in exchange 5.5? Is there somekind of script or maybe a tool (like header...

Outlook 2003 / BCM
Is there any way to set "global" field settings for each opportunity in the Opportunities section - versus having to adjust each Opportunity's view one by one? ...

Setting up OWA External Access, No FQDN, using .local domain.
Hello everyone, I am trying to enable users to access OWA externally on our SBS 2003 server. Current set up is XXXXX.local as the domain name with XXXX.org registered but currently only forwarding to a hosted website. Running ISA 2004 on the server as well. OWA and RWW work fine internally but I am struggling to publish these services externally. Currently using a Draytek router with a static IP address. I know that changing the domain is not a practical option in SBS 2003 and have tried using OWA publishing rule & web listener but still unable ...

email settings for pop accounts
just reinstalled outlook and have set all pop email settings for various email accounts but cannot send or receive email. (only hotmail as http works). when send test email, all actions work except last one: "unable to send test message. pleae verify email address field" also cannot reply to existing messages in inbox - error message - relaying email to 'email address' is not allowed. any help is appreciated. Check your SMTP server settings (for the sending mail problem) - use the same SMTP server for all your accounts (your ISP's) or make sure you're aut...

Icon Sets
I would like to display in cell A2 a red diamond if the value in U2="Storage"; a Green Circle if the value in U2="Central Files" "Office" or Floor"; and a yellow triangle if the value in U2="Missing". I saw the response to "ICON Arrows UP or DOWN", but I couldn't understand where the different parts were supposed to go. Nolene, you can put an IF statement in column A that reflects the information in column U: =IF(U2="Storage", 1,IF(or(U2="Central File",U2="Office",U2="Floor"),2,...

Set up publisher to allow email sent as message?
I have Publisher 2003. The program is suppose to allow the sending of a newsletter as a message with the mail. I only have the option of sending it as an attachment. Is there a setting to change this to allow all three options. Send newsletter as attachment, message or email preview? Thanks, BRETMN <BRETMN@discussions.microsoft.com> was very recently heard to utter: > I have Publisher 2003. The program is suppose to allow the sending > of a newsletter as a message with the mail. I only have the option > of sending it as an attachment. Is there a setting to change...

set up 401k #2
I CAN SET UP THE "SHELL" OF A 401K ACCOUNT. ONCE I START ENTERING SHARE PRICES AND QUANTITIES INTO A NEW ACCOUNT (INITIAL VALUE = $0) THE TOTAL ACCOUNT VALUE DOESN'T MAKE ANY SENSE; THE ACCOUNT VALUE IS VERY HIGH FOR HAVING ONLY 4 QUARTERS WORTH OF STATEMENTS ENTERED. WHAT DO I NEED TO ENTER AND NOT TO ENTER?? I NEED HELP UNDERSTANDING WHAT I'M LOOKING AT AND SOME ASSISTANCE ON WHAT I COULD BE DOING WRONG WHEN ENTERING INFO. I AM A 7 YEAR USER OF MONEY BUT HAVE ALWAYS SHYED AWAY FROM SETTING UP MY INVESTMENT ACCOUNTS IN MONEY BECAUSE OF THE DIFFICULTIES MENTIONED...