遇到一个奇怪的有关问题,求高手花点时间看一上。万谢!

遇到一个奇怪的问题,求高手花点时间看一下。。。万谢!!
问题是这样的:我在工具栏上放置了一个进度条。接下来我做了如下操作:
 1、用定时器设置进度条的位置,使进度条从0累加到100,每100ms累加一次,每100ms执行一次定时器;
 2、开一个线程,使进度条从0累加到100,每100ms累加一次。
   SetPos()操作时一个自定义消息。无论上述何种操作,在dug下执行程序,没有出现问题,但是在release下执行时,只要开始进行按键操作(就是按下键盘按键),程序就会出错;如果移动鼠标,只要鼠标进入程序的客户区域,程序就会出错崩溃。
不知道是什么原因,还请高手们指点一下。
------最佳解决方案--------------------
那你麻烦了,接收一定要有两个参数
至于你用不用,都无关紧要
但一定要有两个

那两个参数DEBUG的时候是另外有分配存储的
而Release的时候是没有的
所以你要写全了消息数据才有去处,否则....................
------其他解决方案--------------------
发我qq邮箱285646908
------其他解决方案--------------------
线程里面 你是sendmessage还是直接调setpos?
------其他解决方案--------------------
引用:
线程里面 你是sendmessage还是直接调setpos?

UINT ThreadFun(LPVOID lp)
{
CMainFrame* pmain = (CMainFrame*)::AfxGetMainWnd();
while (1)
{
for (int i = 0; i < 100; i++)
{
pmain->SendMessage(WM_PROGRESS, i);
Sleep(10);
}
for (int j = 100; j > 0; j--)
{
pmain->SendMessage(WM_PROGRESS, j);
Sleep(10);
}

}
return 0;
}

------其他解决方案--------------------
CMainFrame* pmain = (CMainFrame*)::AfxGetMainWnd();  估计是这句的问题  你线程里面把pmain的语句都删了应该debug和release都不会错的吧
------其他解决方案--------------------
If the server has an object that is in-place active inside a container, and this container is active, this function returns a pointer to the frame window object that contains the in-place active document. 

If there is no object that is in-place active within a container, or your application is not an OLE server, this function simply returns the m_pMainWnd of your application object. 

If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call. 



------其他解决方案--------------------
请上线程相关代码
------其他解决方案--------------------
msdn说了 AfxGetMainWnd 这个函数和是不是OLE 服务  是不是激活对象 是主线程还是次线程 等都相关

搞清AfxGetMainWnd怎么用再来用
------其他解决方案--------------------
引用:
请上线程相关代码

2楼就是线程函数。
------其他解决方案--------------------
引用:
msdn说了 AfxGetMainWnd 这个函数和是不是OLE 服务  是不是激活对象 是主线程还是次线程 等都相关