can't get scrollbar to come up -- CScrollView

I am new to MFC and I am trying to get a simple app working with a
scrollable view.  I have put in the call to SetScrollSizes in the
OnInitialUpdate method.  I'm still not quite sure what sizeTotal is supposed
to do.  I just gave it a value of 5 for the y for now, which I think I want
to set to the number of lines of text I have to display.  And then I set y
to 50.

int numLines = 5;
CSize sizeTotal;
sizeTotal.cy = numLines;
sizeTotal.cx = 50;

SetScrollSizes(
   MM_TEXT,
   sizeTotal);

In the OnDraw method, I put in code to draw my text on the view using the
device context.  The text gets drawn, but there is no scrolling
functionality.

 CRect clientRect;
 GetClientRect(clientRect);
 pDC ->DrawText(CString("Blah
blah!\n\n\n\nn\n\n\n\n\n\n\n\n\n\nBlahBlah!\n"), clientRect,0);

Can anyone help?


Thanks,
Chris


0
ijkdc (24)
8/22/2004 1:51:42 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
714 Views

Similar Articles

[PageSpeed] 40

If you use MM_TEXT mapping, the scroll size is the virtual size of the
display in pixels. For example, if actual height of window is 400 and you
set the CScrollView to anything <= 400 there will be no scroll bars.

You can use DrawText(DT_CALCRECT) to figure how big the text will actually
be, and set the scroll size to rect.Width, rect.Height. This will ensure
that the scrollbars will provide sufficient range to show all of the text.


"Chris" <ijkdc@spamhater.hotmail.com> wrote in message
news:utaFSq%23hEHA.384@TK2MSFTNGP10.phx.gbl...
> I am new to MFC and I am trying to get a simple app working with a
> scrollable view.  I have put in the call to SetScrollSizes in the
> OnInitialUpdate method.  I'm still not quite sure what sizeTotal is
supposed
> to do.  I just gave it a value of 5 for the y for now, which I think I
want
> to set to the number of lines of text I have to display.  And then I set y
> to 50.
>
> int numLines = 5;
> CSize sizeTotal;
> sizeTotal.cy = numLines;
> sizeTotal.cx = 50;
>
> SetScrollSizes(
>    MM_TEXT,
>    sizeTotal);
>
> In the OnDraw method, I put in code to draw my text on the view using the
> device context.  The text gets drawn, but there is no scrolling
> functionality.
>
>  CRect clientRect;
>  GetClientRect(clientRect);
>  pDC ->DrawText(CString("Blah
> blah!\n\n\n\nn\n\n\n\n\n\n\n\n\n\nBlahBlah!\n"), clientRect,0);
>
> Can anyone help?
>
>
> Thanks,
> Chris
>
>


0
GuitarBill
8/22/2004 2:19:12 AM
Thanks Bill!  My Scrollbar now comes up, and comes up with an appropriate
size since using the return value from DrawText.

However, I have now encountered another problem.  If I resize the window so
that the last lines of text aren't showing, then scroll down, they don't
show up.  I scroll back up, and the top lines are there.  Then, if I resize
the window back to large, I can see the bottom lines again.  This must have
something to do with the drawing, but I'm not quite sure how exactly the
drawing is handled when scrolling with the CScrollView object.  Please help!


Many thanks,

Chris

"GuitarBill" <GuitarBill_at_cox_dot_net> wrote in message
news:uccLj5#hEHA.3148@TK2MSFTNGP10.phx.gbl...
> If you use MM_TEXT mapping, the scroll size is the virtual size of the
> display in pixels. For example, if actual height of window is 400 and you
> set the CScrollView to anything <= 400 there will be no scroll bars.
>
> You can use DrawText(DT_CALCRECT) to figure how big the text will actually
> be, and set the scroll size to rect.Width, rect.Height. This will ensure
> that the scrollbars will provide sufficient range to show all of the text.
>
>
> "Chris" <ijkdc@spamhater.hotmail.com> wrote in message
> news:utaFSq%23hEHA.384@TK2MSFTNGP10.phx.gbl...
> > I am new to MFC and I am trying to get a simple app working with a
> > scrollable view.  I have put in the call to SetScrollSizes in the
> > OnInitialUpdate method.  I'm still not quite sure what sizeTotal is
> supposed
> > to do.  I just gave it a value of 5 for the y for now, which I think I
> want
> > to set to the number of lines of text I have to display.  And then I set
y
> > to 50.
> >
> > int numLines = 5;
> > CSize sizeTotal;
> > sizeTotal.cy = numLines;
> > sizeTotal.cx = 50;
> >
> > SetScrollSizes(
> >    MM_TEXT,
> >    sizeTotal);
> >
> > In the OnDraw method, I put in code to draw my text on the view using
the
> > device context.  The text gets drawn, but there is no scrolling
> > functionality.
> >
> >  CRect clientRect;
> >  GetClientRect(clientRect);
> >  pDC ->DrawText(CString("Blah
> > blah!\n\n\n\nn\n\n\n\n\n\n\n\n\n\nBlahBlah!\n"), clientRect,0);
> >
> > Can anyone help?
> >
> >
> > Thanks,
> > Chris
> >
> >
>
>


0
ijkdc (24)
8/24/2004 5:02:14 AM
Chris wrote:

> Thanks Bill!  My Scrollbar now comes up, and comes up with an appropriate
> size since using the return value from DrawText.
> 
> However, I have now encountered another problem.  If I resize the window so
> that the last lines of text aren't showing, then scroll down, they don't
> show up.  I scroll back up, and the top lines are there.  Then, if I resize
> the window back to large, I can see the bottom lines again.  This must have
> something to do with the drawing, but I'm not quite sure how exactly the
> drawing is handled when scrolling with the CScrollView object.  Please help!
> 
> 
> Many thanks,
> 
> Chris

When you scroll down OnDraw will be called to repaint.  When you repaint 
  you must use x,y coordinates relative to the logical view size, not 
the physical view size.   In the code snippet you posted, call 
GetTotalSize (logical) instead of GetClientRect (physical).

-- 
Scott McPhillips [VC++ MVP]

0
Scott
8/24/2004 1:15:07 PM
Reply:

Similar Artilces:

Get user to enter all information
I've developed a project database that works quite well - but often times users can be lax in entering all necessary data. I've got a sub routine that fires for the Form's BeforeUpdate event that can check the main form's controls - but I run into trouble with the subforms. In order to stop the user leaving the record before the information is entered, I Cancel the BeforeUpdate event...but the record must update in order to set focus to a subform. At the moment I'm using the following logic: If ControlName = 0 then MsgBox "Enter Data message" ControlName.S...

Get special folder path
Hello, I'm developping an app with VC++ 6.0 and MFC, and I need to get the path of Windows special folders (in particular, folder "My Music", wherever the user may have moved it). I was told there is a possibility for apps running under Windows XP to get this information ? Does somebody know how ? Thank for any help -- Ceci est une signature automatique de MesNews. Site : http://www.mesnews.net ByB wrote: > Hello, > > I'm developping an app with VC++ 6.0 and MFC, and I need to get the path > of Windows special folders (in particular, folder "My M...

Getting total sales by customer
Hi, I need to find the total sales for a customer, I have tried the Group by function but it just groups the company name in ascending order. My fields are: Client_Name, Rep, InvoicePeriod, InvoiceYear, Total I will also need to group by Invoice Period in relevant year. Any help would be appreciated, Thanks in advance. Charlotte You can't group by customer since you don't list a customer field. -- Duane Hookom MS Access MVP "Charlie" <Charlie@discussions.microsoft.com> wrote in message news:47F4A6AC-2594-4A59-BB4E-1090A20B424C@microsoft....

default account keeps getting unset
Hi, A strange problem: Approximately once a day, my email account becomes unconfigured as the default email account. I notice because OE will refuse to send the email that I have just written, but, if I set it back, then OE sends it just fine. Has anyone else encountered this problem? Thanks for any guidance. Jeff PS. I am on XP Pro SP3, OE 6.00.2900.5512 configured as in another becomes the default account? Are all accounts in different identities, or the same one? If different, is the default account the Main identity? -- Bruce Hagen ...

getting more columns and data onto one page in Crystal
Hello: Since you can only place so much data onto a "piece of paper", likely the answer is "no". But, even after choosing "Landscape" in Crytal (10.0), there's not a way of getting as many columns of data onto a report as I want--is there? Ideally, I'd like to get 14 columns on there but am running out of room on the right. Also, I have placed a cross-tab on my report that prints on multiple pages instead of just one. Of course, since the cross-tab has 83 rows of data, my guess is that there is nothing that I can do about this either. Is there? ...

date is in 20010129 format, how can I get it in m/d/y format
-- jsanders Data>text to column, go to step three and select date and YMD and for future posts it's considered rude just using the subject line Regards, Peo Sjoblom With the value 20010129 in cell A1, enter this formula in B1: =DATEVALUE(MID(A1,5,2)&"/"&RIGHT(A1,2)&"/"&LEFT(A1,4)) and the format the cell as a date. The various functions parse the 20010129 string into its components, and the DATEVALUE converts that string to a datevalue that Excel can recognize. ...

Strange error coming from OUTLOOK...
Hi there, I am facing some OUTLOOK error which has started coming after one fine day (25th May), I got a link on web which tried to solve some similar kind of error... http://groups.google.co.in/group/microsoft.public.outlook/browse_thread/thread/15655d7cc99b3d65/c93849b5d9727b9b%23c93849b5d9727b9b?utoken=-H72kDsAAACAT_kPml7nPanGq5_khmjXzG4h8VGqBFmwVVjSBNuDfXtreP3snDtCP_cfraE1QwTb0GCCMyRe4c4ncgoJsxoS The Error that I am getting is not in the temporary internet files, but in a specific folder (D:/Actuate/) in which the OUTLOOK macro saves the file to. Pre Information: -There is one macro wh...

How do I run outlook for the first time, to get the mail icon?
I want to set up multiple email accounts. Help menu indicates start - control panel - user accounts - mail, with a note that the mail icon will only appear after program is run first time. Basically, how do I get to see the mail icon? The mail icon should be in the control panel as soon as outlook is installed but you can go to the outlook shortcut on the Start menu, All programs, Microsoft Office to run outlook. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips...

Listbox scrollbar disappears
I have a program that periodically sets the contents of a listbox. After the program runs for some time, the vertical scrollbar is no longer painted (but otherwise still works). I wrote a small dialog based MFC application that reproduces the problem. The dialog contains a list box control and a button control. Selecting the button control fills the list box with 10 items 10000 times. Here is the button code that reproduces the problem for me: void ClbtestDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here for (int idx1=0; idx1<10000; idx1...

Getting duplicate records, can't figure out why!
I'm creating a database to track inventory movements for reserve calculation purposes. I start out with two tables, Inv Mov and Inv Bal. From Inv Mov, I create a Query "Initial Movements" as a filter. When I run this query, all looks good. I create a new query, "Transaction Summary" that joins fields "P/N" from table "Inv Bal" and Query "Initial Movements". When I run this second query, every record is duplicated. I can't figure out why, and I'm trying to eliminate this. Here's the SQL: SELECT [Inv Bal Eco].[P/N], ...

How to get Outlook 2003 working with comcast.net email acct
Hi, I've got a comcast.net email account and I've successfully implemented the comcast FAQ instructions for setting up Outlook 2003 as my mail manager of the comcast email account (ie, the test results are all positive ... no failures ... no error messages to report). But I'm apparently missing something because no emails come through to Outlook; the comcast system works fine, but I can't use Outlook to manage the emails. Any suggestions/ideas would be appreciated. Thanks. Joe what error is in the send and receive dialog? -- Diane Poremsky [MVP - Outlook] Author,...

Get license related information in Windows Vista
Hi, In Windows Vista, executing slmgr.vbs script with -dli or -dlv option displays the license status, product key and a host of other information. Is there any way in which i can get all this information (especially the license status) programmatically ? I am programming in C++/VC++ and using VS2005. Please help !! Thanks in advance.... ...

cannot get product ID because disk is bad...now what?
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I recently purchased a copy of office for Mac 2008 from an online seller who does not take returns of opened software (understandably). However, the CD that contains the basic applications (WORD, EXCEL, POWERPOINT, Etc...) is not readable. A few points to this: (1) The box of software was sealed and new (2) This CD was tried in 2 MACs and 1 PC - none were readable (3)These same machines (2 MAcs and 1 PC) were subsequently able to read another disk, and the drive checked out in all diagnostics. (4) Cleaning the CD was t...

How do I get the weeks numbered?
I need to create worksheets for the managers at my job and I need to list the work weeks by numbers. Example April 4 - April 10 was the 15th week of the year, I need to know how to get the numbered week on my calender. Tools-> Options-> Calendar Options -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -Properly back-up and restore your Outlook data -Creating a Permanent New Mail Desktop Alert in Outlook 2003 ----- "smwhiten" <smwhiten@discussions.microsoft.com> wrote in message news:92478EC4-CB77-4329-B6A8-F2BA1D4034B9@microsoft.com... &g...

Why would my conversation get ignored?
Am I posting/reply posting correctly? If so--I'm new to the news group--sorry What makes you think it's being ignored? Your last reply was not very long ago....give us a chance here! Jason Brown wrote: > Am I posting/reply posting correctly? > > If so--I'm new to the news group--sorry I don't know why they are getting ignored. The most common reasons would be 1) nobody knows the answer, 2) you posted to the wrong newsgroup, 3) you post is incomprehensible, 4) you didn't give enough info, or 5) you were rude and obnoxious (there are probably more). Mak...

Outlook 2007 signature keeps getting deleted
We are in the process of upgrading to Office 2007 Professional. Several users are complaining that their signatures keep getting deleted. Any suggestions? ...

where can i get an order tracking database
I used to use Office XP but have upgraded to office 2007. Where can i get an order tracking database template from, which is similar to the one that came with office XP On Jul 4, 8:38 pm, Envisage <Envis...@discussions.microsoft.com> wrote: > I used to use Office XP but have upgraded to office 2007. Where can i get an > order tracking database template from, which is similar to the one that came > with office XP can't you just open the XP one in 2007 and go from there? Either that or try the MS site. Or google for one if that doesn't meet your needs... ...

when filling out a form, the main text gets out of alignment?
I just designed a form.....When I "test" it and fill in the blanks, it moves the main text out of alignment. Is there any way to "lock" the main text so it doesn't move but still be able to fill in the blanks on the form? Set up your form as a table with fixed cell dimensions. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "enived2" <enived2@discussions.microsoft.com> wrote in message ...

How to get rid of Customer Credit?
Hi, I have MS Money 2001 and I created this credit by mistake: trying to apply payment to invoice and then changed Payee then deleting payment and reentering it. May be did something else not very wise. :) Anyway now I have two Customers with credits in "See the customer list": Customer1 - (-$1540.29) and Customer2 - $1540.29 both are wrong. I need to get it back Customer1 - $0 and Customer2 - $0 like it was before I started all this mess. Can someone help? Thanks and best regards. ...

How To Get FTP Shortcut to Open Windows Explorer NOT Internet Explorer
If you drop an ftp:/// url into the Address bar of Windows Explorer, this will open up the FTP site in the context of Windows Explorer. This is quite handy when you want to copy and paste between the local file system and the FTP site. Unfortunately, if you try to create an Internet Shortcut, this will always open a browser, and will NOT perform the same action as putting the URL in the Address bar of Windows Explorer. Is there any way to create a folder or shortcut in Windows Explorer that will directly open an FTP site in WIndows Explorer? This might require the help o...

Outgoing email message gets parts of it Bolded after being sent.
We recently converted over to Outlook 2003 with Exchange 2003 as the Server. One of our Administrative Assistants started getting a very strange thing happen when she sent out emails....while she composed them the emails looked OK, but when she sent them certain sections of the email would go from regular font to Bold Font. She was using Glacier Stationary for this under the Mail Format tab. The only thing we could figure out might be going on is that something in her stationary was reading some of the lines (she would tripple space between paragraphs) as Headers...we compared the emai...

how to get the means and stdandard errors of every row in 5 coulum
Hi, can you tell me how to get statistics on five different colums of numbers: specifically, how to get means and st. errors of every row in five columns. Thanks, Joanna "jt42" wrote: > Hi, can you tell me how to get statistics on five different > colums of numbers: specifically, how to get means and > st. errors of every row in five columns. I assume you mean "of each row". The formula =AVERAGE(A1:E1) provides the average of row 1. The formula =STDEV(A1:E1) provides the standard deviation. The standard error is =STDEV(A1:E1)/SQRT(COUNT(A1:E1)) . Use STDEVP(...

How come when I try to insert a chart in Excel, nothing happens?
Hi. In Excel 2007, I am unable to insert a chart. I select a range of cells, go to the insert tab, select Column in the charts group and "clustered column" (or any different type of graph such as a line graph), hit click and nothing happens. To test this issue, I tried to download a chart template from Microsoft, but I received an error message instead "Microsoft Office Excel has encountered a problem and needs to close". The error report contents stated the following: AppName: Excel.exe AppVer: 12.0.6524.5003 AppStamp: 464fba46 ModName: oart.dll ModVer: 12...

How do I get the contents of a directory
Hi, I want to get a the contents of a directory (files and directories, particularly the latter). How do I do this? "hamishd" <Hamish.Dean@gmail.com> schrieb im Newsbeitrag news:1149313849.386484.4590@y43g2000cwc.googlegroups.com... > Hi, I want to get a the contents of a directory (files and directories, > particularly the latter). How do I do this? Use FindFirstFile/FindNextFile/FindClose from the Windows API or CFileFind from MFC. HTH Heinz ...

How to get info filled in automatically
I make a roster for my work with multiple items for each person. An example of what I am looking to do: In cell A1, I have a drop down menu with all employee's names. Cell B1 is for their ID number and cell C1 is for their radio ID #. I wanted to see if their was a way for when I select a name in the drop down menu of A1 for B1 and C1 to automatically fill with that employees' respective ID numbers? Hi Let's say you have a list of employees with their relevant numbers on Sheet2 in cells A2:Cxxx With your dropdown list in cell A2 of Sheet1, enter the followin...