mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Add a DX11 video plugin.
Might or might not work for you, yet. Anyway, read the soon to be created forum thread on this plugin before asking any questions. Huge thanks to rodolfoosvaldobogado for helping me out in various areas. Also, thanks to everyone on IRC who supported me during development ;) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5680 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include "DialogManager.h"
|
||||
|
||||
typedef std::vector <HWND> WindowList;
|
||||
WindowList dialogs;
|
||||
|
||||
void DialogManager::AddDlg(HWND hDialog)
|
||||
{
|
||||
dialogs.push_back(hDialog);
|
||||
}
|
||||
|
||||
bool DialogManager::IsDialogMessage(LPMSG message)
|
||||
{
|
||||
WindowList::iterator iter;
|
||||
for (iter=dialogs.begin(); iter!=dialogs.end(); iter++)
|
||||
{
|
||||
if (::IsDialogMessage(*iter,message))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DialogManager::EnableAll(BOOL enable)
|
||||
{
|
||||
WindowList::iterator iter;
|
||||
for (iter=dialogs.begin(); iter!=dialogs.end(); iter++)
|
||||
EnableWindow(*iter,enable);
|
||||
}
|
12
Source/Plugins/Plugin_VideoDX11/Src/W32Util/DialogManager.h
Normal file
12
Source/Plugins/Plugin_VideoDX11/Src/W32Util/DialogManager.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
class DialogManager
|
||||
{
|
||||
public:
|
||||
static void AddDlg(HWND hDialog);
|
||||
static bool IsDialogMessage(LPMSG message);
|
||||
static void EnableAll(BOOL enable);
|
||||
};
|
||||
|
42
Source/Plugins/Plugin_VideoDX11/Src/W32Util/Misc.cpp
Normal file
42
Source/Plugins/Plugin_VideoDX11/Src/W32Util/Misc.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Misc.h"
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
void CenterWindow(HWND hwnd)
|
||||
{
|
||||
HWND hwndParent;
|
||||
RECT rect, rectP;
|
||||
int width, height;
|
||||
int screenwidth, screenheight;
|
||||
int x, y;
|
||||
|
||||
// make the window relative to its parent
|
||||
hwndParent = GetParent(hwnd);
|
||||
if (!hwndParent)
|
||||
return;
|
||||
|
||||
GetWindowRect(hwnd, &rect);
|
||||
GetWindowRect(hwndParent, &rectP);
|
||||
|
||||
width = rect.right - rect.left;
|
||||
height = rect.bottom - rect.top;
|
||||
|
||||
x = ((rectP.right-rectP.left) - width) / 2 + rectP.left;
|
||||
y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top;
|
||||
|
||||
screenwidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
screenheight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
// make sure that the dialog box never moves outside of
|
||||
// the screen
|
||||
if (x < 0) x = 0;
|
||||
if (y < 0) y = 0;
|
||||
if (x + width > screenwidth) x = screenwidth - width;
|
||||
if (y + height > screenheight) y = screenheight - height;
|
||||
|
||||
MoveWindow(hwnd, x, y, width, height, FALSE);
|
||||
}
|
||||
}
|
8
Source/Plugins/Plugin_VideoDX11/Src/W32Util/Misc.h
Normal file
8
Source/Plugins/Plugin_VideoDX11/Src/W32Util/Misc.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
void CenterWindow(HWND hwnd);
|
||||
}
|
223
Source/Plugins/Plugin_VideoDX11/Src/W32Util/PropertySheet.cpp
Normal file
223
Source/Plugins/Plugin_VideoDX11/Src/W32Util/PropertySheet.cpp
Normal file
@ -0,0 +1,223 @@
|
||||
#include "Misc.h"
|
||||
#include "PropertySheet.h"
|
||||
|
||||
#include <commctrl.h>
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
bool centered;
|
||||
|
||||
PropSheet::PropSheet()
|
||||
{
|
||||
watermark = 0;
|
||||
header = 0;
|
||||
icon = 0;
|
||||
}
|
||||
|
||||
int CALLBACK PropSheet::Callback(HWND hwndDlg, UINT uMsg, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg) {
|
||||
case PSCB_PRECREATE:
|
||||
{
|
||||
if (uMsg == PSCB_PRECREATE)
|
||||
{
|
||||
/*
|
||||
if (lParam)
|
||||
{
|
||||
DLGTEMPLATE* pDlgTemplate;
|
||||
DLGTEMPLATEEX* pDlgTemplateEx;
|
||||
|
||||
pDlgTemplateEx = (DLGTEMPLATEEX*)lParam;
|
||||
if (pDlgTemplateEx->signature == 0xFFFF)
|
||||
{
|
||||
// pDlgTemplateEx points to an extended
|
||||
// dialog template structure.
|
||||
|
||||
//pDlgTemplate->style |= DS_SETFONT;
|
||||
u8* tmp1 = (u8*)&pDlgTemplateEx + sizeof(DLGTEMPLATEEX);
|
||||
u16* tmp = (u16*)tmp1;
|
||||
tmp++; //skip menu
|
||||
tmp++; //skip dlg class
|
||||
//Crash();
|
||||
//Here we should bash in Segoe UI
|
||||
//It turns out to be way complicated though
|
||||
//Not worth it
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a standard dialog template
|
||||
// structure.
|
||||
pDlgTemplate = (DLGTEMPLATE*)lParam;
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case PSCB_INITIALIZED:
|
||||
{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PropSheet::Show(HINSTANCE hInstance, HWND hParent, LPCTSTR title, int startpage, bool floating, bool wizard)
|
||||
{
|
||||
HPROPSHEETPAGE* pages = new HPROPSHEETPAGE[list.size()];
|
||||
PROPSHEETPAGE page;
|
||||
//common settings
|
||||
memset((void*)&page,0,sizeof(PROPSHEETPAGE));
|
||||
page.dwSize = sizeof(PROPSHEETPAGE);
|
||||
page.hInstance = hInstance;
|
||||
|
||||
int i=0;
|
||||
for (DlgList::iterator iter = list.begin(); iter != list.end(); iter++, i++)
|
||||
{
|
||||
if (wizard)
|
||||
{
|
||||
if (i == 0 || i == list.size()-1)
|
||||
page.dwFlags = PSP_HIDEHEADER;
|
||||
else
|
||||
page.dwFlags = PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
page.dwFlags = PSP_USETITLE;
|
||||
}
|
||||
page.pszTemplate = iter->resource;
|
||||
page.pfnDlgProc = Tab::TabDlgProc;
|
||||
page.pszTitle = iter->title;
|
||||
page.pszHeaderTitle = wizard?iter->title:0;
|
||||
page.pszHeaderSubTitle = wizard?iter->hdrSubTitle:0;
|
||||
page.lParam = (LPARAM)iter->tab;
|
||||
pages[i] = CreatePropertySheetPage(&page);
|
||||
}
|
||||
|
||||
PROPSHEETHEADER sheet;
|
||||
memset(&sheet,0,sizeof(sheet));
|
||||
sheet.dwSize = sizeof(PROPSHEETHEADER);
|
||||
sheet.hInstance = hInstance;
|
||||
sheet.hwndParent = hParent;
|
||||
sheet.pszbmWatermark = watermark;
|
||||
sheet.pszbmHeader = header;
|
||||
sheet.pszCaption = title;
|
||||
sheet.nPages = (UINT)list.size();
|
||||
sheet.phpage = pages;
|
||||
sheet.nStartPage = startpage;
|
||||
sheet.pfnCallback = (PFNPROPSHEETCALLBACK)Callback;
|
||||
|
||||
NONCLIENTMETRICS ncm = {0};
|
||||
ncm.cbSize = sizeof(ncm);
|
||||
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
|
||||
hDialogFont = CreateFontIndirect(&ncm.lfMessageFont);
|
||||
|
||||
if (wizard)
|
||||
{
|
||||
sheet.dwFlags = PSH_USECALLBACK | PSH_WIZARD97 | (watermark?PSH_WATERMARK:0) | (header?PSH_HEADER:0);
|
||||
|
||||
//Create the intro/end title font
|
||||
LOGFONT TitleLogFont = ncm.lfMessageFont;
|
||||
TitleLogFont.lfWeight = FW_BOLD;
|
||||
lstrcpy(TitleLogFont.lfFaceName, TEXT("Verdana Bold"));
|
||||
//StringCchCopy(TitleLogFont.lfFaceName, 32, TEXT("Verdana Bold"));
|
||||
|
||||
HDC hdc = GetDC(NULL); //gets the screen DC
|
||||
int FontSize = 12;
|
||||
TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * FontSize / 72;
|
||||
hTitleFont = CreateFontIndirect(&TitleLogFont);
|
||||
ReleaseDC(NULL, hdc);
|
||||
} else {
|
||||
sheet.dwFlags = PSH_USECALLBACK | PSH_PROPTITLE;
|
||||
hTitleFont = 0;
|
||||
}
|
||||
|
||||
if (icon) {
|
||||
sheet.dwFlags |= PSH_USEHICON;
|
||||
sheet.hIcon = icon;
|
||||
}
|
||||
|
||||
sheet.dwFlags |= PSH_NOCONTEXTHELP;
|
||||
|
||||
if (floating)
|
||||
sheet.dwFlags |= PSH_MODELESS;
|
||||
//else
|
||||
// sheet.dwFlags |= PSH_NOAPPLYNOW;
|
||||
|
||||
centered=false;
|
||||
PropertySheet(&sheet);
|
||||
if (!floating)
|
||||
{
|
||||
for (DlgList::iterator iter = list.begin(); iter != list.end(); iter++)
|
||||
{
|
||||
delete iter->tab;
|
||||
}
|
||||
DeleteObject(hTitleFont);
|
||||
}
|
||||
DeleteObject(hDialogFont);
|
||||
delete [] pages;
|
||||
}
|
||||
void PropSheet::Add(Tab* tab, LPCTSTR resource, LPCTSTR title, LPCTSTR subtitle)
|
||||
{
|
||||
tab->sheet = this;
|
||||
list.push_back(Page(tab,resource,title,subtitle));
|
||||
}
|
||||
|
||||
|
||||
void WizExteriorPage::Init(HWND hDlg)
|
||||
{
|
||||
HWND hwndControl = GetDlgItem(hDlg, captionID);
|
||||
//SetWindowFont(hwndControl, sheet->GetTitleFont(), TRUE);
|
||||
SendMessage(hwndControl,WM_SETFONT,(WPARAM)sheet->GetTitleFont(),0);
|
||||
}
|
||||
|
||||
INT_PTR Tab::TabDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
Tab* tab = (Tab*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
|
||||
switch(message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
if (!centered) //HACK
|
||||
{
|
||||
CenterWindow(GetParent(hDlg));
|
||||
centered=true;
|
||||
}
|
||||
LPARAM l = ((LPPROPSHEETPAGE)lParam)->lParam;
|
||||
tab = (Tab*)l;
|
||||
SetWindowLongPtr(hDlg, GWLP_USERDATA, (DWORD_PTR)l);
|
||||
tab->Init(hDlg);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
tab->Command(hDlg,wParam);
|
||||
PropSheet_Changed(GetParent(hDlg), hDlg);
|
||||
break;
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPPSHNOTIFY lppsn = (LPPSHNOTIFY) lParam;
|
||||
HWND sheet = lppsn->hdr.hwndFrom;
|
||||
switch(lppsn->hdr.code) {
|
||||
case PSN_APPLY:
|
||||
tab->Apply(hDlg);
|
||||
break;
|
||||
case PSN_SETACTIVE:
|
||||
PropSheet_SetWizButtons(GetParent(hDlg),
|
||||
(tab->HasPrev()?PSWIZB_BACK:0) |
|
||||
(tab->HasNext()?PSWIZB_NEXT:0) |
|
||||
(tab->HasFinish()?PSWIZB_FINISH:0));
|
||||
break;
|
||||
case PSN_WIZNEXT:
|
||||
tab->Apply(hDlg); //maybe not always good
|
||||
break;
|
||||
case PSN_WIZBACK:
|
||||
case PSN_RESET: //cancel
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
87
Source/Plugins/Plugin_VideoDX11/Src/W32Util/PropertySheet.h
Normal file
87
Source/Plugins/Plugin_VideoDX11/Src/W32Util/PropertySheet.h
Normal file
@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
class PropSheet;
|
||||
|
||||
class Tab
|
||||
{
|
||||
public:
|
||||
PropSheet* sheet; //back pointer ..
|
||||
virtual void Init(HWND hDlg) {}
|
||||
virtual void Command(HWND hDlg, WPARAM wParam) {}
|
||||
virtual void Apply(HWND hDlg) {}
|
||||
virtual bool HasPrev() {return true;}
|
||||
virtual bool HasFinish() {return false;}
|
||||
virtual bool HasNext() {return true;}
|
||||
static INT_PTR __stdcall TabDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
|
||||
|
||||
class WizExteriorPage : public Tab
|
||||
{
|
||||
int captionID;
|
||||
public:
|
||||
WizExteriorPage(int caption) {captionID = caption;}
|
||||
void Init(HWND hDlg);
|
||||
};
|
||||
|
||||
|
||||
class WizFirstPage : public WizExteriorPage
|
||||
{
|
||||
public:
|
||||
WizFirstPage(int caption) : WizExteriorPage(caption) {}
|
||||
bool HasPrev() {return false;}
|
||||
};
|
||||
|
||||
|
||||
class WizLastPage : public WizExteriorPage
|
||||
{
|
||||
public:
|
||||
WizLastPage(int caption) : WizExteriorPage(caption) {}
|
||||
bool HasNext() {return false;}
|
||||
bool HasFinish() {return true;}
|
||||
};
|
||||
|
||||
|
||||
class WizInteriorPage : public Tab
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
class PropSheet
|
||||
{
|
||||
LPCTSTR watermark;
|
||||
LPCTSTR header;
|
||||
HFONT hTitleFont;
|
||||
HFONT hDialogFont;
|
||||
HICON icon;
|
||||
struct Page
|
||||
{
|
||||
Page(Tab* _tab, LPCTSTR _resource, LPCTSTR _title, LPCTSTR _subtitle = 0)
|
||||
: tab(_tab), resource(_resource), title(_title), hdrSubTitle(_subtitle) {}
|
||||
Tab* tab;
|
||||
LPCTSTR resource;
|
||||
LPCTSTR title;
|
||||
LPCTSTR hdrSubTitle;
|
||||
};
|
||||
public:
|
||||
PropSheet();
|
||||
typedef std::vector<Page> DlgList;
|
||||
DlgList list;
|
||||
void SetWaterMark(LPCTSTR _watermark) {watermark=_watermark;}
|
||||
void SetHeader(LPCTSTR _header) {header=_header;}
|
||||
void SetIcon(HICON _icon) {icon = _icon;}
|
||||
void Add(Tab* tab, LPCTSTR resource, LPCTSTR title, LPCTSTR subtitle = 0);
|
||||
void Show(HINSTANCE hInstance, HWND hParent, LPCTSTR title, int startpage=0, bool floating = false, bool wizard = false);
|
||||
HFONT GetTitleFont() {return hTitleFont;}
|
||||
HFONT GetFont() {return hDialogFont;}
|
||||
static int CALLBACK Callback(HWND hwndDlg, UINT uMsg, LPARAM lParam);
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
95
Source/Plugins/Plugin_VideoDX11/Src/W32Util/TabControl.cpp
Normal file
95
Source/Plugins/Plugin_VideoDX11/Src/W32Util/TabControl.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
#include "TabControl.h"
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
// __________________________________________________________________________________________________
|
||||
// constructor
|
||||
//
|
||||
TabControl::TabControl(HINSTANCE _hInstance, HWND _hTabCtrl,DLGPROC _lpDialogFunc) :
|
||||
m_hInstance(_hInstance),
|
||||
m_hTabCtrl(_hTabCtrl),
|
||||
m_numDialogs(0)
|
||||
{
|
||||
for (int i=0; i<MAX_WIN_DIALOGS; i++)
|
||||
m_WinDialogs[i] = NULL;
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// destructor
|
||||
//
|
||||
TabControl::~TabControl(void)
|
||||
{}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// AddItem
|
||||
//
|
||||
HWND TabControl::AddItem (char* _szText,int _iResource,DLGPROC _lpDialogFunc)
|
||||
{
|
||||
TCITEMA tcItem;
|
||||
|
||||
ZeroMemory (&tcItem,sizeof (tcItem));
|
||||
|
||||
tcItem.mask = TCIF_TEXT | TCIF_IMAGE;
|
||||
tcItem.dwState = 0;
|
||||
tcItem.pszText = _szText;
|
||||
tcItem.cchTextMax = sizeof (_szText);
|
||||
tcItem.iImage = -1;
|
||||
|
||||
int nResult = TabCtrl_InsertItem (m_hTabCtrl,TabCtrl_GetItemCount (m_hTabCtrl),&tcItem);
|
||||
|
||||
|
||||
HWND hDialog = CreateDialogA(m_hInstance,(LPCSTR)_iResource,m_hTabCtrl,_lpDialogFunc);
|
||||
RECT rectInnerWindow = {0,0,0,0};
|
||||
|
||||
GetWindowRect (m_hTabCtrl,&rectInnerWindow);
|
||||
|
||||
TabCtrl_AdjustRect (m_hTabCtrl,FALSE,&rectInnerWindow);
|
||||
|
||||
POINT pntPosition = {rectInnerWindow.left,rectInnerWindow.top};
|
||||
ScreenToClient(m_hTabCtrl, &pntPosition);
|
||||
|
||||
SetWindowPos(hDialog, 0,
|
||||
pntPosition.x, pntPosition.y,
|
||||
rectInnerWindow.right - rectInnerWindow.left,rectInnerWindow.bottom - rectInnerWindow.top,0);
|
||||
ShowWindow(hDialog,SW_NORMAL);
|
||||
|
||||
m_WinDialogs[m_numDialogs] = hDialog;
|
||||
m_numDialogs++;
|
||||
|
||||
SelectDialog (0);
|
||||
|
||||
return hDialog;
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// SelectDialog
|
||||
//
|
||||
void TabControl::SelectDialog (int _nDialogId)
|
||||
{
|
||||
for (int i = 0 ; i < m_numDialogs ; i ++)
|
||||
if (m_WinDialogs[i] != NULL)
|
||||
ShowWindow(m_WinDialogs[i],i == _nDialogId ? SW_NORMAL : SW_HIDE);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// MessageHandler
|
||||
//
|
||||
void TabControl::MessageHandler(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (message == WM_NOTIFY)
|
||||
{
|
||||
NMHDR* pNotifyMessage = NULL;
|
||||
pNotifyMessage = (LPNMHDR)lParam;
|
||||
if (pNotifyMessage->hwndFrom == m_hTabCtrl)
|
||||
{
|
||||
int iPage = TabCtrl_GetCurSel (m_hTabCtrl);
|
||||
SelectDialog (iPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
36
Source/Plugins/Plugin_VideoDX11/Src/W32Util/TabControl.h
Normal file
36
Source/Plugins/Plugin_VideoDX11/Src/W32Util/TabControl.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
#define MAX_WIN_DIALOGS 32
|
||||
|
||||
|
||||
class TabControl
|
||||
{
|
||||
private:
|
||||
|
||||
HINSTANCE m_hInstance;
|
||||
HWND m_hWndParent;
|
||||
HWND m_hTabCtrl;
|
||||
|
||||
HWND m_WinDialogs[MAX_WIN_DIALOGS];
|
||||
int m_numDialogs;
|
||||
|
||||
public:
|
||||
|
||||
TabControl(HINSTANCE _hInstance, HWND _hTabCtrl,DLGPROC _lpDialogFunc);
|
||||
|
||||
~TabControl(void);
|
||||
|
||||
//
|
||||
// --- tools ---
|
||||
//
|
||||
|
||||
HWND AddItem (char* _szText,int _iResource,DLGPROC _lpDialogFunc);
|
||||
|
||||
void SelectDialog (int _nDialogId);
|
||||
|
||||
void MessageHandler(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
|
||||
}
|
82
Source/Plugins/Plugin_VideoDX11/Src/W32Util/Thread.cpp
Normal file
82
Source/Plugins/Plugin_VideoDX11/Src/W32Util/Thread.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
#include "Thread.h"
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
// __________________________________________________________________________________________________
|
||||
// Constructor
|
||||
//
|
||||
Thread::Thread ( DWORD (WINAPI * pFun) (void* arg), void* pArg)
|
||||
{
|
||||
_handle = CreateThread (
|
||||
0, // Security attributes
|
||||
0, // Stack size
|
||||
pFun,
|
||||
pArg,
|
||||
CREATE_SUSPENDED,
|
||||
&_tid);
|
||||
}
|
||||
// __________________________________________________________________________________________________
|
||||
// Destructor
|
||||
//
|
||||
Thread::~Thread (void)
|
||||
{
|
||||
if (_handle != NULL)
|
||||
{
|
||||
if (CloseHandle (_handle) == FALSE)
|
||||
{
|
||||
Terminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Resume
|
||||
//
|
||||
void
|
||||
Thread::Resume (void)
|
||||
{
|
||||
if (_handle != NULL)
|
||||
ResumeThread (_handle);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// WaitForDeath
|
||||
//
|
||||
void
|
||||
Thread::WaitForDeath (void)
|
||||
{
|
||||
if (_handle != NULL)
|
||||
WaitForSingleObject (_handle, 100);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Terminate
|
||||
//
|
||||
void
|
||||
Thread::Terminate (void)
|
||||
{
|
||||
if (_handle != NULL)
|
||||
TerminateThread (_handle, 0);
|
||||
_handle = NULL;
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// SetPriority
|
||||
//
|
||||
void
|
||||
Thread::SetPriority (int _nPriority)
|
||||
{
|
||||
if (_handle != NULL)
|
||||
SetThreadPriority(_handle, _nPriority);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Suspend
|
||||
//
|
||||
void
|
||||
Thread::Suspend (void)
|
||||
{
|
||||
if (_handle != NULL)
|
||||
SuspendThread(_handle);
|
||||
}
|
||||
}
|
38
Source/Plugins/Plugin_VideoDX11/Src/W32Util/Thread.h
Normal file
38
Source/Plugins/Plugin_VideoDX11/Src/W32Util/Thread.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
class Thread
|
||||
{
|
||||
private:
|
||||
HANDLE _handle;
|
||||
DWORD _tid; // thread id
|
||||
|
||||
public:
|
||||
Thread ( DWORD (WINAPI * pFun) (void* arg), void* pArg);
|
||||
~Thread () ;
|
||||
|
||||
//
|
||||
// --- tools ---
|
||||
//
|
||||
|
||||
void Resume(void);
|
||||
|
||||
void Suspend(void);
|
||||
|
||||
void WaitForDeath(void);
|
||||
|
||||
void Terminate(void);
|
||||
|
||||
void SetPriority(int _nPriority);
|
||||
|
||||
bool IsActive (void);
|
||||
|
||||
HANDLE GetHandle(void) {return _handle;}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user