[Ttssh2-commit] [5188] listbox マクロコマンドの調整

svnno****@sourc***** svnno****@sourc*****
2013年 4月 4日 (木) 02:18:16 JST


Revision: 5188
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5188
Author:   maya
Date:     2013-04-04 02:18:15 +0900 (Thu, 04 Apr 2013)
Log Message:
-----------
listbox マクロコマンドの調整
  setdlgpos が反映されるようにした
  テキストの内容に応じてウィンドウをリサイズするようにした

Modified Paths:
--------------
    trunk/doc/en/html/macro/command/setdlgpos.html
    trunk/doc/ja/html/macro/command/setdlgpos.html
    trunk/teraterm/ttpmacro/ListDlg.cpp
    trunk/teraterm/ttpmacro/ListDlg.h
    trunk/teraterm/ttpmacro/ttmdlg.cpp

-------------- next part --------------
Modified: trunk/doc/en/html/macro/command/setdlgpos.html
===================================================================
--- trunk/doc/en/html/macro/command/setdlgpos.html	2013-04-03 15:07:45 UTC (rev 5187)
+++ trunk/doc/en/html/macro/command/setdlgpos.html	2013-04-03 17:18:15 UTC (rev 5188)
@@ -24,7 +24,7 @@
 <h2>Remarks</h2>
 
 <p>
-Changes the initial position for dialog boxes opend by the "<a href="inputbox.html">inputbox</a>", "<a href="messagebox.html">messagebox</a>", "<a href="passwordbox.html">passwordbox</a>" and "<a href="statusbox.html">statusbox</a>" commands. If the status dialog box is displayed, the "setdlgpos" command also moves the dialog box.<br>
+Changes the initial position for dialog boxes opend by the "<a href="inputbox.html">inputbox</a>", "<a href="messagebox.html">messagebox</a>", "<a href="passwordbox.html">passwordbox</a>", "<a href="statusbox.html">statusbox</a>" and "<a href="listbox.html">listbox</a>" commands. If the status dialog box is displayed, the "setdlgpos" command also moves the dialog box.<br>
 &lt;x&gt; and &lt;y&gt; specify the position (x,y) in the screen coordinate.<br>
 The origin (0,0) is upper left corner of the screen.
 </p>

Modified: trunk/doc/ja/html/macro/command/setdlgpos.html
===================================================================
--- trunk/doc/ja/html/macro/command/setdlgpos.html	2013-04-03 15:07:45 UTC (rev 5187)
+++ trunk/doc/ja/html/macro/command/setdlgpos.html	2013-04-03 17:18:15 UTC (rev 5188)
@@ -24,7 +24,7 @@
 <h2>\x89\xF0\x90\xE0</h2>
 
 <p>
-<a href="inputbox.html">"inputbox"</a>, <a href="messagebox.html">"messagebox"</a>, <a href="passwordbox.html">"passwordbox"</a>, <a href="statusbox.html">"statusbox"</a> \x83R\x83}\x83\x93\x83h\x82ŕ\\x8E\xA6\x82\xB3\x82\xEA\x82\xE9\x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x82̏\x89\x8A\xFA\x88ʒu\x82\xF0\x95ύX\x82\xB7\x82\xE9\x81B<br>
+<a href="inputbox.html">"inputbox"</a>, <a href="messagebox.html">"messagebox"</a>, <a href="passwordbox.html">"passwordbox"</a>, <a href="statusbox.html">"statusbox"</a> , <a href="listbox.html">"listbox"</a> \x83R\x83}\x83\x93\x83h\x82ŕ\\x8E\xA6\x82\xB3\x82\xEA\x82\xE9\x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x82̏\x89\x8A\xFA\x88ʒu\x82\xF0\x95ύX\x82\xB7\x82\xE9\x81B<br>
 \x82܂\xBD\x81A\x83X\x83e\x81[\x83^\x83X\x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x82\xAA\x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x8Fꍇ\x81Asetdlgpos \x83R\x83}\x83\x93\x83h\x82͂\xBB\x82̃_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x82\xF0\x88ړ\xAE\x82\xB3\x82\xB9\x82\xE9\x81B<br>
 &lt;x&gt; \x82\xC6 &lt;y&gt; \x82͉\xE6\x96ʂ̍\xC0\x95W (x,y) \x82\xF0\x95\\x82킷\x81B\x8C\xB4\x93_ (0,0) \x82͉\xE6\x96ʂ̍\xB6\x8F\xE3\x82̋\xF7\x82̈ʒu\x81B
 </p>

