=== sakura_core/CCommandLine.cpp
==================================================================
--- sakura_core/CCommandLine.cpp	(/mirror/sakura-editor/sakura/trunk2)	(revision 30508)

+++ sakura_core/CCommandLine.cpp	(/private/sakura-editor/open_tab_right)	(revision 30508)

@@ -390,8 +390,16 @@

 			case CMDLINEOPT_GCODE:
 				m_gi.nGrepCharSet = (ECodeType)AtoiOptionInt( arg );	break;
 			case CMDLINEOPT_GROUP:	// GROUP	// 2007.06.26 ryoji
+			{
 				m_nGroup = AtoiOptionInt( arg );
+				TCHAR* comma = _tcschr( arg, _T(','));
+				if(comma != NULL) {
+					m_nTabIndexInGroup = AtoiOptionInt( comma + 1 );
+					// ,‚ÌŒã‚É–³Œø‚È•¶Žš‚ª‚«‚½‚ç 0‚É‚È‚é‚¯‚Ç�A‚Ü‚ ‚¢‚¢‚â�B
+					// ,‚ð•t‚¯‚½‚ç•K‚¸Šó–]‚ÌƒCƒ“ƒfƒbƒNƒX‚ð‘±‚¯‚é‚±‚Æ�B
+				}
 				break;
+			}
 			case CMDLINEOPT_DEBUGMODE:
 				m_bDebugMode = true;
 				break;
@@ -449,6 +457,7 @@

 	m_gi.nGrepOutputStyle	= 1;
 	m_bViewMode			= false;
 	m_nGroup				= 0;		// 2007.06.26 ryoji
+	m_nTabIndexInGroup		= -1;
 	
 	ParseCommandLine();
 }
=== sakura_core/CControlTray.cpp
==================================================================
--- sakura_core/CControlTray.cpp	(/mirror/sakura-editor/sakura/trunk2)	(revision 30508)

+++ sakura_core/CControlTray.cpp	(/private/sakura-editor/open_tab_right)	(revision 30508)

@@ -950,7 +950,16 @@

 	HWND hwndAncestor = MyGetAncestor( hWndParent, GA_ROOTOWNER2 );	// 2007.10.22 ryoji GA_ROOTOWNER -> GA_ROOTOWNER2
 	int nGroup = CAppNodeManager::Instance()->GetEditNode( hwndAncestor )->GetGroup();
 	if( nGroup > 0 ){
-		cCmdLineBuf.AppendF( _T(" -GROUP=%d"), nGroup );
+		int nTabIndex = -1;
+		if( IsSakuraMainWindow( hwndAncestor )) {
+			CEditWnd* pEditWnd = (CEditWnd*)::GetWindowLongPtr( hwndAncestor, GWLP_USERDATA ); // ‚¢‚¢‚Ì‚©‚È�[�B‚æ‚­‚È‚¢‚Ë�[�B
+			nTabIndex = pEditWnd->m_cTabWnd.FindTabIndexByHWND( hwndAncestor ) + 1; // Œ»�Ý‚Ìƒ^ƒu‚Ì�A‰E‘¤�B
+		}
+		if(0 <= nTabIndex) {
+			cCmdLineBuf.AppendF( _T(" -GROUP=%d,%d"), nGroup, nTabIndex );
+		} else {
+			cCmdLineBuf.AppendF( _T(" -GROUP=%d"), nGroup );
+		}
 	}
 
 
=== sakura_core/CEditApp.cpp
==================================================================
--- sakura_core/CEditApp.cpp	(/mirror/sakura-editor/sakura/trunk2)	(revision 30508)

+++ sakura_core/CEditApp.cpp	(/private/sakura-editor/open_tab_right)	(revision 30508)

@@ -32,7 +32,8 @@

 	//ƒEƒBƒ“ƒhƒE‚Ì�ì�¬
 	m_pcEditWnd = new CEditWnd();
 	m_pcEditWnd->Create(
-		CCommandLine::Instance()->GetGroupId()
+		CCommandLine::Instance()->GetGroupId(),
+		CCommandLine::Instance()->GetTabIndexInGroup()
 	);
 
 	//MRUŠÇ—�
=== sakura_core/CCommandLine.h
==================================================================
--- sakura_core/CCommandLine.h	(/mirror/sakura-editor/sakura/trunk2)	(revision 30508)

+++ sakura_core/CCommandLine.h	(/private/sakura-editor/open_tab_right)	(revision 30508)

