已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
创建工程后添加Accel.cpp和Accel.hAccel.cpp文件:#include #include Accel.hCMyApp myApp;/ CMyApp member functionsBOOL CMyApp:InitInstance () m_pMainWnd = new CMainWindow; m_pMainWnd-ShowWindow (m_nCmdShow); m_pMainWnd-UpdateWindow (); return TRUE;/ CMainWindow message map and member functionsBEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd) ON_WM_CREATE () ON_WM_SIZE () ON_WM_PAINT () ON_WM_HSCROLL () ON_WM_VSCROLL ()END_MESSAGE_MAP ()CMainWindow:CMainWindow () Create (NULL, _T (Accel), WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL);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); m_nCellHeight = dc.GetDeviceCaps (LOGPIXELSY) / 4; m_nRibbonWidth = m_nCellWidth / 2; m_nViewWidth = (26 * m_nCellWidth) + m_nRibbonWidth; m_nViewHeight = m_nCellHeight * 100; return 0;void CMainWindow:OnSize (UINT nType, int cx, int cy) 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);void CMainWindow:OnPaint () CPaintDC dc (this); / / Set the window origin to reflect the current scroll positions. / dc.SetWindowOrg (m_nHScrollPos, m_nVScrollPos); / / Draw the grid lines. / CPen pen (PS_SOLID, 0, RGB (192, 192, 192); CPen* pOldPen = dc.SelectObject (&pen); for (int i=0; i99; i+) int y = (i * m_nCellHeight) + m_nCellHeight; dc.MoveTo (0, y); dc.LineTo (m_nViewWidth, y); for (int j=0; j26; j+) int x = (j * m_nCellWidth) + m_nRibbonWidth; dc.MoveTo (x, 0); dc.LineTo (x, m_nViewHeight); dc.SelectObject (pOldPen); / / Draw the bodies of the rows and the column headers. / CBrush brush; brush.CreateStockObject (LTGRAY_BRUSH); CRect rcTop (0, 0, m_nViewWidth, m_nCellHeight); dc.FillRect (rcTop, &brush); CRect rcLeft (0, 0, m_nRibbonWidth, m_nViewHeight); dc.FillRect (rcLeft, &brush); dc.MoveTo (0, m_nCellHeight); dc.LineTo (m_nViewWidth, m_nCellHeight); dc.MoveTo (m_nRibbonWidth, 0); dc.LineTo (m_nRibbonWidth, m_nViewHeight); dc.SetBkMode (TRANSPARENT); / / Add numbers and button outlines to the row headers. / for (i=0; i99; i+) int y = (i * m_nCellHeight) + m_nCellHeight; dc.MoveTo (0, y); dc.LineTo (m_nRibbonWidth, y); CString string; string.Format (_T (%d), i + 1); CRect rect (0, y, m_nRibbonWidth, y + m_nCellHeight); dc.DrawText (string, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); rect.top+; dc.Draw3dRect (rect, RGB (255, 255, 255), RGB (128, 128, 128); / / Add letters and button outlines to the column headers. / for (j=0; j26; j+) int x = (j * m_nCellWidth) + m_nRibbonWidth; dc.MoveTo (x, 0); dc.LineTo (x, m_nCellHeight); CString string; string.Format (_T (%c), j + A); CRect rect (x, 0, x + m_nCellWidth, m_nCellHeight); dc.DrawText (string, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); rect.left+; dc.Draw3dRect (rect, RGB (255, 255, 255), RGB (128, 128, 128); void CMainWindow:OnHScroll (UINT nCode, UINT nPos, CScrollBar* pScrollBar) int nDelta; / / Compute the horizontal scroll distance, or delta. / switch (nCode) case SB_LINELEFT: nDelta = -LINESIZE; break; case SB_PAGELEFT: nDelta = -m_nHPageSize; break; case SB_THUMBTRACK: nDelta = (int) nPos - m_nHScrollPos; break; case SB_PAGERIGHT: nDelta = m_nHPageSize; break; case SB_LINERIGHT: nDelta = LINESIZE; break; default: / Ignore other scroll bar messages return; / / Adjust the delta if adding it to the current scroll position would / cause an underrun or overrun. / int nScrollPos = m_nHScrollPos + nDelta; int nMaxPos = m_nViewWidth - m_nHPageSize; if (nScrollPos nMaxPos) nDelta = nMaxPos - m_nHScrollPos; / / Update the scroll position and scroll the window. / if (nDelta != 0) m_nHScrollPos += nDelta; SetScrollPos (SB_HORZ, m_nHScrollPos, TRUE); ScrollWindow (-nDelta, 0); void CMainWindow:OnVScroll (UINT nCode, UINT nPos, CScrollBar* pScrollBar) int nDelta; / / Compute the vertical scroll distance, or delta. / switch (nCode) case SB_LINEUP: nDelta = -LINESIZE; break; case SB_PAGEUP: nDelta = -m_nVPageSize; break; case SB_THUMBTRACK: nDelta = (int) nPos - m_nVScrollPos; break; case SB_PAGEDOWN: nDelta = m_nVPageSize; break; case SB_LINEDOWN: nDelta = LINESIZE; break; default: / Ignore other scroll bar messages return; / / Adjust the delta if adding it to the current scroll position would / cause an underrun or overrun. / int nScrollPos = m_nVScrollPos + nDelta; int nMaxPos = m_nViewHeight - m_nVPageSize; if (nScrollPos nMaxPos) nDelta = nMaxPos - m_nVScrollPos; / / Update the scroll position and scroll the window. / if (nDelta != 0) m_nVScrollPos += nDelta; SetScrollPos (SB_VERT, m_nVScrollPos, TRUE); ScrollWindow (0, -nDelta); Accel.h文件:#define LINESIZE 8class CMyApp : public CWinApppublic: virtual BOOL InitInstance ();class CMainWindow : public CFrameWndprotected: int m_nCellWidth; / Cell width in pixels int m_nCellHeight; / Cell height in pixels int m_nRibbo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026新疆博尔塔拉州博乐市天山明珠酒店管理有限责任公司招聘36人备考题库含答案详解(精练)
- 2026国家电投集团共享公司人员选聘15人备考题库及一套完整答案详解
- 招38人!德令哈市教育系统2026年面向社会公开招聘普通高中编外教师备考题库附答案详解(培优b卷)
- 2026重庆市三峡人寿保险股份有限公司招聘8人备考题库含答案详解(模拟题)
- 2026山东青岛市即墨区教育体育系统专项招聘公费师范生80人备考题库及答案详解(名校卷)
- 2026浙江宁波通商控股集团有限公司博士后招聘2人备考题库含答案详解(精练)
- 2026河北衡水市植物园公开招聘工作人员30名备考题库附答案详解(达标题)
- 2026年黄石经济技术开发区铁山区城镇初中教师公开招聘10人备考题库及完整答案详解一套
- 2026内蒙古包头固阳县劳动人事争议仲裁院招募20人备考题库带答案详解
- 2026四川泸州市泸县第一次考试选调机关事业单位工作人员53人备考题库含答案详解(研优卷)
- 2026年北京市东城区高三一模地理试卷(含答案)
- 2026年及未来5年市场数据中国外运船舶代理行业市场发展数据监测及投资潜力预测报告
- 2026重庆西科水运工程咨询有限公司招聘4人笔试参考试题及答案解析
- 2026浙江省浙共体中考数学一模试卷(含答案详解)
- 分布式光伏系统巡检维护指南
- 饲料原料采购验收制度
- 雨课堂学堂在线学堂云《岭南乐器的乐种学阐释(星海音乐学院)》单元测试考核答案
- 智能化系统投标智能化系统技术标智能化系统施工组织方案
- 成人继续教育学位英语辅导合同
- 网咖管理办法
- 园区厂房租赁管理制度(3篇)
评论
0/150
提交评论