Modified: trunk/teraterm/ttpmacro/ListDlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/ListDlg.cpp	2013-04-03 15:07:45 UTC (rev 5187)
+++ trunk/teraterm/ttpmacro/ListDlg.cpp	2013-04-03 17:18:15 UTC (rev 5188)
@@ -16,12 +16,14 @@
 
 IMPLEMENT_DYNAMIC(CListDlg, CDialog)
 
-CListDlg::CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists)
+CListDlg::CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int x, int y)
 	: CDialog(CListDlg::IDD)
 {
 	m_Text = Text;
 	m_Caption = Caption;
 	m_Lists = Lists;
+	PosX = x;
+	PosY = y;
 	DlgFont = NULL;
 }
 
@@ -56,11 +58,14 @@
 	char **p;
 	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
 	LOGFONT logfont;
-	HFONT font;
+	HFONT font, tmpfont;
 	int ListMaxWidth = 0;
 	int ListWidth;
 	CDC *pDC;
 	CFont *pOldFont;
+	RECT R;
+	HDC TmpDC;
+	HWND HList, HOk;
 
 	CDialog::OnInitDialog();
 
@@ -106,6 +111,35 @@
 	SetDlgItemText(IDC_STATIC, m_Text);
 	SetWindowText(m_Caption);
 
+
+	TmpDC = ::GetDC(GetDlgItem(IDC_STATIC)->GetSafeHwnd());
+	if (DlgFont) {
+		tmpfont = (HFONT)SelectObject(TmpDC, DlgFont);
+	}
+	CalcTextExtent(TmpDC,m_Text,&s);
+	if (DlgFont && tmpfont != NULL) {
+		SelectObject(TmpDC, tmpfont);
+	}
+	::ReleaseDC(GetDlgItem(IDC_STATIC)->GetSafeHwnd(),TmpDC);
+	TW = s.cx + s.cx/10;
+	TH = s.cy;
+
+	HList = ::GetDlgItem(GetSafeHwnd(), IDC_LISTBOX);
+	::GetWindowRect(HList,&R);
+	LW = R.right-R.left;
+	LH = R.bottom-R.top;
+
+	HOk = ::GetDlgItem(GetSafeHwnd(), IDOK);
+	::GetWindowRect(HOk,&R);
+	BW = R.right-R.left;
+	BH = R.bottom-R.top;
+
+	GetWindowRect(&R);
+	WW = R.right-R.left;
+	WH = R.bottom-R.top;
+
+	Relocation(TRUE, WW);
+
 	SetForegroundWindow();
 
 	return TRUE;  // return TRUE unless you set the focus to a control
@@ -117,3 +151,56 @@
 	// TODO: \x82\xB1\x82\xB1\x82ɃR\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x92ʒm\x83n\x83\x93\x83h\x83\x89 \x83R\x81[\x83h\x82\xF0\x92lj\xC1\x82\xB5\x82܂\xB7\x81B
 	OnCancel();
 }
