[loading window] Now it should build with old SDKs, if you change the constant.

This commit is contained in:
Henrik Andersson
2011-07-01 02:27:22 +02:00
parent 36b9864dfc
commit 7bf7a701ea
3 changed files with 321 additions and 292 deletions
+22 -1
View File
@@ -93,6 +93,7 @@ INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wPara
self=(LoadingWindow_Win32 *)GetWindowLong(hWnd,DWL_USER);
}
#if(WINVER >= 0x0601)
if (self && msg == self->taskbarCreatedEvent && !self->pTaskbarList) {
HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&self->pTaskbarList));
if (SUCCEEDED(hr)) {
@@ -114,6 +115,7 @@ INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wPara
}
#endif
switch( msg )
{
@@ -140,10 +142,12 @@ INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wPara
case WM_DESTROY:
#if(WINVER >= 0x0601)
if (self->pTaskbarList) {
self->pTaskbarList->Release();
self->pTaskbarList = NULL;
}
#endif
DeleteObject( g_hBitmap );
g_hBitmap = NULL;
@@ -173,14 +177,19 @@ void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon )
SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon );
}
LoadingWindow_Win32::LoadingWindow_Win32() : pTaskbarList(NULL)
LoadingWindow_Win32::LoadingWindow_Win32()
{
INITCOMMONCONTROLSEX cceData;
cceData.dwSize=sizeof(INITCOMMONCONTROLSEX);
cceData.dwICC=ICC_PROGRESS_CLASS;
InitCommonControlsEx(&cceData);
#if(WINVER >= 0x0601)
pTaskbarList=NULL;
taskbarCreatedEvent=RegisterWindowMessage("TaskbarButtonCreated");
#endif
m_hIcon = NULL;
@@ -252,16 +261,24 @@ void LoadingWindow_Win32::SetProgress(const int progress)
m_progress=progress;
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
::SendMessage(hwndItem,PBM_SETPOS,progress,0);
#if(WINVER >= 0x0601)
if(pTaskbarList) {
pTaskbarList->SetProgressValue(hwnd, m_progress, m_totalWork);
}
#endif
}
void LoadingWindow_Win32::SetTotalWork(const int totalWork)
{
m_totalWork=totalWork;
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork);
#if(WINVER >= 0x0601)
if(pTaskbarList) {
pTaskbarList->SetProgressValue(hwnd, m_progress, m_totalWork);
}
#endif
}
void LoadingWindow_Win32::SetIndeterminate(bool indeterminate) {
m_indeterminate=indeterminate;
@@ -269,17 +286,21 @@ void LoadingWindow_Win32::SetIndeterminate(bool indeterminate) {
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
if(indeterminate) {
#if(WINVER >= 0x0601)
if(pTaskbarList) {
pTaskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE);
}
#endif
SetWindowLong(hwndItem,GWL_STYLE, PBS_MARQUEE | GetWindowLong(hwndItem,GWL_STYLE));
SendMessage(hwndItem,PBM_SETMARQUEE,1,0);
} else {
SendMessage(hwndItem,PBM_SETMARQUEE,0,0);
SetWindowLong(hwndItem,GWL_STYLE, (~PBS_MARQUEE) & GetWindowLong(hwndItem,GWL_STYLE));
#if(WINVER >= 0x0601)
if(pTaskbarList) {
pTaskbarList->SetProgressState(hwnd, TBPF_NORMAL);
}
#endif
}
}
@@ -3,10 +3,15 @@
#ifndef LOADING_WINDOW_WIN32_H
#define LOADING_WINDOW_WIN32_H
#include "global.h"
#include "LoadingWindow.h"
#include <windows.h>
#include "archutils/Win32/AppInstance.h"
#if(WINVER >= 0x0601)
#include "Shobjidl.h"
#endif
class LoadingWindow_Win32: public LoadingWindow
{
@@ -28,8 +33,11 @@ private:
HANDLE pumpThread;
DWORD pumpThreadId;
HANDLE guiReadyEvent;
#if(WINVER >= 0x0601)
UINT taskbarCreatedEvent;
ITaskbarList3 *pTaskbarList;
#endif
volatile bool runMessageLoop;
+1 -1
View File
@@ -66,7 +66,7 @@ C4355: 'this' : used in base member initializer list
/* Pull in NT-only definitions. Note that we support Win98 and WinME; you can
* make NT calls, but be sure to fall back on 9x if they're not supported. */
#define _WIN32_WINNT 0x0501
#define _WIN32_WINNT 0x0601
#define _WIN32_IE 0x0400
// If this isn't defined to 0, VC fails to define things like stat and alloca.