1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | using namespace ActiveBasic::IDE;
|
---|
4 | using namespace ActiveBasic::IDE::WindowComponents;
|
---|
5 |
|
---|
6 | LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
|
---|
7 | void SetupWindow(HWND hwnd);
|
---|
8 | void ResetTextEditFont(HWND hwnd);
|
---|
9 |
|
---|
10 | void CreateProcessWithStdHandle( const std::string &appPath, const std::string &cmdLine, bool isShowWindow = true )
|
---|
11 | {
|
---|
12 | std::string argsStr = '\"' + appPath + "\" " + cmdLine;
|
---|
13 | STARTUPINFO si;
|
---|
14 | PROCESS_INFORMATION pi;
|
---|
15 | memset(&si,0,sizeof(STARTUPINFO));
|
---|
16 | si.cb=sizeof(STARTUPINFO);
|
---|
17 | si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
---|
18 | si.wShowWindow = isShowWindow ? SW_SHOW : SW_HIDE;
|
---|
19 | si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
---|
20 | si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
---|
21 | si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
---|
22 |
|
---|
23 | std::vector<char> args( argsStr.c_str(), argsStr.c_str() + argsStr.size() + 1 );
|
---|
24 |
|
---|
25 | CreateProcess( NULL, &args[0], NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi );
|
---|
26 | CloseHandle( pi.hProcess );
|
---|
27 | CloseHandle( pi.hThread );
|
---|
28 | }
|
---|
29 |
|
---|
30 | #define MSGFLT_ADD 1
|
---|
31 |
|
---|
32 | #pragma push_macro("_WIN32_WINNT")
|
---|
33 | #undef _WIN32_WINNT
|
---|
34 | #define _WIN32_WINNT 0x0601
|
---|
35 | #include <dwmapi.h>
|
---|
36 | #pragma pop_macro("_WIN32_WINNT")
|
---|
37 |
|
---|
38 | #define WM_DWMSENDICONICTHUMBNAIL 0x0323
|
---|
39 | #define WM_DWMSENDICONICLIVEPREVIEWBITMAP 0x0326
|
---|
40 |
|
---|
41 | // Windows 7タスクバーにボタンとして表示させるためのウィンドウ。
|
---|
42 | // 各MDI子ウィンドウ (wndTarget) と1対1に対応する。
|
---|
43 | class DummyWindowForTaskbarButton : public ATL::CWindowImpl<DummyWindowForTaskbarButton>, boost::noncopyable
|
---|
44 | {
|
---|
45 | public:
|
---|
46 | DECLARE_WND_CLASS(TEXT("DummyWindow For Taskbar Button"));
|
---|
47 |
|
---|
48 | BEGIN_MSG_MAP(DummyWindowForTaskbarButton)
|
---|
49 | MESSAGE_HANDLER_EX(WM_DWMSENDICONICTHUMBNAIL, OnDwmSendIconicThumnail)
|
---|
50 | MESSAGE_HANDLER_EX(WM_DWMSENDICONICLIVEPREVIEWBITMAP, OnDwmSendIconicLivePreviewBitmap)
|
---|
51 | MSG_WM_ACTIVATE(OnActivate)
|
---|
52 | END_MSG_MAP()
|
---|
53 |
|
---|
54 | explicit DummyWindowForTaskbarButton(HWND hwndTarget, const char* title) :
|
---|
55 | wndTarget(hwndTarget)
|
---|
56 | {
|
---|
57 | DWORD const WS_EX_NOACTIVATE = 0x08000000;
|
---|
58 |
|
---|
59 | HWND hwndDummy = Create( hOwner, CRect( -32000, -32000, 1, 1 ), title,
|
---|
60 | WS_BORDER | WS_SYSMENU | WS_CAPTION, WS_EX_NOACTIVATE);
|
---|
61 | SetIcon( wndTarget.GetIcon( FALSE ), FALSE );
|
---|
62 | SetIcon( wndTarget.GetIcon( TRUE ), TRUE );
|
---|
63 |
|
---|
64 | BOOL iconicRepresentation = TRUE;
|
---|
65 | HRESULT hr;
|
---|
66 | hr = DwmSetWindowAttribute(
|
---|
67 | *this,
|
---|
68 | DWMWA_FORCE_ICONIC_REPRESENTATION,
|
---|
69 | &iconicRepresentation,
|
---|
70 | sizeof iconicRepresentation);
|
---|
71 | BOOL iconicBitmap = TRUE;
|
---|
72 | hr = DwmSetWindowAttribute(
|
---|
73 | *this,
|
---|
74 | DWMWA_HAS_ICONIC_BITMAP,
|
---|
75 | &iconicBitmap,
|
---|
76 | sizeof iconicBitmap);
|
---|
77 | }
|
---|
78 |
|
---|
79 | ~DummyWindowForTaskbarButton()
|
---|
80 | {
|
---|
81 | }
|
---|
82 | private:
|
---|
83 | void OnActivate(UINT state, BOOL /*minimized*/, HWND /*hwndOther*/)
|
---|
84 | {
|
---|
85 | if (state == WA_ACTIVE)
|
---|
86 | {
|
---|
87 | if (ActiveBasic::IDE::Program::mainFrame.IsIconic())
|
---|
88 | {
|
---|
89 | ActiveBasic::IDE::Program::mainFrame.ShowWindow(SW_RESTORE);
|
---|
90 | }
|
---|
91 | SetForegroundWindow(ActiveBasic::IDE::Program::mainFrame);
|
---|
92 | ActiveBasic::IDE::Program::mainFrame.MDIActivate(wndTarget);
|
---|
93 | wndTarget.Invalidate(FALSE);
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 | class BitmapMemoryDC : public WTL::CDC, boost::noncopyable
|
---|
98 | {
|
---|
99 | public:
|
---|
100 | explicit BitmapMemoryDC(HBITMAP hbmp) :
|
---|
101 | WTL::CDC(::CreateCompatibleDC(0)),
|
---|
102 | bmp(hbmp),
|
---|
103 | hbmpOld(SelectBitmap(bmp))
|
---|
104 | {
|
---|
105 | }
|
---|
106 | BitmapMemoryDC(int width, int height, void*& bits) :
|
---|
107 | WTL::CDC(::CreateCompatibleDC(0)),
|
---|
108 | bmp(CreateDIBSection32(m_hDC, width, height, bits)),
|
---|
109 | hbmpOld(SelectBitmap(bmp))
|
---|
110 | {
|
---|
111 | }
|
---|
112 | ~BitmapMemoryDC()
|
---|
113 | {
|
---|
114 | SelectBitmap(hbmpOld); // この後、CDCとbmpのデストラクタでそれぞれDeleteDCとDeleteObjectがなされる。
|
---|
115 | }
|
---|
116 | WTL::CBitmap& GetBitmap()
|
---|
117 | {
|
---|
118 | return bmp;
|
---|
119 | }
|
---|
120 | private:
|
---|
121 | WTL::CBitmap bmp;
|
---|
122 | HBITMAP hbmpOld;
|
---|
123 | };
|
---|
124 |
|
---|
125 | LRESULT OnDwmSendIconicThumnail(UINT, WPARAM, LPARAM lp)
|
---|
126 | {
|
---|
127 | HRESULT hr = SetIconicThumbnail(HIWORD(lp), LOWORD(lp));
|
---|
128 | return 0;
|
---|
129 | }
|
---|
130 |
|
---|
131 | LRESULT OnDwmSendIconicLivePreviewBitmap(UINT, WPARAM, LPARAM)
|
---|
132 | {
|
---|
133 | HRESULT hr = SetIconicLivePreviewBitmap();
|
---|
134 | return 0;
|
---|
135 | }
|
---|
136 |
|
---|
137 | HRESULT SetIconicThumbnail(int maximumWidth, int maximumHeight)
|
---|
138 | {
|
---|
139 | int widthBmp, heightBmp;
|
---|
140 | BitmapMemoryDC dcSrc(CreateBitmap(widthBmp, heightBmp));
|
---|
141 | if (dcSrc)
|
---|
142 | {
|
---|
143 | int width, height; // dcSrcの縦横比に合わせて縮小する
|
---|
144 | if (widthBmp * maximumHeight > maximumWidth * heightBmp) // (widthBmp / heightBmp > maximumWidth / maximumHeight)
|
---|
145 | {
|
---|
146 | width = maximumWidth;
|
---|
147 | height = heightBmp * maximumWidth / widthBmp;
|
---|
148 | }
|
---|
149 | else
|
---|
150 | {
|
---|
151 | height = maximumHeight;
|
---|
152 | width = widthBmp * maximumHeight / heightBmp;
|
---|
153 | }
|
---|
154 | void* pvBits;
|
---|
155 | BitmapMemoryDC dc(width, height, pvBits);
|
---|
156 | if (dc)
|
---|
157 | {
|
---|
158 | StretchBlt(dc, 0, 0, width, height, dcSrc, 0, 0, widthBmp, heightBmp, SRCCOPY);
|
---|
159 | return DwmSetIconicThumbnail(*this, dc.GetBitmap(), DWM_SIT_DISPLAYFRAME);
|
---|
160 | }
|
---|
161 | }
|
---|
162 | return HRESULT_FROM_WIN32(GetLastError());
|
---|
163 | }
|
---|
164 |
|
---|
165 | HRESULT SetIconicLivePreviewBitmap()
|
---|
166 | {
|
---|
167 | int w, h;
|
---|
168 | WTL::CBitmap bmp(CreateBitmap(w, h));
|
---|
169 | if (bmp)
|
---|
170 | {
|
---|
171 | POINT pt = {};
|
---|
172 | wndTarget.MapWindowPoints(hOwner, &pt, 1);
|
---|
173 | pt.y += GetSystemMetrics(SM_CYMENU);
|
---|
174 | return DwmSetIconicLivePreviewBitmap(*this, bmp, &pt, wndTarget.IsZoomed() ? 0 : DWM_SIT_DISPLAYFRAME);
|
---|
175 | }
|
---|
176 | return HRESULT_FROM_WIN32(GetLastError());
|
---|
177 | }
|
---|
178 |
|
---|
179 | static void SetAlpha(DWORD& pixel)
|
---|
180 | {
|
---|
181 | pixel |= 0xff000000;
|
---|
182 | }
|
---|
183 |
|
---|
184 | HBITMAP CreateBitmap(int& width, int& height)
|
---|
185 | {
|
---|
186 | RECT rcClient;
|
---|
187 | wndTarget.GetClientRect(&rcClient);
|
---|
188 | void* pvBits;
|
---|
189 | BitmapMemoryDC dc(rcClient.right, rcClient.bottom, pvBits);
|
---|
190 | if (dc)
|
---|
191 | {
|
---|
192 | int wndNum = GetWndNum(wndTarget);
|
---|
193 | if (wndNum != -1)
|
---|
194 | {
|
---|
195 | CPoint origin(0, 0);
|
---|
196 | wndTarget.ClientToScreen( &origin );
|
---|
197 | CRect rcWindow;
|
---|
198 | wndTarget.GetWindowRect( rcWindow );
|
---|
199 | origin -= rcWindow.TopLeft();
|
---|
200 | dc.SetWindowOrg( origin ); // クライアント領域の(0, 0)がビットマップの(0, 0)になるよう合わせる
|
---|
201 | wndTarget.Print( dc, PRF_CHECKVISIBLE | PRF_ERASEBKGND | PRF_CHILDREN | PRF_CLIENT );
|
---|
202 | width = rcClient.right;
|
---|
203 | height = rcClient.bottom;
|
---|
204 | DWORD* pdwBits = static_cast<DWORD*>(pvBits);
|
---|
205 | std::for_each(pdwBits, pdwBits + width * height, SetAlpha);
|
---|
206 | return dc.GetBitmap().Detach();
|
---|
207 | }
|
---|
208 | }
|
---|
209 | return 0;
|
---|
210 | }
|
---|
211 | // 32ビットトップダウンのDIBセクションを作る補助
|
---|
212 | static HBITMAP CreateDIBSection32(HDC hdc, int width, int height, void*& pb)
|
---|
213 | {
|
---|
214 | BITMAPINFO bi;
|
---|
215 | ZeroMemory(&bi.bmiHeader, sizeof bi.bmiHeader);
|
---|
216 | bi.bmiHeader.biSize = sizeof bi.bmiHeader;
|
---|
217 | bi.bmiHeader.biWidth = width;
|
---|
218 | bi.bmiHeader.biHeight = -height; // トップダウンDIBにする必要があるらしい
|
---|
219 | bi.bmiHeader.biPlanes = 1;
|
---|
220 | bi.bmiHeader.biBitCount = 32;
|
---|
221 | return CreateDIBSection(hdc, &bi, DIB_RGB_COLORS, &pb, 0, 0);
|
---|
222 | }
|
---|
223 |
|
---|
224 | CWindow wndTarget;
|
---|
225 | };
|
---|
226 |
|
---|
227 | class TaskbarList
|
---|
228 | {
|
---|
229 | typedef boost::shared_ptr<DummyWindowForTaskbarButton> DummyWindowForTaskbarButtonPtr;
|
---|
230 | typedef std::map<HWND, DummyWindowForTaskbarButtonPtr> WindowMap;
|
---|
231 | public:
|
---|
232 | TaskbarList(HWND hwndFrame) :
|
---|
233 | wndFrame(hwndFrame)
|
---|
234 | {
|
---|
235 | HRESULT hr = taskbarList.CoCreateInstance( CLSID_TaskbarList );
|
---|
236 | if ( FAILED( hr ) ) {
|
---|
237 | return;
|
---|
238 | }
|
---|
239 | HRESULT hr2 = taskbarList->HrInit();
|
---|
240 | if ( FAILED( hr2 ) ) {
|
---|
241 | taskbarList.Release();
|
---|
242 | return;
|
---|
243 | }
|
---|
244 | }
|
---|
245 |
|
---|
246 | void RegisterTab(HWND hwndChild, const char* title)
|
---|
247 | {
|
---|
248 | assert( hwndChild );
|
---|
249 | if (taskbarList)
|
---|
250 | {
|
---|
251 | assert( windowMap.find(hwndChild) == windowMap.end() );
|
---|
252 | DummyWindowForTaskbarButtonPtr p(new DummyWindowForTaskbarButton(hwndChild, title));
|
---|
253 | windowMap.insert(std::make_pair(hwndChild, p));
|
---|
254 | //タスクバーボタンに追加
|
---|
255 | HRESULT hr = taskbarList->RegisterTab(*p, wndFrame);
|
---|
256 | }
|
---|
257 | }
|
---|
258 |
|
---|
259 | void RegisterTab(HWND hwndChild)
|
---|
260 | {
|
---|
261 | ATL::CWindow wnd = hwndChild;
|
---|
262 | ATL::CString title;
|
---|
263 | wnd.GetWindowText(title);
|
---|
264 | RegisterTab(hwndChild, title);
|
---|
265 | }
|
---|
266 |
|
---|
267 | void UnregisterTab(HWND hwndChild)
|
---|
268 | {
|
---|
269 | if (taskbarList)
|
---|
270 | {
|
---|
271 | WindowMap::iterator it = windowMap.find(hwndChild);
|
---|
272 | assert( it != windowMap.end() );
|
---|
273 | HRESULT hr = taskbarList->UnregisterTab(*it->second);
|
---|
274 | it->second->DestroyWindow();
|
---|
275 | windowMap.erase( it );
|
---|
276 | }
|
---|
277 | }
|
---|
278 |
|
---|
279 | void InvalidateIconicBitmaps(HWND hwndChild)
|
---|
280 | {
|
---|
281 | DwmInvalidateIconicBitmaps(*mapAt(hwndChild));
|
---|
282 | }
|
---|
283 |
|
---|
284 | void SetTabActivate(HWND hwndChild)
|
---|
285 | {
|
---|
286 | if (taskbarList)
|
---|
287 | {
|
---|
288 | taskbarList->SetTabActive(*mapAt(hwndChild), wndFrame, 0);
|
---|
289 | }
|
---|
290 | }
|
---|
291 |
|
---|
292 | void SetTabOrder( HWND hwndChild, HWND hwndInsertBefore )
|
---|
293 | {
|
---|
294 | if (taskbarList)
|
---|
295 | {
|
---|
296 | taskbarList->SetTabOrder(*mapAt(hwndChild),
|
---|
297 | hwndInsertBefore
|
---|
298 | ? static_cast<HWND>(*mapAt(hwndInsertBefore))
|
---|
299 | : 0);
|
---|
300 | }
|
---|
301 | }
|
---|
302 | private:
|
---|
303 | DummyWindowForTaskbarButtonPtr mapAt(HWND hwndChild)
|
---|
304 | {
|
---|
305 | DummyWindowForTaskbarButtonPtr p = windowMap[hwndChild];
|
---|
306 | assert(p);
|
---|
307 | return p;
|
---|
308 | }
|
---|
309 | CWindow wndFrame;
|
---|
310 | ATL::CComPtr<ITaskbarList3> taskbarList;
|
---|
311 | WindowMap windowMap;
|
---|
312 | };
|
---|
313 |
|
---|
314 | MainFrame::MainFrame() :
|
---|
315 | TaskbarButtonCreated( RegisterWindowMessage( TEXT("TaskbarButtonCreated") ) )
|
---|
316 | {
|
---|
317 | if ( TaskbarButtonCreated != 0 )
|
---|
318 | {
|
---|
319 | typedef BOOL WINAPI CWMF(UINT, DWORD);
|
---|
320 | HMODULE hmodUser = GetModuleHandle( TEXT("user32.dll") );
|
---|
321 | assert( hmodUser != 0 );
|
---|
322 | if ( CWMF* pcwmf = reinterpret_cast<CWMF*>( GetProcAddress( hmodUser, "ChangeWindowMessageFilter" ) ) )
|
---|
323 | {
|
---|
324 | pcwmf(TaskbarButtonCreated, MSGFLT_ADD);
|
---|
325 | pcwmf(WM_DWMSENDICONICTHUMBNAIL, MSGFLT_ADD);
|
---|
326 | pcwmf(WM_DWMSENDICONICLIVEPREVIEWBITMAP, MSGFLT_ADD);
|
---|
327 | }
|
---|
328 | }
|
---|
329 | }
|
---|
330 |
|
---|
331 | void MainFrame::Resized()
|
---|
332 | {
|
---|
333 | int width_owner,height_owner;
|
---|
334 | int height_Rebar;
|
---|
335 | int height_MdiClient;
|
---|
336 | RECT rect,StatusRect,RebarRect;
|
---|
337 |
|
---|
338 | this->GetClientRect( &rect );
|
---|
339 | width_owner=rect.right;
|
---|
340 | height_owner=rect.bottom;
|
---|
341 |
|
---|
342 | //Rebar
|
---|
343 | SendMessage(pobj_Rebar->hRebar,WM_SIZE,0,MAKELONG(width_owner,height_owner));
|
---|
344 | ::UpdateWindow(pobj_Rebar->hRebar);
|
---|
345 |
|
---|
346 | //Status bar
|
---|
347 | #define STATUSBAR_PARTS_NUM 5
|
---|
348 | int sb_size[STATUSBAR_PARTS_NUM];
|
---|
349 | sb_size[0]=width_owner-340;
|
---|
350 | sb_size[1]=width_owner-220;
|
---|
351 | sb_size[2]=width_owner-120;
|
---|
352 | sb_size[3]=width_owner-50;
|
---|
353 | sb_size[4]=width_owner;
|
---|
354 | extern HWND hStatusBar;
|
---|
355 | ::SendMessage(hStatusBar,SB_SETPARTS,STATUSBAR_PARTS_NUM,(LPARAM)sb_size);
|
---|
356 | ::SendMessage(hStatusBar,WM_SIZE,0,MAKELONG(width_owner,height_owner));
|
---|
357 | ::UpdateWindow(hStatusBar);
|
---|
358 |
|
---|
359 | //Status bar
|
---|
360 | int height_Statusbar;
|
---|
361 | SendMessage(hStatusBar,SB_GETRECT,0,(LPARAM)&StatusRect);
|
---|
362 | height_Statusbar=StatusRect.bottom;
|
---|
363 |
|
---|
364 | ::GetWindowRect(pobj_Rebar->hRebar,&RebarRect);
|
---|
365 | height_Rebar=RebarRect.bottom-RebarRect.top+2;
|
---|
366 |
|
---|
367 | int height_dv; //Width of Debugger View
|
---|
368 | int height_cv; //Width of Compiler View
|
---|
369 | height_dv=0;
|
---|
370 | height_cv=0;
|
---|
371 | #ifndef THETEXT
|
---|
372 | extern BOOL bClipCompileView;
|
---|
373 | if(bClipCompileView){
|
---|
374 | if(pobj_Debugger->IsDebuggerView()){
|
---|
375 | //デバッガビューが表示されているとき
|
---|
376 | height_dv=pobj_nv->height_ClipDebuggerView+LEVER_THICK;
|
---|
377 | }
|
---|
378 |
|
---|
379 | extern HWND hCompileView;
|
---|
380 | if(hCompileView){
|
---|
381 | //コンパイラビューが表示されているとき
|
---|
382 | height_cv=pobj_nv->height_ClipCompileView+LEVER_THICK;
|
---|
383 | }
|
---|
384 | }
|
---|
385 | #endif
|
---|
386 |
|
---|
387 | int width_pjv=0; //Width of Project View
|
---|
388 | if(pobj_nv->bClipProjectView){
|
---|
389 | extern HWND hProjectView;
|
---|
390 | if(::IsWindowVisible(hProjectView)){
|
---|
391 | //プロジェクトビューが表示されているとき
|
---|
392 | width_pjv=pobj_nv->width_ClipProjectView+LEVER_THICK;
|
---|
393 | }
|
---|
394 | }
|
---|
395 |
|
---|
396 | int width_SideWeb=0;
|
---|
397 | if( pobj_SideWeb )
|
---|
398 | {
|
---|
399 | if(pobj_SideWeb->bShow){
|
---|
400 | width_SideWeb=pobj_nv->width_WebSearchView+LEVER_THICK;
|
---|
401 | }
|
---|
402 | }
|
---|
403 |
|
---|
404 | //MDIクライアントの高さ
|
---|
405 | height_MdiClient=height_owner-(
|
---|
406 | height_Rebar+
|
---|
407 | height_dv+
|
---|
408 | height_cv+
|
---|
409 | height_Statusbar
|
---|
410 | );
|
---|
411 |
|
---|
412 | //タブコントロール
|
---|
413 | int tab_height;
|
---|
414 | if(TabCtrl_GetItemCount(pobj_MainTab->hTab)==0) tab_height=0;
|
---|
415 | else{
|
---|
416 | RECT rc;
|
---|
417 | TabCtrl_GetItemRect(pobj_MainTab->hTab,0,&rc);
|
---|
418 | tab_height=rc.bottom-rc.top;
|
---|
419 | }
|
---|
420 | ::MoveWindow(pobj_MainTab->hTab,
|
---|
421 | width_pjv,
|
---|
422 | height_Rebar,
|
---|
423 | width_owner-width_pjv-width_SideWeb,
|
---|
424 | tab_height,
|
---|
425 | 1);
|
---|
426 |
|
---|
427 | //MDIクライアント
|
---|
428 | ::MoveWindow(
|
---|
429 | hClient,
|
---|
430 | width_pjv,
|
---|
431 | height_Rebar+tab_height,
|
---|
432 | width_owner-width_pjv-width_SideWeb,
|
---|
433 | height_MdiClient-tab_height,
|
---|
434 | 1
|
---|
435 | );
|
---|
436 |
|
---|
437 | if( pobj_SideWeb )
|
---|
438 | {
|
---|
439 | if(pobj_SideWeb->bShow){
|
---|
440 | //SideWeb
|
---|
441 | pobj_SideWeb->resize(
|
---|
442 | width_owner - pobj_nv->width_WebSearchView,
|
---|
443 | height_Rebar,
|
---|
444 | pobj_nv->width_WebSearchView,
|
---|
445 | height_MdiClient);
|
---|
446 | }
|
---|
447 | else pobj_SideWeb->resize(0,0,0,0);
|
---|
448 | }
|
---|
449 |
|
---|
450 | if(width_pjv){
|
---|
451 | //プロジェクトビュー
|
---|
452 | extern HWND hProjectView;
|
---|
453 | ::MoveWindow(hProjectView,
|
---|
454 | 0,
|
---|
455 | height_Rebar,
|
---|
456 | pobj_nv->width_ClipProjectView,
|
---|
457 | height_MdiClient,
|
---|
458 | 1);
|
---|
459 | ::InvalidateRect(hProjectView,NULL,0);
|
---|
460 | }
|
---|
461 |
|
---|
462 | if(height_dv){
|
---|
463 | #ifndef THETEXT
|
---|
464 | //デバッガビュー
|
---|
465 | pobj_Debugger->resize(
|
---|
466 | 0,
|
---|
467 | height_Rebar+height_MdiClient+LEVER_THICK,
|
---|
468 | width_owner,
|
---|
469 | pobj_nv->height_ClipDebuggerView);
|
---|
470 | #endif
|
---|
471 | }
|
---|
472 | if(height_cv){
|
---|
473 | //コンパイラビュー
|
---|
474 | extern HWND hCompileView;
|
---|
475 | ::MoveWindow(hCompileView,
|
---|
476 | 0,
|
---|
477 | height_Rebar+height_MdiClient+height_dv+LEVER_THICK,
|
---|
478 | width_owner,
|
---|
479 | pobj_nv->height_ClipCompileView,
|
---|
480 | 1);
|
---|
481 | }
|
---|
482 | }
|
---|
483 |
|
---|
484 | void MainFrame::OpenWebBrowser( const std::string &url )
|
---|
485 | {
|
---|
486 | ShellExecute(m_hWnd,"open",url.c_str(),"",NULL,SW_SHOWNORMAL);
|
---|
487 | }
|
---|
488 |
|
---|
489 | void MainFrame::OpenExplorer( const std::string &filepath )
|
---|
490 | {
|
---|
491 | CreateProcessWithStdHandle( "explorer", "/select,\"" + filepath + "\"" );
|
---|
492 | }
|
---|
493 |
|
---|
494 | ::LRESULT MainFrame::OnCreate( ::CREATESTRUCT const* )
|
---|
495 | {
|
---|
496 | // ウィンドウエリアマネージャに親ウィンドウを登録
|
---|
497 | wam.SetParentWnd( m_hWnd );
|
---|
498 |
|
---|
499 | RECT rect;
|
---|
500 | GetClientRect( &rect );
|
---|
501 |
|
---|
502 | // MDIベースを作成
|
---|
503 | // フレームウィンドウのビューウィンドウを作成
|
---|
504 | int indexOfWindowSubMenu = pobj_MainMenu->FindSubMenuIndex( "ウィンドウ(&W)" );
|
---|
505 | HMENU hWindowSubMenu = NULL;
|
---|
506 | if( indexOfWindowSubMenu != -1 )
|
---|
507 | {
|
---|
508 | hWindowSubMenu = GetSubMenu( pobj_MainMenu->hMenu, indexOfWindowSubMenu );
|
---|
509 | }
|
---|
510 | CreateMDIClient( hWindowSubMenu );
|
---|
511 | wam.AddMdiClientWindow( m_hWndClient );
|
---|
512 |
|
---|
513 | // TODO: hClientを廃止し、m_hWndClientに統一すること
|
---|
514 | extern HWND hClient;
|
---|
515 | hClient = m_hWndClient;
|
---|
516 |
|
---|
517 | // メッセージループにメッセージフィルタとアイドルハンドラを追加
|
---|
518 | CMessageLoop* pLoop = Program::_Module.GetMessageLoop();
|
---|
519 | pLoop->AddMessageFilter(this);
|
---|
520 | pLoop->AddIdleHandler(this);
|
---|
521 |
|
---|
522 |
|
---|
523 |
|
---|
524 |
|
---|
525 |
|
---|
526 | extern HWND hOwner;
|
---|
527 | hOwner = m_hWnd;
|
---|
528 | extern WNDPROC oldMainFrameWndProc;
|
---|
529 | oldMainFrameWndProc = (WNDPROC)::SetWindowLongPtr( hOwner, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(WindowFunc) );
|
---|
530 |
|
---|
531 | SetupWindow(hOwner);
|
---|
532 |
|
---|
533 | //テキストエディタフォント設定
|
---|
534 | ResetTextEditFont(hOwner);
|
---|
535 |
|
---|
536 | return 0;
|
---|
537 | }
|
---|
538 |
|
---|
539 | void MainFrame::OnSize(UINT nType, CSize size)
|
---|
540 | {
|
---|
541 | this->Resized();
|
---|
542 | }
|
---|
543 |
|
---|
544 | BOOL MainFrame::OnQueryEndSession(UINT nSource, UINT uLogOff)
|
---|
545 | {
|
---|
546 | OnClose();
|
---|
547 |
|
---|
548 | return TRUE;
|
---|
549 | }
|
---|
550 |
|
---|
551 | void MainFrame::OnClose()
|
---|
552 | {
|
---|
553 | extern BOOL bSearchingClasses;
|
---|
554 | if(bSearchingClasses){
|
---|
555 | pobj_ClassTreeView->bCloseSwitch=1;
|
---|
556 | return;
|
---|
557 | }
|
---|
558 |
|
---|
559 | //コンパイラビューを閉じる
|
---|
560 | extern HWND hCompileView;
|
---|
561 | if( hCompileView && ::IsWindow( hCompileView ) )
|
---|
562 | {
|
---|
563 | SendMessage(hCompileView,WM_COMMAND,IDCANCEL,0);
|
---|
564 | }
|
---|
565 |
|
---|
566 | //次回起動時にMDIウィンドウを最大化させるかを判定
|
---|
567 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
568 | pobj_nv->bMDIZoomed=::IsZoomed(hChild);
|
---|
569 |
|
---|
570 | //プロジェクトを閉じる
|
---|
571 | if( projectInfo.IsOpened() ){
|
---|
572 | if(!projectInfo.Close()) return;
|
---|
573 | }
|
---|
574 |
|
---|
575 | //MDIウィンドウの保存確認
|
---|
576 | hChild=::GetWindow(hClient,GW_CHILD);
|
---|
577 | while(hChild){
|
---|
578 | if(!DocumentModifyCheck(hChild)) return;
|
---|
579 | hChild=::GetNextWindow(hChild,GW_HWNDNEXT);
|
---|
580 | }
|
---|
581 |
|
---|
582 |
|
---|
583 | KillTimer(ID_TIMER_BACKUP);
|
---|
584 |
|
---|
585 |
|
---|
586 | //ProjectViewの位置を保存、ProjectViewを破棄
|
---|
587 | extern HWND hProjectView;
|
---|
588 | extern HWND hProjectView_ToolWindow;
|
---|
589 | ::GetWindowRect(hProjectView_ToolWindow,&pobj_nv->rectProjectView);
|
---|
590 | ::DestroyWindow(hProjectView);
|
---|
591 | ::DestroyWindow(hProjectView_ToolWindow);
|
---|
592 |
|
---|
593 | //Rebarの位置を保存、Rebarを破棄
|
---|
594 | delete pobj_Rebar;
|
---|
595 | pobj_Rebar=0;
|
---|
596 |
|
---|
597 | //タブコントロールを破棄
|
---|
598 | delete pobj_MainTab;
|
---|
599 | pobj_MainTab=0;
|
---|
600 |
|
---|
601 | //SideWebを破棄
|
---|
602 | delete pobj_SideWeb;
|
---|
603 | pobj_SideWeb=0;
|
---|
604 |
|
---|
605 | //メインウィンドウの最大化有無、座標を保存
|
---|
606 | if(IsZoomed()) pobj_nv->bWindowMax=1;
|
---|
607 | else if(!IsIconic()){
|
---|
608 | pobj_nv->bWindowMax=0;
|
---|
609 | GetWindowRect(&pobj_nv->StartupWindowRect);
|
---|
610 | }
|
---|
611 |
|
---|
612 | hChild=::GetWindow(hClient,GW_CHILD);
|
---|
613 | while(hChild){
|
---|
614 | CloseDocWindow(GetWndNum(hChild));
|
---|
615 | ::DestroyWindow(hChild);
|
---|
616 | hChild=::GetWindow(hClient,GW_CHILD);
|
---|
617 | }
|
---|
618 |
|
---|
619 | EndProjectEditor(); //ProjectEditorの情報を保存
|
---|
620 |
|
---|
621 | //エディタ用フォントを破棄
|
---|
622 | extern HFONT hFont_TextEdit,hFont_HyperLink_TextEdit;
|
---|
623 | if(hFont_TextEdit) DeleteObject(hFont_TextEdit);
|
---|
624 | if(hFont_HyperLink_TextEdit) DeleteObject(hFont_HyperLink_TextEdit);
|
---|
625 |
|
---|
626 | DestroyWindow();
|
---|
627 | }
|
---|
628 | void MainFrame::OnDestroy()
|
---|
629 | {
|
---|
630 | ::PostQuitMessage( 0 );
|
---|
631 | }
|
---|
632 |
|
---|
633 | void backup(void *dummy);
|
---|
634 | void MainFrame::OnTimer( UINT_PTR id )
|
---|
635 | {
|
---|
636 | switch( id )
|
---|
637 | {
|
---|
638 | case ID_TIMER_BACKUP:
|
---|
639 | _beginthread( backup, 0, 0 );
|
---|
640 | break;
|
---|
641 |
|
---|
642 | #ifndef THETEXT
|
---|
643 | case ID_DEBUGSAFTY:
|
---|
644 | {
|
---|
645 | //BasicCompiler.exeが強制終了しているかどうかを検証
|
---|
646 | extern CDebugger *pobj_Debugger;
|
---|
647 | pobj_Debugger->SaftyCheck();
|
---|
648 | break;
|
---|
649 | }
|
---|
650 | #endif
|
---|
651 | }
|
---|
652 | }
|
---|
653 |
|
---|
654 | void ResetState_EditMenu(void);
|
---|
655 | void MainFrame::OnDrawClipboard()
|
---|
656 | {
|
---|
657 | ResetState_EditMenu();
|
---|
658 | }
|
---|
659 |
|
---|
660 | void MenuAdvice(WPARAM msg);
|
---|
661 | void MainFrame::OnMenuSelect( UINT nItemID, UINT nFlags, HMENU menu )
|
---|
662 | {
|
---|
663 | MenuAdvice( nItemID );
|
---|
664 | }
|
---|
665 |
|
---|
666 | void MainFrame::OnInitMenu( HMENU menu )
|
---|
667 | {
|
---|
668 | extern CNonVolatile *pobj_nv;
|
---|
669 | extern CSubMenuEx *pobj_FileHistoryMenu;
|
---|
670 | pobj_nv->pobj_History->ResetFileMenu(pobj_FileHistoryMenu,1);
|
---|
671 | #ifndef THETEXT
|
---|
672 | extern CSubMenuEx *pobj_ProjectHistoryMenu;
|
---|
673 | pobj_nv->pobj_ProjectHistory->ResetFileMenu(pobj_ProjectHistoryMenu,0);
|
---|
674 | #endif
|
---|
675 | }
|
---|
676 |
|
---|
677 | void MainFrame::OnMeasureItem( int nIDCtl, LPMEASUREITEMSTRUCT lpMI )
|
---|
678 | {
|
---|
679 | if(lpMI->CtlType==ODT_MENU){
|
---|
680 | SIZE size;
|
---|
681 | CMenuItemData *pobj_MenuItemData;
|
---|
682 | pobj_MenuItemData=(CMenuItemData *)lpMI->itemData;
|
---|
683 | if(pobj_MenuItemData->pobj_ThisMenu->hMenu==pobj_MainMenu->hMenu){
|
---|
684 | //メインメニューの親アイテム
|
---|
685 | pobj_MainMenu->GetItemSize(pobj_MenuItemData->item_index,&size);
|
---|
686 | lpMI->itemWidth = size.cx;
|
---|
687 | lpMI->itemHeight = size.cy;
|
---|
688 | }
|
---|
689 | else{
|
---|
690 | //メインメニューにぶらさがるサブメニュー
|
---|
691 | pobj_MenuItemData->pobj_ThisMenu->GetItemSize(pobj_MenuItemData->item_index,&size);
|
---|
692 | lpMI->itemWidth = size.cx;
|
---|
693 | lpMI->itemHeight = size.cy;
|
---|
694 | }
|
---|
695 | }
|
---|
696 | }
|
---|
697 |
|
---|
698 | void MainFrame::OnDrawItem( int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct )
|
---|
699 | {
|
---|
700 | if(lpDrawItemStruct->CtlType==ODT_MENU){
|
---|
701 | if(!pobj_MainMenu) return;
|
---|
702 |
|
---|
703 | CMenuItemData *pobj_MenuItemData;
|
---|
704 | pobj_MenuItemData=(CMenuItemData *)lpDrawItemStruct->itemData;
|
---|
705 | if(pobj_MainMenu->hMenu==pobj_MenuItemData->pobj_ThisMenu->hMenu){
|
---|
706 | //メインメニューの親アイテム
|
---|
707 | pobj_MainMenu->OwnerDrawMenu(lpDrawItemStruct->hDC,
|
---|
708 | &lpDrawItemStruct->rcItem,
|
---|
709 | (lpDrawItemStruct->itemState&ODS_SELECTED)!=0,
|
---|
710 | pobj_MenuItemData->item_index);
|
---|
711 | }
|
---|
712 | else{
|
---|
713 | //メインメニューにぶらさがるサブメニュー
|
---|
714 | pobj_MainMenu->OwnerDrawSubMenu(pobj_MenuItemData->pobj_ThisMenu->hMenu,
|
---|
715 | lpDrawItemStruct->hDC,
|
---|
716 | &lpDrawItemStruct->rcItem,
|
---|
717 | (lpDrawItemStruct->itemState&ODS_SELECTED)!=0,
|
---|
718 | pobj_MenuItemData->item_index);
|
---|
719 | }
|
---|
720 | }
|
---|
721 | }
|
---|
722 |
|
---|
723 | LRESULT MainFrame::OnNotify( int idCtrl, LPNMHDR pnmh )
|
---|
724 | {
|
---|
725 | NMPGCALCSIZE *lpCalcSize;
|
---|
726 | NMPGSCROLL *lpScroll;
|
---|
727 |
|
---|
728 | if(!pnmh) return 0;
|
---|
729 | LPTOOLTIPTEXT TipText=(LPTOOLTIPTEXT)pnmh;
|
---|
730 | if(TipText->hdr.code==TTN_NEEDTEXT) ShowToolTipText(TipText);
|
---|
731 |
|
---|
732 | extern HWND hStandardToolbarPager;
|
---|
733 | extern HWND hDebuggerToolbarPager;
|
---|
734 | if(pobj_Rebar){
|
---|
735 | //レバーオブジェクトが存在するとき
|
---|
736 | if(pnmh->hwndFrom==pobj_Rebar->hRebar&&pnmh->code==RBN_HEIGHTCHANGE){
|
---|
737 | this->Resized();
|
---|
738 | return 0;
|
---|
739 | }
|
---|
740 | }
|
---|
741 | if(pnmh->hwndFrom==hStandardToolbarPager){
|
---|
742 | if(pnmh->code==PGN_CALCSIZE){
|
---|
743 | lpCalcSize=(LPNMPGCALCSIZE)pnmh;
|
---|
744 | if(lpCalcSize->dwFlag==PGF_CALCWIDTH)
|
---|
745 | lpCalcSize->iWidth=BMPNUM_STANDARDTOOLBAR*23+SEPNUM_STANDARDTOOLBAR*8;
|
---|
746 | }
|
---|
747 | else if(pnmh->code==PGN_SCROLL){
|
---|
748 | lpScroll=(LPNMPGSCROLL)pnmh;
|
---|
749 | lpScroll->iScroll=20;
|
---|
750 | }
|
---|
751 | }
|
---|
752 | else if(pnmh->hwndFrom==hDebuggerToolbarPager){
|
---|
753 | if(pnmh->code==PGN_CALCSIZE){
|
---|
754 | lpCalcSize=(LPNMPGCALCSIZE)pnmh;
|
---|
755 | if(lpCalcSize->dwFlag==PGF_CALCWIDTH)
|
---|
756 | lpCalcSize->iWidth=BMPNUM_DEBUGGERTOOLBAR*23+SEPNUM_DEBUGGERTOOLBAR*8;
|
---|
757 | }
|
---|
758 | else if(pnmh->code==PGN_SCROLL){
|
---|
759 | lpScroll=(LPNMPGSCROLL)pnmh;
|
---|
760 | lpScroll->iScroll=20;
|
---|
761 | }
|
---|
762 | }
|
---|
763 |
|
---|
764 | if(pobj_MainTab){
|
---|
765 | if(pnmh->hwndFrom==pobj_MainTab->hTab){
|
---|
766 | if(pnmh->code==TCN_SELCHANGE)
|
---|
767 | pobj_MainTab->SelChangeEvent();
|
---|
768 |
|
---|
769 | if(pnmh->code==NM_RCLICK){
|
---|
770 |
|
---|
771 | TCHITTESTINFO tcHitTest;
|
---|
772 | GetCursorPos(&tcHitTest.pt);
|
---|
773 | ::ScreenToClient(pobj_MainTab->hTab,&tcHitTest.pt);
|
---|
774 | int index = TabCtrl_HitTest(pobj_MainTab->hTab,&tcHitTest);
|
---|
775 | if( index == -1 ) return 0;
|
---|
776 |
|
---|
777 | TabCtrl_SetCurSel(pobj_MainTab->hTab,index);
|
---|
778 |
|
---|
779 | pobj_MainTab->SelChangeEvent();
|
---|
780 |
|
---|
781 |
|
---|
782 | /////////////////////
|
---|
783 | // メニューを表示
|
---|
784 | /////////////////////
|
---|
785 |
|
---|
786 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
787 | int WndNum=GetWndNum(hChild);
|
---|
788 |
|
---|
789 | //保存コマンドの文字列をセット
|
---|
790 | char temporary[1024], temp2[1024];
|
---|
791 | MENUITEMINFO mii;
|
---|
792 | mii.cbSize=sizeof(MENUITEMINFO);
|
---|
793 | mii.fMask=MIIM_TYPE;
|
---|
794 | mii.dwTypeData=temporary;
|
---|
795 | mii.fType=MFT_STRING;
|
---|
796 | if(!MdiInfo[WndNum]->path.empty()){
|
---|
797 | _splitpath(MdiInfo[WndNum]->path.c_str(),NULL,NULL,temporary,temp2);
|
---|
798 | lstrcat(temporary,temp2);
|
---|
799 | lstrcat(temporary," を保存(&S)");
|
---|
800 | }
|
---|
801 | else{
|
---|
802 | lstrcpy(temporary,"保存(&S)");
|
---|
803 | }
|
---|
804 | extern HMENU hTabMenu;
|
---|
805 | SetMenuItemInfo(hTabMenu,IDM_SAVE,FALSE,&mii);
|
---|
806 |
|
---|
807 | /*「絶対パスをコピー」「フォルダを開く」「ファイルを削除」
|
---|
808 | コマンドを場合によって無効化にする */
|
---|
809 | if(!MdiInfo[WndNum]->path.empty()){
|
---|
810 | EnableMenuItem(hTabMenu,IDM_PATH_COPY,MF_BYCOMMAND|MF_ENABLED);
|
---|
811 | EnableMenuItem(hTabMenu,IDM_FOLDER_OPEN,MF_BYCOMMAND|MF_ENABLED);
|
---|
812 | EnableMenuItem(hTabMenu,IDM_DELETE_FILE,MF_BYCOMMAND|MF_ENABLED);
|
---|
813 | }
|
---|
814 | else{
|
---|
815 | EnableMenuItem(hTabMenu,IDM_PATH_COPY,MF_BYCOMMAND|MF_GRAYED);
|
---|
816 | EnableMenuItem(hTabMenu,IDM_FOLDER_OPEN,MF_BYCOMMAND|MF_GRAYED);
|
---|
817 | EnableMenuItem(hTabMenu,IDM_DELETE_FILE,MF_BYCOMMAND|MF_GRAYED);
|
---|
818 | }
|
---|
819 |
|
---|
820 | POINT MousePos;
|
---|
821 | GetCursorPos(&MousePos);
|
---|
822 | TrackPopupMenu(hTabMenu,TPM_LEFTALIGN|TPM_RIGHTBUTTON,MousePos.x,MousePos.y,0,hOwner,NULL);
|
---|
823 | }
|
---|
824 | }
|
---|
825 | }
|
---|
826 | if(pobj_SideWeb){
|
---|
827 | if(pnmh->hwndFrom==pobj_SideWeb->hTab&&pnmh->code==TCN_SELCHANGE){
|
---|
828 | pobj_SideWeb->SelChangeEvent();
|
---|
829 | }
|
---|
830 | }
|
---|
831 |
|
---|
832 | return 0;
|
---|
833 | }
|
---|
834 |
|
---|
835 | void MainFrame::OnDropFiles( HDROP hDropInfo )
|
---|
836 | {
|
---|
837 | int max = DragQueryFile(hDropInfo,static_cast<DWORD>(-1),0,0);
|
---|
838 | for(int i=0;i<max;i++){
|
---|
839 | char temporary[1024];
|
---|
840 | DragQueryFile(hDropInfo,i,temporary,MAX_PATH);
|
---|
841 | OpenFileWithExtension(temporary);
|
---|
842 | }
|
---|
843 | DragFinish(hDropInfo);
|
---|
844 | }
|
---|
845 |
|
---|
846 | void MainFrame::OnPaint( HDC )
|
---|
847 | {
|
---|
848 | WTL::CPaintDC dc( m_hWnd );
|
---|
849 |
|
---|
850 | RECT rect;
|
---|
851 | this->GetClientRect( &rect );
|
---|
852 |
|
---|
853 | dc.FillRect( &rect, GetSysColorBrush( COLOR_3DFACE ) );
|
---|
854 | }
|
---|
855 |
|
---|
856 | ::LRESULT MainFrame::OnShowSourceLine( ::UINT msg, ::WPARAM wParam, ::LPARAM lParam, ::BOOL& handled )
|
---|
857 | {
|
---|
858 | char temporary[1024];
|
---|
859 |
|
---|
860 | //エラー部分を反転表示
|
---|
861 | DWORD AccBytes;
|
---|
862 | {
|
---|
863 | sprintf(temporary,"%s\\pgm.tmp",ActiveBasic::Common::Environment::GetUserAppDir().c_str());
|
---|
864 | ATL::CHandle fh(CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL));
|
---|
865 | if(fh==INVALID_HANDLE_VALUE){
|
---|
866 | fh.Detach();
|
---|
867 | return 0;
|
---|
868 | }
|
---|
869 | ReadFile(fh,temporary,MAX_PATH,&AccBytes,NULL);
|
---|
870 | }
|
---|
871 | temporary[AccBytes]=0;
|
---|
872 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
873 | int WndNum = -1;
|
---|
874 | while(hChild){
|
---|
875 | WndNum=GetWndNum(hChild);
|
---|
876 | if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
|
---|
877 | if(lstrcmpi(MdiInfo[WndNum]->path.c_str(),temporary)==0) break;
|
---|
878 | }
|
---|
879 | hChild=::GetNextWindow(hChild,GW_HWNDNEXT);
|
---|
880 | }
|
---|
881 | if(!hChild){
|
---|
882 | hChild=OpenFileWithExtension(temporary);
|
---|
883 | WndNum=GetWndNum(hChild);
|
---|
884 | }
|
---|
885 |
|
---|
886 | if(WndNum==-1) return 0;
|
---|
887 |
|
---|
888 | //ウィンドウを最前面に表示
|
---|
889 | ::BringWindowToTop(hChild);
|
---|
890 | ::UpdateWindow(hChild);
|
---|
891 |
|
---|
892 | const char *pTemp=MdiInfo[WndNum]->pMdiTextEdit->buffer;
|
---|
893 |
|
---|
894 | //行の先頭インデックスを取得(取得する行の番号はwParamで渡される)
|
---|
895 | int i,i2;
|
---|
896 | for(i=0,i2=0;;i++){
|
---|
897 | if(i2>=(int)wParam) break;
|
---|
898 | if(pTemp[i]=='\0') break;
|
---|
899 | if(pTemp[i]=='\r'&&pTemp[i+1]=='\n'){
|
---|
900 | i++;
|
---|
901 | i2++;
|
---|
902 | }
|
---|
903 | }
|
---|
904 | POINT pos;
|
---|
905 | pos.x=i;
|
---|
906 |
|
---|
907 | //行の終端インデックスを取得
|
---|
908 | for(;;i++){
|
---|
909 | if(pTemp[i]=='\0') break;
|
---|
910 | if(pTemp[i]=='\r'&&pTemp[i+1]=='\n') break;
|
---|
911 | }
|
---|
912 | pos.y=i;
|
---|
913 |
|
---|
914 | //行を選択する
|
---|
915 | TextEdit_SetSel(WndNum,pos.x,pos.y,TRUE);
|
---|
916 |
|
---|
917 | return 0;
|
---|
918 | }
|
---|
919 |
|
---|
920 | ::LRESULT MainFrame::OnTaskbarButtonCreated( ::UINT msg, ::WPARAM, ::LPARAM )
|
---|
921 | {
|
---|
922 | if ( msg == 0 ) { // 念のため確認
|
---|
923 | return 0;
|
---|
924 | }
|
---|
925 | taskbarList.reset(new TaskbarList(*this));
|
---|
926 | return 0;
|
---|
927 | }
|
---|
928 |
|
---|
929 | void MainFrame::AddChildWindow( HWND hwndChild )
|
---|
930 | {
|
---|
931 | if (taskbarList)
|
---|
932 | {
|
---|
933 | taskbarList->RegisterTab( hwndChild );
|
---|
934 | }
|
---|
935 | }
|
---|
936 |
|
---|
937 | void MainFrame::DeleteChildWindow( HWND hwndChild )
|
---|
938 | {
|
---|
939 | if (taskbarList)
|
---|
940 | {
|
---|
941 | taskbarList->UnregisterTab( hwndChild );
|
---|
942 | }
|
---|
943 | }
|
---|
944 |
|
---|
945 | void MainFrame::ActivateChildWindow( HWND hwndChild )
|
---|
946 | {
|
---|
947 | if (taskbarList)
|
---|
948 | {
|
---|
949 | taskbarList->SetTabActivate( hwndChild );
|
---|
950 | }
|
---|
951 | }
|
---|
952 |
|
---|
953 | void MainFrame::SetTabOrder( HWND hwndChild, HWND hwndInsertBefore )
|
---|
954 | {
|
---|
955 | if (taskbarList)
|
---|
956 | {
|
---|
957 | taskbarList->SetTabOrder( hwndChild, hwndInsertBefore );
|
---|
958 | }
|
---|
959 | }
|
---|
960 |
|
---|
961 | void MainFrame::InvalidateBitmap( HWND hwndChild )
|
---|
962 | {
|
---|
963 | if (taskbarList)
|
---|
964 | {
|
---|
965 | taskbarList->InvalidateIconicBitmaps( hwndChild );
|
---|
966 | }
|
---|
967 | }
|
---|
968 |
|
---|
969 | void MainFrame::OnCmdNew( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
970 | {
|
---|
971 |
|
---|
972 | #ifdef THETEXT
|
---|
973 | NewTextEditWindow(NULL,WNDTYPE_TEXT);
|
---|
974 | return;
|
---|
975 | #else
|
---|
976 | int FileType;
|
---|
977 | BOOL bAddToProject;
|
---|
978 | char temporary[MAX_PATH];
|
---|
979 |
|
---|
980 | FileType = ActiveBasic::Resource::DialogBoxAlt(hResInst, IDD_NEWFILE, hOwner, DlgNewFile);
|
---|
981 | if(FileType==-1) return;
|
---|
982 |
|
---|
983 | if(FileType&0x00008000){
|
---|
984 | bAddToProject=1;
|
---|
985 | FileType&=0x0FFF;
|
---|
986 | extern char NewFileName[MAX_PATH];
|
---|
987 | lstrcpy(temporary,NewFileName);
|
---|
988 | if(!strstr(temporary,".")) lstrcat(temporary,".ab");
|
---|
989 |
|
---|
990 | lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
|
---|
991 | }
|
---|
992 | else bAddToProject=0;
|
---|
993 |
|
---|
994 | switch(FileType){
|
---|
995 | case FT_BASICPROGRAM: //Basicプログラム
|
---|
996 | case FT_SUBPROGRAM:
|
---|
997 | if(bAddToProject){
|
---|
998 | WriteBuffer(temporary,0,0);
|
---|
999 | NewTextEditWindow(temporary,WNDTYPE_BASIC);
|
---|
1000 | Project_File_Insert(temporary);
|
---|
1001 | }
|
---|
1002 | else NewTextEditWindow(NULL,WNDTYPE_BASIC);
|
---|
1003 | break;
|
---|
1004 |
|
---|
1005 | case FT_PROJECT:
|
---|
1006 | DlgNewProjectWizard(hOwner);
|
---|
1007 | break;
|
---|
1008 |
|
---|
1009 | case FT_TEXT:
|
---|
1010 | NewTextEditWindow(NULL,WNDTYPE_TEXT);
|
---|
1011 | break;
|
---|
1012 |
|
---|
1013 | case FT_HTML:
|
---|
1014 | NewTextEditWindow(NULL,WNDTYPE_HTML);
|
---|
1015 | break;
|
---|
1016 |
|
---|
1017 | case FT_ICON:
|
---|
1018 | NewIconEditWindow(NULL);
|
---|
1019 | break;
|
---|
1020 | }
|
---|
1021 | #endif
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 | void MainFrame::OnCmdOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1025 | {
|
---|
1026 | //"ファイルを指定してください"
|
---|
1027 | extern const LPCSTR DefFileFilter;
|
---|
1028 | char temporary[1024];
|
---|
1029 | if(!GetFilePathDialog(m_hWnd,temporary,DefFileFilter,STRING_FILEOPENTITLE_DEFAULT,TRUE)) return;
|
---|
1030 |
|
---|
1031 | OpenFileWithExtension( temporary );
|
---|
1032 | }
|
---|
1033 |
|
---|
1034 | void MainFrame::OnCmdClose( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1035 | {
|
---|
1036 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1037 | if(::IsWindow(hChild)) SendMessage(hChild,WM_CLOSE,0,0);
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 | void MainFrame::OnCmdProjectOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1041 | {
|
---|
1042 | //"プロジェクト ファイルを指定して下さい"
|
---|
1043 | extern const LPCSTR ProjectFileFilter;
|
---|
1044 | char temporary[1024];
|
---|
1045 | if(!GetFilePathDialog(m_hWnd,temporary,ProjectFileFilter,STRING_FILEOPENTITLE_PROJECT,TRUE))
|
---|
1046 | {
|
---|
1047 | return;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | projectInfo.Load(temporary);
|
---|
1051 | }
|
---|
1052 |
|
---|
1053 | void MainFrame::OnCmdProjectSave( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1054 | {
|
---|
1055 | projectInfo.Save();
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | void MainFrame::OnCmdProjectClose( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1059 | {
|
---|
1060 | projectInfo.Close();
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | void MainFrame::OnCmdProjectFolderOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1064 | {
|
---|
1065 | ShellExecute(m_hWnd,"explore",projectInfo.GetWorkDir().GetPath().c_str(),NULL,NULL,SW_SHOWNORMAL);
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 | void MainFrame::OnCmdSave( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1069 | {
|
---|
1070 | SaveDocument(::GetWindow(hClient,GW_CHILD),NULL);
|
---|
1071 | }
|
---|
1072 |
|
---|
1073 | void MainFrame::OnCmdNewSave( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1074 | {
|
---|
1075 | //"保存先のファイルを指定してください"
|
---|
1076 | extern const LPCSTR DefFileFilter;
|
---|
1077 | char temporary[1024];
|
---|
1078 | if(!GetFilePathDialog(m_hWnd,temporary,DefFileFilter,STRING_FILESAVETITLE_DEFAULT,FALSE)) return;
|
---|
1079 |
|
---|
1080 | SaveDocument(::GetWindow(hClient,GW_CHILD),temporary);
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | void MainFrame::OnCmdCodeSave( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1084 | {
|
---|
1085 | //文字コードを指定して保存
|
---|
1086 | DialogBox(hResInst,MAKEINTRESOURCE(IDD_CODE_SAVE),m_hWnd,nkfDlgCodeSave);
|
---|
1087 | }
|
---|
1088 |
|
---|
1089 | void MainFrame::OnCmdAllSave( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1090 | {
|
---|
1091 | foreach( MDIINFO *mi, MdiInfo ){
|
---|
1092 | if(mi->hwnd) SaveDocument(mi->hwnd,NULL);
|
---|
1093 | }
|
---|
1094 | if( projectInfo.IsOpened() )
|
---|
1095 | {
|
---|
1096 | projectInfo.Save();
|
---|
1097 | }
|
---|
1098 | }
|
---|
1099 |
|
---|
1100 | void MainFrame::OnCmdPageSet( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1101 | {
|
---|
1102 | //ページ設定
|
---|
1103 | obj_Page.SetupDlg();
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | void MainFrame::OnCmdPreview( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1107 | {
|
---|
1108 | //プレビュー(Pro版のみ)
|
---|
1109 | Preview();
|
---|
1110 | }
|
---|
1111 |
|
---|
1112 | void MainFrame::OnCmdPrintOut( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1113 | {
|
---|
1114 | //印刷
|
---|
1115 | Printout();
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 | void MainFrame::OnCmdExit( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1119 | {
|
---|
1120 | SendMessage(WM_CLOSE);
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 | void MainFrame::OnCmdUndo( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1124 | {
|
---|
1125 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1126 | if(!hChild) return;
|
---|
1127 | int WndNum=GetWndNum(hChild);
|
---|
1128 | if( IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType) )
|
---|
1129 | {
|
---|
1130 | TextEdit_UndoCommand(WndNum);
|
---|
1131 | }
|
---|
1132 | else if( MdiInfo[WndNum]->DocType == WNDTYPE_RAD )
|
---|
1133 | {
|
---|
1134 | Rad_UndoCommand(WndNum);
|
---|
1135 | }
|
---|
1136 | else if( MdiInfo[WndNum]->DocType == WNDTYPE_ICONEDIT )
|
---|
1137 | {
|
---|
1138 | IconEdit_UndoCommand(WndNum);
|
---|
1139 | }
|
---|
1140 | }
|
---|
1141 |
|
---|
1142 | void MainFrame::OnCmdRedo( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1143 | {
|
---|
1144 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1145 | if(!hChild) return;
|
---|
1146 | int WndNum=GetWndNum(hChild);
|
---|
1147 | if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType))
|
---|
1148 | TextEdit_RedoCommand(WndNum);
|
---|
1149 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD)
|
---|
1150 | Rad_RedoCommand(WndNum);
|
---|
1151 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_ICONEDIT)
|
---|
1152 | IconEdit_RedoCommand(WndNum);
|
---|
1153 | }
|
---|
1154 |
|
---|
1155 | void MainFrame::OnCmdCut( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1156 | {
|
---|
1157 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1158 | int WndNum=GetWndNum(hChild);
|
---|
1159 | if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
|
---|
1160 | HWND hEdit=::GetWindow(hChild,GW_CHILD);
|
---|
1161 |
|
---|
1162 | CHARRANGE CharRange;
|
---|
1163 | TextEdit_GetSel(WndNum,&CharRange);
|
---|
1164 |
|
---|
1165 | HGLOBAL hGlobal=GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
|
---|
1166 | char *pTemp=(char *)GlobalLock(hGlobal);
|
---|
1167 | memcpy(pTemp,MdiInfo[WndNum]->pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
|
---|
1168 | pTemp[CharRange.cpMax-CharRange.cpMin]=0;
|
---|
1169 | GlobalUnlock(hGlobal);
|
---|
1170 |
|
---|
1171 | //クリップボードに保存
|
---|
1172 | OpenClipboard();
|
---|
1173 | EmptyClipboard();
|
---|
1174 | SetClipboardData(CF_TEXT,hGlobal);
|
---|
1175 | CloseClipboard();
|
---|
1176 |
|
---|
1177 | //選択文字列を消去
|
---|
1178 | SendMessage(hEdit,WM_KEYDOWN,VK_DELETE,0);
|
---|
1179 | }
|
---|
1180 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD){
|
---|
1181 | ActiveBasic::PM::WindowInfo *pWindowInfo = GetWndInfo(MdiInfo[WndNum]->path);
|
---|
1182 | int indexOfWndInfo = GetWndInfoNum(MdiInfo[WndNum]->path);
|
---|
1183 |
|
---|
1184 | //クリップボードに格納するためのデータを用意する
|
---|
1185 | pWindowInfo->childWindowInfos[MdiInfo[WndNum]->MdiRadInfo->SelectingItem[0]]->pos.x-=17;
|
---|
1186 | pWindowInfo->childWindowInfos[MdiInfo[WndNum]->MdiRadInfo->SelectingItem[0]]->pos.y-=10;
|
---|
1187 | HGLOBAL hGlobal=Rad_GetChildInfoClipboardData(WndNum,indexOfWndInfo);
|
---|
1188 | pWindowInfo->childWindowInfos[MdiInfo[WndNum]->MdiRadInfo->SelectingItem[0]]->pos.x+=17;
|
---|
1189 | pWindowInfo->childWindowInfos[MdiInfo[WndNum]->MdiRadInfo->SelectingItem[0]]->pos.y+=10;
|
---|
1190 |
|
---|
1191 | OpenClipboard();
|
---|
1192 | EmptyClipboard();
|
---|
1193 | extern DWORD dwRadClipboardID;
|
---|
1194 | SetClipboardData(dwRadClipboardID,hGlobal);
|
---|
1195 | CloseClipboard();
|
---|
1196 |
|
---|
1197 | SendMessage(MdiInfo[WndNum]->MdiRadInfo->hRad,WM_COMMAND,IDM_RAD_ITEM_DELETE,0);
|
---|
1198 | }
|
---|
1199 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_ICONEDIT){
|
---|
1200 | //クリップボードに格納するためのデータを用意する
|
---|
1201 | HGLOBAL hGlobal=IconEdit_GetChildInfoClipboardData(WndNum);
|
---|
1202 | if(hGlobal==0) return;
|
---|
1203 |
|
---|
1204 | OpenClipboard();
|
---|
1205 | EmptyClipboard();
|
---|
1206 | SetClipboardData(CF_BITMAP,hGlobal);
|
---|
1207 | CloseClipboard();
|
---|
1208 |
|
---|
1209 | DeleteObject(MdiInfo[WndNum]->MdiIconEditInfo->hSelectingBmp);
|
---|
1210 | MdiInfo[WndNum]->MdiIconEditInfo->SelectLevel=0;
|
---|
1211 |
|
---|
1212 | IconEdit_EraseRect(WndNum,&MdiInfo[WndNum]->MdiIconEditInfo->DraggingRect);
|
---|
1213 | }
|
---|
1214 | }
|
---|
1215 |
|
---|
1216 | void MainFrame::OnCmdCopy( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1217 | {
|
---|
1218 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1219 | int WndNum=GetWndNum(hChild);
|
---|
1220 | if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
|
---|
1221 | HWND hEdit = ::GetWindow(hChild,GW_CHILD);
|
---|
1222 |
|
---|
1223 | CHARRANGE CharRange;
|
---|
1224 | TextEdit_GetSel(WndNum,&CharRange);
|
---|
1225 |
|
---|
1226 | HGLOBAL hGlobal=GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
|
---|
1227 | char *pTemp=(char *)GlobalLock(hGlobal);
|
---|
1228 | memcpy(pTemp,MdiInfo[WndNum]->pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
|
---|
1229 | pTemp[CharRange.cpMax-CharRange.cpMin]=0;
|
---|
1230 | GlobalUnlock(hGlobal);
|
---|
1231 |
|
---|
1232 | //クリップボードに保存
|
---|
1233 | OpenClipboard();
|
---|
1234 | EmptyClipboard();
|
---|
1235 | SetClipboardData(CF_TEXT,hGlobal);
|
---|
1236 | CloseClipboard();
|
---|
1237 | }
|
---|
1238 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD){
|
---|
1239 | int indexOfWndInfo = GetWndInfoNum(MdiInfo[WndNum]->path);
|
---|
1240 |
|
---|
1241 | //クリップボードに格納するためのデータを用意する
|
---|
1242 | HGLOBAL hGlobal=Rad_GetChildInfoClipboardData(WndNum,indexOfWndInfo);
|
---|
1243 |
|
---|
1244 | OpenClipboard();
|
---|
1245 | EmptyClipboard();
|
---|
1246 | extern DWORD dwRadClipboardID;
|
---|
1247 | SetClipboardData(dwRadClipboardID,hGlobal);
|
---|
1248 | CloseClipboard();
|
---|
1249 | }
|
---|
1250 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_ICONEDIT){
|
---|
1251 | //クリップボードに格納するためのデータを用意する
|
---|
1252 | HGLOBAL hGlobal=IconEdit_GetChildInfoClipboardData(WndNum);
|
---|
1253 |
|
---|
1254 | OpenClipboard();
|
---|
1255 | EmptyClipboard();
|
---|
1256 | SetClipboardData(CF_BITMAP,hGlobal);
|
---|
1257 | CloseClipboard();
|
---|
1258 | }
|
---|
1259 | }
|
---|
1260 |
|
---|
1261 | void MainFrame::OnCmdPaste( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1262 | {
|
---|
1263 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1264 | int WndNum=GetWndNum(hChild);
|
---|
1265 | if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
|
---|
1266 | HWND hEdit=::GetWindow(hChild,GW_CHILD);
|
---|
1267 |
|
---|
1268 | //クリップボードを開く
|
---|
1269 | OpenClipboard();
|
---|
1270 | HGLOBAL hGlobal=GetClipboardData(CF_TEXT);
|
---|
1271 | if(!hGlobal){
|
---|
1272 | CloseClipboard();
|
---|
1273 | return;
|
---|
1274 | }
|
---|
1275 |
|
---|
1276 |
|
---|
1277 | char *pTemp;
|
---|
1278 | if(pobj_nv->bPasteIndent){
|
---|
1279 | //インデント整形
|
---|
1280 | pTemp=CodeFormatter((char *)GlobalLock(hGlobal));
|
---|
1281 | GlobalUnlock(hGlobal);
|
---|
1282 | }
|
---|
1283 | else pTemp=(char *)GlobalLock(hGlobal);
|
---|
1284 |
|
---|
1285 |
|
---|
1286 | //テキストエディタの文字列をリプレイス
|
---|
1287 | TextEdit_ReplaceUpdateUndoData(WndNum,
|
---|
1288 | pTemp,
|
---|
1289 | 1,
|
---|
1290 | 1);
|
---|
1291 |
|
---|
1292 | if(pobj_nv->bPasteIndent)
|
---|
1293 | HeapDefaultFree(pTemp);
|
---|
1294 | else
|
---|
1295 | GlobalUnlock(hGlobal);
|
---|
1296 |
|
---|
1297 | //クリップボードを閉じる
|
---|
1298 | CloseClipboard();
|
---|
1299 |
|
---|
1300 |
|
---|
1301 | //キャレット位置までスクロールする
|
---|
1302 | TextEdit_ScrollCaret(WndNum,0);
|
---|
1303 | ResetCaretPos(WndNum);
|
---|
1304 | }
|
---|
1305 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD){
|
---|
1306 | OpenClipboard();
|
---|
1307 | extern DWORD dwRadClipboardID;
|
---|
1308 | HGLOBAL hGlobal=GetClipboardData(dwRadClipboardID);
|
---|
1309 | if(!hGlobal){
|
---|
1310 | CloseClipboard();
|
---|
1311 | return;
|
---|
1312 | }
|
---|
1313 | Rad_PasteChildInfoClipboardData(WndNum,hGlobal);
|
---|
1314 | CloseClipboard();
|
---|
1315 | }
|
---|
1316 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_ICONEDIT){
|
---|
1317 | OpenClipboard();
|
---|
1318 | HGLOBAL hGlobal=GetClipboardData(CF_BITMAP);
|
---|
1319 | if(!hGlobal){
|
---|
1320 | CloseClipboard();
|
---|
1321 | return;
|
---|
1322 | }
|
---|
1323 | IconEdit_PasteChildInfoClipboardData(WndNum,(HBITMAP)hGlobal);
|
---|
1324 | CloseClipboard();
|
---|
1325 | }
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | void MainFrame::OnCmdDelete( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1329 | {
|
---|
1330 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1331 | int WndNum=GetWndNum(hChild);
|
---|
1332 | if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
|
---|
1333 | HWND hEdit=::GetWindow(hChild,GW_CHILD);
|
---|
1334 | TextEdit_ReplaceUpdateUndoData(WndNum,"",0,1);
|
---|
1335 | }
|
---|
1336 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD)
|
---|
1337 | SendMessage(MdiInfo[WndNum]->MdiRadInfo->hRad,WM_COMMAND,IDM_RAD_ITEM_DELETE,0);
|
---|
1338 | }
|
---|
1339 |
|
---|
1340 | void MainFrame::OnCmdAllSelect( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1341 | {
|
---|
1342 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1343 | int WndNum=GetWndNum(hChild);
|
---|
1344 | if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
|
---|
1345 | HWND hEdit=::GetWindow(hChild,GW_CHILD);
|
---|
1346 |
|
---|
1347 | MdiInfo[WndNum]->pMdiTextEdit->StartCaretPos.x=0;
|
---|
1348 | MdiInfo[WndNum]->pMdiTextEdit->StartCaretPos.y=0;
|
---|
1349 |
|
---|
1350 | GetCaretPosFromBufferIndex(
|
---|
1351 | MdiInfo[WndNum]->pMdiTextEdit->buffer,
|
---|
1352 | lstrlen(MdiInfo[WndNum]->pMdiTextEdit->buffer),
|
---|
1353 | &MdiInfo[WndNum]->pMdiTextEdit->EndCaretPos);
|
---|
1354 |
|
---|
1355 | ::InvalidateRect(hEdit,NULL,0);
|
---|
1356 |
|
---|
1357 | ResetState_EditMenu();
|
---|
1358 | }
|
---|
1359 | else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD){
|
---|
1360 | ActiveBasic::PM::WindowInfo *pWindowInfo = GetWndInfo(MdiInfo[WndNum]->path);
|
---|
1361 | for( int i3=0; i3<static_cast<int>(pWindowInfo->childWindowInfos.size()); i3++ )
|
---|
1362 | {
|
---|
1363 | MdiInfo[WndNum]->MdiRadInfo->SelectingItem[i3] = i3;
|
---|
1364 | }
|
---|
1365 | DrawRadWindow(WndNum,pWindowInfo);
|
---|
1366 | }
|
---|
1367 | }
|
---|
1368 |
|
---|
1369 | void MainFrame::OnCmdFind( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1370 | {
|
---|
1371 | ActiveBasic::Resource::DialogBoxAlt(hResInst, IDD_FIND, m_hWnd, DlgFind);
|
---|
1372 | }
|
---|
1373 |
|
---|
1374 | void MainFrame::OnCmdPermutation( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1375 | {
|
---|
1376 | ActiveBasic::Resource::DialogBoxAlt(hResInst, IDD_PERMUTATION, m_hWnd, DlgPermutation);
|
---|
1377 | }
|
---|
1378 |
|
---|
1379 | void MainFrame::OnCmdConvertX( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1380 | {
|
---|
1381 | TextEdit_Convert( nID );
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | #ifdef THETEXT
|
---|
1385 | void MainFrame::OnCmdStringCount( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1386 | {
|
---|
1387 | DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_STRING_COUNT),m_hWnd,DlgStringCount,0);
|
---|
1388 | }
|
---|
1389 |
|
---|
1390 | void MainFrame::OnCmdSelStringCount( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1391 | {
|
---|
1392 | DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_STRING_COUNT),m_hWnd,DlgStringCount,1);
|
---|
1393 | }
|
---|
1394 | #endif
|
---|
1395 |
|
---|
1396 | void MainFrame::OnCmdProjectView( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1397 | {
|
---|
1398 | extern HWND hProjectView;
|
---|
1399 | bool isCheck = false;
|
---|
1400 | if(pobj_nv->bClipProjectView){
|
---|
1401 | if(::IsWindowVisible(hProjectView)){
|
---|
1402 | ::ShowWindow(hProjectView,SW_HIDE);
|
---|
1403 | }
|
---|
1404 | else{
|
---|
1405 | ::ShowWindow(hProjectView,SW_SHOW);
|
---|
1406 | isCheck = true;
|
---|
1407 | }
|
---|
1408 | }
|
---|
1409 | else{
|
---|
1410 | extern HWND hProjectView_ToolWindow;
|
---|
1411 | if(::IsWindowVisible(hProjectView_ToolWindow)){
|
---|
1412 | ::ShowWindow(hProjectView_ToolWindow,SW_HIDE);
|
---|
1413 | }
|
---|
1414 | else{
|
---|
1415 | ::ShowWindow(hProjectView_ToolWindow,SW_SHOW);
|
---|
1416 | ::ShowWindow(hProjectView,SW_SHOW);
|
---|
1417 | isCheck = true;
|
---|
1418 | }
|
---|
1419 | }
|
---|
1420 | pobj_MainMenu->CheckMenu(IDM_PROJECTVIEW,isCheck);
|
---|
1421 |
|
---|
1422 | //再配置
|
---|
1423 | this->Resized();
|
---|
1424 |
|
---|
1425 | ::ShowWindow(hClient,SW_SHOW);
|
---|
1426 | }
|
---|
1427 |
|
---|
1428 | void MainFrame::OnCmdProjectOption( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1429 | {
|
---|
1430 | DlgProjectOptionSetting( m_hWnd );
|
---|
1431 | }
|
---|
1432 |
|
---|
1433 | void MainFrame::OnCmdTopMost( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1434 | {
|
---|
1435 | if(pobj_MainMenu->IsCheck(IDM_TOPMOST)){
|
---|
1436 | SetWindowPos( HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
|
---|
1437 | pobj_MainMenu->CheckMenu(IDM_TOPMOST,0);
|
---|
1438 | }
|
---|
1439 | else{
|
---|
1440 | SetWindowPos( HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
|
---|
1441 | pobj_MainMenu->CheckMenu(IDM_TOPMOST,1);
|
---|
1442 | }
|
---|
1443 | }
|
---|
1444 |
|
---|
1445 | void ResetState_ViewMenu(void);
|
---|
1446 | void MainFrame::OnCmdRightTurn( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1447 | {
|
---|
1448 | pobj_nv->bRightTurn^=1;
|
---|
1449 | ResetState_ViewMenu();
|
---|
1450 |
|
---|
1451 | //トップのウィンドウを再描画
|
---|
1452 | RedrawAllWindow();
|
---|
1453 | }
|
---|
1454 |
|
---|
1455 | void MainFrame::OnCmdSet( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1456 | {
|
---|
1457 | DlgOptionSetting( m_hWnd );
|
---|
1458 | }
|
---|
1459 |
|
---|
1460 | #ifndef THETEXT
|
---|
1461 | void MainFrame::OnCmdDebug( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1462 | {
|
---|
1463 | char temporary[1024], temp2[1024], temp3[1024];
|
---|
1464 | if(pobj_Debugger->IsDebugging()){
|
---|
1465 | pobj_Debugger->DebugContinue();
|
---|
1466 | return;
|
---|
1467 | }
|
---|
1468 |
|
---|
1469 | HWND hChild = ::GetWindow(hClient,GW_CHILD);
|
---|
1470 | if( projectInfo.IsOpened() ){
|
---|
1471 | //プロジェクトが開かれている場合
|
---|
1472 | if(!SetProjectToRun()) return;
|
---|
1473 |
|
---|
1474 | //デバッグ用のコマンドライン及び実行可能ファイル(DLLのみ)
|
---|
1475 | sprintf(temporary,"%s\r\n%s",projectInfo.szExePath,projectInfo.szCmdLine);
|
---|
1476 | sprintf(temp2,"%s\\pgm.tmp",ActiveBasic::Common::Environment::GetUserAppDir().c_str());
|
---|
1477 | {
|
---|
1478 | ATL::CHandle hFile(CreateFile(temp2,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_TEMPORARY,NULL));
|
---|
1479 | if(hFile==INVALID_HANDLE_VALUE){
|
---|
1480 | hFile.Detach();
|
---|
1481 | MessageBox(TEXT("デバッグ用ファイルを開けませんでした。"));
|
---|
1482 | return;
|
---|
1483 | }
|
---|
1484 | DWORD dwAccessBytes;
|
---|
1485 | WriteFile(hFile,temporary,lstrlen(temporary),&dwAccessBytes,NULL);
|
---|
1486 | }
|
---|
1487 |
|
---|
1488 | //ソースファイル名をtemp2へ
|
---|
1489 | lstrcpy( temp2, projectInfo.fileSystem.root.files[0].GetFullPath().c_str() );
|
---|
1490 |
|
---|
1491 | //出力ファイル名をtemp3へ
|
---|
1492 | lstrcpy(temp3,projectInfo.lpszOutput_Debug);
|
---|
1493 | lstrcpy( temp3, projectInfo.GetWorkDir().GetFullPath( temp3 ).c_str() );
|
---|
1494 |
|
---|
1495 | if(IsNeedCompileForProject(1))
|
---|
1496 | sprintf(temporary,"\"%s\" \"%s\" /debug /run /wnd:%p",temp2,temp3,m_hWnd);
|
---|
1497 | else
|
---|
1498 | sprintf(temporary,"\"%s\" \"%s\" /run /wnd:%p",temp2,temp3,m_hWnd);
|
---|
1499 |
|
---|
1500 | // DLLオプション
|
---|
1501 | if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
|
---|
1502 | {
|
---|
1503 | lstrcat(temporary," /dll");
|
---|
1504 | }
|
---|
1505 |
|
---|
1506 | // SLLオプション
|
---|
1507 | if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Sll )
|
---|
1508 | {
|
---|
1509 | lstrcat(temporary," /static_library");
|
---|
1510 | }
|
---|
1511 |
|
---|
1512 | //Unicodeオプション
|
---|
1513 | if(projectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
|
---|
1514 |
|
---|
1515 | //ブレークポイントをセーブ
|
---|
1516 | projectInfo.pobj_DBBreakPoint->SaveToTempFile();
|
---|
1517 | }
|
---|
1518 | else{
|
---|
1519 | //単独ソースコード
|
---|
1520 | if(!SetRunning(hChild)) return;
|
---|
1521 | if(IsNeedCompile(MdiInfo[GetWndNum(hChild)]->path,1))
|
---|
1522 | sprintf(temporary,"\"%s\" /debug /run /wnd:%p",MdiInfo[GetWndNum(hChild)]->path.c_str(),m_hWnd);
|
---|
1523 | else
|
---|
1524 | sprintf(temporary,"\"%s\" /run /wnd:%p",MdiInfo[GetWndNum(hChild)]->path.c_str(),m_hWnd);
|
---|
1525 |
|
---|
1526 | //ブレークポイントをセーブ
|
---|
1527 | extern CDBBreakPoint *pobj_DBBreakPoint;
|
---|
1528 | pobj_DBBreakPoint->SaveToTempFile();
|
---|
1529 | }
|
---|
1530 |
|
---|
1531 | //コンパイルビューをクリップするかどうか
|
---|
1532 | extern BOOL bClipCompileView;
|
---|
1533 | if(bClipCompileView){
|
---|
1534 | lstrcat(temporary," /clip_compile_view");
|
---|
1535 |
|
---|
1536 | //コンパイラビューを閉じる
|
---|
1537 | extern HWND hCompileView;
|
---|
1538 | if(hCompileView==(HWND)-1) return;
|
---|
1539 | if(hCompileView){
|
---|
1540 | hChild=hCompileView;
|
---|
1541 | hCompileView=(HWND)-1;
|
---|
1542 | SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 | //重複起動防止のため
|
---|
1546 | hCompileView=(HWND)-1;
|
---|
1547 | }
|
---|
1548 |
|
---|
1549 | //インクルードディレクトリ
|
---|
1550 | sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
|
---|
1551 | lstrcat(temporary,temp2);
|
---|
1552 |
|
---|
1553 | extern ActiveBasic::Common::Platform::EnumType selectingPlatform;
|
---|
1554 | CreateProcessWithStdHandle( ActiveBasic::Common::Environment::GetCompilerExePath( selectingPlatform ), temporary, false );
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 | void MainFrame::OnCmdDebugCompile( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1558 | {
|
---|
1559 | char temporary[1024], temp2[1024], temp3[1024];
|
---|
1560 |
|
---|
1561 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1562 | if( projectInfo.IsOpened() ){
|
---|
1563 | //プロジェクトが開かれている場合
|
---|
1564 | if(!SetProjectToRun()) return;
|
---|
1565 |
|
---|
1566 | //ソースファイル名をtemp2へ
|
---|
1567 | lstrcpy( temp2, projectInfo.fileSystem.root.files[0].GetFullPath().c_str() );
|
---|
1568 |
|
---|
1569 | //出力ファイル名をtemp3へ
|
---|
1570 | lstrcpy(temp3,projectInfo.lpszOutput_Debug);
|
---|
1571 | lstrcpy( temp3, projectInfo.GetWorkDir().GetFullPath( temp3 ).c_str() );
|
---|
1572 |
|
---|
1573 | sprintf(temporary,"\"%s\" \"%s\" /debug /wnd:%p",temp2,temp3,m_hWnd);
|
---|
1574 |
|
---|
1575 | //DLLオプション
|
---|
1576 | if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
|
---|
1577 | {
|
---|
1578 | lstrcat(temporary," /dll");
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 | // SLLオプション
|
---|
1582 | if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Sll )
|
---|
1583 | {
|
---|
1584 | lstrcat(temporary," /static_library");
|
---|
1585 | }
|
---|
1586 |
|
---|
1587 | //Unicodeオプション
|
---|
1588 | if(projectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
|
---|
1589 | }
|
---|
1590 | else{
|
---|
1591 | //単独ソースコード
|
---|
1592 | if(!SetRunning(hChild)) return;
|
---|
1593 | sprintf(temporary,"\"%s\" /debug /wnd:%p",MdiInfo[GetWndNum(hChild)]->path.c_str(),m_hWnd);
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 | //コンパイルビューをクリップするかどうか
|
---|
1597 | extern BOOL bClipCompileView;
|
---|
1598 | if(bClipCompileView){
|
---|
1599 | lstrcat(temporary," /clip_compile_view");
|
---|
1600 |
|
---|
1601 | //コンパイラビューを閉じる
|
---|
1602 | extern HWND hCompileView;
|
---|
1603 | if(hCompileView==(HWND)-1) return;
|
---|
1604 | if(hCompileView){
|
---|
1605 | hChild=hCompileView;
|
---|
1606 | hCompileView=(HWND)-1;
|
---|
1607 | if( ::IsWindow( hChild ) )
|
---|
1608 | {
|
---|
1609 | SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
|
---|
1610 | }
|
---|
1611 | }
|
---|
1612 |
|
---|
1613 | //重複起動防止のため
|
---|
1614 | hCompileView=(HWND)-1;
|
---|
1615 | }
|
---|
1616 |
|
---|
1617 | //インクルードディレクトリ
|
---|
1618 | sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
|
---|
1619 | lstrcat(temporary,temp2);
|
---|
1620 |
|
---|
1621 | extern ActiveBasic::Common::Platform::EnumType selectingPlatform;
|
---|
1622 | CreateProcessWithStdHandle( ActiveBasic::Common::Environment::GetCompilerExePath( selectingPlatform ), temporary, false );
|
---|
1623 | }
|
---|
1624 |
|
---|
1625 | void MainFrame::OnCmdAttach( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1626 | {
|
---|
1627 | char temporary[1024], temp2[1024];
|
---|
1628 |
|
---|
1629 | int idProcess;
|
---|
1630 | DWORD dwPlatform;
|
---|
1631 | idProcess = ActiveBasic::Resource::DialogBoxAlt(hResInst, IDD_ATTACH, m_hWnd, DlgAttach, reinterpret_cast<LPARAM>(&dwPlatform));
|
---|
1632 | if(idProcess==0) return;
|
---|
1633 |
|
---|
1634 | sprintf(temporary,"/attach:%08x /wnd:%p",idProcess,m_hWnd);
|
---|
1635 |
|
---|
1636 | //コンパイルビューをクリップするかどうか
|
---|
1637 | extern BOOL bClipCompileView;
|
---|
1638 | if(bClipCompileView){
|
---|
1639 | lstrcat(temporary," /clip_compile_view");
|
---|
1640 |
|
---|
1641 | //コンパイラビューを閉じる
|
---|
1642 | extern HWND hCompileView;
|
---|
1643 | if(hCompileView==(HWND)-1) return;
|
---|
1644 | if(hCompileView){
|
---|
1645 | HWND hChild=hCompileView;
|
---|
1646 | hCompileView=(HWND)-1;
|
---|
1647 | SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
|
---|
1648 | }
|
---|
1649 |
|
---|
1650 | //重複起動防止のため
|
---|
1651 | hCompileView=(HWND)-1;
|
---|
1652 | }
|
---|
1653 |
|
---|
1654 | //インクルードディレクトリ
|
---|
1655 | sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
|
---|
1656 | lstrcat(temporary,temp2);
|
---|
1657 |
|
---|
1658 | ActiveBasic::Common::Platform::EnumType platform;
|
---|
1659 | if(dwPlatform==IMAGE_FILE_MACHINE_I386)
|
---|
1660 | {
|
---|
1661 | platform = ActiveBasic::Common::Platform::X86;
|
---|
1662 | }
|
---|
1663 | else if(dwPlatform==IMAGE_FILE_MACHINE_AMD64)
|
---|
1664 | {
|
---|
1665 | platform = ActiveBasic::Common::Platform::X64;
|
---|
1666 | }
|
---|
1667 | else
|
---|
1668 | {
|
---|
1669 | throw;
|
---|
1670 | }
|
---|
1671 |
|
---|
1672 | extern ActiveBasic::Common::Platform::EnumType selectingPlatform;
|
---|
1673 | CreateProcessWithStdHandle( ActiveBasic::Common::Environment::GetCompilerExePath( platform ), temporary, false );
|
---|
1674 | }
|
---|
1675 |
|
---|
1676 | void MainFrame::OnCmdReleaseCompile( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1677 | {
|
---|
1678 | char temporary[1024], temp2[1024], temp3[1024];
|
---|
1679 |
|
---|
1680 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1681 | if( projectInfo.IsOpened() ){
|
---|
1682 | //プロジェクトが開かれている場合
|
---|
1683 | if(!SetProjectToRun()) return;
|
---|
1684 |
|
---|
1685 | //ソースファイル名をtemp2へ
|
---|
1686 | lstrcpy( temp2, projectInfo.fileSystem.root.files[0].GetFullPath().c_str() );
|
---|
1687 |
|
---|
1688 | //出力ファイル名をtemp3へ
|
---|
1689 | lstrcpy(temp3,projectInfo.lpszOutput_Release);
|
---|
1690 | lstrcpy( temp3, projectInfo.GetWorkDir().GetFullPath( temp3 ).c_str() );
|
---|
1691 |
|
---|
1692 | sprintf(temporary,"\"%s\" \"%s\" /wnd:%p",temp2,temp3,m_hWnd);
|
---|
1693 |
|
---|
1694 | //DLLオプション
|
---|
1695 | if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
|
---|
1696 | {
|
---|
1697 | lstrcat(temporary," /dll");
|
---|
1698 | }
|
---|
1699 |
|
---|
1700 | // SLLオプション
|
---|
1701 | if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Sll )
|
---|
1702 | {
|
---|
1703 | lstrcat(temporary," /static_library");
|
---|
1704 | }
|
---|
1705 |
|
---|
1706 | //Unicodeオプション
|
---|
1707 | if(projectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
|
---|
1708 | }
|
---|
1709 | else{
|
---|
1710 | //単独ソースコード
|
---|
1711 | if(!SetRunning(hChild)) return;
|
---|
1712 | sprintf(temporary,"\"%s\" /wnd:%p",MdiInfo[GetWndNum(hChild)]->path.c_str(),m_hWnd);
|
---|
1713 | }
|
---|
1714 |
|
---|
1715 | //コンパイルビューをクリップするかどうか
|
---|
1716 | extern BOOL bClipCompileView;
|
---|
1717 | if(bClipCompileView){
|
---|
1718 | lstrcat(temporary," /clip_compile_view");
|
---|
1719 |
|
---|
1720 | //コンパイラビューを閉じる
|
---|
1721 | extern HWND hCompileView;
|
---|
1722 | if(hCompileView==(HWND)-1) return;
|
---|
1723 | if(hCompileView){
|
---|
1724 | hChild=hCompileView;
|
---|
1725 | hCompileView=(HWND)-1;
|
---|
1726 | if( ::IsWindow( hChild ) )
|
---|
1727 | {
|
---|
1728 | SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
|
---|
1729 | }
|
---|
1730 | }
|
---|
1731 |
|
---|
1732 | //重複起動防止のため
|
---|
1733 | hCompileView=(HWND)-1;
|
---|
1734 | }
|
---|
1735 |
|
---|
1736 | //インクルードディレクトリ
|
---|
1737 | sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
|
---|
1738 | lstrcat(temporary,temp2);
|
---|
1739 |
|
---|
1740 | extern ActiveBasic::Common::Platform::EnumType selectingPlatform;
|
---|
1741 | CreateProcessWithStdHandle( ActiveBasic::Common::Environment::GetCompilerExePath( selectingPlatform ), temporary, false );
|
---|
1742 | }
|
---|
1743 |
|
---|
1744 | void MainFrame::OnCmdReleaseRun( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1745 | {
|
---|
1746 | char temporary[1024], temp2[1024], temp3[1024];
|
---|
1747 |
|
---|
1748 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1749 | if( projectInfo.IsOpened() ){
|
---|
1750 | /* //プロジェクトが開かれている場合
|
---|
1751 | if(!SetProjectToRun()) return;
|
---|
1752 |
|
---|
1753 | //必要であればリリースコンパイル
|
---|
1754 | if(IsNeedCompileForProject(0))
|
---|
1755 | SendMessage(WM_COMMAND,IDM_RELEASECOMPILE,0);*/
|
---|
1756 |
|
---|
1757 | if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
|
---|
1758 | {
|
---|
1759 | lstrcpy(temporary,projectInfo.szExePath);
|
---|
1760 | }
|
---|
1761 | else{
|
---|
1762 | lstrcpy(temporary,projectInfo.lpszOutput_Debug);
|
---|
1763 | lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
|
---|
1764 | }
|
---|
1765 | }
|
---|
1766 | else{
|
---|
1767 | /* //必要であればリリースコンパイル
|
---|
1768 | if(!SetRunning(hChild)) return;
|
---|
1769 |
|
---|
1770 | if(IsNeedCompile(MdiInfo[GetWndNum(hChild)]->path,0))
|
---|
1771 | SendMessage(WM_COMMAND,IDM_RELEASECOMPILE,0);*/
|
---|
1772 |
|
---|
1773 | //単独ソースコード
|
---|
1774 | _splitpath(MdiInfo[GetWndNum(hChild)]->path.c_str(),temporary,temp2,temp3,NULL);
|
---|
1775 | lstrcat(temporary,temp2);
|
---|
1776 | lstrcat(temporary,temp3);
|
---|
1777 | lstrcat(temporary,".exe");
|
---|
1778 | }
|
---|
1779 |
|
---|
1780 | //インクルードディレクトリ
|
---|
1781 | sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
|
---|
1782 | lstrcat(temporary,temp2);
|
---|
1783 |
|
---|
1784 | ShellExecute(m_hWnd,"open",temporary,NULL,NULL,SW_SHOWNORMAL);
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 | void MainFrame::OnCmdStepIn( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1788 | {
|
---|
1789 | pobj_Debugger->StepIn();
|
---|
1790 | }
|
---|
1791 |
|
---|
1792 | void MainFrame::OnCmdStepOver( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1793 | {
|
---|
1794 | pobj_Debugger->StepOver();
|
---|
1795 | }
|
---|
1796 |
|
---|
1797 | void MainFrame::OnCmdStepCursor( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1798 | {
|
---|
1799 | pobj_Debugger->StepToCursor();
|
---|
1800 | }
|
---|
1801 |
|
---|
1802 | void MainFrame::OnCmdBreakPoint( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1803 | {
|
---|
1804 | if( projectInfo.IsOpened() ){
|
---|
1805 | projectInfo.pobj_DBBreakPoint->Event_BreakPoint();
|
---|
1806 | }
|
---|
1807 | else{
|
---|
1808 | extern CDBBreakPoint *pobj_DBBreakPoint;
|
---|
1809 | pobj_DBBreakPoint->Event_BreakPoint();
|
---|
1810 | }
|
---|
1811 | }
|
---|
1812 |
|
---|
1813 | void MainFrame::OnCmdDebugStop( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1814 | {
|
---|
1815 | pobj_Debugger->DebugStop();
|
---|
1816 | }
|
---|
1817 |
|
---|
1818 | void MainFrame::OnCmdDebugPause( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1819 | {
|
---|
1820 | pobj_Debugger->DebugPause();
|
---|
1821 | }
|
---|
1822 |
|
---|
1823 | #endif // not THETEXT
|
---|
1824 |
|
---|
1825 | void MainFrame::OnCmdWebLink( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1826 | {
|
---|
1827 | switch( nID )
|
---|
1828 | {
|
---|
1829 | #ifndef THETEXT
|
---|
1830 | case IDM_COMMUNITY:
|
---|
1831 | OpenWebBrowser( "http://www.activebasic.com/forum/" );
|
---|
1832 | break;
|
---|
1833 | case IDM_COMMU_SEARCH:
|
---|
1834 | OpenWebBrowser( "http://www.activebasic.com/forum/search.php" );
|
---|
1835 | break;
|
---|
1836 | case IDM_COMMU_PM:
|
---|
1837 | OpenWebBrowser( "http://www.activebasic.com/forum/privmsg.php?folder=inbox" );
|
---|
1838 | break;
|
---|
1839 | case ID_COMMU_FORUM1:
|
---|
1840 | OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=1" );
|
---|
1841 | break;
|
---|
1842 | case ID_COMMU_FORUM2:
|
---|
1843 | OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=2" );
|
---|
1844 | break;
|
---|
1845 | case ID_COMMU_FORUM3:
|
---|
1846 | OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=5" );
|
---|
1847 | break;
|
---|
1848 | case ID_COMMU_FORUM4:
|
---|
1849 | OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=3" );
|
---|
1850 | break;
|
---|
1851 | case ID_COMMU_FORUM5:
|
---|
1852 | OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=6" );
|
---|
1853 | break;
|
---|
1854 | case ID_COMMU_FORUM6:
|
---|
1855 | OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=8" );
|
---|
1856 | break;
|
---|
1857 | case ID_COMMU_FORUM7:
|
---|
1858 | OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=4" );
|
---|
1859 | break;
|
---|
1860 | case ID_COMMU_FORUM8:
|
---|
1861 | OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=7" );
|
---|
1862 | break;
|
---|
1863 | case IDM_AB_WEBSITE:
|
---|
1864 | OpenWebBrowser( "http://www.activebasic.com/" );
|
---|
1865 | break;
|
---|
1866 | case IDM_ACTBDL:
|
---|
1867 | OpenWebBrowser( "http://www.activebasic.com/activebasic5/download.htm" );
|
---|
1868 | break;
|
---|
1869 | #else
|
---|
1870 | case IDM_DSHOMEPAGE:
|
---|
1871 | OpenWebBrowser( "http://www.discoversoft.net/" );
|
---|
1872 | break;
|
---|
1873 | #endif // not THETEXT
|
---|
1874 | default:
|
---|
1875 | throw;
|
---|
1876 | }
|
---|
1877 | }
|
---|
1878 |
|
---|
1879 | void MainFrame::OnCmdTopics( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1880 | {
|
---|
1881 | char temporary[1024];
|
---|
1882 | #ifdef THETEXT
|
---|
1883 | sprintf(temporary,"%sTopics\\index.html",pj_editor_Dir);
|
---|
1884 | ShellExecute(m_hWnd,"open",temporary,NULL,NULL,SW_SHOWNORMAL);
|
---|
1885 | #else
|
---|
1886 | sprintf(temporary,"%sBasicHelp.chm",pj_editor_Dir);
|
---|
1887 | HtmlHelp(NULL,temporary,HH_DISPLAY_TOPIC,0);
|
---|
1888 | #endif
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | void MainFrame::OnCmdAbout( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1892 | {
|
---|
1893 | ActiveBasic::Resource::DialogBoxAlt(hResInst, IDD_ABOUT, m_hWnd, DialogAbout);
|
---|
1894 | }
|
---|
1895 |
|
---|
1896 | void MainFrame::OnCmdDocSelectBand( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1897 | {
|
---|
1898 | pobj_Rebar->ChangeRebarBand(ID_DOCCOMBO);
|
---|
1899 | }
|
---|
1900 |
|
---|
1901 | void MainFrame::OnCmdStandardBand( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1902 | {
|
---|
1903 | pobj_Rebar->ChangeRebarBand(ID_STANDARDTOOLBAR);
|
---|
1904 | }
|
---|
1905 |
|
---|
1906 | void MainFrame::OnCmdReleaseBand( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1907 | {
|
---|
1908 | pobj_Rebar->ChangeRebarBand(ID_RELEASETOOLBAR);
|
---|
1909 | }
|
---|
1910 |
|
---|
1911 | void MainFrame::OnCmdDebugBand( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1912 | {
|
---|
1913 | pobj_Rebar->ChangeRebarBand(ID_DEBUGGERTOOLBAR);
|
---|
1914 | }
|
---|
1915 |
|
---|
1916 | void MainFrame::OnCmdSelectCompilerBand( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1917 | {
|
---|
1918 | pobj_Rebar->ChangeRebarBand(ID_SELECTCOMPILERCOMBO);
|
---|
1919 | }
|
---|
1920 |
|
---|
1921 | void MainFrame::OnCmdNoGripper( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1922 | {
|
---|
1923 | if(pobj_nv->bNoGripper) pobj_nv->bNoGripper=0;
|
---|
1924 | else pobj_nv->bNoGripper=1;
|
---|
1925 |
|
---|
1926 | //レバーコントロールを再生成
|
---|
1927 | pobj_Rebar->ResetRebar();
|
---|
1928 |
|
---|
1929 | //メニュー状態を設定
|
---|
1930 | ResetState_DocMenu();
|
---|
1931 | }
|
---|
1932 |
|
---|
1933 | void MainFrame::OnCmdResetRebar( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1934 | {
|
---|
1935 | //"ツールバーの配置をすべて初期状態に戻します。\nよろしいですか?"
|
---|
1936 | if( MessageBox(STRING_TOOLBAR_RESET,APPLICATION_NAME,MB_OKCANCEL|MB_ICONEXCLAMATION) == IDCANCEL )
|
---|
1937 | {
|
---|
1938 | return;
|
---|
1939 | }
|
---|
1940 |
|
---|
1941 | //レバーコントロールを再生成
|
---|
1942 | pobj_Rebar->ResetInitRebar();
|
---|
1943 |
|
---|
1944 | //メニュー状態を設定
|
---|
1945 | ResetState_DocMenu();
|
---|
1946 | }
|
---|
1947 |
|
---|
1948 | void MainFrame::OnCmdAllCloseOmitMyself( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1949 | {
|
---|
1950 | //このウィンドウ以外をすべて閉じる(&A)
|
---|
1951 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1952 | foreach ( MDIINFO *mi, MdiInfo ){
|
---|
1953 | if ( mi->hwnd == hChild ){
|
---|
1954 | continue;
|
---|
1955 | }
|
---|
1956 | if(mi->hwnd){
|
---|
1957 | ::PostMessage( mi->hwnd, WM_CLOSE, 0, 0 );
|
---|
1958 | //foreachの最中に削除されるとイテレータが回らないのでSendを使っていない。
|
---|
1959 | }
|
---|
1960 | }
|
---|
1961 | }
|
---|
1962 |
|
---|
1963 | void MainFrame::OnCmdPathCopy( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1964 | {
|
---|
1965 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1966 | int WndNum=GetWndNum(hChild);
|
---|
1967 |
|
---|
1968 | //絶対パスをコピー
|
---|
1969 | HGLOBAL hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,MdiInfo[WndNum]->path.size()+1);
|
---|
1970 | char *pTemp=(char *)GlobalLock(hGlobal);
|
---|
1971 | lstrcpy(pTemp,MdiInfo[WndNum]->path.c_str());
|
---|
1972 | GlobalUnlock(hGlobal);
|
---|
1973 |
|
---|
1974 | //クリップボードに保存
|
---|
1975 | OpenClipboard();
|
---|
1976 | EmptyClipboard();
|
---|
1977 | SetClipboardData(CF_TEXT,hGlobal);
|
---|
1978 | CloseClipboard();
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 | void MainFrame::OnCmdFolderOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1982 | {
|
---|
1983 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1984 | int WndNum=GetWndNum(hChild);
|
---|
1985 |
|
---|
1986 | OpenExplorer( MdiInfo[WndNum]->path );
|
---|
1987 | }
|
---|
1988 |
|
---|
1989 | void MainFrame::OnCmdDeleteFile( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
1990 | {
|
---|
1991 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
1992 | int WndNum=GetWndNum(hChild);
|
---|
1993 |
|
---|
1994 | char temporary[1024], temp2[1024];
|
---|
1995 | _splitpath(MdiInfo[WndNum]->path.c_str(),NULL,NULL,temporary,temp2);
|
---|
1996 | lstrcat(temporary,temp2);
|
---|
1997 |
|
---|
1998 | lstrcat(temporary," をごみ箱に移動して閉じます。よろしいですか?");
|
---|
1999 | if(MessageBox(temporary,APPLICATION_NAME,MB_OKCANCEL|MB_ICONQUESTION)==IDCANCEL) return;
|
---|
2000 |
|
---|
2001 | //ゴミ箱へ
|
---|
2002 | SHFILEOPSTRUCT fo;
|
---|
2003 | fo.hwnd=m_hWnd;
|
---|
2004 | fo.wFunc=FO_DELETE;
|
---|
2005 | fo.pFrom =MdiInfo[WndNum]->path.c_str();
|
---|
2006 | fo.pTo="\0";
|
---|
2007 | fo.fFlags =FOF_ALLOWUNDO|FOF_NOCONFIRMATION;
|
---|
2008 | SHFileOperation(&fo);
|
---|
2009 |
|
---|
2010 | //閉じる
|
---|
2011 | MdiInfo[WndNum]->pMdiTextEdit->UnModify();
|
---|
2012 | SendMessage(MdiInfo[WndNum]->hwnd,WM_CLOSE,0,0);
|
---|
2013 | }
|
---|
2014 |
|
---|
2015 | void MainFrame::OnCmdColor( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
2016 | {
|
---|
2017 | static COLORREF colorUser=RGB(255,255,255);
|
---|
2018 |
|
---|
2019 | switch( nID )
|
---|
2020 | {
|
---|
2021 | case IDM_USER_COLOR:
|
---|
2022 | {
|
---|
2023 | CHOOSECOLOR cc;
|
---|
2024 | COLORREF CusColors[16]={
|
---|
2025 | RGB(255,255,255),
|
---|
2026 | RGB(0,0,0),
|
---|
2027 | RGB(128,128,128),
|
---|
2028 | RGB(192,192,192),
|
---|
2029 | RGB(128,0,0),
|
---|
2030 | RGB(255,0,0),
|
---|
2031 | RGB(128,128,0),
|
---|
2032 | RGB(255,255,0),
|
---|
2033 | RGB(0,128,0),
|
---|
2034 | RGB(0,255,0),
|
---|
2035 | RGB(0,128,128),
|
---|
2036 | RGB(0,255,255),
|
---|
2037 | RGB(0,0,128),
|
---|
2038 | RGB(0,0,255),
|
---|
2039 | RGB(128,0,128),
|
---|
2040 | RGB(255,0,255)};
|
---|
2041 | cc.lStructSize=sizeof(CHOOSECOLOR);
|
---|
2042 | cc.hwndOwner=m_hWnd;
|
---|
2043 | cc.rgbResult=colorUser;
|
---|
2044 | cc.lpCustColors=CusColors;
|
---|
2045 | cc.Flags=CC_RGBINIT|CC_FULLOPEN;
|
---|
2046 | if(!ChooseColor(&cc)){
|
---|
2047 | return;
|
---|
2048 | }
|
---|
2049 | colorUser=cc.rgbResult;
|
---|
2050 | }
|
---|
2051 | case IDM_GRAY:
|
---|
2052 | case IDM_WHITE:
|
---|
2053 | case IDM_RED:
|
---|
2054 | case IDM_GREEN:
|
---|
2055 | case IDM_BLUE:
|
---|
2056 | case IDM_YELLOW:
|
---|
2057 | {
|
---|
2058 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
2059 |
|
---|
2060 | TC_ITEM tcItem;
|
---|
2061 | tcItem.mask=TCIF_PARAM;
|
---|
2062 | if(nID==IDM_GRAY) tcItem.lParam=TABCOLOR_GRAY;
|
---|
2063 | if(nID==IDM_WHITE) tcItem.lParam=TABCOLOR_WHITE;
|
---|
2064 | if(nID==IDM_RED) tcItem.lParam=TABCOLOR_RED;
|
---|
2065 | if(nID==IDM_GREEN) tcItem.lParam=TABCOLOR_GREEN;
|
---|
2066 | if(nID==IDM_BLUE) tcItem.lParam=TABCOLOR_BLUE;
|
---|
2067 | if(nID==IDM_YELLOW) tcItem.lParam=TABCOLOR_YELLOW;
|
---|
2068 | if(nID==IDM_USER_COLOR) tcItem.lParam=colorUser;
|
---|
2069 | TabCtrl_SetItem(pobj_MainTab->hTab,
|
---|
2070 | TabCtrl_GetCurSel(pobj_MainTab->hTab),
|
---|
2071 | &tcItem);
|
---|
2072 | ::InvalidateRect(pobj_MainTab->hTab,NULL,0);
|
---|
2073 | break;
|
---|
2074 | }
|
---|
2075 | default:
|
---|
2076 | throw;
|
---|
2077 | }
|
---|
2078 | }
|
---|