+
+void CListDlg::Relocation(BOOL is_init, int new_WW)
+{
+	RECT R;
+	HDC TmpDC;
+	HWND HText, HOk, HCancel, HList;
+	int CW, CH;
+
+	GetClientRect(&R);
+	CW = R.right-R.left;
+	CH = R.bottom-R.top;
+
+	// \x8F\x89\x89\xF1\x82̂\xDD
+	if (is_init) {
+		// \x83e\x83L\x83X\x83g\x83R\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x83T\x83C\x83Y\x82\xF0\x95␳
+		if (TW < CW) {
+			TW = CW;
+		}
+		// \x83E\x83C\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82̌v\x8EZ
+		WW = TW + (WW - CW);
+		WH = TH + LH + (int)(BH*1.5) + (WH - CH);
+		init_WW = WW;
+		// \x83\x8A\x83X\x83g\x83{\x83b\x83N\x83X\x83T\x83C\x83Y\x82̌v\x8EZ
+		if (LW < WW - BW - 14*3) {
+			LW = WW - BW - 14*3;
+		}
+	}
+	else {
+		TW = CW;
+		WW = new_WW;
+	}
+
+	HText = ::GetDlgItem(GetSafeHwnd(), IDC_STATIC);
+	HOk = ::GetDlgItem(GetSafeHwnd(), IDOK);
+	HCancel = ::GetDlgItem(GetSafeHwnd(), IDCANCEL);
+	HList = ::GetDlgItem(GetSafeHwnd(), IDC_LISTBOX);
+
+	::MoveWindow(HText,(TW-s.cx)/2,LH+BH,TW,TH,TRUE);
+	::MoveWindow(HList,14,BH/2,LW,LH,TRUE);
+	::MoveWindow(HOk,14+14+LW,BH/2,BW,BH,TRUE);
+	::MoveWindow(HCancel,14+14+LW,BH*2,BW,BH,TRUE);
+
+	if (PosX<=GetMonitorLeftmost(PosX, PosY)-100) {
+		GetWindowRect(&R);
+		TmpDC = ::GetDC(GetSafeHwnd());
+		PosX = (GetDeviceCaps(TmpDC,HORZRES)-R.right+R.left) / 2;
+		PosY = (GetDeviceCaps(TmpDC,VERTRES)-R.bottom+R.top) / 2;
+		::ReleaseDC(GetSafeHwnd(),TmpDC);
+	}
+	SetWindowPos(&wndTop,PosX,PosY,WW,WH,0);
+
+	InvalidateRect(NULL);
+}

Modified: trunk/teraterm/ttpmacro/ListDlg.h
===================================================================
--- trunk/teraterm/ttpmacro/ListDlg.h	2013-04-03 15:07:45 UTC (rev 5187)
+++ trunk/teraterm/ttpmacro/ListDlg.h	2013-04-03 17:18:15 UTC (rev 5188)
@@ -9,7 +9,7 @@
 	DECLARE_DYNAMIC(CListDlg)
 
 public:
-	CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists);   // \x95W\x8F\x80\x83R\x83\x93\x83X\x83g\x83\x89\x83N\x83^
+	CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int x, int y);
 	virtual ~CListDlg();
 
 // \x83_\x83C\x83A\x83\x8D\x83O \x83f\x81[\x83^
@@ -20,8 +20,12 @@
 	PCHAR m_Caption;
 	CHAR **m_Lists;
 	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;
 	HFONT DlgFont;
 
+	void Relocation(BOOL is_init, int WW);
+
 	DECLARE_MESSAGE_MAP()
 public:
 	CListBox m_xcList;

Modified: trunk/teraterm/ttpmacro/ttmdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/ttmdlg.cpp	2013-04-03 15:07:45 UTC (rev 5187)
+++ trunk/teraterm/ttpmacro/ttmdlg.cpp	2013-04-03 17:18:15 UTC (rev 5188)
@@ -306,7 +306,7 @@
 {
 	int ret = -1;
 
-	CListDlg ListDlg(Text, Caption, Lists);
+	CListDlg ListDlg(Text,Caption,Lists,DlgPosX,DlgPosY);
 	if (ListDlg.DoModal() == IDOK) {
 		ret = ListDlg.m_SelectItem;
 	}



Ttssh2-commit メーリングリストの案内