api 进度条的显示
我用api实现的一个进度条,不知道为什么SendMessage(_hProgressControl,PBM_SETPOS,(WPARAM)percent,0); 一直不能返回.程序一直阻塞在这个地方.
void DisplayDownloadProgress(int percent)
{
EB_Printf("percent %d\n",percent);
SendMessage(_hProgressControl,PBM_SETPOS,(WPARAM)percent,0);
}
但是如果采用 PostMessage(_hProgressControl,PBM_SETPOS,(WPARAM)percent,0);
PostMessage(),是立即返回的,
所以程序可以继续运行,但是就是进度条上的信息不能够显示.
请问大家这可能是什么问题
.
这个是我的原代码:
void InitDownloadProgress(void)
{
while(_hDlgDownloadProgress==NULL); //wait until the progress dialog box is ready.
_hProgressControl=GetDlgItem(_hDlgDownloadProgress,IDC_PROGRESS1);
SendMessage(_hProgressControl,PBM_SETRANGE,0,MAKELPARAM(0, 100));
downloadCanceled=0;
EB_Printf("Init in function\n");
}
void DisplayDownloadProgress(int percent)
{
EB_Printf("percent %d\n",percent);
//SendMessage(_hProgressControl,PBM_SETPOS,(WPARAM)percent,0);
PostMessage(_hProgressControl,PBM_SETPOS,(WPARAM)percent,0);
}
void CloseDownloadProgress(void)
{
if(_hDlgDownloadProgress!=NULL)
{
//DestroyWindow(_hDlgDownloadProgress);
//Doesn't work because CloseDownloadProgress() is called another thread,
//which is different the thread calling CreatDialog().
SendMessage(_hDlgDownloadProgress,WM_CLOSE,0,0);
_hDlgDownloadProgress=NULL;
}
}