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

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