求 八零年败类生存手扎 法医狂妃txt全本微盘 微盘网站都可以 急急急 感谢各位大神

DevExpress之ChartControl实现柱状图演示实例-c#教程-源码库|专注为中国站长提供免费商业网站源码下载!
当前位置:----DevExpress之ChartControl实现柱状图演示实例
DevExpress之ChartControl实现柱状图演示实例
这篇文章主要介绍了DevExpress中ChartControl实现柱状图演示方法,实例展示了相关绘图函数的具体用法,具有一定的实用价值,需要的朋友可以参考下
本文实例讲述了DevExpress中ChartControl实现柱状图演示的方法。分享给大家供大家参考。具体实现方法如下:
关键代码如下:
复制代码代码如下:
using System.D
using System.Windows.F
using CSharpUtilHelpV2;
using DevExpress.XtraC
namespace DevExpressChart
&&& public partial class winProduct : Form
&&&&&&& public winProduct()
&&&&&&&&&&& InitializeComponent();
&&&&&&& static readonly string AccessFullPath = string.Format(@&{0}\Northwind.MDB&, AppDomain.CurrentDomain.BaseDirectory);
&&&&&&& static DataTable ProductList =
&&&&&&& AccessUtilsV2 AccessHelper =
&&&&&&& private void winChat_Load(object sender, EventArgs e)
&&&&&&&&&&& AccessHelper = new AccessUtilsV2(AccessFullPath);
&&&&&&&&&&& ProductList = AccessHelper.ExecuteDataTable(&select * from Products&, null);
&&&&&&&&&&& BuilderDevChart();
&&&&&&& private void BuilderDevChart()
&&&&&&&&&&& if (ProductList != null)
&&&&&&&&&&& {
&&&&&&&&&&&&&&& Series _barSeries = new Series(&测试&, ViewType.Bar);
&&&&&&&&&&&&&&& _barSeries.ArgumentDataMember = &ProductName&;//x轴
&&&&&&&&&&&&&&& _barSeries.ValueDataMembers[0] = &UnitPrice&;//Y轴
&&&&&&&&&&&&&&& _barSeries.DataSource = ProductL
&&&&&&&&&&&&&&& _barSeries.AddDataFilter(&CategoryID&, 4, DataFilterCondition.Equal);
&&&&&&&&&&&&&&& _barSeries.SetColorEach(true);
&&&&&&&&&&&&&&& chartControl1.Series.Add(_barSeries);
&&&&&&&&&&&&&&& _barSeries.LegendPointOptions.PointView = PointView.ArgumentAndV
&&&&&&&&&&&&&&& //chartControl1.SeriesDataMember = &UnitPrice&;
&&&&&&&&&&&&&&& //chartControl1.SeriesTemplate.ValueDataMembers[0] = &UnitPrice&;
&&&&&&&&&&&&&&& //chartControl1.SeriesTemplate.ArgumentDataMember = &ProductName&;
&&&&&&&&&&&&&&& //chartControl1.SeriesTemplate.ArgumentScaleType = ScaleType.Q
&&&&&&&&&&&&&&& //chartControl1.SeriesTemplate.AddDataFilter(&CategoryID&, 4, DataFilterCondition.Equal);
&&&&&&&&&&&&&&& //chartControl1.SeriesTemplate.LegendPointOptions.PointView = PointView.ArgumentAndV
&&&&&&&&&&&&&&& chartControl1.SetXLableAngle(-35);
&&&&&&&&&&&&&&& chartControl1.SetCrosshair(true);
&&&&&&&&&&&&&&& chartControl1.Legend.Direction = LegendDirection.LeftToR
&&&&&&&&&&&&&&& chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.C
&&&&&&&&&&&&&&& chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.BottomO
&&&&&&&&&&&&&&& chartControl1.DataSource = ProductL
&&&&&&&&&&&&&&& chartControl1.AddTitle(&Product List&);
&&&&&&&&&&&&&&& //--------------------------
&&&&&&&&&&& }
复制代码代码如下:
using DevExpress.U
using DevExpress.XtraC
namespace DevExpressChart
&&& public static class ChartUtils
&&&&&&& /// &summary&
&&&&&&& /// 增加数据筛选
&&&&&&& /// &/summary&
&&&&&&& /// &param name=&SeriesBase&&Series&/param&
&&&&&&& /// &param name=&columnName&&列名称&/param&
&&&&&&& /// &param name=&value&&列名称对应的筛选数值&/param&
&&&&&&& /// &param name=&dataFilterCondition&&DataFilterCondition枚举&/param&
&&&&&&& public static void AddDataFilter(this SeriesBase series, string columnName, object value, DataFilterCondition dataFilterCondition)
&&&&&&&&&&& series.DataFilters.Add(new DataFilter(columnName, value.GetType().FullName, dataFilterCondition, value));
&&&&&&& /// &summary&
&&&&&&& /// 设置X轴Lable角度
&&&&&&& /// &/summary&
&&&&&&& /// &param name=&chart&&ChartControl&/param&
&&&&&&& /// &param name=&angle&&角度&/param&
&&&&&&& public static void SetXLableAngle(this ChartControl chart, int angle)
&&&&&&&&&&& XYDiagram _xyDiagram = (XYDiagram)chart.D
&&&&&&&&&&& if (_xyDiagram != null)
&&&&&&&&&&&&&&& _xyDiagram.AxisX.Label.Angle =
&&&&&&& /// &summary&
&&&&&&& ///& 设置Y轴Lable角度
&&&&&&& /// &/summary&
&&&&&&& /// &param name=&chart&&ChartControl&/param&
&&&&&&& /// &param name=&angle&&角度&/param&
&&&&&&& public static void SetYLableAngle(this ChartControl chart, int angle)
&&&&&&&&&&& XYDiagram _xyDiagram = (XYDiagram)chart.D
&&&&&&&&&&& _xyDiagram.AxisY.Label.Angle =
&&&&&&& /// &summary&
&&&&&&& /// 设置ColorEach
&&&&&&& /// &/summary&
&&&&&&& /// &param name=&chart&&ChartControl&/param&
&&&&&&& /// &param name=&colorEach&&是否设置成ColorEach&/param&
&&&&&&& public static void SetColorEach(this Series series, bool colorEach)
&&&&&&&&&&& SeriesViewColorEachSupportBase colorEachView = (SeriesViewColorEachSupportBase)series.V
&&&&&&&&&&& if (colorEachView != null)
&&&&&&&&&&& {
&&&&&&&&&&&&&&& colorEachView.ColorEach = colorE
&&&&&&&&&&& }
&&&&&&& /// &summary&
&&&&&&& /// 设置是否显示十字标线
&&&&&&& /// &/summary&
&&&&&&& /// &param name=&chart&&ChartControl&/param&
&&&&&&& /// &param name=&crosshair&&是否显示十字标线&/param&
&&&&&&& public static void SetCrosshair(this ChartControl chart, bool crosshair)
&&&&&&&&&&& chart.CrosshairEnabled = crosshair ? DefaultBoolean.True : DefaultBoolean.F
&&&&&&&&&&& chart.CrosshairOptions.ShowArgumentLabels =
&&&&&&&&&&& chart.CrosshairOptions.ShowArgumentLine =
&&&&&&&&&&& chart.CrosshairOptions.ShowValueLabels =
&&&&&&&&&&& chart.CrosshairOptions.ShowValueLine =
&&&&&&& /// &summary&
&&&&&&& /// 新增ChartControl的Title文字
&&&&&&& /// &/summary&
&&&&&&& /// &param name=&chart&&ChartControl&/param&
&&&&&&& /// &param name=&title&&Title文字&/param&
&&&&&&& public static void AddTitle(this ChartControl chart, string title)
&&&&&&&&&&& ChartTitle _title = new ChartTitle();
&&&&&&&&&&& _title.Text =
&&&&&&&&&&& chart.Titles.Add(_title);
&&&&&&& /// &summary&
&&&&&&& /// 饼状Series设置成百分比显示
&&&&&&& /// &/summary&
&&&&&&& /// &param name=&series&&Series&/param&
&&&&&&& public static void SetPiePercentage(this Series series)
&&&&&&&&&&& if (series.View is PieSeriesView)
&&&&&&&&&&& {
&&&&&&&&&&&&&&& ((PiePointOptions)series.PointOptions).PercentOptions.ValueAsPercent =
&&&&&&&&&&&&&&& ((PiePointOptions)series.PointOptions).ValueNumericOptions.Format = NumericFormat.P
&&&&&&&&&&&&&&& ((PiePointOptions)series.PointOptions).ValueNumericOptions.Precision = 0;
&&&&&&&&&&& }
运行效果如下图所示:
希望本文所述对大家的C#程序设计有所帮助。
相关c#教程:
相关资源下载:
c#教程搜索
c#教程推荐
热门源码推荐
热门c#教程
©2012How do I control the horizontal alignment of text? - Web Tutorials -
How do I control the horizontal alignment of text?&
How do I control the horizontal alignment of text?&The Slider Control - 王朝网络 -
分享&&&&&当前位置: &&&&&&&&The Slider Control&&&  摘要:The Slider Control     Overview  A slider is a Windows control equipped with a small bar, also called a thumb, that slides along a visible line. There are two types of sliders: horizontal and vertical:   To use the slider control, the user can drag the thumb in one of two directions. If the slider is horizontal, the user can drag the thumb left or right. The thumb of a vertical slider can be dragged up or down. This changes the position of the thumb. The user can also click the desired position along the line to place the thumb at the desired location. Alternatively, when the slider has focus, the user can also use the arrow keys of the keyboard to move the thumb.  A slider is configured with a set of values from a minimum to a maximum. Therefore, the user can make a selection included in that range. Optionally, a slider can be equipped with small indicators called ticks:   The ticks can visually guide the user for the available positions of the thumb mark. A slider can be used to let the user specify a value that conforms to a range. When equipped with ticks, a slider can be used to control exact values that the user can select in a range, preventing the user from setting just any desired value.   For this application, we will help the user display different pictures from a series of 10. If you want, you can start a new Dialog-based application named CarInventory with no About Box and set the Dialog Title to Car Inventory  Delete the TODO line and the OK button   Save the following pictures to your hard drive:    On the main menu, click Insert -& Resource or Project -& Add Resource…   On the Add Resource dialog box, click Import… and import the above pictures. If you are using MSVC 6, you may receive a message box when you import each picture, simply click OK   Change the ID of the new bitmap to IDB_CIVIC, IDB_ELANTRA, IDB_ESCAPE, IDB_ESCORT, IDB_FOCUS, IDB_MARQUIS, IDB_MYSTIQUE, IDB_NAVIGATOR, IDB_SENTRA, and IDB_SEPHIA respectively   Add a Picture control
to the top side of the dialog box and change its ID to IDC_PREVIEW   Type to Bitmap and set its Bitmap to IDB_CIVIC   Add a Control variable for the picture control and name it m_Preview   To store the values for the controls on the dialog box, in the header file of the dialog box, declare a private UINT array named CarPicture[10]   To initialize the array, type the following in the OnInitDialog event:  BOOL CSlider1Dlg::OnInitDialog()  {  CDialog::OnInitDialog();  SetIcon(m_hIcon, TRUE);
// Set big icon  SetIcon(m_hIcon, FALSE);
// Set small icon  // TODO: Add extra initialization here  CarPicture[0] = IDB_CIVIC;  CarPicture[1] = IDB_ELANTRA;  CarPicture[2] = IDB_ESCAPE;  CarPicture[3] = IDB_ESCORT;  CarPicture[4] = IDB_MARQUIS;  CarPicture[5] = IDB_MYSTIQUE;  CarPicture[6] = IDB_NAVIGATOR;  CarPicture[7] = IDB_SENTRA;  CarPicture[8] = IDB_FOCUS;  CarPicture[9] = IDB_SEPHIA;  return TRUE;
// return TRUE
unless you set the focus to a control  }  To display default values in the dialog box, on top of its OnPaint() event, type the following:  void CSlider1Dlg::OnPaint()   {  CBitmap B  Bmp.LoadBitmap(CarPicture[0]);  m_Preview.SetBitmap(Bmp);  UpdateData(FALSE);  if (IsIconic())  {   CPaintDC dc(this); // device context for painting   SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);   // Center icon in client rectangle   int cxIcon = GetSystemMetrics(SM_CXICON);   int cyIcon = GetSystemMetrics(SM_CYICON);   CR   GetClientRect(&rect);   int x = (rect.Width() - cxIcon + 1) / 2;   int y = (rect.Height() - cyIcon + 1) / 2;   // Draw the icon   dc.DrawIcon(x, y, m_hIcon);  }  else  {   CDialog::OnPaint();  }  }  Test the application and return to MSVC   Slider Creation  To provide a slider to an application, from the Controls toolbox, click the Slider button
and click the desired area on the dialog box or the form.  To programmatically create a slider, declare a pointer to CSliderCtrl using the new operator. To initialize the control, call its Create() method. Here is an example:   BOOL CDlgSlide::OnInitDialog()   {  CDialog::OnInitDialog();  // TODO: Add extra initialization here  CSliderCtrl *TrackBar = new CSliderC  TrackBar-&Create(WS_CHILD | WS_VISIBLE,  CRect(15, 20, 222, 50), this, 0x14);  return TRUE; // return TRUE unless you set the focus to a control  // EXCEPTION: OCX Property Pages should return FALSE  }  On the Controls toolbox, click the Slider button
and click in lower-left section of the dialog box   Save All   Slider Properties  After placing a slider control on a form or other host, by default, its assumes a horizontal direction. If you want a vertical slider, change the value of the Orientation property. If you are dynamically creating the control, its default orientation would be horizontal, whose style is TBS_HORZ. If you want a vertical slider, apply the TBS_VERT style:   BOOL CDlgSlide::OnInitDialog()   {  CDialog::OnInitDialog();  // TODO: Add extra initialization here  CSliderCtrl *TrackBar = new CSliderC  TrackBar-&Create(WS_CHILD | WS_VISIBLE | TBS_VERT,  CRect(20, 20, 50, 250), this, 0x14);  return TRUE; // return TRUE unless you set the focus to a control  // EXCEPTION: OCX Property Pages should return FALSE  }  The new slider appears as one line, horizontal or vertical, that guides the user with the area to slide the thumb. When sliding the thumb along the line, the user can set only the value where the thumb is positioned. Alternatively, if you want the user to be able to select a range of values instead of just a value, at design time, you can set the Enable Selection property to True. This is equivalent to adding the TBS_ENABLESELECTION style. A slider equipped with this style displays a 3-D “whole” in the body of the slider:   The selection area allows the user to select a range of values.  The thumb of a slider can assume one of three shapes. By default, it appears as a rectangular box. Alternatively, you can convert one of its shorter borders to appear as an arrow. The shape of the thumb is controlled at design time by the Point property. Its default value is Both, which gives it a rectangular shape. You can get this same shape by omitting or adding the TBS_BOTH value.  For a horizontal slider, you can make the thumb’s arrow point to the left by changing the Point property to Top/Left. If the slider is horizontal, this Point value would orient the thumb arrow to the top:   To make the thumb of a dynamically created horizontal slider point up, add the TBS_TOP style. If the slider is vertical, to point its thumb to the left, add the TBS_LEFT style to it.  If you want the thumb to point down for a horizontal slider, set the Point property to Bottom/Right. This same value would make the thumb of a vertical slider point n the right direction:   To point the thumb up for a horizontal slider you are programmatically creating, add the TBS_BOTTOM. For the thumb of a vertical slider to point right, add the TBS_RIGHT to it.  If you want to guide the user with some ticks on the control, at design time, set the Tick Marks property to True. If you are dynamically creating the slider and you want it to display ticks, simply adding the either the TBS_VERT or the TBS_HORZ style equips the slider with ticks. If you don’t want to display the ticks at all, at design time, clear the Tick Marks property or set its value to False.  The ticks are positioned on the side the thumb is pointing. If the slider is created with the Both value for the Point property or the TBS_BOTH style, the ticks would appear on both sides the thumb.  The thumb of a slider is used to scroll from one minimum value to another. The range of these extreme values can be divided in regular increments that can further guide the user with value selection. To display where these increments are set, at design time, set the Auto Ticks property to True or add the TBS_AUTOTICKS style to a dynamic slider.   While the slider control is selected on the dialog box, on the Properties window, change its ID to IDC_SLIDER   Check its Auto Ticks check box or set it to True   Check its Tick Marks check box or set it to True   Set its Point property to Top/Left  Set to True the Tooltips property of the slider control (MSVC 7)   Add a CSliderCtrl Control variable for the slider and name it m_CarSlider   Save All   Slider Methods  As seen earlier, the slider control is based on the CSliderCtrl class. Therefore, we saw that we can dynamically create a slider by declaring pointer to CSliderCtrl and call its Create() method to initialize it. Once a slider has been designed and received the desired style, you can programmatically use it and provide the necessary feedback to the user.  A slider is a control that provides a range of values between which the user can navigate using the control’s thumb or by clicking on the slider’s line. Usually, the first aspect you may need to configure on your control is to specify its limit values. To specify the minimum value of a slider control, you can call the CSliderCtrl::SetRangeMin() method. Its syntax is:   void SetRangeMin(int nMin, BOOL bRedraw = FALSE);  The nMin value is the new minimum value that the slider can assume. The control is typically redrawn once the new value has been set. If you don’t want the control to be redrawn, pass a second argument with the FALSE value. If the lowest value of the control has already been set and you want to find out what that value is, you can call the CSliderCtrl::GetRangeMin() method. Its syntax is:   int GetRangeMin()  This method simply returns the lowest value that the slider can assume when the user has dragged the thumb to the extreme left or bottom.  To set the highest value of a slider control, you can call the SliderCtrl::SetRangeMax() method. Its syntax is:   void SetRangeMax(int nMax, BOOL bRedraw = FALSE);  The nMax argument holds the new maximum value for the control. Here is an example:   BOOL CControlsDlg::OnInitDialog()   {  CDialog::OnInitDialog();  // TODO: Add extra initialization here  m_Slider.SetRangeMin(0);  m_Slider.SetRangeMax(50);  return TRUE; // return TRUE unless you set the focus to a control  // EXCEPTION: OCX Property Pages should return FALSE  }  If the maximum value of the control had previously been set, you can find it out by calling the SliderCtrl::GetRangeMax() method. Its syntax is:   int GetRangeMax()  This method returns the highest value that the slider control can have.  To set both the minimum and the maximum values of the slider with one line of code, you can call the CSliderCtrl::SetRange() method. Its syntax is:   void SetRange(int nMin, int nMax, BOOL bRedraw = FALSE);  The nMin and the nMax arguments hold the lowest and the highest respective values of the control. Here is an example:  BOOL CControlsDlg::OnInitDialog()   {  CDialog::OnInitDialog();  // TODO: Add extra initialization here  m_Slider.SetRange(0, 50);  return TRUE; // return TRUE unless you set the focus to a control  // EXCEPTION: OCX Property Pages should return FALSE  }  If the control is already functioning and you want to know its limit values, you can call the CSliderCtrl::SetRange() method whose syntax is:   void GetRange(int& nMin, int& nMax)  This method returns two values, namely the lowest value, as nMin, and the highest value, as nMax.   Once the minimum and maximum values have been set, the user can slide the thumb to select a value or a range. This value is what mostly interests you. While sliding the thumb, the value of the slider is called its position. At startup or at any time, you can set a specific position for the thumb. This can be done by calling the CSliderCtrl::SetPos() method. Its syntax is:   void SetPos(int nPos);  The nPos argument holds the new position of the slider. Here is an example:   BOOL CControlsDlg::OnInitDialog()   {  CDialog::OnInitDialog();  // TODO: Add extra initialization here  m_Slider.SetRange(0, 50);  m_Slider.SetPos(32);  return TRUE; // return TRUE unless you set the focus to a control  // EXCEPTION: OCX Property Pages should return FALSE  }  The value specified using the SetPos() method should be in the range nMax – nMin of the SetRange() method. If there is a possibility that this value is outside the valid range, you can call the CSliderCtrl::VerifyPos() method to check it. Its syntax is:  void VerifyPos( );  When the position of the thumb has change and you want to find out what it is, call the CSliderCtrl::GetPos() method whose syntax is:  int GetPos()  If the slider control was specified to let the user select a range, you can define your own selected range at any time by callin the CSliderCtrl::SetSelection() method. Its syntax is:  void SetSelection(int nMin, int nMax);  When calling this method, make sure you specify the nMin and the nMax values so that this nMin is greater than the minimum value of the slider and this nMax is less than the highest possible value of the slider. Furthermore, the value of this nMin must be less than that of nMax. This relationshipd can be illustrated as follows:  Minimum &= nMin & nMax &= Maximum  Here is an example:   BOOL CControlsDlg::OnInitDialog()   {  CDialog::OnInitDialog();  // TODO: Add extra initialization here  m_Slider.SetRange(0, 50);  m_Slider.SetPos(32);  m_Slider.SetSelection(22, 42);  return TRUE; // return TRUE unless you set the focus to a control  // EXCEPTION: OCX Property Pages should return FALSE  }  If a selected range has been performed on the slider, if you want to get the minimum and the maximum values of the selection, you can call the CSliderCtrl::GetSelection() method whose syntax is:  void GetSelection(int& nMin, int& nMax)  This method returns two values, the minimum as nMin and the maximum as nMax.  If the slider controla is configure to displays ticks, you can specify their frequncy with a call to the CSliderCtrl::SetTicFreq() method. Its syntax is:   void SetTicFreq(int nFreq);  In the OnInitDialog event of the dialog class, set the range of values of the slider to 0 to 9 and the frequency of its ticks to:  
m_CarSlider.SetRange(1, 10);  m_CarSlider.SetTicFreq(1);  return TRUE; // return TRUE unless you set the focus to a control  }  Test the application and return to MSVC  Slider Events  On its own, the slider controls can send three notification messages:   The NM_OUTOFMEMORY message is sent when the slider has run out of memory and could not complete a task   The NM_RELEASECAPTURE message is sent when the user releases the mouse on the slider   The NM_CUSTOMDRAW message is used if you want to draw something on the slider or you want to customize the appearance of the slider beyond what Visual C++ proposes   For its functionality, the slider highly relies on its parent. When the user clicks the thumb or any part of the slider, which causes it to slide, a scroll event is fired. If the slider is horizontal, the CWnd::OnHScroll() event is sent. If the slider is vertical, the CWnd::OnVScroll() event is sent.   Change the OnPaint() event of the dialog class as follows:   void CCarInventoryDlg::OnPaint()   {  int CurPos = m_CarSlider.GetPos() - 1;  CBitmap B  Bmp.LoadBitmap(CarPicture[CurPos]);  m_Picture.SetBitmap(Bmp);  UpdateData(FALSE);  . . .  }  Using either the ClassWizard (MSVC 6) or the Messages button , for the dialog, generate the WM_HSCROLL message and implement it as follows:   vvoid CCarInventoryDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)   {  // TODO: Add your message handler code here and/or call default  CRect RectP  // Get the location and dimensions of the picture area  m_Preview.GetWindowRect(&RectPicture);  // Convert the current coordinates from the monitor (Screen) to the dialog box (Client)  ScreenToClient(&RectPicture);  // Repaint the picture area  InvalidateRect(&RectPicture);  CDialog::OnHScroll(nSBCode, nPos, pScrollBar);  }  Test the application     Return to MSVC&&&&&今日推荐
&&&&&日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。
最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。
歌手:Def...老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...把牛仔裤磨出有线的破洞
1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...先来看下敬业福和爱国福
今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。
今天该活动正式启动,和去年一样,需要收集“五福”...有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。
1、很多人有这种习...简介
《极品家丁》讲述了现代白领林晚荣无意回到古代金陵,并追随萧二小姐化名“林三”进入萧府,不料却阴差阳错上演了一出低级家丁拼搏上位的“林三升职记”。...你就是我最爱的宝宝 - 李溪芮
(电视剧《极品家丁》片尾曲)
作词:常馨内
作曲:常馨内
你的眉 又鬼马的挑
你的嘴 又坏坏的笑
上一秒吵闹 下...乌梅,又称春梅,中医认为,乌梅味酸,性温,无毒,具有安心、除热、下气、祛痰、止渴调中、杀虫的功效,治肢体痛、肺痨病。乌梅泡水喝能治伤寒烦热、止吐泻,与干姜一起制...什么是脂肪粒
在我们的脸上总会长一个个像脂肪的小颗粒,弄也弄不掉,而且颜色还是白白的。它既不是粉刺也不是其他的任何痘痘,它就是脂肪粒。
脂肪粒虽然也是由油脂...来源:中国青年报
新的攻击方法不断涌现,黑客几乎永远占据网络攻击的上风,我们不可能通过技术手段杜绝网络攻击。国家安全保障的主要方向是打击犯罪,而不是处置和惩罚...夫妻网络直播“造人”爆红
  1月9日,温岭城北派出所接到南京警方的协查通告,他们近期打掉了一个涉黄直播APP平台。而根据掌握的线索,其中有一对涉案的夫妻主播...如何防止墙纸老化?
(1)选择透气性好的墙纸
市场上墙纸的材质分无纺布的、木纤维的、PVC的、玻璃纤维基材的、布面的等,相对而言,PVC材质的墙纸最不透气...观点一:破日本销售量的“鲜肌之谜” 非日本生产
近一段时间,淘宝上架了一款名为“鲜肌之谜的” 鲑鱼卵巢美容液,号称是最近日本的一款推出的全新护肤品,产品本身所...系腰裙(北宋词人 张先)
惜霜蟾照夜云天,朦胧影、画勾阑。人情纵似长情月,算一年年。又能得、几番圆。
欲寄西江题叶字,流不到、五亭前。东池始有荷新绿,尚小如...关于女人的经典语句1、【做一个独立的女人】
思想独立:有主见、有自己的人生观、价值观。有上进心,永远不放弃自己的理想,做一份自己喜爱的事业,拥有快乐和成就...你想体验机器人性爱吗?你想和性爱机器人结婚吗?如果你想,机器人有拒绝你的权利吗?
近日,第二届“国际人类-机器人性爱研讨会”大会在伦敦金史密斯大学落下帷幕。而...10.土耳其地下洞穴城市
变态指数:★★☆☆☆
这是土耳其卡帕多西亚的一个著名景点,传说是当年基督教徒们为了躲避战争而在此修建。里面曾住着20000人,......据英国《每日快报》报道,一位科学家兼理论家Robert Lanza博士宣称,世界上并不存在人类死亡,死亡的只是身体。他认为我们的意识借助我们体内的能量生存,而且...《我爱狐狸精》 - 刘馨棋
  (电视剧《屏里狐》主题曲)
  作词:金十三&李旦
  作曲:刘嘉
  狐狸精 狐狸仙
  千年修...·&·&·&·&·&·&·&·&·&·&&&&&&摘要:The Slider Control
A slider is a Windows control equipped with a small bar, also called a thumb, that slides along a visible line. There are two types of sliders: horizontal and vertical:
To use the slider control, the user can drag the thumb in one of two directions. If the slider is horizontal, the user can drag the thumb left or right. The thumb of a vertical slider can be dragged up or down. This changes the position of the thumb. The user can also click the desired position along the line to place the thumb at the desired location. Alternatively, when the slider has focus, the user can also use the arrow keys of the keyboard to move the thumb.
A slider is configured with a set of values from a minimum to a maximum. Therefore, the user can make a selection included in that range. Optionally, a slider can be equipped with small indicators called ticks:
The ticks can visually guide the user for the available positions of the thumb mark. A slider can be used to let the user specify a value that conforms to a range. When equipped with ticks, a slider can be used to control exact values that the user can select in a range, preventing the user from setting just any desired value.
For this application, we will help the user display different pictures from a series of 10. If you want, you can start a new Dialog-based application named CarInventory with no About Box and set the Dialog Title to Car Inventory
Delete the TODO line and the OK button
Save the following pictures to your hard drive:
On the main menu, click Insert -& Resource or Project -& Add Resource…
On the Add Resource dialog box, click Import… and import the above pictures. If you are using MSVC 6, you may receive a message box when you import each picture, simply click OK
Change the ID of the new bitmap to IDB_CIVIC, IDB_ELANTRA, IDB_ESCAPE, IDB_ESCORT, IDB_FOCUS, IDB_MARQUIS, IDB_MYSTIQUE, IDB_NAVIGATOR, IDB_SENTRA, and IDB_SEPHIA respectively
Add a Picture control
to the top side of the dialog box and change its ID to IDC_PREVIEW
Type to Bitmap and set its Bitmap to IDB_CIVIC
Add a Control variable for the picture control and name it m_Preview
To store the values for the controls on the dialog box, in the header file of the dialog box, declare a private UINT array named CarPicture[10]
To initialize the array, type the following in the OnInitDialog event:
BOOL CSlider1Dlg::OnInitDialog()
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
// Set big icon
SetIcon(m_hIcon, FALSE);
// Set small icon
// TODO: Add extra initialization here
CarPicture[0] = IDB_CIVIC;
CarPicture[1] = IDB_ELANTRA;
CarPicture[2] = IDB_ESCAPE;
CarPicture[3] = IDB_ESCORT;
CarPicture[4] = IDB_MARQUIS;
CarPicture[5] = IDB_MYSTIQUE;
CarPicture[6] = IDB_NAVIGATOR;
CarPicture[7] = IDB_SENTRA;
CarPicture[8] = IDB_FOCUS;
CarPicture[9] = IDB_SEPHIA;
return TRUE;
// return TRUE
unless you set the focus to a control
To display default values in the dialog box, on top of its OnPaint() event, type the following:
void CSlider1Dlg::OnPaint()
Bmp.LoadBitmap(CarPicture[0]);
m_Preview.SetBitmap(Bmp);
UpdateData(FALSE);
if (IsIconic())
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
CDialog::OnPaint();
Test the application and return to MSVC
Slider Creation
To provide a slider to an application, from the Controls toolbox, click the Slider button
and click the desired area on the dialog box or the form.
To programmatically create a slider, declare a pointer to CSliderCtrl using the new operator. To initialize the control, call its Create() method. Here is an example:
BOOL CDlgSlide::OnInitDialog()
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CSliderCtrl *TrackBar = new CSliderC
TrackBar-&Create(WS_CHILD | WS_VISIBLE,
CRect(15, 20, 222, 50), this, 0x14);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
On the Controls toolbox, click the Slider button
and click in lower-left section of the dialog box
Slider Properties
After placing a slider control on a form or other host, by default, its assumes a horizontal direction. If you want a vertical slider, change the value of the Orientation property. If you are dynamically creating the control, its default orientation would be horizontal, whose style is TBS_HORZ. If you want a vertical slider, apply the TBS_VERT style:
BOOL CDlgSlide::OnInitDialog()
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CSliderCtrl *TrackBar = new CSliderC
TrackBar-&Create(WS_CHILD | WS_VISIBLE | TBS_VERT,
CRect(20, 20, 50, 250), this, 0x14);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
The new slider appears as one line, horizontal or vertical, that guides the user with the area to slide the thumb. When sliding the thumb along the line, the user can set only the value where the thumb is positioned. Alternatively, if you want the user to be able to select a range of values instead of just a value, at design time, you can set the Enable Selection property to True. This is equivalent to adding the TBS_ENABLESELECTION style. A slider equipped with this style displays a 3-D “whole” in the body of the slider:
The selection area allows the user to select a range of values.
The thumb of a slider can assume one of three shapes. By default, it appears as a rectangular box. Alternatively, you can convert one of its shorter borders to appear as an arrow. The shape of the thumb is controlled at design time by the Point property. Its default value is Both, which gives it a rectangular shape. You can get this same shape by omitting or adding the TBS_BOTH value.
For a horizontal slider, you can make the thumb’s arrow point to the left by changing the Point property to Top/Left. If the slider is horizontal, this Point value would orient the thumb arrow to the top:
To make the thumb of a dynamically created horizontal slider point up, add the TBS_TOP style. If the slider is vertical, to point its thumb to the left, add the TBS_LEFT style to it.
If you want the thumb to point down for a horizontal slider, set the Point property to Bottom/Right. This same value would make the thumb of a vertical slider point n the right direction:
To point the thumb up for a horizontal slider you are programmatically creating, add the TBS_BOTTOM. For the thumb of a vertical slider to point right, add the TBS_RIGHT to it.
If you want to guide the user with some ticks on the control, at design time, set the Tick Marks property to True. If you are dynamically creating the slider and you want it to display ticks, simply adding the either the TBS_VERT or the TBS_HORZ style equips the slider with ticks. If you don’t want to display the ticks at all, at design time, clear the Tick Marks property or set its value to False.
The ticks are positioned on the side the thumb is pointing. If the slider is created with the Both value for the Point property or the TBS_BOTH style, the ticks would appear on both sides the thumb.
The thumb of a slider is used to scroll from one minimum value to another. The range of these extreme values can be divided in regular increments that can further guide the user with value selection. To display where these increments are set, at design time, set the Auto Ticks property to True or add the TBS_AUTOTICKS style to a dynamic slider.
While the slider control is selected on the dialog box, on the Properties window, change its ID to IDC_SLIDER
Check its Auto Ticks check box or set it to True
Check its Tick Marks check box or set it to True
Set its Point property to Top/Left
Set to True the Tooltips property of the slider control (MSVC 7)
Add a CSliderCtrl Control variable for the slider and name it m_CarSlider
Slider Methods
As seen earlier, the slider control is based on the CSliderCtrl class. Therefore, we saw that we can dynamically create a slider by declaring pointer to CSliderCtrl and call its Create() method to initialize it. Once a slider has been designed and received the desired style, you can programmatically use it and provide the necessary feedback to the user.
A slider is a control that provides a range of values between which the user can navigate using the control’s thumb or by clicking on the slider’s line. Usually, the first aspect you may need to configure on your control is to specify its limit values. To specify the minimum value of a slider control, you can call the CSliderCtrl::SetRangeMin() method. Its syntax is:
void SetRangeMin(int nMin, BOOL bRedraw = FALSE);
The nMin value is the new minimum value that the slider can assume. The control is typically redrawn once the new value has been set. If you don’t want the control to be redrawn, pass a second argument with the FALSE value. If the lowest value of the control has already been set and you want to find out what that value is, you can call the CSliderCtrl::GetRangeMin() method. Its syntax is:
int GetRangeMin()
This method simply returns the lowest value that the slider can assume when the user has dragged the thumb to the extreme left or bottom.
To set the highest value of a slider control, you can call the SliderCtrl::SetRangeMax() method. Its syntax is:
void SetRangeMax(int nMax, BOOL bRedraw = FALSE);
The nMax argument holds the new maximum value for the control. Here is an example:
BOOL CControlsDlg::OnInitDialog()
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_Slider.SetRangeMin(0);
m_Slider.SetRangeMax(50);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
If the maximum value of the control had previously been set, you can find it out by calling the SliderCtrl::GetRangeMax() method. Its syntax is:
int GetRangeMax()
This method returns the highest value that the slider control can have.
To set both the minimum and the maximum values of the slider with one line of code, you can call the CSliderCtrl::SetRange() method. Its syntax is:
void SetRange(int nMin, int nMax, BOOL bRedraw = FALSE);
The nMin and the nMax arguments hold the lowest and the highest respective values of the control. Here is an example:
BOOL CControlsDlg::OnInitDialog()
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_Slider.SetRange(0, 50);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
If the control is already functioning and you want to know its limit values, you can call the CSliderCtrl::SetRange() method whose syntax is:
void GetRange(int& nMin, int& nMax)
This method returns two values, namely the lowest value, as nMin, and the highest value, as nMax.
Once the minimum and maximum values have been set, the user can slide the thumb to select a value or a range. This value is what mostly interests you. While sliding the thumb, the value of the slider is called its position. At startup or at any time, you can set a specific position for the thumb. This can be done by calling the CSliderCtrl::SetPos() method. Its syntax is:
void SetPos(int nPos);
The nPos argument holds the new position of the slider. Here is an example:
BOOL CControlsDlg::OnInitDialog()
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_Slider.SetRange(0, 50);
m_Slider.SetPos(32);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
The value specified using the SetPos() method should be in the range nMax – nMin of the SetRange() method. If there is a possibility that this value is outside the valid range, you can call the CSliderCtrl::VerifyPos() method to check it. Its syntax is:
void VerifyPos( );
When the position of the thumb has change and you want to find out what it is, call the CSliderCtrl::GetPos() method whose syntax is:
int GetPos()
If the slider control was specified to let the user select a range, you can define your own selected range at any time by callin the CSliderCtrl::SetSelection() method. Its syntax is:
void SetSelection(int nMin, int nMax);
When calling this method, make sure you specify the nMin and the nMax values so that this nMin is greater than the minimum value of the slider and this nMax is less than the highest possible value of the slider. Furthermore, the value of this nMin must be less than that of nMax. This relationshipd can be illustrated as follows:
Minimum &= nMin & nMax &= Maximum
Here is an example:
BOOL CControlsDlg::OnInitDialog()
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_Slider.SetRange(0, 50);
m_Slider.SetPos(32);
m_Slider.SetSelection(22, 42);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
If a selected range has been performed on the slider, if you want to get the minimum and the maximum values of the selection, you can call the CSliderCtrl::GetSelection() method whose syntax is:
void GetSelection(int& nMin, int& nMax)
This method returns two values, the minimum as nMin and the maximum as nMax.
If the slider controla is configure to displays ticks, you can specify their frequncy with a call to the CSliderCtrl::SetTicFreq() method. Its syntax is:
void SetTicFreq(int nFreq);
In the OnInitDialog event of the dialog class, set the range of values of the slider to 0 to 9 and the frequency of its ticks to:
m_CarSlider.SetRange(1, 10);
m_CarSlider.SetTicFreq(1);
return TRUE; // return TRUE unless you set the focus to a control
Test the application and return to MSVC
Slider Events
On its own, the slider controls can send three notification messages:
The NM_OUTOFMEMORY message is sent when the slider has run out of memory and could not complete a task
The NM_RELEASECAPTURE message is sent when the user releases the mouse on the slider
The NM_CUSTOMDRAW message is used if you want to draw something on the slider or you want to customize the appearance of the slider beyond what Visual C++ proposes
For its functionality, the slider highly relies on its parent. When the user clicks the thumb or any part of the slider, which causes it to slide, a scroll event is fired. If the slider is horizontal, the CWnd::OnHScroll() event is sent. If the slider is vertical, the CWnd::OnVScroll() event is sent.
Change the OnPaint() event of the dialog class as follows:
void CCarInventoryDlg::OnPaint()
int CurPos = m_CarSlider.GetPos() - 1;
Bmp.LoadBitmap(CarPicture[CurPos]);
m_Picture.SetBitmap(Bmp);
UpdateData(FALSE);
Using either the ClassWizard (MSVC 6) or the Messages button , for the dialog, generate the WM_HSCROLL message and implement it as follows:
vvoid CCarInventoryDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
// TODO: Add your message handler code here and/or call default
CRect RectP
// Get the location and dimensions of the picture area
m_Preview.GetWindowRect(&RectPicture);
// Convert the current coordinates from the monitor (Screen) to the dialog box (Client)
ScreenToClient(&RectPicture);
// Repaint the picture area
InvalidateRect(&RectPicture);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
Test the application
Return to MSVC&&&&&  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。&&&&&&为你推荐&&&&&&转载本文&UBB代码&HTML代码复制到剪贴板...&更多内容··········&&&&&&&&&频道精选&&&王朝女性&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&王朝分栏&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&王朝编程&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&王朝导购&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&王朝其他&&|&&|&&|&&|&&|&&|&&&&2005-&&版权所有&

我要回帖

更多关于 法医狂妃txt全本微盘 的文章

 

随机推荐