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