source: dev/branches/egtra/ab5.0/abdev/abdev/src/MainFrame.cpp@ 778

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

XP以前対応途中(Win98でabdevが起動するところまで)

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