#include_afxwin.h_//replace "_"with"<>"
#include_afxext.h_
#include_afxcmn.h_
class myframe:public CFrameWnd
{
CSliderCtrl slid;
CButton gb;
CStatic s1;
CEdit e;
public:
myframe()
{
Create(0,"Slider Demo");
}
int OnCreate()
{
s1.Create("Slider value",WS_CHILDWS_VISIBLESS_CENTERSS_CENTERIMAGE,CRect(100,70,250,100),this,1);
e.CreateEx(WS_EX_CLIENTEDGE,"Edit","",WS_CHILDWS_VISIBLE,CRect(270,70,340,100),this,2);
gb.Create("Select options",BS_GROUPBOXWS_CHILDWS_VISIBLE,CRect(100,100,450,350),this,3);
slid.Create(WS_CHILDWS_VISIBLETBS_HORZTBS_AUTOTICKSTBS_BOTTOMTBS_ENABLESELRANGE,CRect(130,140,295,190),this,4);
slid.SetRange(0,20);
slid.SetPos(2);
slid.SetLineSize(2);
slid.SetPageSize(3);
return 0;
}
void OnHScroll(UINT code,UINT pos,CScrollBar *sc)
{
TCHAR str[100];
switch(code)
{
case TB_LINEUP:
case TB_LINEDOWN:
case TB_PAGEUP:
case TB_PAGEDOWN:
case TB_BOTTOM:
case TB_TOP:
case TB_THUMBPOSITION:
case TB_THUMBTRACK:
slid.SetSelection(0,pos);
slid.SetTic(pos);
wsprintf(str,TEXT("%i"),pos);
e.SetWindowText(str);
break;
}
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)
ON_WM_CREATE()
ON_WM_HSCROLL()
END_MESSAGE_MAP()
class myapp:public CWinApp
{
public:
int InitInstance()
{
myframe *p;
p=new myframe;
p->ShowWindow (3);
m_pMainWnd=p;
return 1;
}
};
myapp a;
Output
0 comments:
Post a Comment