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

Last change on this file since 681 was 655, checked in by dai_9181, 15 years ago

FileManager周りをリファクタリング

File size: 46.1 KB
Line 
1#include "stdafx.h"
2
3using namespace ActiveBasic::IDE;
4using namespace ActiveBasic::IDE::WindowComponents;
5
6LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
7void SetupWindow(HWND hwnd);
8void ResetTextEditFont(HWND hwnd);
9
10void 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( ::UINT msg, ::WPARAM wParam, ::LPARAM lParam, ::BOOL& handled )
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    ::SetWindowLong( hOwner, GWL_WNDPROC, (LONG)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,-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 dummy )
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    HANDLE fh;
552    sprintf(temporary,"%spgm.tmp",pj_editor_Dir);
553    fh=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
554    ReadFile(fh,temporary,MAX_PATH,&AccBytes,NULL);
555    CloseHandle(fh);
556    temporary[AccBytes]=0;
557    HWND hChild=::GetWindow(hClient,GW_CHILD);
558    int WndNum = -1;
559    while(hChild){
560        WndNum=GetWndNum(hChild);
561        if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
562            if(lstrcmpi(MdiInfo[WndNum]->path.c_str(),temporary)==0) break;
563        }
564        hChild=::GetNextWindow(hChild,GW_HWNDNEXT);
565    }
566    if(!hChild){
567        hChild=OpenFileWithExtension(temporary);
568        WndNum=GetWndNum(hChild);
569    }
570
571    if(WndNum==-1) return 0;
572
573    //ウィンドウを最前面に表示
574    ::BringWindowToTop(hChild);
575    ::UpdateWindow(hChild);
576
577    char *pTemp=MdiInfo[WndNum]->pMdiTextEdit->buffer;
578
579    //行の先頭インデックスを取得(取得する行の番号はwParamで渡される)
580    int i,i2;
581    for(i=0,i2=0;;i++){
582        if(i2>=(int)wParam) break;
583        if(pTemp[i]=='\0') break;
584        if(pTemp[i]=='\r'&&pTemp[i+1]=='\n'){
585            i++;
586            i2++;
587        }
588    }
589    POINT pos;
590    pos.x=i;
591
592    //行の終端インデックスを取得
593    for(;;i++){
594        if(pTemp[i]=='\0') break;
595        if(pTemp[i]=='\r'&&pTemp[i+1]=='\n') break;
596    }
597    pos.y=i;
598
599    //行を選択する
600    TextEdit_SetSel(WndNum,pos.x,pos.y,TRUE);
601
602    return 0;
603}
604
605void MainFrame::OnCmdNew( UINT uNotifyCode, int nID, CWindow wndCtl )
606{
607
608#ifdef THETEXT
609    NewTextEditWindow(NULL,WNDTYPE_TEXT);
610    return;
611#else
612    int FileType;
613    BOOL bAddToProject;
614    char temporary[MAX_PATH];
615
616    FileType=DialogBox(hResInst,MAKEINTRESOURCE(IDD_NEWFILE),hOwner,(DLGPROC)DlgNewFile);
617    if(FileType==-1) return;
618
619    if(FileType&0x00008000){
620        bAddToProject=1;
621        FileType&=0x0FFF;
622        extern char NewFileName[MAX_PATH];
623        lstrcpy(temporary,NewFileName);
624        if(!strstr(temporary,".")) lstrcat(temporary,".ab");
625
626        lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
627    }
628    else bAddToProject=0;
629
630    switch(FileType){
631        case FT_BASICPROGRAM:       //Basicプログラム
632        case FT_SUBPROGRAM:
633            if(bAddToProject){
634                WriteBuffer(temporary,0,0);
635                NewTextEditWindow(temporary,WNDTYPE_BASIC);
636                Project_File_Insert(temporary);
637            }
638            else NewTextEditWindow(NULL,WNDTYPE_BASIC);
639            break;
640
641        case FT_PROJECT:
642            DlgNewProjectWizard(hOwner);
643            break;
644
645        case FT_TEXT:
646            NewTextEditWindow(NULL,WNDTYPE_TEXT);
647            break;
648
649        case FT_HTML:
650            NewTextEditWindow(NULL,WNDTYPE_HTML);
651            break;
652
653        case FT_ICON:
654            NewIconEditWindow(NULL);
655            break;
656    }
657#endif
658}
659
660void MainFrame::OnCmdOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
661{
662    //"ファイルを指定してください"
663    extern LPSTR DefFileFilter;
664    char temporary[1024];
665    if(!GetFilePathDialog(m_hWnd,temporary,DefFileFilter,STRING_FILEOPENTITLE_DEFAULT,TRUE)) return;
666
667    OpenFileWithExtension( temporary );
668}
669
670void MainFrame::OnCmdClose( UINT uNotifyCode, int nID, CWindow wndCtl )
671{
672    HWND hChild=::GetWindow(hClient,GW_CHILD);
673    if(::IsWindow(hChild)) SendMessage(hChild,WM_CLOSE,0,0);
674}
675
676void MainFrame::OnCmdProjectOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
677{
678    //"プロジェクト ファイルを指定して下さい"
679    extern LPSTR ProjectFileFilter;
680    char temporary[1024];
681    if(!GetFilePathDialog(m_hWnd,temporary,ProjectFileFilter,STRING_FILEOPENTITLE_PROJECT,TRUE))
682    {
683        return;
684    }
685
686    projectInfo.Load(temporary);
687}
688
689void MainFrame::OnCmdProjectSave( UINT uNotifyCode, int nID, CWindow wndCtl )
690{
691    projectInfo.Save();
692}
693
694void MainFrame::OnCmdProjectClose( UINT uNotifyCode, int nID, CWindow wndCtl )
695{
696    projectInfo.Close();
697}
698
699void MainFrame::OnCmdProjectFolderOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
700{
701    ShellExecute(m_hWnd,"explore",projectInfo.GetWorkDir().GetPath().c_str(),NULL,NULL,SW_SHOWNORMAL);
702}
703
704void MainFrame::OnCmdSave( UINT uNotifyCode, int nID, CWindow wndCtl )
705{
706    SaveDocument(::GetWindow(hClient,GW_CHILD),NULL);
707}
708
709void MainFrame::OnCmdNewSave( UINT uNotifyCode, int nID, CWindow wndCtl )
710{
711    //"保存先のファイルを指定してください"
712    extern LPSTR DefFileFilter;
713    char temporary[1024];
714    if(!GetFilePathDialog(m_hWnd,temporary,DefFileFilter,STRING_FILESAVETITLE_DEFAULT,FALSE)) return;
715
716    SaveDocument(::GetWindow(hClient,GW_CHILD),temporary);
717}
718
719void MainFrame::OnCmdCodeSave( UINT uNotifyCode, int nID, CWindow wndCtl )
720{
721    //文字コードを指定して保存
722    DialogBox(hResInst,MAKEINTRESOURCE(IDD_CODE_SAVE),m_hWnd,(DLGPROC)nkfDlgCodeSave);
723}
724
725void MainFrame::OnCmdAllSave( UINT uNotifyCode, int nID, CWindow wndCtl )
726{
727    for( int i=0;i<MdiInfo.size();i++){
728        if(MdiInfo[i]->hwnd) SaveDocument(MdiInfo[i]->hwnd,NULL);
729    }
730    if( projectInfo.IsOpened() )
731    {
732        projectInfo.Save();
733    }
734}
735
736void MainFrame::OnCmdPageSet( UINT uNotifyCode, int nID, CWindow wndCtl )
737{
738    //ページ設定
739    obj_Page.SetupDlg();
740}
741
742void MainFrame::OnCmdPreview( UINT uNotifyCode, int nID, CWindow wndCtl )
743{
744    //プレビュー(Pro版のみ)
745    Preview();
746}
747
748void MainFrame::OnCmdPrintOut( UINT uNotifyCode, int nID, CWindow wndCtl )
749{
750    //印刷
751    Printout();
752}
753
754void MainFrame::OnCmdExit( UINT uNotifyCode, int nID, CWindow wndCtl )
755{
756    SendMessage(WM_CLOSE);
757}
758
759void MainFrame::OnCmdUndo( UINT uNotifyCode, int nID, CWindow wndCtl )
760{
761    HWND hChild=::GetWindow(hClient,GW_CHILD);
762    if(!hChild) return;
763    int WndNum=GetWndNum(hChild);
764    if( IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType) )
765    {
766        TextEdit_UndoCommand(WndNum);
767    }
768    else if( MdiInfo[WndNum]->DocType == WNDTYPE_RAD )
769    {
770        Rad_UndoCommand(WndNum);
771    }
772    else if( MdiInfo[WndNum]->DocType == WNDTYPE_ICONEDIT )
773    {
774        IconEdit_UndoCommand(WndNum);
775    }
776}
777
778void MainFrame::OnCmdRedo( UINT uNotifyCode, int nID, CWindow wndCtl )
779{
780    HWND hChild=::GetWindow(hClient,GW_CHILD);
781    if(!hChild) return;
782    int WndNum=GetWndNum(hChild);
783    if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType))
784        TextEdit_RedoCommand(WndNum);
785    else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD)
786        Rad_RedoCommand(WndNum);
787    else if(MdiInfo[WndNum]->DocType==WNDTYPE_ICONEDIT)
788        IconEdit_RedoCommand(WndNum);
789}
790
791void MainFrame::OnCmdCut( UINT uNotifyCode, int nID, CWindow wndCtl )
792{
793    HWND hChild=::GetWindow(hClient,GW_CHILD);
794    int WndNum=GetWndNum(hChild);
795    if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
796        HWND hEdit=::GetWindow(hChild,GW_CHILD);
797
798        CHARRANGE CharRange;
799        TextEdit_GetSel(WndNum,&CharRange);
800
801        HGLOBAL hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
802        char *pTemp=(char *)GlobalLock(hGlobal);
803        memcpy(pTemp,MdiInfo[WndNum]->pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
804        pTemp[CharRange.cpMax-CharRange.cpMin]=0;
805        GlobalUnlock(hGlobal);
806
807        //クリップボードに保存
808        OpenClipboard();
809        EmptyClipboard();
810        SetClipboardData(CF_TEXT,hGlobal);
811        CloseClipboard();
812
813        //選択文字列を消去
814        SendMessage(hEdit,WM_KEYDOWN,VK_DELETE,0);
815    }
816    else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD){
817        ActiveBasic::PM::WindowInfo *pWindowInfo = GetWndInfo(MdiInfo[WndNum]->path);
818        int indexOfWndInfo = GetWndInfoNum(MdiInfo[WndNum]->path);
819
820        //クリップボードに格納するためのデータを用意する
821        pWindowInfo->childWindowInfos[MdiInfo[WndNum]->MdiRadInfo->SelectingItem[0]]->pos.x-=17;
822        pWindowInfo->childWindowInfos[MdiInfo[WndNum]->MdiRadInfo->SelectingItem[0]]->pos.y-=10;
823        HGLOBAL hGlobal=Rad_GetChildInfoClipboardData(WndNum,indexOfWndInfo);
824        pWindowInfo->childWindowInfos[MdiInfo[WndNum]->MdiRadInfo->SelectingItem[0]]->pos.x+=17;
825        pWindowInfo->childWindowInfos[MdiInfo[WndNum]->MdiRadInfo->SelectingItem[0]]->pos.y+=10;
826
827        OpenClipboard();
828        EmptyClipboard();
829        extern DWORD dwRadClipboardID;
830        SetClipboardData(dwRadClipboardID,hGlobal);
831        CloseClipboard();
832
833        SendMessage(MdiInfo[WndNum]->MdiRadInfo->hRad,WM_COMMAND,IDM_RAD_ITEM_DELETE,0);
834    }
835    else if(MdiInfo[WndNum]->DocType==WNDTYPE_ICONEDIT){
836        //クリップボードに格納するためのデータを用意する
837        HGLOBAL hGlobal=IconEdit_GetChildInfoClipboardData(WndNum);
838        if(hGlobal==0) return;
839
840        OpenClipboard();
841        EmptyClipboard();
842        SetClipboardData(CF_BITMAP,hGlobal);
843        CloseClipboard();
844
845        DeleteObject(MdiInfo[WndNum]->MdiIconEditInfo->hSelectingBmp);
846        MdiInfo[WndNum]->MdiIconEditInfo->SelectLevel=0;
847
848        IconEdit_EraseRect(WndNum,&MdiInfo[WndNum]->MdiIconEditInfo->DraggingRect);
849    }
850}
851
852void MainFrame::OnCmdCopy( UINT uNotifyCode, int nID, CWindow wndCtl )
853{
854    HWND hChild=::GetWindow(hClient,GW_CHILD);
855    int WndNum=GetWndNum(hChild);
856    if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
857        HWND hEdit = ::GetWindow(hChild,GW_CHILD);
858
859        CHARRANGE CharRange;
860        TextEdit_GetSel(WndNum,&CharRange);
861
862        HGLOBAL hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
863        char *pTemp=(char *)GlobalLock(hGlobal);
864        memcpy(pTemp,MdiInfo[WndNum]->pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
865        pTemp[CharRange.cpMax-CharRange.cpMin]=0;
866        GlobalUnlock(hGlobal);
867
868        //クリップボードに保存
869        OpenClipboard();
870        EmptyClipboard();
871        SetClipboardData(CF_TEXT,hGlobal);
872        CloseClipboard();
873    }
874    else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD){
875        int indexOfWndInfo = GetWndInfoNum(MdiInfo[WndNum]->path);
876
877        //クリップボードに格納するためのデータを用意する
878        HGLOBAL hGlobal=Rad_GetChildInfoClipboardData(WndNum,indexOfWndInfo);
879
880        OpenClipboard();
881        EmptyClipboard();
882        extern DWORD dwRadClipboardID;
883        SetClipboardData(dwRadClipboardID,hGlobal);
884        CloseClipboard();
885    }
886    else if(MdiInfo[WndNum]->DocType==WNDTYPE_ICONEDIT){
887        //クリップボードに格納するためのデータを用意する
888        HGLOBAL hGlobal=IconEdit_GetChildInfoClipboardData(WndNum);
889
890        OpenClipboard();
891        EmptyClipboard();
892        SetClipboardData(CF_BITMAP,hGlobal);
893        CloseClipboard();
894    }
895}
896
897void MainFrame::OnCmdPaste( UINT uNotifyCode, int nID, CWindow wndCtl )
898{
899    HWND hChild=::GetWindow(hClient,GW_CHILD);
900    int WndNum=GetWndNum(hChild);
901    if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
902        HWND hEdit=::GetWindow(hChild,GW_CHILD);
903
904        //クリップボードを開く
905        OpenClipboard();
906        HGLOBAL hGlobal=GetClipboardData(CF_TEXT);
907        if(!hGlobal){
908            CloseClipboard();
909            return;
910        }
911
912
913        char *pTemp;
914        if(pobj_nv->bPasteIndent){
915            //インデント整形
916            pTemp=CodeFormatter((char *)GlobalLock(hGlobal));
917            GlobalUnlock(hGlobal);
918        }
919        else pTemp=(char *)GlobalLock(hGlobal);
920
921
922        //テキストエディタの文字列をリプレイス
923        TextEdit_ReplaceUpdateUndoData(WndNum,
924            pTemp,
925            1,
926            1);
927
928        if(pobj_nv->bPasteIndent)
929            HeapDefaultFree(pTemp);
930        else
931            GlobalUnlock(hGlobal);
932
933        //クリップボードを閉じる
934        CloseClipboard();
935
936
937        //キャレット位置までスクロールする
938        TextEdit_ScrollCaret(WndNum,0);
939        ResetCaretPos(WndNum);
940    }
941    else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD){
942        OpenClipboard();
943        extern DWORD dwRadClipboardID;
944        HGLOBAL hGlobal=GetClipboardData(dwRadClipboardID);
945        if(!hGlobal){
946            CloseClipboard();
947            return;
948        }
949        Rad_PasteChildInfoClipboardData(WndNum,hGlobal);
950        CloseClipboard();
951    }
952    else if(MdiInfo[WndNum]->DocType==WNDTYPE_ICONEDIT){
953        OpenClipboard();
954        HGLOBAL hGlobal=GetClipboardData(CF_BITMAP);
955        if(!hGlobal){
956            CloseClipboard();
957            return;
958        }
959        IconEdit_PasteChildInfoClipboardData(WndNum,(HBITMAP)hGlobal);
960        CloseClipboard();
961    }
962}
963
964void MainFrame::OnCmdDelete( UINT uNotifyCode, int nID, CWindow wndCtl )
965{
966    HWND hChild=::GetWindow(hClient,GW_CHILD);
967    int WndNum=GetWndNum(hChild);
968    if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
969        HWND hEdit=::GetWindow(hChild,GW_CHILD);
970        TextEdit_ReplaceUpdateUndoData(WndNum,"",0,1);
971    }
972    else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD)
973        SendMessage(MdiInfo[WndNum]->MdiRadInfo->hRad,WM_COMMAND,IDM_RAD_ITEM_DELETE,0);
974}
975
976void MainFrame::OnCmdAllSelect( UINT uNotifyCode, int nID, CWindow wndCtl )
977{
978    HWND hChild=::GetWindow(hClient,GW_CHILD);
979    int WndNum=GetWndNum(hChild);
980    if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
981        HWND hEdit=::GetWindow(hChild,GW_CHILD);
982
983        MdiInfo[WndNum]->pMdiTextEdit->StartCaretPos.x=0;
984        MdiInfo[WndNum]->pMdiTextEdit->StartCaretPos.y=0;
985
986        GetCaretPosFromBufferIndex(
987            MdiInfo[WndNum]->pMdiTextEdit->buffer,
988            lstrlen(MdiInfo[WndNum]->pMdiTextEdit->buffer),
989            &MdiInfo[WndNum]->pMdiTextEdit->EndCaretPos);
990
991        ::InvalidateRect(hEdit,NULL,0);
992
993        ResetState_EditMenu();
994    }
995    else if(MdiInfo[WndNum]->DocType==WNDTYPE_RAD){
996        ActiveBasic::PM::WindowInfo *pWindowInfo = GetWndInfo(MdiInfo[WndNum]->path);
997        for( int i3=0; i3<static_cast<int>(pWindowInfo->childWindowInfos.size()); i3++ )
998        {
999            MdiInfo[WndNum]->MdiRadInfo->SelectingItem[i3] = i3;
1000        }
1001        DrawRadWindow(WndNum,pWindowInfo);
1002    }
1003}
1004
1005void MainFrame::OnCmdFind( UINT uNotifyCode, int nID, CWindow wndCtl )
1006{
1007    DialogBox(hResInst,MAKEINTRESOURCE(IDD_FIND),m_hWnd,(DLGPROC)DlgFind);
1008}
1009
1010void MainFrame::OnCmdPermutation( UINT uNotifyCode, int nID, CWindow wndCtl )
1011{
1012    DialogBox(hResInst,MAKEINTRESOURCE(IDD_PERMUTATION),m_hWnd,(DLGPROC)DlgPermutation);
1013}
1014
1015void MainFrame::OnCmdConvertX( UINT uNotifyCode, int nID, CWindow wndCtl )
1016{
1017    TextEdit_Convert( nID );
1018}
1019
1020#ifdef THETEXT
1021void MainFrame::OnCmdStringCount( UINT uNotifyCode, int nID, CWindow wndCtl )
1022{
1023    DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_STRING_COUNT),m_hWnd,(DLGPROC)DlgStringCount,0);
1024}
1025
1026void MainFrame::OnCmdSelStringCount( UINT uNotifyCode, int nID, CWindow wndCtl )
1027{
1028    DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_STRING_COUNT),m_hWnd,(DLGPROC)DlgStringCount,1);
1029}
1030#endif
1031
1032void MainFrame::OnCmdProjectView( UINT uNotifyCode, int nID, CWindow wndCtl )
1033{
1034    extern HWND hProjectView;
1035    bool isCheck = false;
1036    if(pobj_nv->bClipProjectView){
1037        if(::IsWindowVisible(hProjectView)){
1038            ::ShowWindow(hProjectView,SW_HIDE);
1039        }
1040        else{
1041            ::ShowWindow(hProjectView,SW_SHOW);
1042            isCheck = true;
1043        }
1044    }
1045    else{
1046        extern HWND hProjectView_ToolWindow;
1047        if(::IsWindowVisible(hProjectView_ToolWindow)){
1048            ::ShowWindow(hProjectView_ToolWindow,SW_HIDE);
1049        }
1050        else{
1051            ::ShowWindow(hProjectView_ToolWindow,SW_SHOW);
1052            ::ShowWindow(hProjectView,SW_SHOW);
1053            isCheck = true;
1054        }
1055    }
1056    pobj_MainMenu->CheckMenu(IDM_PROJECTVIEW,isCheck);
1057
1058    //再配置
1059    this->Resized();
1060
1061    ::ShowWindow(hClient,SW_SHOW);
1062}
1063
1064void MainFrame::OnCmdProjectOption( UINT uNotifyCode, int nID, CWindow wndCtl )
1065{
1066    DlgProjectOptionSetting( m_hWnd );
1067}
1068
1069void MainFrame::OnCmdTopMost( UINT uNotifyCode, int nID, CWindow wndCtl )
1070{
1071    if(pobj_MainMenu->IsCheck(IDM_TOPMOST)){
1072        SetWindowPos( HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
1073        pobj_MainMenu->CheckMenu(IDM_TOPMOST,0);
1074    }
1075    else{
1076        SetWindowPos( HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
1077        pobj_MainMenu->CheckMenu(IDM_TOPMOST,1);
1078    }
1079}
1080
1081void ResetState_ViewMenu(void);
1082void MainFrame::OnCmdRightTurn( UINT uNotifyCode, int nID, CWindow wndCtl )
1083{
1084    pobj_nv->bRightTurn^=1;
1085    ResetState_ViewMenu();
1086
1087    //トップのウィンドウを再描画
1088    RedrawAllWindow();
1089}
1090
1091void MainFrame::OnCmdSet( UINT uNotifyCode, int nID, CWindow wndCtl )
1092{
1093    DlgOptionSetting( m_hWnd );
1094}
1095
1096void CreateProcessWithStdHandle( const std::string &appPath, const std::string &cmdLine)
1097{
1098    std::string argsStr = (std::string)"\"" + appPath + "\" " + cmdLine;
1099    STARTUPINFO si;
1100    PROCESS_INFORMATION pi;
1101    memset(&si,0,sizeof(STARTUPINFO));
1102    si.cb=sizeof(STARTUPINFO);
1103    si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
1104    si.wShowWindow = SW_HIDE;
1105    si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
1106    si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
1107    si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
1108   
1109    char args[8192];
1110    lstrcpy( args, argsStr.c_str() );
1111
1112    CreateProcess( NULL, args, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi );
1113}
1114
1115#ifndef THETEXT
1116void MainFrame::OnCmdDebug( UINT uNotifyCode, int nID, CWindow wndCtl )
1117{
1118    char temporary[1024], temp2[1024], temp3[1024];
1119    if(pobj_Debugger->IsDebugging()){
1120        pobj_Debugger->DebugContinue();
1121        return;
1122    }
1123
1124    HWND hChild = ::GetWindow(hClient,GW_CHILD);
1125    if( projectInfo.IsOpened() ){
1126        //プロジェクトが開かれている場合
1127        if(!SetProjectToRun()) return;
1128
1129        //デバッグ用のコマンドライン及び実行可能ファイル(DLLのみ)
1130        sprintf(temporary,"%s\r\n%s",projectInfo.szExePath,projectInfo.szCmdLine);
1131        sprintf(temp2,"%spgm.tmp",pj_editor_Dir);
1132        HANDLE hFile=CreateFile(temp2,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_TEMPORARY,NULL);
1133        DWORD dwAccessBytes;
1134        WriteFile(hFile,temporary,lstrlen(temporary),&dwAccessBytes,NULL);
1135        CloseHandle(hFile);
1136
1137        //ソースファイル名をtemp2へ
1138        lstrcpy( temp2, projectInfo.fileSystem.root.files[0].GetFullPath().c_str() );
1139
1140        //出力ファイル名をtemp3へ
1141        lstrcpy(temp3,projectInfo.lpszOutput_Debug);
1142        lstrcpy( temp3, projectInfo.GetWorkDir().GetFullPath( temp3 ).c_str() );
1143
1144        if(IsNeedCompileForProject(1))
1145            sprintf(temporary,"\"%s\" \"%s\" /debug /run /wnd:%08x",temp2,temp3,m_hWnd);
1146        else
1147            sprintf(temporary,"\"%s\" \"%s\" /run /wnd:%08x",temp2,temp3,m_hWnd);
1148
1149        // DLLオプション
1150        if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
1151        {
1152            lstrcat(temporary," /dll");
1153        }
1154
1155        // SLLオプション
1156        if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Sll )
1157        {
1158            lstrcat(temporary," /static_library");
1159        }
1160
1161        //Unicodeオプション
1162        if(projectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
1163
1164        //ブレークポイントをセーブ
1165        projectInfo.pobj_DBBreakPoint->SaveToTempFile();
1166    }
1167    else{
1168        //単独ソースコード
1169        if(!SetRunning(hChild)) return;
1170        if(IsNeedCompile(MdiInfo[GetWndNum(hChild)]->path,1))
1171            sprintf(temporary,"\"%s\" /debug /run /wnd:%08x",MdiInfo[GetWndNum(hChild)]->path.c_str(),m_hWnd);
1172        else
1173            sprintf(temporary,"\"%s\" /run /wnd:%08x",MdiInfo[GetWndNum(hChild)]->path.c_str(),m_hWnd);
1174
1175        //ブレークポイントをセーブ
1176        extern CDBBreakPoint *pobj_DBBreakPoint;
1177        pobj_DBBreakPoint->SaveToTempFile();
1178    }
1179
1180    //コンパイルビューをクリップするかどうか
1181    extern BOOL bClipCompileView;
1182    if(bClipCompileView){
1183        lstrcat(temporary," /clip_compile_view");
1184
1185        //コンパイラビューを閉じる
1186        extern HWND hCompileView;
1187        if(hCompileView==(HWND)-1) return;
1188        if(hCompileView){
1189            hChild=hCompileView;
1190            hCompileView=(HWND)-1;
1191            SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
1192        }
1193
1194        //重複起動防止のため
1195        hCompileView=(HWND)-1;
1196    }
1197
1198    //インクルードディレクトリ
1199    sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
1200    lstrcat(temporary,temp2);
1201
1202    extern ActiveBasic::Common::Platform::EnumType selectingPlatform;
1203    CreateProcessWithStdHandle( ActiveBasic::Common::Environment::GetCompilerExePath( selectingPlatform ), temporary );
1204}
1205
1206void MainFrame::OnCmdDebugCompile( UINT uNotifyCode, int nID, CWindow wndCtl )
1207{
1208    char temporary[1024], temp2[1024], temp3[1024];
1209
1210    HWND hChild=::GetWindow(hClient,GW_CHILD);
1211    if( projectInfo.IsOpened() ){
1212        //プロジェクトが開かれている場合
1213        if(!SetProjectToRun()) return;
1214
1215        //ソースファイル名をtemp2へ
1216        lstrcpy( temp2, projectInfo.fileSystem.root.files[0].GetFullPath().c_str() );
1217
1218        //出力ファイル名をtemp3へ
1219        lstrcpy(temp3,projectInfo.lpszOutput_Debug);
1220        lstrcpy( temp3, projectInfo.GetWorkDir().GetFullPath( temp3 ).c_str() );
1221
1222        sprintf(temporary,"\"%s\" \"%s\" /debug /wnd:%08x",temp2,temp3,m_hWnd);
1223
1224        //DLLオプション
1225        if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
1226        {
1227            lstrcat(temporary," /dll");
1228        }
1229
1230        // SLLオプション
1231        if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Sll )
1232        {
1233            lstrcat(temporary," /static_library");
1234        }
1235
1236        //Unicodeオプション
1237        if(projectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
1238    }
1239    else{
1240        //単独ソースコード
1241        if(!SetRunning(hChild)) return;
1242        sprintf(temporary,"\"%s\" /debug /wnd:%08x",MdiInfo[GetWndNum(hChild)]->path.c_str(),m_hWnd);
1243    }
1244
1245    //コンパイルビューをクリップするかどうか
1246    extern BOOL bClipCompileView;
1247    if(bClipCompileView){
1248        lstrcat(temporary," /clip_compile_view");
1249
1250        //コンパイラビューを閉じる
1251        extern HWND hCompileView;
1252        if(hCompileView==(HWND)-1) return;
1253        if(hCompileView){
1254            hChild=hCompileView;
1255            hCompileView=(HWND)-1;
1256            if( ::IsWindow( hChild ) )
1257            {
1258                SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
1259            }
1260        }
1261
1262        //重複起動防止のため
1263        hCompileView=(HWND)-1; 
1264    }
1265
1266    //インクルードディレクトリ
1267    sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
1268    lstrcat(temporary,temp2);
1269
1270    extern ActiveBasic::Common::Platform::EnumType selectingPlatform;
1271    CreateProcessWithStdHandle( ActiveBasic::Common::Environment::GetCompilerExePath( selectingPlatform ), temporary );
1272
1273}
1274
1275void MainFrame::OnCmdAttach( UINT uNotifyCode, int nID, CWindow wndCtl )
1276{
1277    char temporary[1024], temp2[1024];
1278
1279    int idProcess;
1280    DWORD dwPlatform;
1281    idProcess=DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_ATTACH),m_hWnd,(DLGPROC)DlgAttach,(LPARAM)&dwPlatform);
1282    if(idProcess==0) return;
1283
1284    sprintf(temporary,"/attach:%08x /wnd:%08x",idProcess,m_hWnd);
1285
1286    //コンパイルビューをクリップするかどうか
1287    extern BOOL bClipCompileView;
1288    if(bClipCompileView){
1289        lstrcat(temporary," /clip_compile_view");
1290
1291        //コンパイラビューを閉じる
1292        extern HWND hCompileView;
1293        if(hCompileView==(HWND)-1) return;
1294        if(hCompileView){
1295            HWND hChild=hCompileView;
1296            hCompileView=(HWND)-1;
1297            SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
1298        }
1299
1300        //重複起動防止のため
1301        hCompileView=(HWND)-1;
1302    }
1303
1304    //インクルードディレクトリ
1305    sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
1306    lstrcat(temporary,temp2);
1307
1308    ActiveBasic::Common::Platform::EnumType platform;
1309    if(dwPlatform==IMAGE_FILE_MACHINE_I386)
1310    {
1311        platform = ActiveBasic::Common::Platform::X86;
1312    }
1313    else if(dwPlatform==IMAGE_FILE_MACHINE_AMD64)
1314    {
1315        platform = ActiveBasic::Common::Platform::X64;
1316    }
1317    else
1318    {
1319        throw;
1320    }
1321
1322    extern ActiveBasic::Common::Platform::EnumType selectingPlatform;
1323    CreateProcessWithStdHandle( ActiveBasic::Common::Environment::GetCompilerExePath( platform ), temporary );
1324}
1325
1326void MainFrame::OnCmdReleaseCompile( UINT uNotifyCode, int nID, CWindow wndCtl )
1327{
1328    char temporary[1024], temp2[1024], temp3[1024];
1329
1330    HWND hChild=::GetWindow(hClient,GW_CHILD);
1331    if( projectInfo.IsOpened() ){
1332        //プロジェクトが開かれている場合
1333        if(!SetProjectToRun()) return;
1334
1335        //ソースファイル名をtemp2へ
1336        lstrcpy( temp2, projectInfo.fileSystem.root.files[0].GetFullPath().c_str() );
1337
1338        //出力ファイル名をtemp3へ
1339        lstrcpy(temp3,projectInfo.lpszOutput_Release);
1340        lstrcpy( temp3, projectInfo.GetWorkDir().GetFullPath( temp3 ).c_str() );
1341
1342        sprintf(temporary,"\"%s\" \"%s\" /wnd:%08x",temp2,temp3,m_hWnd);
1343
1344        //DLLオプション
1345        if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
1346        {
1347            lstrcat(temporary," /dll");
1348        }
1349
1350        // SLLオプション
1351        if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Sll )
1352        {
1353            lstrcat(temporary," /static_library");
1354        }
1355
1356        //Unicodeオプション
1357        if(projectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
1358    }
1359    else{
1360        //単独ソースコード
1361        if(!SetRunning(hChild)) return;
1362        sprintf(temporary,"\"%s\" /wnd:%08x",MdiInfo[GetWndNum(hChild)]->path.c_str(),m_hWnd);
1363    }
1364
1365    //コンパイルビューをクリップするかどうか
1366    extern BOOL bClipCompileView;
1367    if(bClipCompileView){
1368        lstrcat(temporary," /clip_compile_view");
1369
1370        //コンパイラビューを閉じる
1371        extern HWND hCompileView;
1372        if(hCompileView==(HWND)-1) return;
1373        if(hCompileView){
1374            hChild=hCompileView;
1375            hCompileView=(HWND)-1;
1376            if( ::IsWindow( hChild ) )
1377            {
1378                SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
1379            }
1380        }
1381
1382        //重複起動防止のため
1383        hCompileView=(HWND)-1;
1384    }
1385
1386    //インクルードディレクトリ
1387    sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
1388    lstrcat(temporary,temp2);
1389
1390    extern ActiveBasic::Common::Platform::EnumType selectingPlatform;
1391    CreateProcessWithStdHandle( ActiveBasic::Common::Environment::GetCompilerExePath( selectingPlatform ), temporary );
1392}
1393
1394void MainFrame::OnCmdReleaseRun( UINT uNotifyCode, int nID, CWindow wndCtl )
1395{
1396    char temporary[1024], temp2[1024], temp3[1024];
1397
1398    HWND hChild=::GetWindow(hClient,GW_CHILD);
1399    if( projectInfo.IsOpened() ){
1400/*                      //プロジェクトが開かれている場合
1401        if(!SetProjectToRun()) return;
1402
1403        //必要であればリリースコンパイル
1404        if(IsNeedCompileForProject(0))
1405            SendMessage(WM_COMMAND,IDM_RELEASECOMPILE,0);*/
1406
1407        if( projectInfo.GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
1408        {
1409            lstrcpy(temporary,projectInfo.szExePath);
1410        }
1411        else{
1412            lstrcpy(temporary,projectInfo.lpszOutput_Debug);
1413            lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
1414        }
1415    }
1416    else{
1417/*                      //必要であればリリースコンパイル
1418        if(!SetRunning(hChild)) return;
1419
1420        if(IsNeedCompile(MdiInfo[GetWndNum(hChild)]->path,0))
1421            SendMessage(WM_COMMAND,IDM_RELEASECOMPILE,0);*/
1422
1423        //単独ソースコード
1424        _splitpath(MdiInfo[GetWndNum(hChild)]->path.c_str(),temporary,temp2,temp3,NULL);
1425        lstrcat(temporary,temp2);
1426        lstrcat(temporary,temp3);
1427        lstrcat(temporary,".exe");
1428    }
1429
1430    //インクルードディレクトリ
1431    sprintf(temp2," /include_dir:\"%s\"",pobj_nv->GetIncludeDirFullPath().c_str());
1432    lstrcat(temporary,temp2);
1433
1434    ShellExecute(m_hWnd,"open",temporary,NULL,NULL,SW_SHOWNORMAL);
1435}
1436
1437void MainFrame::OnCmdStepIn( UINT uNotifyCode, int nID, CWindow wndCtl )
1438{
1439    pobj_Debugger->StepIn();
1440}
1441
1442void MainFrame::OnCmdStepOver( UINT uNotifyCode, int nID, CWindow wndCtl )
1443{
1444    pobj_Debugger->StepOver();
1445}
1446
1447void MainFrame::OnCmdStepCursor( UINT uNotifyCode, int nID, CWindow wndCtl )
1448{
1449    pobj_Debugger->StepToCursor();
1450}
1451
1452void MainFrame::OnCmdBreakPoint( UINT uNotifyCode, int nID, CWindow wndCtl )
1453{
1454    if( projectInfo.IsOpened() ){
1455        projectInfo.pobj_DBBreakPoint->Event_BreakPoint();
1456    }
1457    else{
1458        extern CDBBreakPoint *pobj_DBBreakPoint;
1459        pobj_DBBreakPoint->Event_BreakPoint();
1460    }
1461}
1462
1463void MainFrame::OnCmdDebugStop( UINT uNotifyCode, int nID, CWindow wndCtl )
1464{
1465    pobj_Debugger->DebugStop();
1466}
1467
1468void MainFrame::OnCmdDebugPause( UINT uNotifyCode, int nID, CWindow wndCtl )
1469{
1470    pobj_Debugger->DebugPause();
1471}
1472
1473#endif  // not THETEXT
1474
1475void MainFrame::OnCmdWebLink( UINT uNotifyCode, int nID, CWindow wndCtl )
1476{
1477    switch( nID )
1478    {
1479#ifndef THETEXT
1480    case IDM_COMMUNITY:
1481        OpenWebBrowser( "http://www.activebasic.com/forum/" );
1482        break;
1483    case IDM_COMMU_SEARCH:
1484        OpenWebBrowser( "http://www.activebasic.com/forum/search.php" );
1485        break;
1486    case IDM_COMMU_PM:
1487        OpenWebBrowser( "http://www.activebasic.com/forum/privmsg.php?folder=inbox" );
1488        break;
1489    case ID_COMMU_FORUM1:
1490        OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=1" );
1491        break;
1492    case ID_COMMU_FORUM2:
1493        OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=2" );
1494        break;
1495    case ID_COMMU_FORUM3:
1496        OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=5" );
1497        break;
1498    case ID_COMMU_FORUM4:
1499        OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=3" );
1500        break;
1501    case ID_COMMU_FORUM5:
1502        OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=6" );
1503        break;
1504    case ID_COMMU_FORUM6:
1505        OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=8" );
1506        break;
1507    case ID_COMMU_FORUM7:
1508        OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=4" );
1509        break;
1510    case ID_COMMU_FORUM8:
1511        OpenWebBrowser( "http://www.activebasic.com/forum/viewforum.php?f=7" );
1512        break;
1513    case IDM_AB_WEBSITE:
1514        OpenWebBrowser( "http://www.activebasic.com/" );
1515        break;
1516    case IDM_ACTBDL:
1517        OpenWebBrowser( "http://www.activebasic.com/activebasic5/download.htm" );
1518        break;
1519#else
1520    case IDM_DSHOMEPAGE:
1521        OpenWebBrowser( "http://www.discoversoft.net/" );
1522        break;
1523#endif // not THETEXT
1524    default:
1525        throw;
1526    }
1527}
1528
1529void MainFrame::OnCmdTopics( UINT uNotifyCode, int nID, CWindow wndCtl )
1530{
1531    char temporary[1024];
1532#ifdef THETEXT
1533    sprintf(temporary,"%sTopics\\index.html",pj_editor_Dir);
1534    ShellExecute(m_hWnd,"open",temporary,NULL,NULL,SW_SHOWNORMAL);
1535#else
1536    sprintf(temporary,"%sBasicHelp.chm",pj_editor_Dir);
1537    HtmlHelp(NULL,temporary,HH_DISPLAY_TOPIC,0);
1538#endif
1539}
1540
1541void MainFrame::OnCmdAbout( UINT uNotifyCode, int nID, CWindow wndCtl )
1542{
1543    DialogBox(hResInst,MAKEINTRESOURCE(IDD_ABOUT),m_hWnd,(DLGPROC)DialogAbout);
1544}
1545
1546void MainFrame::OnCmdDocSelectBand( UINT uNotifyCode, int nID, CWindow wndCtl )
1547{
1548    pobj_Rebar->ChangeRebarBand(ID_DOCCOMBO);
1549}
1550
1551void MainFrame::OnCmdStandardBand( UINT uNotifyCode, int nID, CWindow wndCtl )
1552{
1553    pobj_Rebar->ChangeRebarBand(ID_STANDARDTOOLBAR);
1554}
1555
1556void MainFrame::OnCmdReleaseBand( UINT uNotifyCode, int nID, CWindow wndCtl )
1557{
1558    pobj_Rebar->ChangeRebarBand(ID_RELEASETOOLBAR);
1559}
1560
1561void MainFrame::OnCmdDebugBand( UINT uNotifyCode, int nID, CWindow wndCtl )
1562{
1563    pobj_Rebar->ChangeRebarBand(ID_DEBUGGERTOOLBAR);
1564}
1565
1566void MainFrame::OnCmdSelectCompilerBand( UINT uNotifyCode, int nID, CWindow wndCtl )
1567{
1568    pobj_Rebar->ChangeRebarBand(ID_SELECTCOMPILERCOMBO);
1569}
1570
1571void MainFrame::OnCmdNoGripper( UINT uNotifyCode, int nID, CWindow wndCtl )
1572{
1573    if(pobj_nv->bNoGripper) pobj_nv->bNoGripper=0;
1574    else pobj_nv->bNoGripper=1;
1575
1576    //レバーコントロールを再生成
1577    pobj_Rebar->ResetRebar();
1578
1579    //メニュー状態を設定
1580    ResetState_DocMenu();
1581}
1582
1583void MainFrame::OnCmdResetRebar( UINT uNotifyCode, int nID, CWindow wndCtl )
1584{
1585    //"ツールバーの配置をすべて初期状態に戻します。\nよろしいですか?"
1586    if( MessageBox(STRING_TOOLBAR_RESET,APPLICATION_NAME,MB_OKCANCEL|MB_ICONEXCLAMATION) == IDCANCEL )
1587    {
1588        return;
1589    }
1590
1591    //レバーコントロールを再生成
1592    pobj_Rebar->ResetInitRebar();
1593
1594    //メニュー状態を設定
1595    ResetState_DocMenu();
1596}
1597
1598void MainFrame::OnCmdAllCloseOmitMyself( UINT uNotifyCode, int nID, CWindow wndCtl )
1599{
1600    //このウィンドウ以外をすべて閉じる(&A)
1601    HWND hChild=::GetWindow(hClient,GW_CHILD);
1602    int WndNum=GetWndNum(hChild);
1603    for(int i=0;i<MdiInfo.size();i++){
1604        if(i==WndNum) continue;
1605        if(MdiInfo[i]->hwnd) SendMessage(MdiInfo[i]->hwnd,WM_CLOSE,0,0);
1606    }
1607}
1608
1609void MainFrame::OnCmdPathCopy( UINT uNotifyCode, int nID, CWindow wndCtl )
1610{
1611    HWND hChild=::GetWindow(hClient,GW_CHILD);
1612    int WndNum=GetWndNum(hChild);
1613
1614    //絶対パスをコピー
1615    HGLOBAL hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,MdiInfo[WndNum]->path.size()+1);
1616    char *pTemp=(char *)GlobalLock(hGlobal);
1617    lstrcpy(pTemp,MdiInfo[WndNum]->path.c_str());
1618    GlobalUnlock(hGlobal);
1619
1620    //クリップボードに保存
1621    OpenClipboard();
1622    EmptyClipboard();
1623    SetClipboardData(CF_TEXT,hGlobal);
1624    CloseClipboard();
1625}
1626
1627void MainFrame::OnCmdFolderOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
1628{
1629    HWND hChild=::GetWindow(hClient,GW_CHILD);
1630    int WndNum=GetWndNum(hChild);
1631
1632    char temporary[1024], temp2[1024];
1633    _splitpath(MdiInfo[WndNum]->path.c_str(),temporary,temp2,NULL,NULL);
1634    lstrcat(temporary,temp2);
1635
1636    OpenExplorer( temporary );
1637}
1638
1639void MainFrame::OnCmdDeleteFile( 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(),NULL,NULL,temporary,temp2);
1646    lstrcat(temporary,temp2);
1647
1648    lstrcat(temporary," をごみ箱に移動して閉じます。よろしいですか?");
1649    if(MessageBox(temporary,APPLICATION_NAME,MB_OKCANCEL|MB_ICONQUESTION)==IDCANCEL) return;
1650
1651    //ゴミ箱へ
1652    SHFILEOPSTRUCT fo;
1653    fo.hwnd=m_hWnd;
1654    fo.wFunc=FO_DELETE;
1655    fo.pFrom =MdiInfo[WndNum]->path.c_str();
1656    fo.pTo="\0";
1657    fo.fFlags =FOF_ALLOWUNDO|FOF_NOCONFIRMATION;
1658    SHFileOperation(&fo);
1659
1660    //閉じる
1661    MdiInfo[WndNum]->pMdiTextEdit->UnModify();
1662    SendMessage(MdiInfo[WndNum]->hwnd,WM_CLOSE,0,0);
1663}
1664
1665void MainFrame::OnCmdColor( UINT uNotifyCode, int nID, CWindow wndCtl )
1666{
1667    static COLORREF colorUser=RGB(255,255,255);
1668
1669    switch( nID )
1670    {
1671    case IDM_USER_COLOR:
1672        {
1673            CHOOSECOLOR cc;
1674            COLORREF CusColors[16]={
1675                RGB(255,255,255),
1676                RGB(0,0,0),
1677                RGB(128,128,128),
1678                RGB(192,192,192),
1679                RGB(128,0,0),
1680                RGB(255,0,0),
1681                RGB(128,128,0),
1682                RGB(255,255,0),
1683                RGB(0,128,0),
1684                RGB(0,255,0),
1685                RGB(0,128,128),
1686                RGB(0,255,255),
1687                RGB(0,0,128),
1688                RGB(0,0,255),
1689                RGB(128,0,128),
1690                RGB(255,0,255)};
1691            cc.lStructSize=sizeof(CHOOSECOLOR);
1692            cc.hwndOwner=m_hWnd;
1693            cc.rgbResult=colorUser;
1694            cc.lpCustColors=CusColors;
1695            cc.Flags=CC_RGBINIT|CC_FULLOPEN;
1696            if(!ChooseColor(&cc)){
1697                return;
1698            }
1699            colorUser=cc.rgbResult;
1700        }
1701    case IDM_GRAY:
1702    case IDM_WHITE:
1703    case IDM_RED:
1704    case IDM_GREEN:
1705    case IDM_BLUE:
1706    case IDM_YELLOW:
1707        {
1708            HWND hChild=::GetWindow(hClient,GW_CHILD);
1709            int WndNum=GetWndNum(hChild);
1710
1711            TC_ITEM tcItem;
1712            tcItem.mask=TCIF_PARAM;
1713            if(nID==IDM_GRAY)   tcItem.lParam=TABCOLOR_GRAY;
1714            if(nID==IDM_WHITE)  tcItem.lParam=TABCOLOR_WHITE;
1715            if(nID==IDM_RED)        tcItem.lParam=TABCOLOR_RED;
1716            if(nID==IDM_GREEN)  tcItem.lParam=TABCOLOR_GREEN;
1717            if(nID==IDM_BLUE)   tcItem.lParam=TABCOLOR_BLUE;
1718            if(nID==IDM_YELLOW) tcItem.lParam=TABCOLOR_YELLOW;
1719            if(nID==IDM_USER_COLOR) tcItem.lParam=colorUser;
1720            TabCtrl_SetItem(pobj_MainTab->hTab,
1721                TabCtrl_GetCurSel(pobj_MainTab->hTab),
1722                &tcItem);
1723            ::InvalidateRect(pobj_MainTab->hTab,NULL,0);
1724            break;
1725        }
1726    default:
1727        throw;
1728    }
1729}
Note: See TracBrowser for help on using the repository browser.