void CTryView::OnMouseMove(UINT nFlags, CPoint point)
{
//RedrawWindow();
// TODO: Add your message handler code here and/or call default
CClientDC *pDC = new CClientDC(this);
CPen p1;
if(m_i<100)
{
p1.CreatePen(PS_SOLID,2,RGB(255,235,65));
pDC->SelectObject(&p1);
pDC->MoveTo(m_start);
pDC->LineTo(point);
m_start=point;
}
else if(m_i<200)
{
p1.CreatePen(PS_SOLID,2,RGB(100,230,82));
pDC->SelectObject(&p1);
pDC->MoveTo(m_start);
pDC->LineTo(point);
m_start=point;
}
else if(m_i<300)
{
p1.CreatePen(PS_SOLID,2,RGB(50,130,182));
pDC->SelectObject(&p1);
pDC->MoveTo(m_start);
pDC->LineTo(point);
m_start=point;
}
else if(m_i<400)
{
p1.CreatePen(PS_SOLID,2,RGB(255,0,0));
pDC->SelectObject(&p1);
pDC->MoveTo(m_start);
pDC->LineTo(point);
m_start=point;
}
else
{
p1.CreatePen(PS_SOLID,2,RGB(10,30,242));
pDC->SelectObject(&p1);
pDC->MoveTo(m_start);
pDC->LineTo(point);
m_start=point;
}
if(m_i==0)
{
m_start=point;
}
if(m_i==400)
{
m_i=0;
}
else
{
pDC->MoveTo(m_start);
pDC->LineTo(point);
m_start=point;
}
m_i++;
CView::OnMouseMove(nFlags, point);
}
Monday, November 9, 2009
Moving ball around screen
void CDrawCPRView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC *cr = new CClientDC(this);
CPen pn1;
pn1.CreatePen(PS_SOLID,2,RGB(255,0,0));
cr->SelectObject(pn1);
CBrush br1(RGB(255,0,0));
cr->SelectObject(br1);
//RedrawWindow();
while(1)
{
CRect rc;
GetClientRect(rc);
int x1=0,y1=0,a=0,b=0;
while(1)
{
if(a==0 && b==0)
{
x1+=5;
y1+=5;
}
if(a==0 && b==1)
{
x1+=5;
y1-=5;
}
if(a==1 && b==0)
{
x1-=5;
y1+=5;
}
if(a==1 && b==1)
{
x1-=5;
y1-=5;
}
if(x1 < a="0;" b="0;"> rc.right-2)
{
a=1;
}
else if(y1 > rc.bottom-2)
{
b=1;
}
RedrawWindow();
cr->Ellipse(x1,y1,x1+10,y1+10);
Sleep(20);
}
}
CView::OnLButtonDblClk(nFlags, point);
}
{
// TODO: Add your message handler code here and/or call default
CClientDC *cr = new CClientDC(this);
CPen pn1;
pn1.CreatePen(PS_SOLID,2,RGB(255,0,0));
cr->SelectObject(pn1);
CBrush br1(RGB(255,0,0));
cr->SelectObject(br1);
//RedrawWindow();
while(1)
{
CRect rc;
GetClientRect(rc);
int x1=0,y1=0,a=0,b=0;
while(1)
{
if(a==0 && b==0)
{
x1+=5;
y1+=5;
}
if(a==0 && b==1)
{
x1+=5;
y1-=5;
}
if(a==1 && b==0)
{
x1-=5;
y1+=5;
}
if(a==1 && b==1)
{
x1-=5;
y1-=5;
}
if(x1 < a="0;" b="0;"> rc.right-2)
{
a=1;
}
else if(y1 > rc.bottom-2)
{
b=1;
}
RedrawWindow();
cr->Ellipse(x1,y1,x1+10,y1+10);
Sleep(20);
}
}
CView::OnLButtonDblClk(nFlags, point);
}
Saturday, November 7, 2009
List of Function in VC++, Explain with Example
- GetClientRect
- CloseWindow
- GetDlgItem
- EnableWindow
- Invalidate
- RedrawWindow
- GetWindowText
- SetWindowText
- GetScrollPos
- GetScrollRange
- SetScrollPos
- SetScrollRange
- SetTimer
- MessageBox
- GetCurSel
- GetLBText
- GetLBTextLen
- AddString
- DeleteString
- InsertString
- ResetContent
- GetCount
- GetText
- GetTextLen
- UpdateData
- MoveTo
- LineTo
- Rectangle
- Ellipse
- DoModal
- atoi
- IsEmpty
- Empty
- GetAt
- SetAt
- MakeLower
- MakeUpper
- MakeReverse
- Remove
- Format
- Insert
- Delete
- Find
- ReverseFind
- SetRange
- GetRange
- GetPos
- SetPos
- OffsetPos
- SetStep
- StepIt
Labels:
AITS,
Atmiya,
Explain Function,
M.Sc (IT and CA),
Rajkot,
VC++
Code To Make Edit Box Enable and Disable
GetDlgItem(IDC_EDIT1)->EnableWindow();
GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
Friday, November 6, 2009
How to Get System Time in VC++
How can we get system time ?
void CTimeDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CTime t=CTime::GetCurrentTime();
CString str;
str.Format("%d:%d:%d",t.GetHour(),t.GetMinute(),t.GetSecond());
this->SetWindowText(str);
}
void CTimeDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CTime t=CTime::GetCurrentTime();
CString str;
str.Format("%d:%d:%d",t.GetHour(),t.GetMinute(),t.GetSecond());
this->SetWindowText(str);
}
Subscribe to:
Posts (Atom)