Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/ttcomtester/teraterm/teraterm/debug_pp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8750 - (hide annotations) (download) (as text)
Sun Apr 26 14:35:40 2020 UTC (3 years, 11 months ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/debug_pp.cpp
File MIME type: text/x-c++src
File size: 4379 byte(s)
デバグダイアログで描画APIのUnicode/ANSI切り替えができるようにした
1 doda 8445 /*
2 zmatsuo 8750 * (C) 2019-2020 TeraTerm Project
3 doda 8445 * 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     /* debug property page */
30    
31     #include <stdio.h>
32    
33     #include "tmfc.h"
34     #include "tt_res.h"
35     #include "debug_pp.h"
36     #include "../common/tt_res.h"
37     #include "unicode_test.h"
38     #include "dlglib.h"
39     #include "compat_win.h"
40 zmatsuo 8749 #include "setting.h"
41 doda 8445
42     CDebugPropPage::CDebugPropPage(HINSTANCE inst, TTCPropertySheet *sheet)
43     : TTCPropertyPage(inst, IDD_TABSHEET_DEBUG, sheet)
44     {
45     }
46    
47     CDebugPropPage::~CDebugPropPage()
48     {
49     }
50    
51     static const struct {
52     WORD key_code;
53     const char *key_str;
54     } key_list[] = {
55     {VK_CONTROL, "VT_CONTROL"},
56     {VK_SHIFT, "VK_SHIFT"},
57     };
58    
59     void CDebugPropPage::OnInitDialog()
60     {
61     // popup
62     SetCheck(IDC_DEBUG_POPUP_ENABLE, UnicodeDebugParam.CodePopupEnable);
63 zmatsuo 8467 for (int i = 0; i < (int)_countof(key_list); i++) {
64 doda 8445 SendDlgItemMessage(IDC_DEBUG_POPUP_KEY1, CB_ADDSTRING, 0, (LPARAM)key_list[i].key_str);
65     SendDlgItemMessage(IDC_DEBUG_POPUP_KEY2, CB_ADDSTRING, 0, (LPARAM)key_list[i].key_str);
66     if (UnicodeDebugParam.CodePopupKey1 == key_list[i].key_code) {
67     SendDlgItemMessageA(IDC_DEBUG_POPUP_KEY1, CB_SETCURSEL, i, 0);
68     }
69     if (UnicodeDebugParam.CodePopupKey2 == key_list[i].key_code) {
70     SendDlgItemMessageA(IDC_DEBUG_POPUP_KEY2, CB_SETCURSEL, i, 0);
71     }
72     }
73    
74     // console button
75     const char *caption;
76     HWND hWnd = pGetConsoleWindow();
77     if (hWnd == NULL) {
78     caption = "Open console window";
79     } else {
80     if (::IsWindowVisible(hWnd)) {
81     caption = "Hide console window";
82     } else {
83     caption = "Show console window";
84     }
85     }
86     SetDlgItemTextA(IDC_DEBUG_CONSOLE_BUTTON, caption);
87 zmatsuo 8750
88     // use unicode API
89     SetCheck(IDC_DEBUG_USE_UNICODE_API, UnicodeDebugParam.UseUnicodeApi);
90 doda 8445 }
91    
92     BOOL CDebugPropPage::OnCommand(WPARAM wParam, LPARAM)
93     {
94     switch (wParam) {
95     case IDC_DEBUG_CONSOLE_BUTTON | (BN_CLICKED << 16): {
96     const char *caption;
97     HWND hWnd = pGetConsoleWindow();
98     if (hWnd == NULL) {
99     FILE *fp;
100     AllocConsole();
101     freopen_s(&fp, "CONOUT$", "w", stdout);
102     freopen_s(&fp, "CONOUT$", "w", stderr);
103     caption = "Hide console window";
104     hWnd = pGetConsoleWindow();
105     HMENU hmenu = GetSystemMenu(hWnd, FALSE);
106     RemoveMenu(hmenu, SC_CLOSE, MF_BYCOMMAND);
107     }
108     else {
109     if (::IsWindowVisible(hWnd)) {
110     ::ShowWindow(hWnd, SW_HIDE);
111     caption = "Show console window";
112     }
113     else {
114     ::ShowWindow(hWnd, SW_SHOW);
115     caption = "Hide console window";
116     }
117     }
118     SetDlgItemTextA(IDC_DEBUG_CONSOLE_BUTTON, caption);
119     break;
120     }
121     default:
122     break;
123     }
124     return FALSE;
125     }
126    
127     void CDebugPropPage::OnOK()
128     {
129     UnicodeDebugParam.CodePopupEnable = GetCheck(IDC_DEBUG_POPUP_ENABLE);
130     int i = GetCurSel(IDC_DEBUG_POPUP_KEY1);
131     UnicodeDebugParam.CodePopupKey1 = key_list[i].key_code;
132     i = GetCurSel(IDC_DEBUG_POPUP_KEY2);
133     UnicodeDebugParam.CodePopupKey2 = key_list[i].key_code;
134 zmatsuo 8750
135     UnicodeDebugParam.UseUnicodeApi = GetCheck(IDC_DEBUG_USE_UNICODE_API);
136 doda 8445 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26