Mfc--accel tmp

Source: Internet
Author: User

Code

Class Cmainwindow:public CFrameWnd
{
Protected
int m_ncellwidth; Cell width in pixels
int m_ncellheight; Cell height in pixels
int m_nribbonwidth; Ribbon width in pixels
int m_nviewwidth; Workspace width in pixels
int m_nviewheight; Workspace height in pixels
int m_nhscrollpos; Horizontal scroll position
int m_nvscrollpos; Vertical Scroll Position
int m_nhpagesize; Horizontal page Size
int m_nvpagesize; Vertical Page Size

//...

}

int cmainwindow::oncreate (lpcreatestruct lpcreatestruct)
{
if (cframewnd::oncreate (lpcreatestruct) = =-1)
return-1;

//
Initialize internal width and Height values based on screen metrics.
//
CCLIENTDC DC (this);
M_ncellwidth = DC. GetDeviceCaps (LOGPIXELSX);//cell width is 1 inches, logpixelsx is the screen horizontal pixels per inch 96;
M_ncellheight = DC. GetDeviceCaps (logpixelsy)/4;//cell height is 1/4 inches, Logpixelsy is the screen portrait of 96 pixels per inch;
M_nribbonwidth = m_ncellwidth/2;//Left vertical column banner width
M_nviewwidth = (m_ncellwidth) + m_nribbonwidth;//view is the logical window, also known as the workspace, the maximum window logic width, a~z a total of 26 columns, plus the left vertical banner width
M_nviewheight = M_ncellheight * 100;//view is logical window, window logic maximum height, 100 rows
return 0;
}

void Cmainwindow::onsize (UINT nType, int cx, int cy)
{
Switch (nType)
{
Case size_restored://manually resizing windows
Case size_maximized://Window Maximization
Case size_minimized://Window Minimized
Case size_maxhide://Other windows to maximize the
Case size_maxshow://Other Windows restores the
Default
Break
}

CX is the actual window width (pixels)
Cy is the actual window height (number of pixels)

Cframewnd::onsize (NType, CX, CY);

//
Set the horizontal scrolling parameters.
//
int Nhscrollmax = 0;
M_nhscrollpos = m_nhpagesize = 0;

if (CX < m_nviewwidth) {
Nhscrollmax = m_nviewwidth-1;
M_nhpagesize = CX;
M_nhscrollpos = min (M_nhscrollpos, M_nviewwidth-
M_NHPAGESIZE-1);
}

SCROLLINFO si;
Si.fmask = Sif_page | Sif_range | Sif_pos;
si.nmin = 0;
Si.nmax = Nhscrollmax;
Si.npos = M_nhscrollpos;
Si.npage = m_nhpagesize;

Setscrollinfo (Sb_horz, &si, TRUE);

//
Set the vertical scrolling parameters.
//
int Nvscrollmax = 0;
M_nvscrollpos = m_nvpagesize = 0;

if (Cy < m_nviewheight) {
Nvscrollmax = m_nviewheight-1;
M_nvpagesize = cy;
M_nvscrollpos = min (M_nvscrollpos, M_nviewheight-
M_NVPAGESIZE-1);
}

Si.fmask = Sif_page | Sif_range | Sif_pos;
si.nmin = 0;
Si.nmax = Nvscrollmax;
Si.npos = M_nvscrollpos;
Si.npage = m_nvpagesize;

Setscrollinfo (Sb_vert, &si, TRUE);
}

Mfc--accel tmp

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.