| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1017 人关注过本帖
标题:为什么我使用Sleep()函数后改变了我的CWnd指针对象的m_pCtrlSite的值
只看楼主 加入收藏
xiaoweizile
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-4-30
收藏
 问题点数:0 回复次数:0 
为什么我使用Sleep()函数后改变了我的CWnd指针对象的m_pCtrlSite的值
我想使用线程控制我的按钮的摆动,可是当我使用sleep函数后,我的CWnd *pWnd的m_pCtrlSize值被改变,使得程序无法继续,请问该如何解决
附件为挑出来的代码写的测试程序,也是同样的问题
部分代码如下:UINT ButtonFlutterThread(LPVOID pParam)
{
FLT_THREAD *pStruct =static_cast<FLT_THREAD *>(pParam);
CWnd *pWnd;
CRect rectMain,rectButton1,rectButton2,rectButton3,rectButton;
int offset=3;

pStruct->pViewWnd->GetWindowRect(rectMain);
pStruct->pWnd1->GetWindowRect(rectButton1);
pStruct->pWnd2->GetWindowRect(rectButton2);
pStruct->pWnd3->GetWindowRect(rectButton3);
while(WaitForSingleObject(pStruct->hEvent,0)==WAIT_TIMEOUT)
{
switch(*pStruct->pnThreadType)
{
case SHIJUANXINXI:
rectButton.left=rectButton1.left-rectMain.left;
rectButton.top=rectButton1.top-rectMain.top;
rectButton.right=rectButton1.right-rectMain.left;
rectButton.bottom=rectButton1.bottom-rectMain.top;
pWnd=pStruct->pWnd1;
break;
case JIANKAOXINXI:
rectButton.left=rectButton2.left-rectMain.left;
rectButton.top=rectButton2.top-rectMain.top;
rectButton.right=rectButton2.right-rectMain.left;
rectButton.bottom=rectButton2.bottom-rectMain.top;
pWnd=pStruct->pWnd2;
break;
case KAOCHANGANPAI:
rectButton.left=rectButton3.left-rectMain.left;
rectButton.top=rectButton3.top-rectMain.top;
rectButton.right=rectButton3.right-rectMain.left;
rectButton.bottom=rectButton3.bottom-rectMain.top;
pWnd=pStruct->pWnd3;
break;
default:
break;
}
pWnd->MoveWindow(rectButton.left-offset,rectButton.top+offset
,rectButton.Width(),rectButton.Height());
Sleep(200);

pWnd->MoveWindow(rectButton.left,rectButton.top,rectButton.Width()
,rectButton.Height());
Sleep(200);

pWnd->MoveWindow(rectButton.left+offset,rectButton.top+offset
,rectButton.Width(),rectButton.Height());
Sleep(200);

pWnd->MoveWindow(rectButton.left,rectButton.top,rectButton.Width()
,rectButton.Height());
Sleep(1000);
}
return true;
}

void CMyView::ButtonThreadInit(void)
{
m_pStruct->pViewWnd=(CWnd *)this;
m_pStruct->pWnd1=GetDlgItem(IDC_BUTTON_SHIJUAN);
m_pStruct->pWnd2=GetDlgItem(IDC_BUTTON_JIANKAO);
m_pStruct->pWnd3=GetDlgItem(IDC_BUTTON_KAOCHANG);
m_pStruct->hEvent=m_hEventFlutter;

m_wtFlutter=AfxBeginThread(ButtonFlutterThread,m_pStruct,THREAD_PRIORITY_ABOVE_NORMAL);
}

线程.rar (56.66 KB)
搜索更多相关主题的帖子: CWnd Sleep pCtrlSite 函数 
2008-04-30 22:22
快速回复:为什么我使用Sleep()函数后改变了我的CWnd指针对象的m_pCtrlSite的值
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012005 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved