[Ttssh2-commit] [6074] listbox で、最初に選択されている項目を設定できるようにした。

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2015年 11月 5日 (木) 20:15:54 JST


Revision: 6074
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6074
Author:   doda
Date:     2015-11-05 20:15:54 +0900 (Thu, 05 Nov 2015)
Log Message:
-----------
listbox で、最初に選択されている項目を設定できるようにした。

Modified Paths:
--------------
    trunk/teraterm/ttpmacro/ListDlg.cpp
    trunk/teraterm/ttpmacro/ListDlg.h
    trunk/teraterm/ttpmacro/ttl.c
    trunk/teraterm/ttpmacro/ttmdlg.cpp
    trunk/teraterm/ttpmacro/ttmdlg.h

-------------- next part --------------
Modified: trunk/teraterm/ttpmacro/ListDlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/ListDlg.cpp	2015-11-05 11:13:38 UTC (rev 6073)
+++ trunk/teraterm/ttpmacro/ListDlg.cpp	2015-11-05 11:15:54 UTC (rev 6074)
@@ -16,12 +16,13 @@
 
 IMPLEMENT_DYNAMIC(CListDlg, CDialog)
 
-CListDlg::CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int x, int y)
+CListDlg::CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int Selected, int x, int y)
 	: CDialog(CListDlg::IDD)
 {
 	m_Text = Text;
 	m_Caption = Caption;
 	m_Lists = Lists;
+	m_Selected = Selected;
 	PosX = x;
 	PosY = y;
 	DlgFont = NULL;
@@ -61,6 +62,7 @@
 	HFONT font, tmpfont;
 	int ListMaxWidth = 0;
 	int ListWidth;
+	int ListCount = 0;
 	CDC *pDC;
 	CFont *pOldFont;
 	RECT R;
@@ -96,6 +98,7 @@
 		if (ListWidth > ListMaxWidth) {
 			ListMaxWidth = ListWidth;
 		}
+		ListCount++;
 		p++;
 	}
 	UpdateData(FALSE);
@@ -104,8 +107,10 @@
 	pDC->SelectObject(pOldFont);
 	ReleaseDC(pDC);
 
-	// 1\x82‚߂\xF0\x91I\x91\xF0\x8F\xF3\x91Ԃɂ\xB7\x82\xE9\x81B
-	m_xcList.SetCurSel(0);
+	if (m_Selected < 0 || m_Selected >= ListCount) {
+		m_Selected = 0;
+	}
+	m_xcList.SetCurSel(m_Selected);
 
 	// \x96{\x95\xB6\x82ƃ^\x83C\x83g\x83\x8B
 	SetDlgItemText(IDC_STATIC, m_Text);

Modified: trunk/teraterm/ttpmacro/ListDlg.h
===================================================================
--- trunk/teraterm/ttpmacro/ListDlg.h	2015-11-05 11:13:38 UTC (rev 6073)
+++ trunk/teraterm/ttpmacro/ListDlg.h	2015-11-05 11:15:54 UTC (rev 6074)
@@ -9,7 +9,7 @@
 	DECLARE_DYNAMIC(CListDlg)
 
 public:
-	CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int x, int y);
+	CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int Selected, int x, int y);
 	virtual ~CListDlg();
 
 // \x83_\x83C\x83A\x83\x8D\x83O \x83f\x81[\x83^
@@ -19,6 +19,7 @@
 	PCHAR m_Text;
 	PCHAR m_Caption;
 	CHAR **m_Lists;
