mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 22:09:19 -07:00
3ea2a1387c
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
96 lines
2.5 KiB
C++
96 lines
2.5 KiB
C++
#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);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|