source: dev/trunk/ab5.0/abdev/abdev/src/MainFrame.cpp@ 824

Last change on this file since 824 was 824, checked in by イグトランス (egtra), 12 years ago

Windows SDK 7.1以上を前提とし、それ以前のWindows/Platform SDK対応の記述を削除。

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