C++ Code_ScrollBar
|
主题 |
|
1. ScrollBar的使用 2. 3. 4. 5. |
|
属性 |
|
HScrollBar VScrollBar 直接拖拽1其中任意空间到对话框上面是,你一拖拽滚动条,它立即回到原始位置 |
|
代码:: |
|
/* 在控件上面添加1个HScrollBar和1个Edit控件
*/ //初始化部分添加代码 // TODO: Add extra initialization
here CScrollBar *pScroll=(CScrollBar*)GetDlgItem(IDC_SCROLLBAR1);
pScroll->SetScrollRange(0, 100);
pScroll->SetScrollPos(0);
SetDlgItemInt(IDC_EDIT1, 0); //为对话杠添加1个OnHScroll消息,添加如下代码 void CProject01Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or
call default int iPos=pScrollBar->GetScrollPos();
switch (nSBCode)
{
case SB_LINERIGHT:
iPos+=1;
break;
case SB_LINELEFT:
iPos-=1;
break;
case SB_PAGERIGHT:
iPos+=10;
break;
case SB_PAGELEFT:
iPos-=10;
break;
case SB_THUMBTRACK:
iPos=nPos;
break;
default:
break;
}
if (iPos<0) iPos=0;
if (iPos>100) iPos=100;
pScrollBar->SetScrollPos(iPos);
SetDlgItemInt(IDC_EDIT1, iPos);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
} //为Edit1添加OnChange消息 void CProject01Dlg::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control
will not // send this notification unless you override the
CDialog::OnInitDialog() // function and call
CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the
mask. CString STR;
GetDlgItemText(IDC_EDIT1, STR);
STR.TrimLeft();
STR.TrimRight();
INT iPos=0;
if (STR!="-"
&& STR!="") {
if
(!UpdateData()) {
return;
}
iPos=m_nEdt1;
}
CScrollBar *pScroll=(CScrollBar*)GetDlgItem(IDC_SCROLLBAR1);
pScroll->SetScrollPos(iPos);
// TODO: Add your control notification handler code
here }
效果图:
|
附件列表
C++ Code_ScrollBar的更多相关文章
随机推荐
- 【LeetCode】107 - Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left ...
- 数往知来C#之接口 值类型与引用类型 静态非静态 异常处理 GC垃圾回收 值类型引用类型内存分配<四>
C# 基础接口篇 一.多态复习 使用个new来实现,使用virtual与override -->new隐藏父类方法 根据当前类型,电泳对应的方法(成员) -->override ...
- linux c多线程编程范例
#include <stdio.h> #include <pthread.h> #include <unistd.h> #include <stdlib.h& ...
- kali2 vmtools
root@kali:~# cat /etc/apt/sources.list# Regular Repositoriesdeb http://http.kali.org/kali sana main ...
- WS之cxf与spring整合2
在action中加入webservice
- 《学习OpenCV》练习题第五章第一题ab
这道题是载入一幅带有有趣纹理的图像并用不同的模板(窗口,核)大小做高斯模糊(高斯平滑),然后比较用5*5大小的窗口平滑图像两次和用11*11大小的窗口平滑图像一次是否接近相同. 先说下我的做法,a部分 ...
- html5 canvas 钟表
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- IDE Plug
IDE Plug 使用 cnpack提供的IDE External Wizard Management 管理插件.添加插件.删除插件 Cnpack D:\Program Files (x86)\CnP ...
- 如何让Java和C++接口互相调用:JNI使用指南
如何让Java和C++接口互相调用:JNI使用指南 转自:http://cn.cocos2d-x.org/article/index?type=cocos2d-x&url=/doc/cocos ...
- 导出Excel Gridview
/// <summary> /// 定义导出Excel的函数 /// </summary> /// <param name="FileType ...

