Use cscrollview to create a scroll bar

Source: Internet
Author: User

the scroll bar is used when the size of the drawn image exceeds the size of the customer area, move the scroll bar to observe the entire image. The cscrollview class is provided in VC to draw the scroll bar. In Step 6 of the Project Creation, select csrollview as the base class. If you have already selected cview as the base class, make the following changes to your Program : (1) Change cxxxview. CPP and cxxxview. replace all the cviews in H with csrollview (XXX is the project name) (2) use classwizard to add the response function oninitialupdate () for cxxxview (), add Code :
csize sizetotal;
sizetotal. cx = sizetotal. cy = 0;
setscrollsizes (mm_text, sizetotal);

the purpose of this Code is to complete the initialization of the scroll bar. If no problem occurs during compilation but an error occurs, setscrollsizes (INT nmapmode, size sizetotal, const size & sizepage = sizedefault, const size & sizeline = sizedefault) the meaning of the four parameters is: nmapmode indicates the ing mode, sizetotal indicates the scroll bar range, and sizepage indicates the scroll bar moving distance when you click the blank area of the scroll bar, sizeline indicates the moving distance of the scroll bar at the clicked endpoint.

After the settings are complete, pass the parameters used for your drawing to setscrollsizes () in ondraw to determine the scroll bar range. Note the following: in the drawing process, use the CDC * PDC to call the drawing directly. Do not use the DC of cclientdc (this) for drawing, otherwise, the figure will remain unchanged when the scroll bar is moved (it took two days to find the solution to this problem, which is stupid !)

We recommend that you add the following code:

// This is very important
Void cprogramview: onpreparedc (CDC * PDC, cprintinfo * pinfo)
{
// Todo: add your specialized code here and/or call the base class

Cscrollview: onpreparedc (PDC, pinfo );
}

Void cprogramview: onvscroll (uint nsbcode, uint NPOs, cscrollbar * pscrollbar)
{
// Todo: add your message handler code here and/or call default

Cscrollview: onvscroll (nsbcode, NPOs, pscrollbar );
}

Void cprogramview: onhscroll (uint nsbcode, uint NPOs, cscrollbar * pscrollbar)
{
// Todo: add your message handler code here and/or call default

Cscrollview: onhscroll (nsbcode, NPOs, pscrollbar );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.