Google Search

Saturday, January 29, 2011

Slider Control 600459– Visual Programming Anna University lab manual download fourth semester

Slider Control 600459– Visual Programming Anna University lab manual download fourth semester


Aim:
            To write a Visual C++ program for creating a Slider Control using win32 application.

Logical Description:

            The program starts with object creation. After initializing the instance, the user created window is assigned as main window. Using Show window option project user created window. 

Algorithm:

  1. Start the Process
  2. Create an object for an class which inherits CWinApp
  3. The object access InitInstance() function
  4. Create a pointer object for the class which inherits CFrameWindow by allocating the memory to the object
  5. Show the created window using SW_SHOWNORMAL
  6. Stop the process
Source Code:
#include<afxwin.h>
#include<afxcmn.h>
class myframe:public CFrameWnd
{
private:
            CSliderCtrl sli;
            CButton gr;
public:
            myframe()
            {
                        CString mywindowclass;
                        mywindowclass=AfxRegisterWndClass(
                                    CS_VREDRAW|CS_HREDRAW,0,
                                    (HBRUSH)::GetStockObject(LTGRAY_BRUSH),0);
                        Create(mywindowclass,"Slider Control");
            }
            int OnCreate(LPCREATESTRUCT I)
            {
                        CFrameWnd::OnCreate(I);
                        gr.Create("SLIDER DISPLAY",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,CRect(30,30,310,100),this,1);
                        sli.Create(WS_CHILD|WS_VISIBLE|TBS_HORZ|TBS_AUTOTICKS|TBS_BOTTOM|TBS_ENABLESELRANGE,CRect(35,50,305,90),this,2);
                        sli.SetRange(0,8);
                        sli.SetPos(2);
                        sli.SetSelection(0,2);
                        sli.SetPageSize(3);
                        return 0;
            }
            void OnHScroll(UINT code,UINT pos,CScrollBar *scroll)
            {
                        switch(code)
                        {
                        case TB_LINEUP:

                        case TB_LINEDOWN:
                        case TB_PAGEUP:
                        case TB_PAGEDOWN:
                        case TB_TOP:
                        case TB_BOTTOM:

                                    pos=sli.GetPos();
                                    sli.SetSelection(0,pos);
                                    sli.SetTic(pos);
                                    break;
                        case TB_THUMBPOSITION:
                                    sli.SetSelection(0,pos);
                                    sli.SetTic(pos);
                                    break;
                        case TB_THUMBTRACK:
                                    sli.SetSelection(0,pos);
                                    sli.SetTic(pos);
                                    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;


0 comments:

Post a Comment