@@ -82,6 +82,7 @@

 	bool GetEditInfo(EditInfo* fi) const { *fi = m_fi; return true; }
 	bool GetGrepInfo(GrepInfo* gi) const { *gi = m_gi; return true; }
 	int GetGroupId() const {return m_nGroup;};	// 2007.06.26 ryoji
+	int GetTabIndexInGroup() const {return m_nTabIndexInGroup;};
 
 // member valiables
 private:
@@ -96,6 +97,7 @@

 	GrepInfo	m_gi;				//!
 	bool		m_bViewMode;	//! [out] TRUE: Read Only
 	int			m_nGroup;			//! ƒOƒ‹�[ƒvID	// 2007.06.26 ryoji
+	int			m_nTabIndexInGroup;
 };
 
 ///////////////////////////////////////////////////////////////////////
=== sakura_core/window/CEditWnd.cpp
==================================================================
--- sakura_core/window/CEditWnd.cpp	(/mirror/sakura-editor/sakura/trunk2)	(revision 30508)

+++ sakura_core/window/CEditWnd.cpp	(/private/sakura-editor/open_tab_right)	(revision 30508)

@@ -439,7 +439,8 @@

 	@date 2008.04.19 ryoji �‰‰ñƒAƒCƒhƒŠƒ“ƒOŒŸ�o—pƒ[ƒ�•bƒ^ƒCƒ}�[‚ÌƒZƒbƒg�ˆ—�‚ð’Ç‰Á
 */
 HWND CEditWnd::Create(
-	int				nGroup			//!< [in] ƒOƒ‹�[ƒvID
+	int				nGroup,				//!< [in] ƒOƒ‹�[ƒvID
+	int             nTabIndexInGroup	//!< [in] ƒ^ƒu‚ðƒOƒ‹�[ƒv“à‚Å�¶‚©‚ç‰½”Ô–Ú‚É’Ç‰Á‚·‚é‚©�B
 )
 {
 	MY_RUNNINGTIMER( cRunningTimer, "CEditWnd::Create" );
@@ -562,6 +563,15 @@

 	}
 	CShareData::getInstance()->SetTraceOutSource( GetHwnd() );	// TraceOut()‹N“®Œ³ƒEƒBƒ“ƒhƒE‚Ì�Ý’è	// 2006.06.26 ryoji
 
+	/* ƒ^ƒuˆÊ’u’²�® */
+	if(this->m_cTabWnd.GetHwnd() && 0 <= nTabIndexInGroup) {
+		this->m_cTabWnd.Refresh(false); // �V‹K�ì�¬‚³‚ê‚½Ž©ƒEƒBƒ“ƒhƒE‚ðƒ^ƒu‚É’Ç‰Á‚·‚é�B
+		int tabIndexOfMe = this->m_cTabWnd.FindTabIndexByHWND(GetHwnd());
+		if(-1 != tabIndexOfMe) {
+			this->m_cTabWnd.ReorderTab(tabIndexOfMe, nTabIndexInGroup);
+		}
+	}
+
 	//	Aug. 29, 2003 wmlhq
 	m_nTimerCount = 0;
 	/* ƒ^ƒCƒ}�[‚ð‹N“® */ // ƒ^ƒCƒ}�[‚ÌID‚ÆŠÔŠu‚ð•Ï�X 20060128 aroka
=== sakura_core/window/CEditWnd.h
==================================================================
--- sakura_core/window/CEditWnd.h	(/mirror/sakura-editor/sakura/trunk2)	(revision 30508)

+++ sakura_core/window/CEditWnd.h	(/private/sakura-editor/open_tab_right)	(revision 30508)

@@ -93,7 +93,8 @@

 	// 2007.06.26 ryoji ƒOƒ‹�[ƒvŽw’èˆø�”’Ç‰Á
 	//! �ì�¬
 	HWND Create(
-		int				nGroup				//!< [in] ƒOƒ‹�[ƒvID
+		int				nGroup,					//!< [in] ƒOƒ‹�[ƒvID
+		int             nTabIndexInGroup = -1	//!< [in] ƒ^ƒu‚ðƒOƒ‹�[ƒv“à‚Å�¶‚©‚ç‰½”Ô–Ú‚É’Ç‰Á‚·‚é‚©�B
 	);
 	void _GetTabGroupInfo(STabGroupInfo* pTabGroupInfo, int& nGroup);
 	void _GetWindowRectForInit(CMyRect* rcResult, int nGroup, const STabGroupInfo& sTabGroupInfo);	//!< ƒEƒBƒ“ƒhƒE�¶�¬—p‚Ì‹éŒ`‚ðŽæ“¾
=== sakura_core/window/CTabWnd.cpp
==================================================================
--- sakura_core/window/CTabWnd.cpp	(/mirror/sakura-editor/sakura/trunk2)	(revision 30508)

+++ sakura_core/window/CTabWnd.cpp	(/private/sakura-editor/open_tab_right)	(revision 30508)

@@ -378,16 +378,24 @@

 
 	if( 0 > nSrcTab || 0 > nDstTab || nSrcTab == nDstTab )
 		return FALSE;
+	int nTabCount = TabCtrl_GetItemCount( m_hwndTab );
+	if(nTabCount <= nSrcTab || nTabCount <= nDstTab) {
+		return FALSE;
+	}
 
 	// ˆÚ“®Œ³ƒ^ƒu�AˆÚ“®�æƒ^ƒu‚ÌƒEƒBƒ“ƒhƒE‚ðŽæ“¾‚·‚é
 	tcitem.mask   = TCIF_PARAM;
 	tcitem.lParam = 0;
-	TabCtrl_GetItem( m_hwndTab, nSrcTab, &tcitem );
+	if(! TabCtrl_GetItem( m_hwndTab, nSrcTab, &tcitem )) {
+		return FALSE;
+	}
 	hwndSrc = (HWND)tcitem.lParam;
 
 	tcitem.mask   = TCIF_PARAM;
 	tcitem.lParam = 0;
-	TabCtrl_GetItem( m_hwndTab, nDstTab, &tcitem );
+	if(! TabCtrl_GetItem( m_hwndTab, nDstTab, &tcitem )) {
+		return FALSE;
+	}
 	hwndDst = (HWND)tcitem.lParam;
 
 	//	2007.07.07 genta CShareData::ReorderTab‚Æ‚µ‚Ä“Æ—§
=== sakura_core/window/CTabWnd.h
==================================================================
--- sakura_core/window/CTabWnd.h	(/mirror/sakura-editor/sakura/trunk2)	(revision 30508)

+++ sakura_core/window/CTabWnd.h	(/private/sakura-editor/open_tab_right)	(revision 30508)

@@ -71,11 +71,13 @@

 	LRESULT TabWndDispatchEvent( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
 	LRESULT TabListMenu( POINT pt, BOOL bSel = TRUE, BOOL bFull = FALSE, BOOL bOtherGroup = TRUE );	/*!< ƒ^ƒuˆê——ƒ�ƒjƒ…�[�ì�¬�ˆ—� */	// 2006.03.23 fon
 
+	int FindTabIndexByHWND( HWND hWnd );
+	BOOL ReorderTab( int nSrcTab, int nDstTab );	/*!< ƒ^ƒu�‡�˜•Ï�X�ˆ—� */
+
 protected:
 	/*
 	|| ŽÀ‘•ƒwƒ‹ƒpŒn
 	*/
-	int FindTabIndexByHWND( HWND hWnd );
 	void AdjustWindowPlacement( void );							/*!< •Ò�WƒEƒBƒ“ƒhƒE‚ÌˆÊ’u�‡‚í‚¹ */	// 2007.04.03 ryoji
 	int SetCarmWindowPlacement( HWND hwnd, const WINDOWPLACEMENT* pWndpl );	/* ƒAƒNƒeƒBƒu‰»‚Ì�­‚È‚¢ SetWindowPlacement() ‚ðŽÀ�s‚·‚é */	// 2007.11.30 ryoji
 	void ShowHideWindow( HWND hwnd, BOOL bDisp );
@@ -118,7 +120,6 @@

 
 	//ŽÀ‘••â�•ƒCƒ“ƒ^�[ƒtƒF�[ƒX
 	void BreakDrag( void ) { if( ::GetCapture() == m_hwndTab ) ::ReleaseCapture(); m_eDragState = DRAG_NONE; }	/*!< ƒhƒ‰ƒbƒO�ó‘Ô‰ð�œ�ˆ—� */
-	BOOL ReorderTab( int nSrcTab, int nDstTab );	/*!< ƒ^ƒu�‡�˜•Ï�X�ˆ—� */
 	BOOL SeparateGroup( HWND hwndSrc, HWND hwndDst, POINT ptDrag, POINT ptDrop );	/*!< ƒ^ƒu•ª—£�ˆ—� */	// 2007.06.20 ryoji
 	LRESULT ExecTabCommand( int nId, POINTS pts );	/*!< ƒ^ƒu•” ƒRƒ}ƒ“ƒhŽÀ�s�ˆ—� */
 	void LayoutTab( void );							/*!< ƒ^ƒu‚ÌƒŒƒCƒAƒEƒg’²�®�ˆ—� */
