[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
+24 -3
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); self=(LoadingWindow_Win32 *)GetWindowLong(hWnd,DWL_USER);
} }
#if(WINVER >= 0x0601)
if (self && msg == self->taskbarCreatedEvent && !self->pTaskbarList) { if (self && msg == self->taskbarCreatedEvent && !self->pTaskbarList) {
HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&self->pTaskbarList)); HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&self->pTaskbarList));
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
@@ -114,6 +115,7 @@ INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wPara
} }
#endif
switch( msg ) switch( msg )
{ {
@@ -140,10 +142,12 @@ INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wPara
case WM_DESTROY: case WM_DESTROY:
#if(WINVER >= 0x0601)
if (self->pTaskbarList) { if (self->pTaskbarList) {
self->pTaskbarList->Release(); self->pTaskbarList->Release();
self->pTaskbarList = NULL; self->pTaskbarList = NULL;
} }
#endif
DeleteObject( g_hBitmap ); DeleteObject( g_hBitmap );
g_hBitmap = NULL; g_hBitmap = NULL;
@@ -173,14 +177,19 @@ void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon )
SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon ); SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon );
} }
LoadingWindow_Win32::LoadingWindow_Win32() : pTaskbarList(NULL) LoadingWindow_Win32::LoadingWindow_Win32()
{ {
INITCOMMONCONTROLSEX cceData; INITCOMMONCONTROLSEX cceData;
cceData.dwSize=sizeof(INITCOMMONCONTROLSEX); cceData.dwSize=sizeof(INITCOMMONCONTROLSEX);
cceData.dwICC=ICC_PROGRESS_CLASS; cceData.dwICC=ICC_PROGRESS_CLASS;
InitCommonControlsEx(&cceData); InitCommonControlsEx(&cceData);
#if(WINVER >= 0x0601)
pTaskbarList=NULL;
taskbarCreatedEvent=RegisterWindowMessage("TaskbarButtonCreated"); taskbarCreatedEvent=RegisterWindowMessage("TaskbarButtonCreated");
#endif
m_hIcon = NULL; m_hIcon = NULL;
@@ -252,7 +261,11 @@ void LoadingWindow_Win32::SetProgress(const int progress)
m_progress=progress; m_progress=progress;
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
::SendMessage(hwndItem,PBM_SETPOS,progress,0); ::SendMessage(hwndItem,PBM_SETPOS,progress,0);
pTaskbarList->SetProgressValue(hwnd, m_progress, m_totalWork); #if(WINVER >= 0x0601)
if(pTaskbarList) {
pTaskbarList->SetProgressValue(hwnd, m_progress, m_totalWork);
}
#endif
} }
void LoadingWindow_Win32::SetTotalWork(const int totalWork) void LoadingWindow_Win32::SetTotalWork(const int totalWork)
@@ -260,7 +273,11 @@ void LoadingWindow_Win32::SetTotalWork(const int totalWork)
m_totalWork=totalWork; m_totalWork=totalWork;
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork);
pTaskbarList->SetProgressValue(hwnd, m_progress, m_totalWork); #if(WINVER >= 0x0601)
if(pTaskbarList) {
pTaskbarList->SetProgressValue(hwnd, m_progress, m_totalWork);
}
#endif
} }
void LoadingWindow_Win32::SetIndeterminate(bool indeterminate) { void LoadingWindow_Win32::SetIndeterminate(bool indeterminate) {
@@ -269,17 +286,21 @@ void LoadingWindow_Win32::SetIndeterminate(bool indeterminate) {
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
if(indeterminate) { if(indeterminate) {
#if(WINVER >= 0x0601)
if(pTaskbarList) { if(pTaskbarList) {
pTaskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE); pTaskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE);
} }
#endif
SetWindowLong(hwndItem,GWL_STYLE, PBS_MARQUEE | GetWindowLong(hwndItem,GWL_STYLE)); SetWindowLong(hwndItem,GWL_STYLE, PBS_MARQUEE | GetWindowLong(hwndItem,GWL_STYLE));
SendMessage(hwndItem,PBM_SETMARQUEE,1,0); SendMessage(hwndItem,PBM_SETMARQUEE,1,0);
} else { } else {
SendMessage(hwndItem,PBM_SETMARQUEE,0,0); SendMessage(hwndItem,PBM_SETMARQUEE,0,0);
SetWindowLong(hwndItem,GWL_STYLE, (~PBS_MARQUEE) & GetWindowLong(hwndItem,GWL_STYLE)); SetWindowLong(hwndItem,GWL_STYLE, (~PBS_MARQUEE) & GetWindowLong(hwndItem,GWL_STYLE));
#if(WINVER >= 0x0601)
if(pTaskbarList) { if(pTaskbarList) {
pTaskbarList->SetProgressState(hwnd, TBPF_NORMAL); pTaskbarList->SetProgressState(hwnd, TBPF_NORMAL);
} }
#endif
} }
} }
@@ -3,10 +3,15 @@
#ifndef LOADING_WINDOW_WIN32_H #ifndef LOADING_WINDOW_WIN32_H
#define LOADING_WINDOW_WIN32_H #define LOADING_WINDOW_WIN32_H
#include "global.h"
#include "LoadingWindow.h" #include "LoadingWindow.h"
#include <windows.h> #include <windows.h>
#include "archutils/Win32/AppInstance.h" #include "archutils/Win32/AppInstance.h"
#if(WINVER >= 0x0601)
#include "Shobjidl.h" #include "Shobjidl.h"
#endif
class LoadingWindow_Win32: public LoadingWindow class LoadingWindow_Win32: public LoadingWindow
{ {
@@ -28,8 +33,11 @@ private:
HANDLE pumpThread; HANDLE pumpThread;
DWORD pumpThreadId; DWORD pumpThreadId;
HANDLE guiReadyEvent; HANDLE guiReadyEvent;
#if(WINVER >= 0x0601)
UINT taskbarCreatedEvent; UINT taskbarCreatedEvent;
ITaskbarList3 *pTaskbarList; ITaskbarList3 *pTaskbarList;
#endif
volatile bool runMessageLoop; 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 /* 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. */ * 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 #define _WIN32_IE 0x0400
// If this isn't defined to 0, VC fails to define things like stat and alloca. // If this isn't defined to 0, VC fails to define things like stat and alloca.