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

Last change on this file since 749 was 749, checked in by dai, 16 years ago

「フォルダを開く」コマンドで、ファイル選択を可能にした。

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