-
-
[求助]子线程中控制进度条不起作用,什么原因?
-
发表于:
2008-10-4 21:44
6807
-
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
INITCOMMONCONTROLSEX icc;
WNDCLASSEX wcx;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_WIN95_CLASSES | ICC_PROGRESS_CLASS;
InitCommonControlsEx(&icc);
wcx.cbSize = sizeof(wcx);
if (!GetClassInfoEx(NULL, MAKEINTRESOURCE(32770), &wcx))
return 0;
/* Add our own stuff */
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDR_ICO_MAIN));
wcx.lpszClassName = TEXT("OK");
if (!RegisterClassEx(&wcx))
return 0;
/* The user interface is a modal dialog box */
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)MainDlgProc);
}
static INT_PTR CALLBACK MainDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HMENU hMenu;
HANDLE hThread,hPgb;
DWORD ThreadId;
switch (uMsg)
{
case WM_INITDIALOG:
AnimateWindow(hDlg, 800, AW_SLIDE | AW_VER_NEGATIVE);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_BTN_START:
hPgb=GetDlgItem(hDlg,ID_PGB_MAIN);
[COLOR=Red] SendMessage(hPgb,PBM_SETRANGE32,0,100);
SendMessage(hPgb,PBM_SETPOS,10,0); //这里能正常显示进度[/COLOR]
hThread=CreateThread(NULL,0,&ThreadProc,&hPgb,0,&ThreadId);
return TRUE;
}
break;
case WM_CLOSE:
EndDialog(hDlg, 0);
return TRUE;
}
return FALSE;
}
static DWORD WINAPI ThreadDownLoad (PVOID pParam)
{
[COLOR=Red] SendMessage(pParam,PBM_SETPOS,60,0); //这里没作用[/COLOR]
return 0;
}
偶需要在线程中控制一个进度条,写了上面的程序,红色部分在主线程中没问题,但是在子线程中就不起作用,搞半天没发现原因,特来请教。
谢谢先,在线等了。
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)