Browse Source

Windows 7 taskbar goodies

Update the Windows 7 taskbarlist progress bar on plOperationProgress
callbacks. It's not totally nesecary, but it adds a nice bit of polish to
the experience.
Adam Johnson 13 years ago
parent
commit
dcba1fb60a
  1. 19
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 41
      Sources/Plasma/Apps/plClient/winmain.cpp

19
Sources/Plasma/Apps/plClient/plClient.cpp

@ -168,6 +168,10 @@ static plDispatchBase* gDisp = nil;
static plTimerCallbackManager* gTimerMgr = nil; static plTimerCallbackManager* gTimerMgr = nil;
static plAudioSystem* gAudio = nil; static plAudioSystem* gAudio = nil;
#ifdef HS_BUILD_FOR_WIN32
extern ITaskbarList3* gTaskbarList;
#endif
hsBool plClient::fDelayMS = false; hsBool plClient::fDelayMS = false;
plClient* plClient::fInstance=nil; plClient* plClient::fInstance=nil;
@ -1291,6 +1295,21 @@ void plClient::IProgressMgrCallbackProc(plOperationProgress * progress)
if(!fInstance) if(!fInstance)
return; return;
// Increments the taskbar progress [Windows 7+]
#ifdef HS_BUILD_FOR_WIN32
if (gTaskbarList)
{
HWND hwnd = fInstance->GetWindowHandle(); // lazy
if (progress->IsLastUpdate())
gTaskbarList->SetProgressState(hwnd, TBPF_NOPROGRESS);
else if (progress->GetMax() == 0.f)
gTaskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE);
else
// This will set TBPF_NORMAL for us
gTaskbarList->SetProgressValue(hwnd, (ULONGLONG)progress->GetProgress(), (ULONGLONG)progress->GetMax());
}
#endif
fInstance->fMessagePumpProc(); fInstance->fMessagePumpProc();
// HACK HACK HACK HACK! // HACK HACK HACK HACK!

41
Sources/Plasma/Apps/plClient/winmain.cpp

@ -92,6 +92,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Globals // Globals
// //
hsBool gHasMouse = false; hsBool gHasMouse = false;
ITaskbarList3* gTaskbarList = nil; // NT 6.1+ taskbar stuff
extern hsBool gDataServerLocal; extern hsBool gDataServerLocal;
@ -121,6 +122,7 @@ bool gPendingActivateFlag = false;
static bool s_loginDlgRunning = false; static bool s_loginDlgRunning = false;
static CEvent s_statusEvent(kEventManualReset); static CEvent s_statusEvent(kEventManualReset);
static UINT s_WmTaskbarList = RegisterWindowMessage("TaskbarButtonCreated");
FILE *errFP = nil; FILE *errFP = nil;
HINSTANCE gHInst = NULL; // Instance of this app HINSTANCE gHInst = NULL; // Instance of this app
@ -401,12 +403,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd); gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
} }
} }
break; return TRUE;
#if 0 #if 0
case WM_KILLFOCUS: case WM_KILLFOCUS:
SetForegroundWindow(hWnd); SetForegroundWindow(hWnd);
break; return TRUE;
#endif #endif
case WM_SYSKEYUP: case WM_SYSKEYUP:
@ -418,7 +420,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
//DefWindowProc(hWnd, message, wParam, lParam); //DefWindowProc(hWnd, message, wParam, lParam);
} }
break; return TRUE;
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
switch (wParam) { switch (wParam) {
@ -434,9 +436,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (plNetClientMgr * mgr = plNetClientMgr::GetInstance()) if (plNetClientMgr * mgr = plNetClientMgr::GetInstance())
mgr->QueueDisableNet(false, nil); mgr->QueueDisableNet(false, nil);
DestroyWindow(gClient->GetWindowHandle()); DestroyWindow(gClient->GetWindowHandle());
break; return TRUE;
} }
break; return TRUE;
case WM_ACTIVATE: case WM_ACTIVATE:
{ {
@ -477,7 +479,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gPendingActivateFlag = active; gPendingActivateFlag = active;
} }
} }
break; return TRUE;
// Let go of the mouse if the window is being moved. // Let go of the mouse if the window is being moved.
case WM_ENTERSIZEMOVE: case WM_ENTERSIZEMOVE:
@ -485,7 +487,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gDragging = true; gDragging = true;
if( gClient ) if( gClient )
gClient->WindowActivate(false); gClient->WindowActivate(false);
break; return TRUE;
// Redo the mouse capture if the window gets moved // Redo the mouse capture if the window gets moved
case WM_EXITSIZEMOVE: case WM_EXITSIZEMOVE:
@ -493,7 +495,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gDragging = false; gDragging = false;
if( gClient ) if( gClient )
gClient->WindowActivate(true); gClient->WindowActivate(true);
break; return TRUE;
// Redo the mouse capture if the window gets moved (special case for Colin // Redo the mouse capture if the window gets moved (special case for Colin
// and his cool program that bumps windows out from under the taskbar) // and his cool program that bumps windows out from under the taskbar)
@ -505,7 +507,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
else else
DebugMsgF("Got WM_MOVE, but ignoring"); DebugMsgF("Got WM_MOVE, but ignoring");
break; return TRUE;
/// Resize the window /// Resize the window
// (we do WM_SIZING here instead of WM_SIZE because, for some reason, WM_SIZE is // (we do WM_SIZING here instead of WM_SIZE because, for some reason, WM_SIZE is
@ -520,7 +522,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
::GetClientRect(hWnd, &r); ::GetClientRect(hWnd, &r);
gClient->GetPipeline()->Resize(r.right - r.left, r.bottom - r.top); gClient->GetPipeline()->Resize(r.right - r.left, r.bottom - r.top);
} }
break; return TRUE;
case WM_SIZE: case WM_SIZE:
// Let go of the mouse if the window is being minimized // Let go of the mouse if the window is being minimized
@ -537,7 +539,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (gClient) if (gClient)
gClient->WindowActivate(true); gClient->WindowActivate(true);
} }
break; return TRUE;
case WM_CLOSE: case WM_CLOSE:
gClient->SetDone(TRUE); gClient->SetDone(TRUE);
@ -553,9 +555,22 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
case WM_CREATE: case WM_CREATE:
// Create renderer // Create renderer
break; return TRUE;
} }
return DefWindowProc(hWnd, message, wParam, lParam);
// Messages we registered for manually (no const value)
if (message == s_WmTaskbarList)
{
// Grab the Windows 7 taskbar list stuff
if (gTaskbarList)
gTaskbarList->Release();
HRESULT result = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&gTaskbarList);
if (FAILED(result))
gTaskbarList = nil;
return TRUE;
}
else
return DefWindowProc(hWnd, message, wParam, lParam);
} }
void PumpMessageQueueProc( void ) void PumpMessageQueueProc( void )

Loading…
Cancel
Save