Different Color and Style Example Program in VC++

VC++ Example Programs


#include<afxwin.h>
#include<afxext.h>
#include "resource.h"



class Frame:public CFrameWnd
{
private:
CToolBar Bar1,Bar2;
public:
int Xaxis,Yaxis,col,Style,wid;
int Red,Blue,Green;


Frame()
{
Create(0,"ToolBar",WS_OVERLAPPEDWINDOW,
rectDefault,0,MAKEINTRESOURCE(IDR_MENU1));
}


void OnLButtonDown(UINT i, CPoint Point)
{
Xaxis = Point.x;
Yaxis = Point.y;
}


void StyleFn(int Value)
{
switch(Value)
{
case 40004: Style = 0; break;
case 40005: Style = 1; break;
case 40006: Style = 2; break;
}
}


void ColorFn(int Value)
{
Red = 0;
Blue = 0;
Green = 0;
switch(Value)
{
case 40001: Red =255; break;
case 40002: Green = 255; break;
case 40003: Blue = 255; break;
}
}


void OnLButtonUp(UINT i, CPoint Cur)
{
CClientDC Obj(this);
CPen Pen;
Pen.CreatePen(Style,1,RGB(Red,Green,Blue));
Obj.SelectObject (&Pen);
Obj.MoveTo (Xaxis,Yaxis);
Obj.LineTo (Cur.x ,Cur.y);
Xaxis=Cur.x ;
Yaxis=Cur.y ;
}
DECLARE_MESSAGE_MAP()
};


BEGIN_MESSAGE_MAP(Frame,CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_CREATE()
ON_COMMAND_RANGE(40001,40003,ColorFn)
ON_COMMAND_RANGE(40004,40006,StyleFn)
END_MESSAGE_MAP()



class Applet:public CWinApp
{
public:
int InitInstance()
{
Frame *Pointer = new Frame();
Pointer->ShowWindow (3);
m_pMainWnd = Pointer;
return true;
}
};


Applet Instance;