+	int m_Selected;
 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV \x83T\x83|\x81[\x83g
 	int PosX, PosY, init_WW, WW, WH, TW, TH, BH, BW, LW, LH;
 	SIZE s;

Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2015-11-05 11:13:38 UTC (rev 6073)
+++ trunk/teraterm/ttpmacro/ttl.c	2015-11-05 11:15:54 UTC (rev 6074)
@@ -3379,6 +3379,7 @@
 	int ret;
 	char **s;
 	int i, ary_size;
+	int sel = 0;
 	TVarId VarId, VarId2;
 
 	*Err = 0;
@@ -3403,14 +3404,14 @@
 	if (BoxId==IdMsgBox) {
 		ret = OpenMsgDlg(Str1,Str2,FALSE);
 		// \x83\x81\x83b\x83Z\x81[\x83W\x83{\x83b\x83N\x83X\x82\xF0\x83L\x83\x83\x83\x93\x83Z\x83\x8B\x82\xB7\x82\xE9\x82ƁA\x83}\x83N\x83\x8D\x82̏I\x97\xB9\x82Ƃ\xB7\x82\xE9\x81B
-		// (2008.8.5 yutaka)		
+		// (2008.8.5 yutaka)
 		if (ret == IDCANCEL) {
 			TTLStatus = IdTTLEnd;
 		}
 	} else if (BoxId==IdYesNoBox) {
 		ret = OpenMsgDlg(Str1,Str2,TRUE);
 		// \x83\x81\x83b\x83Z\x81[\x83W\x83{\x83b\x83N\x83X\x82\xF0\x83L\x83\x83\x83\x93\x83Z\x83\x8B\x82\xB7\x82\xE9\x82ƁA\x83}\x83N\x83\x8D\x82̏I\x97\xB9\x82Ƃ\xB7\x82\xE9\x81B
-		// (2008.8.6 yutaka)		
+		// (2008.8.6 yutaka)
 		if (ret == IDCLOSE) {
 			TTLStatus = IdTTLEnd;
 		}
@@ -3422,9 +3423,19 @@
 	} else if (BoxId==IdListBox) {
 		//  \x83\x8A\x83X\x83g\x83{\x83b\x83N\x83X\x82̑I\x91\xF0\x8E\x88\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B
 		GetStrAryVar(&VarId, Err);
+
+		if (CheckParameterGiven()) {
+			GetIntVal(&sel, Err);
+		}
+		if (*Err==0 && GetFirstChar()!=0)
+			*Err = ErrSyntax;
 		if (*Err!=0) return 0;
 
 		ary_size = GetStrAryVarSize(VarId);
+		if (sel < 0 || sel >= ary_size) {
+			sel = 0;
+		}
+
 		s = (char **)calloc(ary_size + 1, sizeof(char *));
 		if (s == NULL) {
 			*Err = ErrFewMemory;
@@ -3443,7 +3454,7 @@
 		// return 
 		//   0\x88ȏ\xE3: \x91I\x91\xF0\x8D\x80\x96\xDA
 		//   -1: \x83L\x83\x83\x83\x93\x83Z\x83\x8B
-		ret = OpenListDlg(Str1, Str2, s);
+		ret = OpenListDlg(Str1, Str2, s, sel);
 
 		for (i = 0 ; i < ary_size ; i++) {
 			free(s[i]);

Modified: trunk/teraterm/ttpmacro/ttmdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/ttmdlg.cpp	2015-11-05 11:13:38 UTC (rev 6073)
+++ trunk/teraterm/ttpmacro/ttmdlg.cpp	2015-11-05 11:15:54 UTC (rev 6074)
@@ -325,11 +325,11 @@
 }
 
 extern "C" {
-int OpenListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists)
+int OpenListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int Selected)
 {
 	int ret = -1;
 
-	CListDlg ListDlg(Text,Caption,Lists,DlgPosX,DlgPosY);
+	CListDlg ListDlg(Text, Caption, Lists, Selected, DlgPosX, DlgPosY);
 	if (ListDlg.DoModal() == IDOK) {
 		ret = ListDlg.m_SelectItem;
 	}

Modified: trunk/teraterm/ttpmacro/ttmdlg.h
===================================================================
--- trunk/teraterm/ttpmacro/ttmdlg.h	2015-11-05 11:13:38 UTC (rev 6073)
+++ trunk/teraterm/ttpmacro/ttmdlg.h	2015-11-05 11:15:54 UTC (rev 6074)
@@ -23,7 +23,7 @@
 void CloseStatDlg();
 void BringupStatDlg();
 
-int OpenListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists);
+int OpenListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int Selected);
 
 extern char HomeDir[MAXPATHLEN];
 extern char FileName[MAX_PATH];



Ttssh2-commit メーリングリストの案内
アーカイブの一覧に戻る