• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7382 (tree)
Time2019-01-03 01:58:56
Authorzmatsuo

Log Message

ログローテートの単位(Byte,KB,MB)設定できていなかったので修正
MessageBox系をUnicode化

Change Summary

Incremental Difference

--- branches/cmake/teraterm/common/tmfc.cpp (revision 7381)
+++ branches/cmake/teraterm/common/tmfc.cpp (revision 7382)
@@ -1,800 +1,807 @@
1-/*
2- * Copyright (C) 2018 TeraTerm Project
3- * All rights reserved.
4- *
5- * Redistribution and use in source and binary forms, with or without
6- * modification, are permitted provided that the following conditions
7- * are met:
8- *
9- * 1. Redistributions of source code must retain the above copyright
10- * notice, this list of conditions and the following disclaimer.
11- * 2. Redistributions in binary form must reproduce the above copyright
12- * notice, this list of conditions and the following disclaimer in the
13- * documentation and/or other materials provided with the distribution.
14- * 3. The name of the author may not be used to endorse or promote products
15- * derived from this software without specific prior written permission.
16- *
17- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27- */
28-
29-/*
30- * Tera term Micro Framework class
31- */
32-#include "tmfc.h"
33-
34-#include <windowsx.h>
35-#include <assert.h>
36-#include <tchar.h>
37-#include "dlglib.h"
38-#include "ttlib.h"
39-
40-// テンプレートの書き換えを行う
41-#define REWRITE_TEMPLATE
42-
43-#if (defined(_MSC_VER) && (_MSC_VER <= 1500)) || \
44- (__cplusplus <= 199711L)
45-#define nullptr NULL // C++11,nullptr / > VS2010
46-#endif
47-
48-TTCWnd::TTCWnd()
49-{
50- m_hWnd = nullptr;
51- m_hInst = nullptr;
52- m_hAccel = nullptr;
53- m_hParentWnd = nullptr;
54-}
55-
56-LRESULT TTCWnd::SendMessage(UINT msg, WPARAM wp, LPARAM lp)
57-{
58- return ::SendMessage(m_hWnd, msg, wp, lp);
59-}
60-
61-HWND TTCWnd::GetDlgItem(int id)
62-{
63- return ::GetDlgItem(m_hWnd, id);
64-}
65-
66-LRESULT TTCWnd::SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp)
67-{
68- return ::SendDlgItemMessage(m_hWnd, id, msg, wp, lp);
69-}
70-
71-#if defined(UNICODE)
72-LRESULT TTCWnd::SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp)
73-{
74- return ::SendDlgItemMessageW(m_hWnd, id, msg, wp, lp);
75-}
76-#endif
77-
78-LRESULT TTCWnd::SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp)
79-{
80- return ::SendDlgItemMessageA(m_hWnd, id, msg, wp, lp);
81-}
82-
83-void TTCWnd::GetDlgItemTextT(int id, TCHAR *buf, size_t size)
84-{
85- ::GetDlgItemText(m_hWnd, id, buf, (int)size);
86-}
87-
88-#if defined(UNICODE)
89-void TTCWnd::GetDlgItemTextW(int id, wchar_t *buf, size_t size)
90-{
91- ::GetDlgItemTextW(m_hWnd, id, buf, (int)size);
92-}
93-#endif
94-
95-void TTCWnd::GetDlgItemTextA(int id, char *buf, size_t size)
96-{
97- ::GetDlgItemTextA(m_hWnd, id, buf, (int)size);
98-}
99-
100-void TTCWnd::SetDlgItemTextT(int id, const TCHAR *str)
101-{
102- ::SetDlgItemText(m_hWnd, id, str);
103-}
104-
105-#if defined(UNICODE)
106-void TTCWnd::SetDlgItemTextW(int id, const wchar_t *str)
107-{
108- ::SetDlgItemTextW(m_hWnd, id, str);
109-}
110-#endif
111-
112-void TTCWnd::SetDlgItemTextA(int id, const char *str)
113-{
114- ::SetDlgItemTextA(m_hWnd, id, str);
115-}
116-
117-void TTCWnd::SetDlgItemNum(int id, LONG Num)
118-{
119- SetDlgNum(m_hWnd, id, Num);
120-}
121-
122-// nCheck BST_UNCHECKED / BST_CHECKED / BST_INDETERMINATE
123-void TTCWnd::SetCheck(int id, int nCheck)
124-{
125- ::SendMessage(GetDlgItem(id), BM_SETCHECK, nCheck, 0);
126-}
127-
128-UINT TTCWnd::GetCheck(int id)
129-{
130- return ::IsDlgButtonChecked(m_hWnd, id);
131-}
132-
133-void TTCWnd::SetCurSel(int id, int no)
134-{
135- HWND hWnd = GetDlgItem(id);
136- assert(hWnd != 0);
137- TCHAR ClassName[32];
138- int r = GetClassName(hWnd, ClassName, _countof(ClassName));
139- assert(r != 0); (void)r;
140- UINT msg =
141- (_tcscmp(ClassName, _T("ListBox")) == 0) ? LB_SETCURSEL :
142- (_tcscmp(ClassName, _T("ComboBox")) == 0) ? CB_SETCURSEL : 0;
143- assert(msg != 0);
144- ::SendMessage(hWnd, msg, no, 0);
145-}
146-
147-int TTCWnd::GetCurSel(int id)
148-{
149- HWND hWnd = GetDlgItem(id);
150- assert(hWnd != 0);
151- TCHAR ClassName[32];
152- int r = GetClassName(hWnd, ClassName, _countof(ClassName));
153- assert(r != 0); (void)r;
154- UINT msg =
155- (_tcscmp(ClassName, _T("ListBox")) == 0) ? LB_GETCURSEL :
156- (_tcscmp(ClassName, _T("ComboBox")) == 0) ? CB_GETCURSEL : 0;
157- assert(msg != 0);
158- LRESULT lResult = ::SendMessage(hWnd, msg, 0, 0);
159- return (int)lResult;
160-}
161-
162-void TTCWnd::EnableDlgItem(int id, BOOL enable)
163-{
164- ::EnableWindow(GetDlgItem(id), enable);
165-}
166-
167-void TTCWnd::SetDlgItemInt(int id, UINT val, BOOL bSigned)
168-{
169- ::SetDlgItemInt(m_hWnd, id, val, bSigned);
170-}
171-
172-UINT TTCWnd::GetDlgItemInt(int id, BOOL* lpTrans, BOOL bSigned) const
173-{
174- return ::GetDlgItemInt(m_hWnd, id, lpTrans, bSigned);
175-}
176-
177-void TTCWnd::ShowWindow(int nCmdShow)
178-{
179- ::ShowWindow(m_hWnd, nCmdShow);
180-}
181-
182-void TTCWnd::SetWindowTextT(const TCHAR *str)
183-{
184- ::SetWindowText(m_hWnd, str);
185-}
186-
187-#if defined(UNICODE)
188-void TTCWnd::SetWindowTextW(const wchar_t *str)
189-{
190- ::SetWindowTextW(m_hWnd, str);
191-}
192-#endif
193-
194-void TTCWnd::SetWindowTextA(const char *str)
195-{
196- ::SetWindowTextA(m_hWnd, str);
197-}
198-
199-LONG_PTR TTCWnd::SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong)
200-{
201- return ::SetWindowLongPtr(m_hWnd, nIndex, dwNewLong);
202-}
203-
204-LONG_PTR TTCWnd::GetWindowLongPtr(int nIndex)
205-{
206- return ::GetWindowLongPtr(m_hWnd, nIndex);
207-}
208-
209-void TTCWnd::ModifyStyleCom(int nStyleOffset,
210- DWORD dwRemove, DWORD dwAdd, UINT nFlags)
211-{
212- const LONG_PTR dwStyle = GetWindowLongPtr(nStyleOffset);
213- const LONG_PTR add = dwAdd;
214- const LONG_PTR remove = dwRemove;
215- const LONG_PTR dwNewStyle = (dwStyle & ~remove) | add;
216- if (dwStyle != dwNewStyle) {
217- SetWindowLongPtr(nStyleOffset, dwNewStyle);
218- }
219- if (nFlags != 0)
220- {
221- SetWindowPos(nullptr, 0, 0, 0, 0,
222- SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
223- }
224-}
225-
226-void TTCWnd::ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags)
227-{
228- ModifyStyleCom(GWL_STYLE, dwRemove, dwAdd, nFlags);
229-}
230-
231-void TTCWnd::ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags)
232-{
233- ModifyStyleCom(GWL_EXSTYLE, dwRemove, dwAdd, nFlags);
234-}
235-
236-int TTCWnd::MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
237-{
238- return ::MessageBox(m_hWnd, lpText, lpCaption, uType);
239-}
240-
241-int TTCWnd::MessageBoxA(const char *lpText, const char *lpCaption, UINT uType)
242-{
243- return ::MessageBoxA(m_hWnd, lpText, lpCaption, uType);
244-}
245-
246-BOOL TTCWnd::GetWindowRect(RECT *R)
247-{
248- return ::GetWindowRect(m_hWnd, R);
249-}
250-
251-BOOL TTCWnd::SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
252-{
253- return ::SetWindowPos(m_hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
254-}
255-
256-BOOL TTCWnd::GetClientRect(RECT *R)
257-{
258- return ::GetClientRect(m_hWnd, R);
259-}
260-
261-BOOL TTCWnd::InvalidateRect(RECT *R, BOOL bErase)
262-{
263- return ::InvalidateRect(m_hWnd, R, bErase);
264-}
265-
266-BOOL TTCWnd::EndDialog(int nResult)
267-{
268- return ::EndDialog(m_hWnd, nResult);
269-}
270-
271-void TTCWnd::DestroyWindow()
272-{
273- ::DestroyWindow(m_hWnd);
274-}
275-
276-HDC TTCWnd::BeginPaint(LPPAINTSTRUCT lpPaint)
277-{
278- return ::BeginPaint(m_hWnd, lpPaint);
279-}
280-
281-BOOL TTCWnd::EndPaint(LPPAINTSTRUCT lpPaint)
282-{
283- return ::EndPaint(m_hWnd, lpPaint);
284-}
285-
286-LRESULT TTCWnd::DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam)
287-{
288- return ::DefWindowProc(m_hWnd, msg, wParam, lParam);
289-}
290-
291-////////////////////////////////////////
292-
293-TTCDialog *TTCDialog::pseudoPtr;
294-
295-TTCDialog::TTCDialog()
296-{
297-}
298-
299-TTCDialog::~TTCDialog()
300-{
301-}
302-
303-/**
304- * ダイアログ初期化
305- * @retval TRUE 処理が行われた(次のメッセージ処理は呼び出されない)
306- * @retval FALSE 次のメッセージ処理は呼び出される
307- *
308- * 次のメッセージ処理
309- * TTCDialog::DlgProc(msg=WM_INITDIALOG)
310- */
311-BOOL TTCDialog::OnInitDialog()
312-{
313- return FALSE;
314-}
315-
316-/**
317- * OKボタン
318- * @retval TRUE 処理が行われた(次のメッセージ処理は呼び出されない)
319- * @retval FALSE 次のメッセージ処理は呼び出される
320- *
321- * 次のメッセージ処理
322- * TTCDialog::OnCommand()
323- */
324-BOOL TTCDialog::OnOK()
325-{
326- EndDialog(IDOK);
327- return TRUE;
328-}
329-
330-/**
331- * CANCELボタン
332- * @retval TRUE 処理が行われた(次のメッセージ処理は呼び出されない)
333- * @retval FALSE 次のメッセージ処理は呼び出される
334- *
335- * 次のメッセージ処理
336- * TTCDialog::OnCommand()
337- */
338-BOOL TTCDialog::OnCancel()
339-{
340- EndDialog(IDCANCEL);
341- return TRUE;
342-}
343-
344-BOOL TTCDialog::OnCommand(WPARAM wp, LPARAM lp)
345-{
346- return FALSE;
347-}
348-
349-/**
350- * WM_CLOSEメッセージ処理
351- * @retval TRUE 処理が行われた(次のメッセージ処理は呼び出されない)
352- * @retval FALSE 次のメッセージ処理は呼び出される
353- *
354- * 次のメッセージ処理
355- * TTCDialog::OnCancel()
356- */
357-BOOL TTCDialog::OnClose()
358-{
359- return FALSE;
360-}
361-
362-/**
363- * WM_NCDESTROYメッセージ処理
364- * @retval TRUE 処理が行われた(次のメッセージ処理は呼び出されない)
365- * @retval FALSE 次のメッセージ処理は呼び出される
366- *
367- * 次のメッセージ処理
368- * TTCDialog::DlgProc()
369- */
370-BOOL TTCDialog::PostNcDestroy()
371-{
372- return FALSE;
373-}
374-
375-/*
376- * @retval TRUE メッセージを処理した時
377- * @retval FALSE メッセージを処理しなかった時
378- * @retval その他 メッセージによって異なることがある
379- */
380-LRESULT TTCDialog::DlgProc(UINT msg, WPARAM wp, LPARAM lp)
381-{
382- (void)msg;
383- (void)wp;
384- (void)lp;
385- return (LRESULT)FALSE;
386-}
387-
388-/*
389- * @retval TRUE メッセージを処理した時
390- * @retval FALSE メッセージを処理しなかった時
391- */
392-LRESULT TTCDialog::DlgProcBase(UINT msg, WPARAM wp, LPARAM lp)
393-{
394- BOOL Processed = FALSE;
395- switch (msg) {
396- case WM_INITDIALOG:
397- Processed = OnInitDialog();
398- break;
399- case WM_COMMAND:
400- {
401- const WORD wID = GET_WM_COMMAND_ID(wp, lp);
402- switch (wID) {
403- case IDOK:
404- Processed = OnOK();
405- //self->DestroyWindow();
406- //SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, lResult)
407- // return TRUE
408- break;
409- case IDCANCEL:
410- Processed = OnCancel();
411- break;
412- }
413-
414- if (Processed == FALSE) {
415- Processed = OnCommand(wp, lp);
416- }
417- break;
418- }
419- case WM_NCDESTROY:
420- Processed = PostNcDestroy();
421- break;
422- case WM_CLOSE:
423- // CLOSEボタンを押した時、
424- Processed = OnClose();
425- if (Processed == FALSE) {
426- // オーバーライドされていなければ
427- // dialogならOnCancel()が発生する
428- Processed = OnCancel();
429- }
430- break;
431- default:
432- Processed = FALSE;
433- break;
434- }
435-
436- if (Processed == TRUE) {
437- // 処理した
438- return TRUE;
439- }
440-
441- // 最後のメッセージ処理
442- return DlgProc(msg, wp, lp);
443-}
444-
445-LRESULT TTCDialog::WndProcBase(UINT msg, WPARAM wp, LPARAM lp)
446-{
447- BOOL Processed = FALSE;
448- switch (msg) {
449- case WM_INITDIALOG:
450- Processed = OnInitDialog();
451- break;
452- case WM_COMMAND:
453- {
454- const WORD wID = GET_WM_COMMAND_ID(wp, lp);
455- switch (wID) {
456- case IDOK:
457- Processed = OnOK();
458- //self->DestroyWindow();
459- //SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, lResult)
460- // return TRUE
461- break;
462- case IDCANCEL:
463- Processed = OnCancel();
464- break;
465- }
466-
467- if (Processed == FALSE) {
468- Processed = OnCommand(wp, lp);
469- }
470- break;
471- }
472- case WM_NCDESTROY:
473- Processed = PostNcDestroy();
474- break;
475- case WM_CLOSE:
476- // CLOSEボタンを押した時、
477- Processed = OnClose();
478- if (Processed == FALSE) {
479- // オーバーライドされていなければ
480- // dialogならOnCancel()が発生する
481- Processed = OnCancel();
482- }
483- break;
484- default:
485- Processed = FALSE;
486- break;
487- }
488-
489- if (Processed == TRUE) {
490- // 処理した
491- return TRUE;
492- }
493-
494- // DlgProcをオーバライドするのではなく、
495- // DefWindowProcをオーバーライドすること
496- return DefWindowProc(msg, wp, lp);
497-}
498-
499-/**
500- * for modal dialog
501- */
502-INT_PTR TTCDialog::DoModal(HINSTANCE hInstance, HWND hParent, int idd)
503-{
504- pseudoPtr = this;
505-#if defined(REWRITE_TEMPLATE)
506- INT_PTR result =
507- TTDialogBoxParam(hInstance,
508- MAKEINTRESOURCE(idd),
509- hParent,
510- (DLGPROC)&DlgProcStub, (LPARAM)this);
511-#else
512- INT_PTR result =
513- DialogBoxParam(hInstance,
514- MAKEINTRESOURCE(idd),
515- hParent,
516- (DLGPROC)&DlgProcStub, (LPARAM)this);
517-#endif
518- pseudoPtr = nullptr;
519- return result;
520-}
521-
522-/**
523- * for modeless dialog
524- */
525-BOOL TTCDialog::Create(HINSTANCE hInstance, HWND hParent, int idd)
526-{
527- m_hInst = hInstance;
528- m_hParentWnd = hParent;
529-#if defined(REWRITE_TEMPLATE)
530- DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, MAKEINTRESOURCE(idd));
531-#else
532- HRSRC hResource = ::FindResource(hInstance, MAKEINTRESOURCE(idd), RT_DIALOG);
533- HANDLE hDlgTemplate = ::LoadResource(hInstance, hResource);
534- DLGTEMPLATE *lpTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
535-#endif
536- DLGPROC dlgproc = (DLGPROC)DlgProcStub;
537- const wchar_t *dialog_class = TTGetClassName(lpTemplate);
538- if (dialog_class != nullptr) {
539- // Modaless Dialog & Dialog application
540- // WNDCLASS.lpfnWndProc = TTCDialog::WndProcBase
541- dlgproc = nullptr;
542- }
543- pseudoPtr = this;
544- HWND hWnd = ::CreateDialogIndirectParam(
545- hInstance, lpTemplate, hParent,
546- dlgproc, (LPARAM)this);
547- pseudoPtr = nullptr;
548- if (hWnd == nullptr)
549- {
550-#if defined(_DEBUG)
551- DWORD e = GetLastError();
552-#endif
553- assert(false);
554- return FALSE;
555- }
556-
557- m_hParentWnd = hParent;
558- m_hWnd = hWnd;
559- m_hInst = hInstance;
560-// ::EnableWindow(hParent,FALSE);
561-// ::ShowWindow(hWnd, SW_SHOW); // TODO 外でやるのが良さそう
562-// ::EnableWindow(m_hWnd,TRUE);
563-
564- return TRUE;
565-}
566-
567-/*
568- * @retval TRUE メッセージを処理した時
569- * @retval FALSE メッセージを処理しなかった時
570- */
571-LRESULT CALLBACK TTCDialog::DlgProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
572-{
573- TTCDialog *self = (TTCDialog *)::GetWindowLongPtr(hWnd, DWLP_USER);
574- if (self == nullptr) {
575- self = pseudoPtr;
576- self->m_hWnd = hWnd;
577- if (msg == WM_INITDIALOG) {
578- ::SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR)self);
579- pseudoPtr = nullptr;
580- }
581- }
582- assert(self != nullptr);
583-
584- LRESULT result = self->DlgProcBase(msg, wp, lp);
585- return result;
586-}
587-
588-/*
589- * @retval TRUE メッセージを処理した時
590- * @retval FALSE メッセージを処理しなかった時
591- */
592-LRESULT CALLBACK TTCDialog::WndProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
593-{
594- TTCDialog *self = (TTCDialog *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
595- if (self == nullptr) {
596- assert(pseudoPtr != nullptr);
597- self = pseudoPtr;
598- self->m_hWnd = hWnd;
599- if (msg == WM_CREATE) {
600- ::SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)self);
601- pseudoPtr = nullptr;
602- }
603- }
604- assert(self != nullptr);
605-
606- return self->WndProcBase(msg, wp, lp);
607-}
608-
609-void TTCDialog::DestroyWindow()
610-{
611- if (m_hWnd != nullptr) {
612- ::EnableWindow(m_hParentWnd,TRUE);
613- ::SetFocus(m_hParentWnd);
614- ::DestroyWindow(m_hWnd);
615- m_hWnd = nullptr;
616- }
617-}
618-
619-////////////////////////////////////////
620-
621-// quick hack :-(
622-static HINSTANCE ghInstance;
623-static class TTCPropertySheet *gTTCPS;
624-
625-TTCPropertyPage::TTCPropertyPage(HINSTANCE inst, int id, TTCPropertySheet *sheet)
626-{
627- memset(&m_psp, 0, sizeof(m_psp));
628- m_psp.dwSize = sizeof(m_psp);
629- m_psp.dwFlags = PSP_DEFAULT;
630- m_psp.hInstance = inst;
631- m_psp.pszTemplate = MAKEINTRESOURCE(id);
632-#if defined(REWRITE_TEMPLATE)
633- m_psp.dwFlags |= PSP_DLGINDIRECT;
634- m_psp.pResource = TTGetDlgTemplate(inst, m_psp.pszTemplate);
635-#endif
636-// m_psp.pfnDlgProc = (DLGPROC)Proc;
637- m_psp.pfnDlgProc = Proc;
638- m_psp.lParam = (LPARAM)this;
639-
640- m_pSheet = sheet;
641-}
642-
643-TTCPropertyPage::~TTCPropertyPage()
644-{
645- free((void *)m_psp.pResource);
646-}
647-
648-void TTCPropertyPage::OnInitDialog()
649-{
650-}
651-
652-void TTCPropertyPage::OnOK()
653-{
654-}
655-
656-BOOL TTCPropertyPage::OnCommand(WPARAM wp, LPARAM lp)
657-{
658- return TRUE;
659-}
660-
661-HBRUSH TTCPropertyPage::OnCtlColor(HDC hDC, HWND hWnd)
662-{
663- return (HBRUSH)::DefWindowProc(m_hWnd, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hWnd);
664-}
665-
666-UINT CALLBACK TTCPropertyPage::PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
667-{
668- return 0;
669-}
670-
671-INT_PTR CALLBACK TTCPropertyPage::Proc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
672-{
673- TTCPropertyPage *self = (TTCPropertyPage *)::GetWindowLongPtr(hDlgWnd, DWLP_USER);
674- switch (msg)
675- {
676- case WM_INITDIALOG:
677- self = (TTCPropertyPage *)(((PROPSHEETPAGE *)lp)->lParam);
678- ::SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)self);
679- self->m_hWnd = hDlgWnd;
680- self->OnInitDialog();
681- break;
682- case WM_NOTIFY:
683- {
684- NMHDR * nmhdr = (NMHDR *)lp;
685- switch (nmhdr->code)
686- {
687- case PSN_APPLY:
688- self->OnOK();
689- break;
690- default:
691- break;
692- }
693- break;
694- }
695- case WM_COMMAND:
696- self->OnCommand(wp, lp);
697- break;
698- case WM_CTLCOLORSTATIC:
699- return (INT_PTR)self->OnCtlColor((HDC)wp, (HWND)lp);
700- }
701- return FALSE;
702-}
703-
704-////////////////////////////////////////
705-
706-TTCPropertySheet::TTCPropertySheet(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd)
707-{
708- m_hInst = hInstance;
709- memset(&m_psh, 0, sizeof(m_psh));
710- m_psh.dwSize = sizeof(m_psh);
711- m_psh.dwFlags = PSH_DEFAULT | PSH_NOAPPLYNOW | PSH_USECALLBACK; // | PSH_MODELESS
712- if (pszCaption != nullptr) {
713- m_psh.pszCaption = pszCaption;
714- //m_psh.dwFlags |= PSH_PROPTITLE; // 「のプロパティー」が追加される?
715- }
716- m_psh.hwndParent = hParentWnd;
717- m_psh.pfnCallback = PropSheetProc;
718-}
719-
720-TTCPropertySheet::~TTCPropertySheet()
721-{
722-}
723-
724-INT_PTR TTCPropertySheet::DoModal()
725-{
726- ghInstance = m_hInst;
727- gTTCPS = this;
728- return PropertySheet(&m_psh);
729-
730- // モーダレスにするとタブの動きがおかしい
731-#if 0
732- // モードレスダイアログボックスの場合はウィンドウのハンドル
733- m_hWnd = (HWND)::PropertySheet(&m_psh);
734-// ShowWindow(m_hWnd, SW_SHOW);
735-
736-// ::ModifyStyle(m_hWnd, TCS_MULTILINE, TCS_SINGLELINE, 0);
737-
738- ModalResult = 0;
739- HWND hDlgWnd = m_hWnd;
740- for(;;) {
741- if (ModalResult != 0) {
742- break;
743- }
744- MSG Msg;
745- BOOL quit = !::GetMessage(&Msg, nullptr, nullptr, nullptr);
746- if (quit) {
747- // QM_QUIT
748- PostQuitMessage(0);
749- return IDCANCEL;
750- }
751- if ((hDlgWnd == Msg.hwnd) ||
752- ::SendMessage(hDlgWnd, PSM_ISDIALOGMESSAGE, nullptr, (LPARAM)&Msg))
753- {
754- // ダイアログ以外の処理
755- ::TranslateMessage(&Msg);
756- ::DispatchMessage(&Msg);
757- }
758- if (!SendMessage(hDlgWnd, PSM_GETCURRENTPAGEHWND, 0, 0)) {
759- // プロパティーシート終了
760- break;
761- }
762- }
763- return ModalResult;
764-#endif
765-}
766-
767-int CALLBACK TTCPropertySheet::PropSheetProc(HWND hWnd, UINT msg, LPARAM lp)
768-{
769- switch (msg) {
770- case PSCB_PRECREATE:
771- {
772-#if defined(REWRITE_TEMPLATE)
773- // テンプレートの内容を書き換える 危険
774- // http://home.att.ne.jp/banana/akatsuki/doc/atlwtl/atlwtl15-01/index.html
775- size_t PrevTemplSize;
776- size_t NewTemplSize;
777- DLGTEMPLATE *NewTempl =
778- TTGetNewDlgTemplate(ghInstance, (DLGTEMPLATE *)lp,
779- &PrevTemplSize, &NewTemplSize);
780- NewTempl->style &= ~DS_CONTEXTHELP; // check DLGTEMPLATEEX
781- memcpy((void *)lp, NewTempl, NewTemplSize);
782- free(NewTempl);
783-#endif
784- break;
785- }
786- case PSCB_INITIALIZED:
787- {
788- //TTCPropertySheet *self = (TTCPropertySheet *)lp;
789- TTCPropertySheet *self = gTTCPS;
790- self->m_hWnd = hWnd;
791- self->OnInitDialog();
792- break;
793- }
794- }
795- return 0;
796-}
797-
798-void TTCPropertySheet::OnInitDialog()
799-{
800-}
1+/*
2+ * Copyright (C) 2018 TeraTerm Project
3+ * All rights reserved.
4+ *
5+ * Redistribution and use in source and binary forms, with or without
6+ * modification, are permitted provided that the following conditions
7+ * are met:
8+ *
9+ * 1. Redistributions of source code must retain the above copyright
10+ * notice, this list of conditions and the following disclaimer.
11+ * 2. Redistributions in binary form must reproduce the above copyright
12+ * notice, this list of conditions and the following disclaimer in the
13+ * documentation and/or other materials provided with the distribution.
14+ * 3. The name of the author may not be used to endorse or promote products
15+ * derived from this software without specific prior written permission.
16+ *
17+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+ */
28+
29+/*
30+ * Tera term Micro Framework class
31+ */
32+#include "tmfc.h"
33+
34+#include <windowsx.h>
35+#include <assert.h>
36+#include <tchar.h>
37+#include "dlglib.h"
38+#include "ttlib.h"
39+
40+// ?e???v???[?g?̏??????????s??
41+#define REWRITE_TEMPLATE
42+
43+#if (defined(_MSC_VER) && (_MSC_VER <= 1500)) || \
44+ (__cplusplus <= 199711L)
45+#define nullptr NULL // C++11,nullptr / > VS2010
46+#endif
47+
48+TTCWnd::TTCWnd()
49+{
50+ m_hWnd = nullptr;
51+ m_hInst = nullptr;
52+ m_hAccel = nullptr;
53+ m_hParentWnd = nullptr;
54+}
55+
56+LRESULT TTCWnd::SendMessage(UINT msg, WPARAM wp, LPARAM lp)
57+{
58+ return ::SendMessage(m_hWnd, msg, wp, lp);
59+}
60+
61+HWND TTCWnd::GetDlgItem(int id)
62+{
63+ return ::GetDlgItem(m_hWnd, id);
64+}
65+
66+LRESULT TTCWnd::SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp)
67+{
68+ return ::SendDlgItemMessage(m_hWnd, id, msg, wp, lp);
69+}
70+
71+#if defined(UNICODE)
72+LRESULT TTCWnd::SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp)
73+{
74+ return ::SendDlgItemMessageW(m_hWnd, id, msg, wp, lp);
75+}
76+#endif
77+
78+LRESULT TTCWnd::SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp)
79+{
80+ return ::SendDlgItemMessageA(m_hWnd, id, msg, wp, lp);
81+}
82+
83+void TTCWnd::GetDlgItemTextT(int id, TCHAR *buf, size_t size)
84+{
85+ ::GetDlgItemText(m_hWnd, id, buf, (int)size);
86+}
87+
88+#if defined(UNICODE)
89+void TTCWnd::GetDlgItemTextW(int id, wchar_t *buf, size_t size)
90+{
91+ ::GetDlgItemTextW(m_hWnd, id, buf, (int)size);
92+}
93+#endif
94+
95+void TTCWnd::GetDlgItemTextA(int id, char *buf, size_t size)
96+{
97+ ::GetDlgItemTextA(m_hWnd, id, buf, (int)size);
98+}
99+
100+void TTCWnd::SetDlgItemTextT(int id, const TCHAR *str)
101+{
102+ ::SetDlgItemText(m_hWnd, id, str);
103+}
104+
105+#if defined(UNICODE)
106+void TTCWnd::SetDlgItemTextW(int id, const wchar_t *str)
107+{
108+ ::SetDlgItemTextW(m_hWnd, id, str);
109+}
110+#endif
111+
112+void TTCWnd::SetDlgItemTextA(int id, const char *str)
113+{
114+ ::SetDlgItemTextA(m_hWnd, id, str);
115+}
116+
117+void TTCWnd::SetDlgItemNum(int id, LONG Num)
118+{
119+ SetDlgNum(m_hWnd, id, Num);
120+}
121+
122+// nCheck BST_UNCHECKED / BST_CHECKED / BST_INDETERMINATE
123+void TTCWnd::SetCheck(int id, int nCheck)
124+{
125+ ::SendMessage(GetDlgItem(id), BM_SETCHECK, nCheck, 0);
126+}
127+
128+UINT TTCWnd::GetCheck(int id)
129+{
130+ return ::IsDlgButtonChecked(m_hWnd, id);
131+}
132+
133+void TTCWnd::SetCurSel(int id, int no)
134+{
135+ HWND hWnd = GetDlgItem(id);
136+ assert(hWnd != 0);
137+ TCHAR ClassName[32];
138+ int r = GetClassName(hWnd, ClassName, _countof(ClassName));
139+ assert(r != 0); (void)r;
140+ UINT msg =
141+ (_tcscmp(ClassName, _T("ListBox")) == 0) ? LB_SETCURSEL :
142+ (_tcscmp(ClassName, _T("ComboBox")) == 0) ? CB_SETCURSEL : 0;
143+ assert(msg != 0);
144+ ::SendMessage(hWnd, msg, no, 0);
145+}
146+
147+int TTCWnd::GetCurSel(int id)
148+{
149+ HWND hWnd = GetDlgItem(id);
150+ assert(hWnd != 0);
151+ TCHAR ClassName[32];
152+ int r = GetClassName(hWnd, ClassName, _countof(ClassName));
153+ assert(r != 0); (void)r;
154+ UINT msg =
155+ (_tcscmp(ClassName, _T("ListBox")) == 0) ? LB_GETCURSEL :
156+ (_tcscmp(ClassName, _T("ComboBox")) == 0) ? CB_GETCURSEL : 0;
157+ assert(msg != 0);
158+ LRESULT lResult = ::SendMessage(hWnd, msg, 0, 0);
159+ return (int)lResult;
160+}
161+
162+void TTCWnd::EnableDlgItem(int id, BOOL enable)
163+{
164+ ::EnableWindow(GetDlgItem(id), enable);
165+}
166+
167+void TTCWnd::SetDlgItemInt(int id, UINT val, BOOL bSigned)
168+{
169+ ::SetDlgItemInt(m_hWnd, id, val, bSigned);
170+}
171+
172+UINT TTCWnd::GetDlgItemInt(int id, BOOL* lpTrans, BOOL bSigned) const
173+{
174+ return ::GetDlgItemInt(m_hWnd, id, lpTrans, bSigned);
175+}
176+
177+void TTCWnd::ShowWindow(int nCmdShow)
178+{
179+ ::ShowWindow(m_hWnd, nCmdShow);
180+}
181+
182+void TTCWnd::SetWindowTextT(const TCHAR *str)
183+{
184+ ::SetWindowText(m_hWnd, str);
185+}
186+
187+#if defined(UNICODE)
188+void TTCWnd::SetWindowTextW(const wchar_t *str)
189+{
190+ ::SetWindowTextW(m_hWnd, str);
191+}
192+#endif
193+
194+void TTCWnd::SetWindowTextA(const char *str)
195+{
196+ ::SetWindowTextA(m_hWnd, str);
197+}
198+
199+LONG_PTR TTCWnd::SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong)
200+{
201+ return ::SetWindowLongPtr(m_hWnd, nIndex, dwNewLong);
202+}
203+
204+LONG_PTR TTCWnd::GetWindowLongPtr(int nIndex)
205+{
206+ return ::GetWindowLongPtr(m_hWnd, nIndex);
207+}
208+
209+void TTCWnd::ModifyStyleCom(int nStyleOffset,
210+ DWORD dwRemove, DWORD dwAdd, UINT nFlags)
211+{
212+ const LONG_PTR dwStyle = GetWindowLongPtr(nStyleOffset);
213+ const LONG_PTR add = dwAdd;
214+ const LONG_PTR remove = dwRemove;
215+ const LONG_PTR dwNewStyle = (dwStyle & ~remove) | add;
216+ if (dwStyle != dwNewStyle) {
217+ SetWindowLongPtr(nStyleOffset, dwNewStyle);
218+ }
219+ if (nFlags != 0)
220+ {
221+ SetWindowPos(nullptr, 0, 0, 0, 0,
222+ SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
223+ }
224+}
225+
226+void TTCWnd::ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags)
227+{
228+ ModifyStyleCom(GWL_STYLE, dwRemove, dwAdd, nFlags);
229+}
230+
231+void TTCWnd::ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags)
232+{
233+ ModifyStyleCom(GWL_EXSTYLE, dwRemove, dwAdd, nFlags);
234+}
235+
236+int TTCWnd::MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
237+{
238+ return ::MessageBox(m_hWnd, lpText, lpCaption, uType);
239+}
240+
241+int TTCWnd::MessageBoxA(const char *lpText, const char *lpCaption, UINT uType)
242+{
243+ return ::MessageBoxA(m_hWnd, lpText, lpCaption, uType);
244+}
245+
246+#if defined(UNICODE)
247+int TTCWnd::MessageBoxW(const wchar_t *lpText, const wchar_t *lpCaption, UINT uType)
248+{
249+ return ::MessageBoxW(m_hWnd, lpText, lpCaption, uType);
250+}
251+#endif
252+
253+BOOL TTCWnd::GetWindowRect(RECT *R)
254+{
255+ return ::GetWindowRect(m_hWnd, R);
256+}
257+
258+BOOL TTCWnd::SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
259+{
260+ return ::SetWindowPos(m_hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
261+}
262+
263+BOOL TTCWnd::GetClientRect(RECT *R)
264+{
265+ return ::GetClientRect(m_hWnd, R);
266+}
267+
268+BOOL TTCWnd::InvalidateRect(RECT *R, BOOL bErase)
269+{
270+ return ::InvalidateRect(m_hWnd, R, bErase);
271+}
272+
273+BOOL TTCWnd::EndDialog(int nResult)
274+{
275+ return ::EndDialog(m_hWnd, nResult);
276+}
277+
278+void TTCWnd::DestroyWindow()
279+{
280+ ::DestroyWindow(m_hWnd);
281+}
282+
283+HDC TTCWnd::BeginPaint(LPPAINTSTRUCT lpPaint)
284+{
285+ return ::BeginPaint(m_hWnd, lpPaint);
286+}
287+
288+BOOL TTCWnd::EndPaint(LPPAINTSTRUCT lpPaint)
289+{
290+ return ::EndPaint(m_hWnd, lpPaint);
291+}
292+
293+LRESULT TTCWnd::DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam)
294+{
295+ return ::DefWindowProc(m_hWnd, msg, wParam, lParam);
296+}
297+
298+////////////////////////////////////////
299+
300+TTCDialog *TTCDialog::pseudoPtr;
301+
302+TTCDialog::TTCDialog()
303+{
304+}
305+
306+TTCDialog::~TTCDialog()
307+{
308+}
309+
310+/**
311+ * ?_?C?A???O??????
312+ * @retval TRUE ???????s??ꂽ(???̃??b?Z?[?W?????͌Ăяo????Ȃ?)
313+ * @retval FALSE ???̃??b?Z?[?W?????͌Ăяo?????
314+ *
315+ * ???̃??b?Z?[?W????
316+ * TTCDialog::DlgProc(msg=WM_INITDIALOG)
317+ */
318+BOOL TTCDialog::OnInitDialog()
319+{
320+ return FALSE;
321+}
322+
323+/**
324+ * OK?{?^??
325+ * @retval TRUE ???????s??ꂽ(???̃??b?Z?[?W?????͌Ăяo????Ȃ?)
326+ * @retval FALSE ???̃??b?Z?[?W?????͌Ăяo?????
327+ *
328+ * ???̃??b?Z?[?W????
329+ * TTCDialog::OnCommand()
330+ */
331+BOOL TTCDialog::OnOK()
332+{
333+ EndDialog(IDOK);
334+ return TRUE;
335+}
336+
337+/**
338+ * CANCEL?{?^??
339+ * @retval TRUE ???????s??ꂽ(???̃??b?Z?[?W?????͌Ăяo????Ȃ?)
340+ * @retval FALSE ???̃??b?Z?[?W?????͌Ăяo?????
341+ *
342+ * ???̃??b?Z?[?W????
343+ * TTCDialog::OnCommand()
344+ */
345+BOOL TTCDialog::OnCancel()
346+{
347+ EndDialog(IDCANCEL);
348+ return TRUE;
349+}
350+
351+BOOL TTCDialog::OnCommand(WPARAM wp, LPARAM lp)
352+{
353+ return FALSE;
354+}
355+
356+/**
357+ * WM_CLOSE???b?Z?[?W????
358+ * @retval TRUE ???????s??ꂽ(???̃??b?Z?[?W?????͌Ăяo????Ȃ?)
359+ * @retval FALSE ???̃??b?Z?[?W?????͌Ăяo?????
360+ *
361+ * ???̃??b?Z?[?W????
362+ * TTCDialog::OnCancel()
363+ */
364+BOOL TTCDialog::OnClose()
365+{
366+ return FALSE;
367+}
368+
369+/**
370+ * WM_NCDESTROY???b?Z?[?W????
371+ * @retval TRUE ???????s??ꂽ(???̃??b?Z?[?W?????͌Ăяo????Ȃ?)
372+ * @retval FALSE ???̃??b?Z?[?W?????͌Ăяo?????
373+ *
374+ * ???̃??b?Z?[?W????
375+ * TTCDialog::DlgProc()
376+ */
377+BOOL TTCDialog::PostNcDestroy()
378+{
379+ return FALSE;
380+}
381+
382+/*
383+ * @retval TRUE ???b?Z?[?W????????????
384+ * @retval FALSE ???b?Z?[?W?????????Ȃ???????
385+ * @retval ???̑? ???b?Z?[?W?ɂ???ĈقȂ邱?Ƃ?????
386+ */
387+LRESULT TTCDialog::DlgProc(UINT msg, WPARAM wp, LPARAM lp)
388+{
389+ (void)msg;
390+ (void)wp;
391+ (void)lp;
392+ return (LRESULT)FALSE;
393+}
394+
395+/*
396+ * @retval TRUE ???b?Z?[?W????????????
397+ * @retval FALSE ???b?Z?[?W?????????Ȃ???????
398+ */
399+LRESULT TTCDialog::DlgProcBase(UINT msg, WPARAM wp, LPARAM lp)
400+{
401+ BOOL Processed = FALSE;
402+ switch (msg) {
403+ case WM_INITDIALOG:
404+ Processed = OnInitDialog();
405+ break;
406+ case WM_COMMAND:
407+ {
408+ const WORD wID = GET_WM_COMMAND_ID(wp, lp);
409+ switch (wID) {
410+ case IDOK:
411+ Processed = OnOK();
412+ //self->DestroyWindow();
413+ //SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, lResult)
414+ // return TRUE
415+ break;
416+ case IDCANCEL:
417+ Processed = OnCancel();
418+ break;
419+ }
420+
421+ if (Processed == FALSE) {
422+ Processed = OnCommand(wp, lp);
423+ }
424+ break;
425+ }
426+ case WM_NCDESTROY:
427+ Processed = PostNcDestroy();
428+ break;
429+ case WM_CLOSE:
430+ // CLOSE?{?^?????????????A
431+ Processed = OnClose();
432+ if (Processed == FALSE) {
433+ // ?I?[?o?[???C?h????Ă??Ȃ????
434+ // dialog?Ȃ?OnCancel()??????????
435+ Processed = OnCancel();
436+ }
437+ break;
438+ default:
439+ Processed = FALSE;
440+ break;
441+ }
442+
443+ if (Processed == TRUE) {
444+ // ????????
445+ return TRUE;
446+ }
447+
448+ // ?Ō?̃??b?Z?[?W????
449+ return DlgProc(msg, wp, lp);
450+}
451+
452+LRESULT TTCDialog::WndProcBase(UINT msg, WPARAM wp, LPARAM lp)
453+{
454+ BOOL Processed = FALSE;
455+ switch (msg) {
456+ case WM_INITDIALOG:
457+ Processed = OnInitDialog();
458+ break;
459+ case WM_COMMAND:
460+ {
461+ const WORD wID = GET_WM_COMMAND_ID(wp, lp);
462+ switch (wID) {
463+ case IDOK:
464+ Processed = OnOK();
465+ //self->DestroyWindow();
466+ //SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, lResult)
467+ // return TRUE
468+ break;
469+ case IDCANCEL:
470+ Processed = OnCancel();
471+ break;
472+ }
473+
474+ if (Processed == FALSE) {
475+ Processed = OnCommand(wp, lp);
476+ }
477+ break;
478+ }
479+ case WM_NCDESTROY:
480+ Processed = PostNcDestroy();
481+ break;
482+ case WM_CLOSE:
483+ // CLOSE?{?^?????????????A
484+ Processed = OnClose();
485+ if (Processed == FALSE) {
486+ // ?I?[?o?[???C?h????Ă??Ȃ????
487+ // dialog?Ȃ?OnCancel()??????????
488+ Processed = OnCancel();
489+ }
490+ break;
491+ default:
492+ Processed = FALSE;
493+ break;
494+ }
495+
496+ if (Processed == TRUE) {
497+ // ????????
498+ return TRUE;
499+ }
500+
501+ // DlgProc???I?[?o???C?h????̂ł͂Ȃ??A
502+ // DefWindowProc???I?[?o?[???C?h???邱??
503+ return DefWindowProc(msg, wp, lp);
504+}
505+
506+/**
507+ * for modal dialog
508+ */
509+INT_PTR TTCDialog::DoModal(HINSTANCE hInstance, HWND hParent, int idd)
510+{
511+ pseudoPtr = this;
512+#if defined(REWRITE_TEMPLATE)
513+ INT_PTR result =
514+ TTDialogBoxParam(hInstance,
515+ MAKEINTRESOURCE(idd),
516+ hParent,
517+ (DLGPROC)&DlgProcStub, (LPARAM)this);
518+#else
519+ INT_PTR result =
520+ DialogBoxParam(hInstance,
521+ MAKEINTRESOURCE(idd),
522+ hParent,
523+ (DLGPROC)&DlgProcStub, (LPARAM)this);
524+#endif
525+ pseudoPtr = nullptr;
526+ return result;
527+}
528+
529+/**
530+ * for modeless dialog
531+ */
532+BOOL TTCDialog::Create(HINSTANCE hInstance, HWND hParent, int idd)
533+{
534+ m_hInst = hInstance;
535+ m_hParentWnd = hParent;
536+#if defined(REWRITE_TEMPLATE)
537+ DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, MAKEINTRESOURCE(idd));
538+#else
539+ HRSRC hResource = ::FindResource(hInstance, MAKEINTRESOURCE(idd), RT_DIALOG);
540+ HANDLE hDlgTemplate = ::LoadResource(hInstance, hResource);
541+ DLGTEMPLATE *lpTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
542+#endif
543+ DLGPROC dlgproc = (DLGPROC)DlgProcStub;
544+ const wchar_t *dialog_class = TTGetClassName(lpTemplate);
545+ if (dialog_class != nullptr) {
546+ // Modaless Dialog & Dialog application
547+ // WNDCLASS.lpfnWndProc = TTCDialog::WndProcBase
548+ dlgproc = nullptr;
549+ }
550+ pseudoPtr = this;
551+ HWND hWnd = ::CreateDialogIndirectParam(
552+ hInstance, lpTemplate, hParent,
553+ dlgproc, (LPARAM)this);
554+ pseudoPtr = nullptr;
555+ if (hWnd == nullptr)
556+ {
557+#if defined(_DEBUG)
558+ DWORD e = GetLastError();
559+#endif
560+ assert(false);
561+ return FALSE;
562+ }
563+
564+ m_hParentWnd = hParent;
565+ m_hWnd = hWnd;
566+ m_hInst = hInstance;
567+// ::EnableWindow(hParent,FALSE);
568+// ::ShowWindow(hWnd, SW_SHOW); // TODO ?O?ł??̂??ǂ?????
569+// ::EnableWindow(m_hWnd,TRUE);
570+
571+ return TRUE;
572+}
573+
574+/*
575+ * @retval TRUE ???b?Z?[?W????????????
576+ * @retval FALSE ???b?Z?[?W?????????Ȃ???????
577+ */
578+LRESULT CALLBACK TTCDialog::DlgProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
579+{
580+ TTCDialog *self = (TTCDialog *)::GetWindowLongPtr(hWnd, DWLP_USER);
581+ if (self == nullptr) {
582+ self = pseudoPtr;
583+ self->m_hWnd = hWnd;
584+ if (msg == WM_INITDIALOG) {
585+ ::SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR)self);
586+ pseudoPtr = nullptr;
587+ }
588+ }
589+ assert(self != nullptr);
590+
591+ LRESULT result = self->DlgProcBase(msg, wp, lp);
592+ return result;
593+}
594+
595+/*
596+ * @retval TRUE ???b?Z?[?W????????????
597+ * @retval FALSE ???b?Z?[?W?????????Ȃ???????
598+ */
599+LRESULT CALLBACK TTCDialog::WndProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
600+{
601+ TTCDialog *self = (TTCDialog *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
602+ if (self == nullptr) {
603+ assert(pseudoPtr != nullptr);
604+ self = pseudoPtr;
605+ self->m_hWnd = hWnd;
606+ if (msg == WM_CREATE) {
607+ ::SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)self);
608+ pseudoPtr = nullptr;
609+ }
610+ }
611+ assert(self != nullptr);
612+
613+ return self->WndProcBase(msg, wp, lp);
614+}
615+
616+void TTCDialog::DestroyWindow()
617+{
618+ if (m_hWnd != nullptr) {
619+ ::EnableWindow(m_hParentWnd,TRUE);
620+ ::SetFocus(m_hParentWnd);
621+ ::DestroyWindow(m_hWnd);
622+ m_hWnd = nullptr;
623+ }
624+}
625+
626+////////////////////////////////////////
627+
628+// quick hack :-(
629+static HINSTANCE ghInstance;
630+static class TTCPropertySheet *gTTCPS;
631+
632+TTCPropertyPage::TTCPropertyPage(HINSTANCE inst, int id, TTCPropertySheet *sheet)
633+{
634+ memset(&m_psp, 0, sizeof(m_psp));
635+ m_psp.dwSize = sizeof(m_psp);
636+ m_psp.dwFlags = PSP_DEFAULT;
637+ m_psp.hInstance = inst;
638+ m_psp.pszTemplate = MAKEINTRESOURCE(id);
639+#if defined(REWRITE_TEMPLATE)
640+ m_psp.dwFlags |= PSP_DLGINDIRECT;
641+ m_psp.pResource = TTGetDlgTemplate(inst, m_psp.pszTemplate);
642+#endif
643+// m_psp.pfnDlgProc = (DLGPROC)Proc;
644+ m_psp.pfnDlgProc = Proc;
645+ m_psp.lParam = (LPARAM)this;
646+
647+ m_pSheet = sheet;
648+}
649+
650+TTCPropertyPage::~TTCPropertyPage()
651+{
652+ free((void *)m_psp.pResource);
653+}
654+
655+void TTCPropertyPage::OnInitDialog()
656+{
657+}
658+
659+void TTCPropertyPage::OnOK()
660+{
661+}
662+
663+BOOL TTCPropertyPage::OnCommand(WPARAM wp, LPARAM lp)
664+{
665+ return TRUE;
666+}
667+
668+HBRUSH TTCPropertyPage::OnCtlColor(HDC hDC, HWND hWnd)
669+{
670+ return (HBRUSH)::DefWindowProc(m_hWnd, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hWnd);
671+}
672+
673+UINT CALLBACK TTCPropertyPage::PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
674+{
675+ return 0;
676+}
677+
678+INT_PTR CALLBACK TTCPropertyPage::Proc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
679+{
680+ TTCPropertyPage *self = (TTCPropertyPage *)::GetWindowLongPtr(hDlgWnd, DWLP_USER);
681+ switch (msg)
682+ {
683+ case WM_INITDIALOG:
684+ self = (TTCPropertyPage *)(((PROPSHEETPAGE *)lp)->lParam);
685+ ::SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)self);
686+ self->m_hWnd = hDlgWnd;
687+ self->OnInitDialog();
688+ break;
689+ case WM_NOTIFY:
690+ {
691+ NMHDR * nmhdr = (NMHDR *)lp;
692+ switch (nmhdr->code)
693+ {
694+ case PSN_APPLY:
695+ self->OnOK();
696+ break;
697+ default:
698+ break;
699+ }
700+ break;
701+ }
702+ case WM_COMMAND:
703+ self->OnCommand(wp, lp);
704+ break;
705+ case WM_CTLCOLORSTATIC:
706+ return (INT_PTR)self->OnCtlColor((HDC)wp, (HWND)lp);
707+ }
708+ return FALSE;
709+}
710+
711+////////////////////////////////////////
712+
713+TTCPropertySheet::TTCPropertySheet(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd)
714+{
715+ m_hInst = hInstance;
716+ memset(&m_psh, 0, sizeof(m_psh));
717+ m_psh.dwSize = sizeof(m_psh);
718+ m_psh.dwFlags = PSH_DEFAULT | PSH_NOAPPLYNOW | PSH_USECALLBACK; // | PSH_MODELESS
719+ if (pszCaption != nullptr) {
720+ m_psh.pszCaption = pszCaption;
721+ //m_psh.dwFlags |= PSH_PROPTITLE; // ?u?̃v???p?e?B?[?v???lj???????
722+ }
723+ m_psh.hwndParent = hParentWnd;
724+ m_psh.pfnCallback = PropSheetProc;
725+}
726+
727+TTCPropertySheet::~TTCPropertySheet()
728+{
729+}
730+
731+INT_PTR TTCPropertySheet::DoModal()
732+{
733+ ghInstance = m_hInst;
734+ gTTCPS = this;
735+ return PropertySheet(&m_psh);
736+
737+ // ???[?_???X?ɂ???ƃ^?u?̓?????????????
738+#if 0
739+ // ???[?h???X?_?C?A???O?{?b?N?X?̏ꍇ?̓E?B???h?E?̃n???h??
740+ m_hWnd = (HWND)::PropertySheet(&m_psh);
741+// ShowWindow(m_hWnd, SW_SHOW);
742+
743+// ::ModifyStyle(m_hWnd, TCS_MULTILINE, TCS_SINGLELINE, 0);
744+
745+ ModalResult = 0;
746+ HWND hDlgWnd = m_hWnd;
747+ for(;;) {
748+ if (ModalResult != 0) {
749+ break;
750+ }
751+ MSG Msg;
752+ BOOL quit = !::GetMessage(&Msg, nullptr, nullptr, nullptr);
753+ if (quit) {
754+ // QM_QUIT
755+ PostQuitMessage(0);
756+ return IDCANCEL;
757+ }
758+ if ((hDlgWnd == Msg.hwnd) ||
759+ ::SendMessage(hDlgWnd, PSM_ISDIALOGMESSAGE, nullptr, (LPARAM)&Msg))
760+ {
761+ // ?_?C?A???O?ȊO?̏???
762+ ::TranslateMessage(&Msg);
763+ ::DispatchMessage(&Msg);
764+ }
765+ if (!SendMessage(hDlgWnd, PSM_GETCURRENTPAGEHWND, 0, 0)) {
766+ // ?v???p?e?B?[?V?[?g?I??
767+ break;
768+ }
769+ }
770+ return ModalResult;
771+#endif
772+}
773+
774+int CALLBACK TTCPropertySheet::PropSheetProc(HWND hWnd, UINT msg, LPARAM lp)
775+{
776+ switch (msg) {
777+ case PSCB_PRECREATE:
778+ {
779+#if defined(REWRITE_TEMPLATE)
780+ // ?e???v???[?g?̓??e???????????? ?댯
781+ // http://home.att.ne.jp/banana/akatsuki/doc/atlwtl/atlwtl15-01/index.html
782+ size_t PrevTemplSize;
783+ size_t NewTemplSize;
784+ DLGTEMPLATE *NewTempl =
785+ TTGetNewDlgTemplate(ghInstance, (DLGTEMPLATE *)lp,
786+ &PrevTemplSize, &NewTemplSize);
787+ NewTempl->style &= ~DS_CONTEXTHELP; // check DLGTEMPLATEEX
788+ memcpy((void *)lp, NewTempl, NewTemplSize);
789+ free(NewTempl);
790+#endif
791+ break;
792+ }
793+ case PSCB_INITIALIZED:
794+ {
795+ //TTCPropertySheet *self = (TTCPropertySheet *)lp;
796+ TTCPropertySheet *self = gTTCPS;
797+ self->m_hWnd = hWnd;
798+ self->OnInitDialog();
799+ break;
800+ }
801+ }
802+ return 0;
803+}
804+
805+void TTCPropertySheet::OnInitDialog()
806+{
807+}
--- branches/cmake/teraterm/common/tmfc.h (revision 7381)
+++ branches/cmake/teraterm/common/tmfc.h (revision 7382)
@@ -1,183 +1,186 @@
1-/*
2- * Copyright (C) 2018 TeraTerm Project
3- * All rights reserved.
4- *
5- * Redistribution and use in source and binary forms, with or without
6- * modification, are permitted provided that the following conditions
7- * are met:
8- *
9- * 1. Redistributions of source code must retain the above copyright
10- * notice, this list of conditions and the following disclaimer.
11- * 2. Redistributions in binary form must reproduce the above copyright
12- * notice, this list of conditions and the following disclaimer in the
13- * documentation and/or other materials provided with the distribution.
14- * 3. The name of the author may not be used to endorse or promote products
15- * derived from this software without specific prior written permission.
16- *
17- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27- */
28-
29-/*
30- * Tera term Micro Framework class
31- */
32-#pragma once
33-#include <windows.h>
34-
35-class TTCWnd
36-{
37-public:
38- HWND m_hWnd;
39- HINSTANCE m_hInst;
40- HACCEL m_hAccel;
41- HWND m_hParentWnd;
42-
43- TTCWnd();
44- void DestroyWindow();
45- HWND GetSafeHwnd() const {return m_hWnd;}
46- HWND GetSafeHwnd() { return m_hWnd; }
47- HDC BeginPaint(LPPAINTSTRUCT lpPaint);
48- BOOL EndPaint(LPPAINTSTRUCT lpPaint);
49- LRESULT SendMessage(UINT msg, WPARAM wp, LPARAM lp);
50- void ShowWindow(int nCmdShow);
51- void SetWindowTextT(const TCHAR *str);
52-#if defined(UNICODE)
53- void SetWindowTextW(const wchar_t *str);
54-#endif
55- void SetWindowTextA(const char *str);
56- LONG_PTR SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong);
57- LONG_PTR GetWindowLongPtr(int nIndex);
58- void ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
59- void ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
60- int MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
61- int MessageBoxA(const char * lpText, const char *lpCaption, UINT uType);
62- //virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
63- LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
64- BOOL GetWindowRect(RECT *R);
65- BOOL SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
66- BOOL GetClientRect(RECT *R);
67- BOOL InvalidateRect(RECT *R, BOOL bErase = TRUE);
68- BOOL EndDialog(int nResult);
69- // for controls
70- HWND GetDlgItem(int id);
71- LRESULT SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp);
72-#if defined(UNICODE)
73- LRESULT SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp);
74-#endif
75- LRESULT SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp);
76- void GetDlgItemTextT(int id, TCHAR *buf, size_t size);
77-#if defined(UNICODE)
78- void GetDlgItemTextW(int id, wchar_t *buf, size_t size);
79-#endif
80- void GetDlgItemTextA(int id, char *buf, size_t size);
81- void SetDlgItemTextT(int id, const TCHAR *str);
82-#if defined(UNICODE)
83- void SetDlgItemTextW(int id, const wchar_t *str);
84-#endif
85- void SetDlgItemTextA(int id, const char *str);
86- void SetDlgItemNum(int id, LONG Num);
87- void SetCheck(int id, int nCheck);
88- UINT GetCheck(int id);
89- void SetCurSel(int id, int no);
90- int GetCurSel(int id);
91- void SetDlgItemInt(int id, UINT val, BOOL bSigned = TRUE);
92- UINT GetDlgItemInt(int id, BOOL* lpTrans = NULL, BOOL bSigned = TRUE) const;
93- void EnableDlgItem(int id, BOOL enable);
94-private:
95- void ModifyStyleCom(int nStyleOffset, DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
96-};
97-
98-class TTCFrameWnd : public TTCWnd
99-{
100-public:
101- TTCFrameWnd();
102- virtual ~TTCFrameWnd();
103- static TTCFrameWnd *pseudoPtr;
104- static LRESULT CALLBACK ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
105- virtual BOOL Create(HINSTANCE hInstance,
106- LPCTSTR lpszClassName,
107- LPCTSTR lpszWindowName,
108- DWORD dwStyle = WS_OVERLAPPEDWINDOW,
109- const RECT& rect = rectDefault,
110- HWND pParentWnd = NULL, // != NULL for popups
111- LPCTSTR lpszMenuName = NULL,
112- DWORD dwExStyle = 0);//,
113- //CCreateContext* pContext = NULL);
114- virtual LRESULT Proc(UINT msg, WPARAM wp, LPARAM lp) = 0;
115- static const RECT rectDefault;
116- ///
117- virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
118- ///
119-#if 1
120- void OnKillFocus(HWND hNewWnd);
121- void OnDestroy();
122- void OnSetFocus(HWND hOldWnd);
123- void OnSysCommand(UINT nID, LPARAM lParam);
124- void OnClose();
125-#endif
126- void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
127- void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
128-};
129-
130-class TTCDialog : public TTCWnd
131-{
132-public:
133- TTCDialog();
134- virtual ~TTCDialog();
135- BOOL Create(HINSTANCE hInstance, HWND hParent, int idd);
136- INT_PTR DoModal(HINSTANCE hInstance, HWND hParent, int idd);
137- void DestroyWindow();
138- virtual BOOL OnInitDialog();
139- virtual BOOL OnOK();
140- virtual BOOL OnCancel();
141- virtual BOOL OnCommand(WPARAM wp, LPARAM lp);
142- virtual BOOL OnClose();
143- virtual BOOL PostNcDestroy();
144- virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM lp);
145-
146- static LRESULT CALLBACK DlgProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
147- static LRESULT CALLBACK WndProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
148-private:
149-
150- LRESULT DlgProcBase(UINT msg, WPARAM wp, LPARAM lp);
151- LRESULT WndProcBase(UINT msg, WPARAM wp, LPARAM lp);
152- static TTCDialog *pseudoPtr;
153-};
154-
155-class TTCPropertySheet
156-{
157-public:
158- TTCPropertySheet(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd);
159- virtual ~TTCPropertySheet();
160- virtual void OnInitDialog();
161- INT_PTR DoModal();
162- PROPSHEETHEADER m_psh;
163- HWND m_hWnd;
164- static int CALLBACK PropSheetProc(HWND hWnd, UINT msg, LPARAM lParam);
165- HINSTANCE m_hInst;
166-};
167-
168-class TTCPropertyPage : public TTCWnd
169-{
170-public:
171- TTCPropertyPage(HINSTANCE inst, int id, TTCPropertySheet *sheet);
172- virtual ~TTCPropertyPage();
173- virtual void OnInitDialog();
174- virtual void OnOK();
175- virtual BOOL OnCommand(WPARAM wp, LPARAM lp);
176- virtual HBRUSH OnCtlColor(HDC hDC, HWND hWnd);
177-
178- PROPSHEETPAGE m_psp;
179- static INT_PTR CALLBACK Proc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
180- static UINT CALLBACK PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
181- TTCPropertySheet *m_pSheet;
182-};
183-
1+/*
2+ * Copyright (C) 2018 TeraTerm Project
3+ * All rights reserved.
4+ *
5+ * Redistribution and use in source and binary forms, with or without
6+ * modification, are permitted provided that the following conditions
7+ * are met:
8+ *
9+ * 1. Redistributions of source code must retain the above copyright
10+ * notice, this list of conditions and the following disclaimer.
11+ * 2. Redistributions in binary form must reproduce the above copyright
12+ * notice, this list of conditions and the following disclaimer in the
13+ * documentation and/or other materials provided with the distribution.
14+ * 3. The name of the author may not be used to endorse or promote products
15+ * derived from this software without specific prior written permission.
16+ *
17+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+ */
28+
29+/*
30+ * Tera term Micro Framework class
31+ */
32+#pragma once
33+#include <windows.h>
34+
35+class TTCWnd
36+{
37+public:
38+ HWND m_hWnd;
39+ HINSTANCE m_hInst;
40+ HACCEL m_hAccel;
41+ HWND m_hParentWnd;
42+
43+ TTCWnd();
44+ void DestroyWindow();
45+ HWND GetSafeHwnd() const {return m_hWnd;}
46+ HWND GetSafeHwnd() { return m_hWnd; }
47+ HDC BeginPaint(LPPAINTSTRUCT lpPaint);
48+ BOOL EndPaint(LPPAINTSTRUCT lpPaint);
49+ LRESULT SendMessage(UINT msg, WPARAM wp, LPARAM lp);
50+ void ShowWindow(int nCmdShow);
51+ void SetWindowTextT(const TCHAR *str);
52+#if defined(UNICODE)
53+ void SetWindowTextW(const wchar_t *str);
54+#endif
55+ void SetWindowTextA(const char *str);
56+ LONG_PTR SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong);
57+ LONG_PTR GetWindowLongPtr(int nIndex);
58+ void ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
59+ void ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
60+ int MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
61+ int MessageBoxA(const char * lpText, const char *lpCaption, UINT uType);
62+#if defined(UNICODE)
63+ int MessageBoxW(const wchar_t * lpText, const wchar_t *lpCaption, UINT uType);
64+#endif
65+ //virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
66+ LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
67+ BOOL GetWindowRect(RECT *R);
68+ BOOL SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
69+ BOOL GetClientRect(RECT *R);
70+ BOOL InvalidateRect(RECT *R, BOOL bErase = TRUE);
71+ BOOL EndDialog(int nResult);
72+ // for controls
73+ HWND GetDlgItem(int id);
74+ LRESULT SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp);
75+#if defined(UNICODE)
76+ LRESULT SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp);
77+#endif
78+ LRESULT SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp);
79+ void GetDlgItemTextT(int id, TCHAR *buf, size_t size);
80+#if defined(UNICODE)
81+ void GetDlgItemTextW(int id, wchar_t *buf, size_t size);
82+#endif
83+ void GetDlgItemTextA(int id, char *buf, size_t size);
84+ void SetDlgItemTextT(int id, const TCHAR *str);
85+#if defined(UNICODE)
86+ void SetDlgItemTextW(int id, const wchar_t *str);
87+#endif
88+ void SetDlgItemTextA(int id, const char *str);
89+ void SetDlgItemNum(int id, LONG Num);
90+ void SetCheck(int id, int nCheck);
91+ UINT GetCheck(int id);
92+ void SetCurSel(int id, int no);
93+ int GetCurSel(int id);
94+ void SetDlgItemInt(int id, UINT val, BOOL bSigned = TRUE);
95+ UINT GetDlgItemInt(int id, BOOL* lpTrans = NULL, BOOL bSigned = TRUE) const;
96+ void EnableDlgItem(int id, BOOL enable);
97+private:
98+ void ModifyStyleCom(int nStyleOffset, DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
99+};
100+
101+class TTCFrameWnd : public TTCWnd
102+{
103+public:
104+ TTCFrameWnd();
105+ virtual ~TTCFrameWnd();
106+ static TTCFrameWnd *pseudoPtr;
107+ static LRESULT CALLBACK ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
108+ virtual BOOL Create(HINSTANCE hInstance,
109+ LPCTSTR lpszClassName,
110+ LPCTSTR lpszWindowName,
111+ DWORD dwStyle = WS_OVERLAPPEDWINDOW,
112+ const RECT& rect = rectDefault,
113+ HWND pParentWnd = NULL, // != NULL for popups
114+ LPCTSTR lpszMenuName = NULL,
115+ DWORD dwExStyle = 0);//,
116+ //CCreateContext* pContext = NULL);
117+ virtual LRESULT Proc(UINT msg, WPARAM wp, LPARAM lp) = 0;
118+ static const RECT rectDefault;
119+ ///
120+ virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
121+ ///
122+#if 1
123+ void OnKillFocus(HWND hNewWnd);
124+ void OnDestroy();
125+ void OnSetFocus(HWND hOldWnd);
126+ void OnSysCommand(UINT nID, LPARAM lParam);
127+ void OnClose();
128+#endif
129+ void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
130+ void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
131+};
132+
133+class TTCDialog : public TTCWnd
134+{
135+public:
136+ TTCDialog();
137+ virtual ~TTCDialog();
138+ BOOL Create(HINSTANCE hInstance, HWND hParent, int idd);
139+ INT_PTR DoModal(HINSTANCE hInstance, HWND hParent, int idd);
140+ void DestroyWindow();
141+ virtual BOOL OnInitDialog();
142+ virtual BOOL OnOK();
143+ virtual BOOL OnCancel();
144+ virtual BOOL OnCommand(WPARAM wp, LPARAM lp);
145+ virtual BOOL OnClose();
146+ virtual BOOL PostNcDestroy();
147+ virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM lp);
148+
149+ static LRESULT CALLBACK DlgProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
150+ static LRESULT CALLBACK WndProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
151+private:
152+
153+ LRESULT DlgProcBase(UINT msg, WPARAM wp, LPARAM lp);
154+ LRESULT WndProcBase(UINT msg, WPARAM wp, LPARAM lp);
155+ static TTCDialog *pseudoPtr;
156+};
157+
158+class TTCPropertySheet
159+{
160+public:
161+ TTCPropertySheet(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd);
162+ virtual ~TTCPropertySheet();
163+ virtual void OnInitDialog();
164+ INT_PTR DoModal();
165+ PROPSHEETHEADER m_psh;
166+ HWND m_hWnd;
167+ static int CALLBACK PropSheetProc(HWND hWnd, UINT msg, LPARAM lParam);
168+ HINSTANCE m_hInst;
169+};
170+
171+class TTCPropertyPage : public TTCWnd
172+{
173+public:
174+ TTCPropertyPage(HINSTANCE inst, int id, TTCPropertySheet *sheet);
175+ virtual ~TTCPropertyPage();
176+ virtual void OnInitDialog();
177+ virtual void OnOK();
178+ virtual BOOL OnCommand(WPARAM wp, LPARAM lp);
179+ virtual HBRUSH OnCtlColor(HDC hDC, HWND hWnd);
180+
181+ PROPSHEETPAGE m_psp;
182+ static INT_PTR CALLBACK Proc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
183+ static UINT CALLBACK PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
184+ TTCPropertySheet *m_pSheet;
185+};
186+
--- branches/cmake/teraterm/teraterm/addsetting.cpp (revision 7381)
+++ branches/cmake/teraterm/teraterm/addsetting.cpp (revision 7382)
@@ -50,8 +50,6 @@
5050 #define GetDlgItemText GetDlgItemTextA
5151 #undef SetDlgItemText
5252 #define SetDlgItemText SetDlgItemTextA
53-#undef MessageBox
54-#define MessageBox MessageBoxA
5553
5654 const mouse_cursor_t MouseCursor[] = {
5755 {"ARROW", IDC_ARROW},
@@ -1121,7 +1119,7 @@
11211119 for (int i = 0 ; i < ts.LogRotateSizeType ; i++)
11221120 TmpLogRotateSize /= 1024;
11231121 SetDlgItemInt(IDC_ROTATE_SIZE, TmpLogRotateSize, FALSE);
1124- SendDlgItemMessage(IDC_ROTATE_SIZE_TYPE, CB_SELECTSTRING, -1, (LPARAM)GetLogRotateSizeType(ts.LogRotateSizeType));
1122+ SendDlgItemMessageA(IDC_ROTATE_SIZE_TYPE, CB_SELECTSTRING, -1, (LPARAM)GetLogRotateSizeType(ts.LogRotateSizeType));
11251123 SetDlgItemInt(IDC_ROTATE_STEP, ts.LogRotateStep, FALSE);
11261124 if (ts.LogRotate == ROTATE_NONE) {
11271125 EnableDlgItem(IDC_ROTATE_SIZE_TEXT, FALSE);
@@ -1275,7 +1273,8 @@
12751273 char buf[80], buf2[80];
12761274 time_t time_local;
12771275 struct tm *tm_local;
1278- char uimsg[MAX_UIMSG];
1276+ TCHAR uimsg[MAX_UIMSG];
1277+ TCHAR uimsg2[MAX_UIMSG];
12791278
12801279 // Viewlog Editor path (2005.1.29 yutaka)
12811280 GetDlgItemText(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor, _countof(ts.ViewlogEditor));
@@ -1283,10 +1282,10 @@
12831282 // Log Default File Name (2006.8.28 maya)
12841283 GetDlgItemTextA(IDC_DEFAULTNAME_EDITOR, buf, sizeof(buf));
12851284 if (isInvalidStrftimeChar(buf)) {
1286- get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
1287- get_lang_msg("MSG_LOGFILE_INVALID_CHAR_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
1288- "Invalid character is included in log file name.", ts.UILanguageFile);
1289- MessageBoxA(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
1285+ get_lang_msgT("MSG_ERROR", uimsg, _countof(uimsg), _T("ERROR"), ts.UILanguageFile);
1286+ get_lang_msgT("MSG_LOGFILE_INVALID_CHAR_ERROR", uimsg2, _countof(uimsg2),
1287+ _T("Invalid character is included in log file name."), ts.UILanguageFile);
1288+ MessageBox(uimsg2, uimsg, MB_ICONEXCLAMATION);
12901289 return;
12911290 }
12921291
@@ -1295,17 +1294,17 @@
12951294 tm_local = localtime(&time_local);
12961295 // 時刻文字列に変換
12971296 if (strlen(buf) != 0 && strftime(buf2, sizeof(buf2), buf, tm_local) == 0) {
1298- get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
1299- get_lang_msg("MSG_LOGFILE_TOOLONG_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
1300- "The log file name is too long.", ts.UILanguageFile);
1301- MessageBox(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
1297+ get_lang_msgT("MSG_ERROR", uimsg, _countof(uimsg), _T("ERROR"), ts.UILanguageFile);
1298+ get_lang_msgT("MSG_LOGFILE_TOOLONG_ERROR", uimsg2, _countof(uimsg2),
1299+ _T("The log file name is too long."), ts.UILanguageFile);
1300+ MessageBox(uimsg2, uimsg, MB_ICONEXCLAMATION);
13021301 return;
13031302 }
13041303 if (isInvalidFileNameChar(buf2)) {
1305- get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
1306- get_lang_msg("MSG_LOGFILE_INVALID_CHAR_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
1307- "Invalid character is included in log file name.", ts.UILanguageFile);
1308- MessageBox(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
1304+ get_lang_msgT("MSG_ERROR", uimsg, _countof(uimsg), _T("ERROR"), ts.UILanguageFile);
1305+ get_lang_msgT("MSG_LOGFILE_INVALID_CHAR_ERROR", uimsg2, _countof(uimsg2),
1306+ _T("Invalid character is included in log file name."), ts.UILanguageFile);
1307+ MessageBox(uimsg2, uimsg, MB_ICONEXCLAMATION);
13091308 return;
13101309 }
13111310 strncpy_s(ts.LogDefaultName, sizeof(ts.LogDefaultName), buf, _TRUNCATE);
Show on old repository browser