Really I offered something like this (looks that "others" means I).
What's is not according PB rules ?
Code:
#Compile Exe #Include "WIN32API.INC" #Include "COMMCTRL.INC" %ID_ProgressBar = 501 Global hProg As Long, hPrDlg As Long Global StopDn%, Redrawn As Long Sub StopModal (hdlgClose&) Local hwndact&, scan1&, scan2& scan1& = MapVirtualKey(%VK_MENU, 0) scan2& = MapVirtualKey(%VK_F4, 0) hwndact& = GetForegroundWindow SetForegroundWindow hdlgClose& KeyBd_Event %VK_MENU, scan1&, 0, 0: ApiSleep 20 KeyBd_Event %VK_F4, scan2&, 0, 0: ApiSleep 20 KeyBd_Event %VK_F4, scan2&, %KEYEVENTF_KEYUP, 0: ApiSleep 20 KeyBd_Event %VK_MENU, scan1&, %KEYEVENTF_KEYUP, 0: ApiSleep 20 SetForegroundWindow hwndact& End Sub CallBack Function hDlg_CB() Select Case CbMsg Case %WM_SETTEXT: Redrawn = %True Case %WM_DESTROY: Redrawn = %True: StopDn = 1 End Select End Function Function ExecModeless (ByVal h&) As Long Dim hWindow As Long Dialog New %HWND_DESKTOP, "Progress Bar", _ 1, 1, 170, 50, %DS_CENTER, %WS_EX_TOPMOST To hPrDlg& Control Add "msctls_progress32", hPrDlg&, %ID_ProgressBar, "", 10, 10, 150, 15, %WS_BORDER Or %WS_VISIBLE Or %WS_CHILD, 0 SendMessage GetDlgItem(hPrDlg&, %ID_ProgressBar), %PBM_SETRANGE, 0, MakLng(0,100) SendMessage GetDlgItem(hPrDlg&, %ID_ProgressBar), %PBM_SETPOS, 0, 0 StopDn = 0 Dialog Show Modal hPrDlg&, Call hDlg_CB End Function Sub StartModeless StopDn = -1 Thread Create ExecModeless(h&) To hThread& Thread Close hThread& To lResult& While StopDn <> 0: Sleep 100: Wend End Sub Function PbMain Dim iPos As Long, w$ StartModeless w$ = Time$ Do If StopDn <> 0 Then Exit Do If Time$ <> w$ Then w$ = Time$ iPos = iPos + 5: If iPos > 100 Then Exit Do Redrawn = %False SendMessage GetDlgItem(hPrDlg&, %ID_ProgressBar), %PBM_SETPOS, iPos, 0 SetWindowText hPrDlg&, "Done " + Str$(iPos) + "% (Press Alt-F4 to cancel)" While IsFalse(Redrawn): Sleep 20: Wend End If Loop If StopDn <> 1 Then StopModal hPrDlg& End Function
------------------
Leave a comment: