谁有例子?
解决方案 »
- 小妹有问题,怎么能弹出UAC的框框
- 关于fopen,fread
- 已获得一个组件的接口指针,如何将此组件显示在窗口中?
- 我要向一个按钮发送单击事件,用WM_LBUTTONDOWN或UP似乎没反映。
- Group上放3个选项按钮,若第一个不设Group,是不能给它赋变量的,为何?
- 请高人指点:进程地址空间和虚拟内存的到底是什么关系?好困惑
- recvfrom为什么会不阻塞直接返回SOCKET_ERROR???
- 用户输入一些中英文本,怎样判断哪些是汉字??
- 工控中的图像处理问题
- MFC如何实现ctrl+鼠标画水平/垂直直线
- 关于工具条使用DROPDOWN按钮 弹出菜单的问题
- Excel中类Range的含义
Invalidate( )
在对话框的WM_DRAWITEM中加如下代码.
void CCsdnDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if(IDC_OWNER == nIDCtl)
{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
CRect r;
GetDlgItem(IDC_OWNER)->GetClientRect(&r);
CTime t =CTime::GetCurrentTime();//避免随机数相同,根据当前时间的秒数,先调用几次
int n = t.GetSecond();
for(int i = 0 ; i < n ; i++)
rand();
int maxX = r.right;
int maxY = r.bottom;
CPoint beginPoint,endPoint;
beginPoint.x = rand()%maxX;
beginPoint.y = rand()%maxY;
endPoint.x = rand()%maxX;
endPoint.y = rand()%maxY; dc.MoveTo(beginPoint);
dc.LineTo(endPoint);
} CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);CCsdnDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(1,1100,NULL);...
}
对话框的WM_TIMER中
void CCsdnDlg::OnTimer(UINT nIDEvent)
{
Invalidate(true);
CDialog::OnTimer(nIDEvent);
}
}