void mxTab_resizeChild (HWND hwnd)
{
	TC_ITEM ti;

	int index = TabCtrl_GetCurSel (hwnd);
	if (index >= 0)
	{
		ti.mask = TCIF_PARAM;
		TabCtrl_GetItem (hwnd, index, &ti);
		mxWidget *widget = (mxWidget *) ti.lParam;
		if (widget)
		{
			RECT rc, rc2;

			GetWindowRect (hwnd, &rc);
			ScreenToClient (GetParent (hwnd), (LPPOINT) &rc.left);
			ScreenToClient (GetParent (hwnd), (LPPOINT) &rc.right);

			TabCtrl_GetItemRect (hwnd, index, &rc2);

			int ex = GetSystemMetrics (SM_CXEDGE);
			int ey = GetSystemMetrics (SM_CYEDGE);
			rc.top += (rc2.bottom - rc2.top) + 3 * ey;
			rc.left += 2 * ex;
			rc.right -= 2 * ex;
			rc.bottom -= 2 * ey;
			HDWP hdwp = BeginDeferWindowPos (2);
			DeferWindowPos (hdwp, hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
			DeferWindowPos (hdwp, (HWND) widget->getHandle (), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
			EndDeferWindowPos (hdwp);
		}
	}
}
Beispiel #2
0
wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
{
    // we can't use TabCtrl_AdjustRect here because it only works for wxNB_TOP
    wxSize sizeTotal = sizePage;

    wxSize tabSize;
    if ( GetPageCount() > 0 )
    {
        RECT rect;
        TabCtrl_GetItemRect(GetHwnd(), 0, &rect);
        tabSize.x = rect.right - rect.left;
        tabSize.y = rect.bottom - rect.top;
    }

    const int rows = GetRowCount();

    // add an extra margin in both directions
    const int MARGIN = 8;
    if ( IsVertical() )
    {
        sizeTotal.x += MARGIN;
        sizeTotal.y += tabSize.y * rows + MARGIN;
    }
    else // horizontal layout
    {
        sizeTotal.x += tabSize.x * rows + MARGIN;
        sizeTotal.y += MARGIN;
    }

    return sizeTotal;
}
Beispiel #3
0
// Get the rect corresponding to the tab
bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const
{
    RECT rect;
    if ( !TabCtrl_GetItemRect( (HWND) GetHWND(), item, & rect) )
        return false;
    else
    {
        wxrect.x = rect.left; wxrect.y = rect.top;
        wxrect.width = rect.right - rect.left;
        wxrect.height = rect.bottom - rect.top;
        return true;
    }
}
void TabBar::reSizeTo(RECT & rc2Ajust)
{
	RECT rowRect;
	int rowCount, tabsHight;

	// Important to do that!
	// Otherwise, the window(s) it contains will take all the resouce of CPU
	// We don't need to resize the contained windows if they are even invisible anyway
	display(rc2Ajust.right > 10);
	RECT rc = rc2Ajust;
	Window::reSizeTo(rc);

	// Do our own calculations because TabCtrl_AdjustRect doesn't work
	// on vertical or multi-lined tab controls

	rowCount = TabCtrl_GetRowCount(_hSelf);
	TabCtrl_GetItemRect(_hSelf, 0, &rowRect);

	int larger = _isVertical ? rowRect.right : rowRect.bottom;
	int smaller = _isVertical ? rowRect.left : rowRect.top;
	int marge = 0;

	LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
	if (rowCount == 1)
	{
		style &= ~TCS_BUTTONS;
	}
	else // (rowCount >= 2)
	{
		style |= TCS_BUTTONS;
		marge = (rowCount - 2) * 3; // in TCS_BUTTONS mode, each row has few pixels higher
	}

	::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
	tabsHight = rowCount * (larger - smaller) + marge;
	tabsHight += GetSystemMetrics(_isVertical ? SM_CXEDGE : SM_CYEDGE);

	if (_isVertical)
	{
		rc2Ajust.left += tabsHight;
		rc2Ajust.right -= tabsHight;
	}
	else
	{
		rc2Ajust.top += tabsHight;
		rc2Ajust.bottom -= tabsHight;
	}
}
Beispiel #5
0
static void SoftwareTabView_OnMoveSize(void)
{
	HWND hwndSoftwareTabView;
	HWND hwndSoftwarePicker;
	HWND hwndSoftwareDevView;
	HWND hwndSoftwareList;
	RECT rMain, rSoftwareTabView, rClient, rTab;
	BOOL res = 0;

	hwndSoftwareTabView = GetDlgItem(GetMainWindow(), IDC_SWTAB);
	hwndSoftwarePicker = GetDlgItem(GetMainWindow(), IDC_SWLIST);
	hwndSoftwareDevView = GetDlgItem(GetMainWindow(), IDC_SWDEVVIEW);
	hwndSoftwareList = GetDlgItem(GetMainWindow(), IDC_SOFTLIST);

	GetWindowRect(hwndSoftwareTabView, &rSoftwareTabView);
	GetClientRect(GetMainWindow(), &rMain);
	ClientToScreen(GetMainWindow(), &((POINT *) &rMain)[0]);
	ClientToScreen(GetMainWindow(), &((POINT *) &rMain)[1]);

	// Calculate rClient from rSoftwareTabView in terms of rMain coordinates
	rClient.left = rSoftwareTabView.left - rMain.left;
	rClient.top = rSoftwareTabView.top - rMain.top;
	rClient.right = rSoftwareTabView.right - rMain.left;
	rClient.bottom = rSoftwareTabView.bottom - rMain.top;

	// If the tabs are visible, then make sure that the tab view's tabs are
	// not being covered up
	if (GetWindowLong(hwndSoftwareTabView, GWL_STYLE) & WS_VISIBLE)
	{
		res = TabCtrl_GetItemRect(hwndSoftwareTabView, 0, &rTab);
		rClient.top += rTab.bottom - rTab.top + 2;
	}

	/* Now actually move the controls */
	MoveWindow(hwndSoftwarePicker, rClient.left, rClient.top,
		rClient.right - rClient.left, rClient.bottom - rClient.top,
		TRUE);
	MoveWindow(hwndSoftwareDevView, rClient.left + 3, rClient.top + 2,
		rClient.right - rClient.left - 6, rClient.bottom - rClient.top -4,
		TRUE);
	MoveWindow(hwndSoftwareList, rClient.left, rClient.top,
		rClient.right - rClient.left, rClient.bottom - rClient.top,
		TRUE);
	res++;
}
Beispiel #6
0
void TabBar::reSizeTo(RECT & rc2Ajust)
{
	RECT RowRect;
	int RowCount, TabsLength;

	// Important to do that!
	// Otherwise, the window(s) it contains will take all the resouce of CPU
	// We don't need to resize the contained windows if they are even invisible anyway
	display(rc2Ajust.right > 10);
	RECT rc = rc2Ajust;
	Window::reSizeTo(rc);
	//TabCtrl_AdjustRect(_hSelf, FALSE, &rc2Ajust);

	// Do our own calculations because TabCtrl_AdjustRect doesn't work
	// on vertical or multi-lined tab controls

	RowCount = TabCtrl_GetRowCount(_hSelf);
	TabCtrl_GetItemRect(_hSelf, 0, &RowRect);
	if (_isTraditional)
	{
		TabCtrl_AdjustRect(_hSelf, FALSE, &rc2Ajust);
	}
	else if (_isVertical)
	{
		TabsLength  = RowCount * (RowRect.right - RowRect.left);
		TabsLength += GetSystemMetrics(SM_CXEDGE);

		rc2Ajust.left	+= TabsLength + 5;
		rc2Ajust.right	-= TabsLength + 10;
		rc2Ajust.top    += 5;
		rc2Ajust.bottom -= 10;
	}
	else
	{
		TabsLength  = RowCount * (RowRect.bottom - RowRect.top);
		TabsLength += GetSystemMetrics(SM_CYEDGE);

		rc2Ajust.top	+= TabsLength + 5;
		rc2Ajust.bottom -= TabsLength + 10;
		rc2Ajust.left	+= 5;
		rc2Ajust.right	-= 10;
	}
}
Beispiel #7
0
// Screen-coordinates!
bool CTabPanelWin::GetTabRect(int nTabIdx, RECT* rcTab)
{
	if (!IsTabbarCreated() || !mp_Owner->IsTabsShown())
	{
		_ASSERTE(IsTabbarCreated());
		_ASSERTE(mp_Owner->IsTabsShown());
		return false;
	}

	if (nTabIdx < 0)
		nTabIdx = TabCtrl_GetCurSel(mh_Tabbar);

	TabCtrl_GetItemRect(mh_Tabbar, nTabIdx, rcTab);
	MapWindowPoints(mh_Tabbar, NULL, (LPPOINT)rcTab, 2);
	RECT rcBar = {}; GetWindowRect(mh_Rebar, &rcBar);
	rcTab->bottom = min(rcTab->bottom, rcBar.bottom);
	rcTab->left = max(rcTab->left-2, rcBar.left);

	return true;
}
BOOL CALLBACK SERVERCONSOLE_DMFlagsCallback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
	switch ( Message )
	{
	case WM_CLOSE:

		EndDialog( hDlg, -1 );
		break;
	case WM_INITDIALOG:
		{
			// Enable tab gradients on XP and later.
			HMODULE uxtheme = LoadLibrary ("uxtheme.dll");
			if ( uxtheme != NULL )
				pEnableThemeDialogTexture = (HRESULT (__stdcall *)(HWND,DWORD))GetProcAddress (uxtheme, "EnableThemeDialogTexture");

			g_hDlg = hDlg;
			g_ulDMFlags = dmflags;
			g_ulDMFlags2 = dmflags2;
			g_ulZADMFlags = zadmflags;
			g_ulCompatFlags = compatflags;
			g_ulCompatFlags2 = zacompatflags;
			g_ulLMSAllowedWeapons = lmsallowedweapons;
			g_ulLMSSpectatorSettings = lmsspectatorsettings;

			SendDlgItemMessage( hDlg, IDC_DMFLAGS_VALUE, EM_SETLIMITTEXT, 12, 0 );
			SendDlgItemMessage( hDlg, IDC_DMFLAGS2_VALUE, EM_SETLIMITTEXT, 12, 0 );
			SendDlgItemMessage( hDlg, IDC_COMPATFLAGS_VALUE, EM_SETLIMITTEXT, 12, 0 );
			SendDlgItemMessage( hDlg, IDC_COMPATFLAGS2_VALUE, EM_SETLIMITTEXT, 12, 0 );
			SendMessage( GetDlgItem( hDlg, IDC_TITLE ), WM_SETFONT, (WPARAM) CreateFont( 24, 0, 0, 0, 900, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma" ), (LPARAM) 1);

			// Set up the tab control.
			TCITEM		tcitem;
			tcitem.mask = TCIF_TEXT | TCIF_PARAM;
			HWND edit = GetDlgItem( hDlg, IDC_FLAGSTABCONTROL );
			RECT		tabrect, tcrect;
			GetWindowRect( edit, &tcrect );
			ScreenToClient( hDlg, (LPPOINT) &tcrect.left );
			ScreenToClient( hDlg, (LPPOINT) &tcrect.right );
			TabCtrl_GetItemRect( edit, 0, &tabrect );

			// Create the tabs.		
			int index = 0;
			flags_InsertTab( "General", IDD_DMFLAGS_GENERAL, hDlg, tcitem, edit, tabrect, tcrect, index );
			flags_InsertTab( "Players", IDD_DMFLAGS_PLAYERS, hDlg, tcitem, edit, tabrect, tcrect, index );
			flags_InsertTab( "Cooperative", IDD_DMFLAGS_COOP, hDlg, tcitem, edit, tabrect, tcrect, index );
			flags_InsertTab( "Deathmatch", IDD_DMFLAGS_DM, hDlg, tcitem, edit, tabrect, tcrect, index );
			flags_InsertTab( "LMS", IDD_DMFLAGS_LMS, hDlg, tcitem, edit, tabrect, tcrect, index );
			flags_InsertTab( "Compatibility", IDD_DMFLAGS_COMPAT, hDlg, tcitem, edit, tabrect, tcrect, index );
			
			// Check for any orphan flags that don't have checkboxes.
			for ( unsigned int i = 0; i < NUMBER_OF_FLAGS; i++ )
			{
				if ( g_Flags[i].hObject == NULL )
					g_Flags[i].bStaticValue = !!( *g_Flags[i].ulFlagVariable & g_Flags[i].ulThisFlag );				
			}

			flags_ReadValuesFromForm( ); // Repair damaged flags. Also updates the textboxes.
		}
		break;
	case WM_COMMAND:

		// User is typing in some new flags.
		if ( HIWORD ( wParam ) == EN_CHANGE )
		{
			switch ( LOWORD( wParam ))
			{
			case IDC_DMFLAGS_VALUE:

				flags_ReadNewValue( hDlg, LOWORD( wParam ), g_ulDMFlags );
				break;
			case IDC_DMFLAGS2_VALUE:

				flags_ReadNewValue( hDlg, LOWORD( wParam ), g_ulDMFlags2 );
				break;
			case IDC_COMPATFLAGS_VALUE:

				flags_ReadNewValue( hDlg, LOWORD( wParam ), g_ulCompatFlags );
				break;
			case IDC_COMPATFLAGS2_VALUE:

				flags_ReadNewValue( hDlg, LOWORD( wParam ), g_ulCompatFlags2 );
				break;
			}
		}
		else if ( HIWORD( wParam ) == EN_KILLFOCUS )
			flags_ReadValuesFromForm( );

		switch ( LOWORD( wParam ))
		{
		case IDOK:

			// Save the flags.
			if ( dmflags != g_ulDMFlags )
				dmflags = g_ulDMFlags;
			if ( dmflags2 != g_ulDMFlags2 )
				dmflags2 = g_ulDMFlags2;
			if ( zadmflags != g_ulZADMFlags )
				zadmflags = g_ulZADMFlags;
			if ( compatflags != g_ulCompatFlags )
				compatflags = g_ulCompatFlags;
			if ( zacompatflags != g_ulCompatFlags2 )
				zacompatflags = g_ulCompatFlags2;
			if ( lmsallowedweapons != g_ulLMSAllowedWeapons )
				lmsallowedweapons = g_ulLMSAllowedWeapons;
			if ( lmsspectatorsettings != g_ulLMSSpectatorSettings )
				lmsspectatorsettings = g_ulLMSSpectatorSettings;

			EndDialog( hDlg, -1 );

			// These might have changed.
			SERVERCONSOLE_SetupColumns( );
			SERVERCONSOLE_ReListPlayers( );
			break;
		case IDCANCEL:

			EndDialog( hDlg, -1 );
			break;
		}
		break;
	case WM_NOTIFY:
		{
			LPNMHDR	nmhdr = (LPNMHDR) lParam;

			// User clicked the tab control.
			if ( nmhdr->idFrom == IDC_FLAGSTABCONTROL )
				return flags_HandleTabSwitch( hDlg, nmhdr );
		}
		break;
	default:

		return ( FALSE );
	}

	return ( TRUE );
}
Beispiel #9
0
void AnimeDialog::Tab::OnPaint(HDC hdc, LPPAINTSTRUCT lpps) {
  // Adapted from Paul Sanders' example code, located at:
  // http://www.glennslayden.com/code/win32/tab-control-background-brush

  ::CallWindowProc(m_PrevWindowProc, m_hWindow, WM_PRINTCLIENT, 
                   reinterpret_cast<WPARAM>(hdc), PRF_CLIENT);

  HRGN region = ::CreateRectRgn(0, 0, 0, 0);
  RECT rect, lh_corner = {0}, rh_corner = {0};

  int item_count = GetItemCount();
  int current_item = GetCurrentlySelected();
  int tab_height = 0;
  
  bool is_vista = win32::GetWinVersion() >= win32::VERSION_VISTA;
  bool is_themed_xp = !is_vista && ::IsThemeActive();

  for (int i = 0; i < item_count; ++i) {
    TabCtrl_GetItemRect(m_hWindow, i, &rect);
    if (i == current_item) {
      tab_height = (rect.bottom - rect.top) + 2;
      rect.left -= 1;
      rect.right += 1;
      rect.top -= 2;
      if (i == 0) {
        rect.left -= 1;
        if (!is_themed_xp)
          rect.right += 1;
      }
      if (i == item_count - 1)
        rect.right += 1;
    } else {
      rect.right -= 1;
      if ((is_themed_xp || is_vista) && i == item_count - 1)
        rect.right -= 1;
    }

    if (is_themed_xp) {
      if (i != current_item + 1) {
        lh_corner = rect;
        lh_corner.bottom = lh_corner.top + 1;
        lh_corner.right = lh_corner.left + 1;
      }
      rh_corner = rect;
      rh_corner.bottom = rh_corner.top + 1;
      rh_corner.left = rh_corner.right - 1;
    }

    HRGN tab_region = ::CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
    ::CombineRgn(region, region, tab_region, RGN_OR);
    ::DeleteObject(tab_region);

    if (lh_corner.right > lh_corner.left) {
      HRGN rounded_corner = ::CreateRectRgn(
        lh_corner.left, lh_corner.top, lh_corner.right, lh_corner.bottom);
      ::CombineRgn(region, region, rounded_corner, RGN_DIFF);
      ::DeleteObject(rounded_corner);
    }
    if (rh_corner.right > rh_corner.left) {
      HRGN rounded_corner = ::CreateRectRgn(
        rh_corner.left, rh_corner.top, rh_corner.right, rh_corner.bottom);
      ::CombineRgn(region, region, rounded_corner, RGN_DIFF);
      ::DeleteObject(rounded_corner);
    }
  }

  GetClientRect(&rect);
  HRGN fill_region = ::CreateRectRgn(
    rect.left, rect.top, rect.right, rect.top + tab_height);
  ::CombineRgn(fill_region, fill_region, region, RGN_DIFF);
  ::SelectClipRgn(hdc, fill_region);
  HBRUSH hBGBrush = ::GetSysColorBrush(COLOR_WINDOW);
  ::FillRgn(hdc, fill_region, hBGBrush);
  ::DeleteObject(fill_region);
  ::DeleteObject(region);
}
Beispiel #10
0
LRESULT CALLBACK 
ClientWndProc (HWND hwnd, UINT mMsg, WPARAM wParam, LPARAM lParam)
     {
	RECT rect;

     switch (mMsg)
          {
          case WM_CREATE :
			   poppad_ini( hwnd,lParam );
               return 0 ;

          case WM_DESTROY :
               //DeleteObject (hbr) ;
			   DestroyMenu(hMenu) ;
			   poppad_bye();
               return 0 ;

		  case WM_INITMENUPOPUP :
			   return poppad_menupop( (WPARAM)hSubMenu, -1 );

//          case WM_CTLCOLOREDIT :
//               {
//               DefWindowProc (hwnd, mMsg, wParam, lParam) ;
//               SetBkColor ((HDC) wParam, crBack) ;
//               //SetBkMode ((HDC) wParam, TRANSPARENT) ;
//			   SetTextColor( (HDC) wParam, crText );
//               return (LRESULT) (HBRUSH) hbr ;
//               }

          case WM_SETFOCUS :
//               hwndNotify = GetWindow (hwnd, GW_CHILD) ;
//               SetFocus (hwndNotify) ;
			   Footy2SetFocus(activeFootyID, 0);
               return 0 ;

          case WM_SIZE :
               {
//               hwndNotify = GetWindow (hwnd, GW_CHILD) ;
               int cx = LOWORD (lParam) ;
               int cy = HIWORD (lParam) ;

               // Ignore if notification window is absent.
//               if (hwndNotify != NULL)
//                    {
//                    MoveWindow (hwndNotify, 0, 0, cx, cy, TRUE) ;
//                    }
			   MoveWindow(hwndTab, 0, 0, cx, cy, TRUE);
			   GetClientRect(hwndTab, &rect);
			   TabCtrl_AdjustRect(hwndTab, FALSE, &rect);
			   Footy2Move(activeFootyID, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top);
			   poppad_setsb_current(activeFootyID);

			   return 0 ;
               }

          case WM_NOTIFY:
			  switch (((NMHDR *)lParam)->code){
				   case TCN_SELCHANGE:
				   {
					   int presID = activeID, newID = TabCtrl_GetCurSel(hwndTab);
					   ActivateTab(presID, newID);
					   ChangeZOrder(presID, newID);
					   return 0;
				   }

				   case NM_RCLICK:
					   POINT pt, cpt;
					   int i;

					   GetCursorPos(&pt);
					   cpt = pt;
					   ScreenToClient(hwndTab, &cpt);

					   for(i = 0; TabCtrl_GetItemCount(hwndTab); i++){
						   TabCtrl_GetItemRect(hwndTab, i, &rect);
						   if(rect.left <= cpt.x && cpt.x <= rect.right && rect.top <= cpt.y && cpt.y <= rect.bottom){
							   TrackPopupMenu(hSubMenu2, TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwndClient, NULL);
							   ClickID = i;
							   break;
						   }

					   }
 					   return 0;
			  }
			  return 0;

          default :
               return (EditProc (hwnd, mMsg, wParam, lParam)) ;
               //return (DefWindowProc (hwnd, mMsg, wParam, lParam)) ;
          }
     }
Beispiel #11
0
BOOL CALLBACK gui_MainDialogBoxCallback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
	switch ( Message )
	{
	case WM_INITDIALOG:

		// Load the icon.
		g_hSmallIcon = (HICON)LoadImage( g_hInst,
				MAKEINTRESOURCE( IDI_ICON ),
				IMAGE_ICON,
				16,
				16,
				LR_SHARED );

		SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)g_hSmallIcon );
		SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)LoadIcon( g_hInst, MAKEINTRESOURCE( IDI_ICON )));

		//========================
		// Set up the tab control.
		//========================

		HWND		edit;
		TCITEM		tcitem;
		RECT		tabrect, tcrect;
		LPNMHDR		nmhdr;
		tcitem.mask = TCIF_TEXT | TCIF_PARAM;
		edit = GetDlgItem( hDlg, IDC_TABC );

		GetWindowRect( edit, &tcrect );
		ScreenToClient( hDlg, (LPPOINT) &tcrect.left );
		ScreenToClient( hDlg, (LPPOINT) &tcrect.right );

		TabCtrl_GetItemRect( edit, 0, &tabrect );

		// Create the main tab.
		tcitem.pszText = "Overview";
		tcitem.lParam = (LPARAM) CreateDialogParam( g_hInst, MAKEINTRESOURCE( IDD_OVERVIEW ), hDlg, tab_OverviewCallback, (LPARAM) edit );
		TabCtrl_InsertItem( edit, 0, &tcitem );
		SetWindowPos( (HWND) tcitem.lParam, HWND_TOP, tcrect.left + 3, tcrect.top + tabrect.bottom + 3,
			tcrect.right - tcrect.left - 8, tcrect.bottom - tcrect.top - tabrect.bottom - 8, 0 );

		// Create a tab for each port.
		for ( unsigned int i = 0; i < NUM_PORTS; i++ )
		{
			tcitem.pszText = g_PortInfo[i].szName;			
			tcitem.lParam = (LPARAM) CreateDialogParam( g_hInst, MAKEINTRESOURCE( IDD_SKULLTAG ), hDlg, tab_PortCallback, (LPARAM) i );
			TabCtrl_InsertItem( edit, i + 1, &tcitem );		
			SetWindowPos( (HWND) tcitem.lParam, HWND_TOP, tcrect.left + 3, tcrect.top + tabrect.bottom + 3,
			tcrect.right - tcrect.left - 8, tcrect.bottom - tcrect.top - tabrect.bottom - 8, 0 );
		}
		
		//==============================
		// Create the notification icon.
		//==============================

		ZeroMemory( &g_NotifyIconData, sizeof( g_NotifyIconData ));
		g_NotifyIconData.cbSize = sizeof( g_NotifyIconData );
		g_NotifyIconData.hWnd = hDlg;
		g_NotifyIconData.uID = 0;
		g_NotifyIconData.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;
		g_NotifyIconData.uCallbackMessage = UWM_TRAY_TRAYID;
		g_NotifyIconData.hIcon = g_hSmallIcon;			
		lstrcpy( g_NotifyIconData.szTip, g_szTooltip );
		Shell_NotifyIcon( NIM_ADD, &g_NotifyIconData );

		break;
	case WM_CLOSE:

		Shell_NotifyIcon( NIM_DELETE, &g_NotifyIconData );
		EndDialog( hDlg, -1 );
		CloseHandle( g_hThread );
		exit( 0 );
		break;
	case WM_DESTROY:

		Shell_NotifyIcon( NIM_DELETE, &g_NotifyIconData );
		PostQuitMessage( 0 );
		break;
	case WM_SYSCOMMAND:

		if ( wParam == SC_MINIMIZE )
		{
			// Hide the window.
			ShowWindow( hDlg, SW_HIDE );
			break;
		}

		DefWindowProc( hDlg, Message, wParam, lParam );
		break;
	case UWM_TRAY_TRAYID:

		switch ( lParam )
		{
		case WM_LBUTTONDOWN:

			return TRUE;
		case WM_LBUTTONDBLCLK:

			gui_ToggleWindow( hDlg );			
			return TRUE;
		case WM_RBUTTONUP:

			{
				// Show a little menu.
				HMENU	hMenu = CreatePopupMenu();
				POINT	pt;					
		
				AppendMenu( hMenu, MF_STRING, IDR_TOGGLE, "Show/Hide" );
				// AppendMenu( hMenu, MF_STRING, IDR_BROWSE, "Browse files" );				
				AppendMenu( hMenu, MF_SEPARATOR, 0, 0 );
				AppendMenu( hMenu, MF_STRING, IDR_EXIT, "Exit" );								

				// Show it, and get the selected item.
				GetCursorPos( &pt );
				int iSelection = ::TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD | TPM_HORIZONTAL, 
					pt.x, pt.y, 0, hDlg, NULL );
				DestroyMenu( hMenu );

				if ( iSelection == IDR_EXIT )
				{					
					Shell_NotifyIcon( NIM_DELETE, &g_NotifyIconData );
					PostQuitMessage( 0 );
					EndDialog( hDlg, -1 );
					CloseHandle( g_hThread );
					exit( 0 );
				}
				else if ( iSelection == IDR_TOGGLE )
					gui_ToggleWindow( hDlg );

			}
			break;
		default:

			break;
		}
		return FALSE;
	case WM_NOTIFY:

		nmhdr = (LPNMHDR)lParam;

		// Tab switching.
		if (nmhdr->idFrom == IDC_TABC)
		{
			int i = TabCtrl_GetCurSel( nmhdr->hwndFrom );
			tcitem.mask = TCIF_PARAM;
			TabCtrl_GetItem( nmhdr->hwndFrom, i, &tcitem );
			edit = (HWND) tcitem.lParam;

			// The tab is right about to switch. Hide the current tab pane.
			if ( nmhdr->code == TCN_SELCHANGING )
			{
				ShowWindow( edit, SW_HIDE );
				SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
				return TRUE;
			}
			
			// The tab has just switched. Show the new tab pane.
			else if ( nmhdr->code == TCN_SELCHANGE )
			{
				ShowWindow ( edit, SW_SHOW );
				return TRUE;
			}

			else
				return FALSE;
		}
		break;
	default:

		return FALSE;
	}

	return TRUE;
}
Beispiel #12
0
BOOL CALLBACK settings_Dialog_Callback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
	HWND		edit;
	TCITEM		tcitem;
	RECT		tabrect, tcrect;
	LPNMHDR		nmhdr;
	HMODULE		uxtheme;

	switch (Message)
	{
	case WM_INITDIALOG:

		g_hDlg_Dialog = hDlg;
		uxtheme = LoadLibrary ("uxtheme.dll");
		if ( uxtheme != NULL )
			pEnableThemeDialogTexture = (HRESULT (__stdcall *)(HWND,DWORD))GetProcAddress (uxtheme, "EnableThemeDialogTexture");

		SendMessage( GetDlgItem( hDlg, IDC_TITLE ), WM_SETFONT, (WPARAM) CreateFont( 24, 0, 0, 0, 900, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma" ), (LPARAM) 1);

		// Set up the tab control.
		tcitem.mask = TCIF_TEXT | TCIF_PARAM;
		edit = GetDlgItem( hDlg, IDC_SETTINGSTAB );

		GetWindowRect( edit, &tcrect );
		ScreenToClient( hDlg, (LPPOINT) &tcrect.left );
		ScreenToClient( hDlg, (LPPOINT) &tcrect.right );

		TabCtrl_GetItemRect( edit, 0, &tabrect );

		// Create the tabs.
		tcitem.pszText = "Server information";
		tcitem.lParam = (LPARAM) CreateDialogParam( g_hInst, MAKEINTRESOURCE( IDD_SERVERSETTINGS_SERVERTAB ), hDlg, settings_ServerTab_Callback, (LPARAM) edit );
		TabCtrl_InsertItem( edit, 0, &tcitem );
		SetWindowPos( (HWND) tcitem.lParam, HWND_TOP, tcrect.left + 3, tcrect.top + tabrect.bottom + 3,
			tcrect.right - tcrect.left - 8, tcrect.bottom - tcrect.top - tabrect.bottom - 8, 0 );

		tcitem.pszText = "Gameplay";
		tcitem.lParam = (LPARAM) CreateDialogParam( g_hInst, MAKEINTRESOURCE( IDD_SERVERSETTINGS_GAMEPLAYTAB ), hDlg, settings_GameplayTab_Callback, (LPARAM) edit );
		TabCtrl_InsertItem( edit, 1, &tcitem );		
		SetWindowPos( (HWND) tcitem.lParam, HWND_TOP, tcrect.left + 3, tcrect.top + tabrect.bottom + 3,
			tcrect.right - tcrect.left - 8, tcrect.bottom - tcrect.top - tabrect.bottom - 8, 0 );

		tcitem.pszText = "Access";
		tcitem.lParam = (LPARAM) CreateDialogParam( g_hInst, MAKEINTRESOURCE( IDD_SERVERSETTINGS_ACCESSTAB ), hDlg, settings_AccessTab_Callback, (LPARAM) edit );
		TabCtrl_InsertItem( edit, 3, &tcitem );		
		SetWindowPos( (HWND) tcitem.lParam, HWND_TOP, tcrect.left + 3, tcrect.top + tabrect.bottom + 3,
			tcrect.right - tcrect.left - 8, tcrect.bottom - tcrect.top - tabrect.bottom - 8, 0 );

		tcitem.pszText = "Administration";
		tcitem.lParam = (LPARAM) CreateDialogParam( g_hInst, MAKEINTRESOURCE( IDD_SERVERSETTINGS_ADMINTAB ), hDlg, settings_AdminTab_Callback, (LPARAM) edit );
		TabCtrl_InsertItem( edit, 4, &tcitem );		
		SetWindowPos( (HWND) tcitem.lParam, HWND_TOP, tcrect.left + 3, tcrect.top + tabrect.bottom + 3,
			tcrect.right - tcrect.left - 8, tcrect.bottom - tcrect.top - tabrect.bottom - 8, 0 );
		break;
	case WM_NOTIFY:

		nmhdr = (LPNMHDR) lParam;

		// User clicked the tab control.
		if (nmhdr->idFrom == IDC_SETTINGSTAB )
			return settings_HandleTabSwitch( hDlg, nmhdr );

		break;

	case WM_COMMAND:

			switch ( LOWORD( wParam ))
			{				
			case IDOK:

				settings_Dialog_SaveSettings( );				
				EndDialog( hDlg, -1 );
				break;
			case IDCANCEL:

				EndDialog( hDlg, -1 );
				break;
			}
		break;
	}
	return FALSE;
}