source: dev/ProjectEditor/ProjectEditor.cpp@ 61

Last change on this file since 61 was 56, checked in by dai_9181, 18 years ago

・[Unicode]リテラル文字列のスイッチング
・[Unicode]Char型を文字型として扱うようにする
・[Unicode]SByte型を追加する
に対応。

/unicodeコマンドオプションに対応。

File size: 89.7 KB
Line 
1#include "ProjectEditor.h"
2
3
4#if defined HeapAlloc
5#define MEM_MAX 65536
6LPVOID pCheckMem[MEM_MAX];
7int now;
8#undef HeapAlloc
9#undef HeapReAlloc
10LPVOID CheckHeapAlloc(HANDLE hf,DWORD dwFlags,DWORD dwBytes){
11 LPVOID ret;
12 ret=HeapAlloc(hf,dwFlags,dwBytes);
13 pCheckMem[now]=ret;
14
15 //この部分にnowのチェックを挿入
16
17
18 now++;
19 if(now>=MEM_MAX){
20 MessageBox(0,"pCheckMemの最大値を超えました","Check",0);
21 }
22 return ret;
23}
24LPVOID CheckHeapReAlloc(HANDLE hf,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes){
25 int i;
26 LPVOID ret;
27 for(i=0;;i++){
28 if(lpMem==pCheckMem[i]) break;
29 if(i>=MEM_MAX){
30 MessageBox(0,"エラー","CheckHeapReAlloc",0);
31 break;
32 }
33 }
34 ret=HeapReAlloc(hf,dwFlags,lpMem,dwBytes);
35 pCheckMem[i]=ret;
36 return ret;
37}
38void HeapDefaultFree(LPVOID lpMem){
39 int i;
40 for(i=0;;i++){
41 if(lpMem==pCheckMem[i]) break;
42 if(i>=MEM_MAX){
43 MessageBox(0,"エラー","HeapDefaultFree",0);
44 break;
45 }
46 }
47 pCheckMem[i]=0;
48 HeapFree(hHeap,0,lpMem);
49}
50void CheckHeapCheck(){
51 int i,i2;
52 char temp[100];
53 temp[0]=0;
54 for(i=0,i2=0;i<MEM_MAX;i++){
55 if(pCheckMem[i]){
56 sprintf(temp+lstrlen(temp),"%d\r\n",i);
57 i2++;
58 if(i2==10){
59 lstrcat(temp,"これ以上の未解放が確認されています");
60 break;
61 }
62 }
63 }
64 if(temp[0]) MessageBox(0,temp,"Check - BasicCompiler.exe",0);
65}
66#define HeapAlloc CheckHeapAlloc
67#define HeapReAlloc CheckHeapReAlloc
68#else
69void HeapDefaultFree(LPVOID lpMem){
70 HeapFree(hHeap,0,lpMem);
71}
72#endif
73
74#ifdef DeleteObject
75#undef DeleteObject
76BOOL CheckDeleteObject(HGDIOBJ hObject){
77 BOOL bRet;
78 bRet=DeleteObject(hObject);
79
80 if(bRet==0){
81 MessageBox(0,"DeleteObject Error","Check",0);
82 }
83 return bRet;
84}
85#define DeleteObject CheckDeleteObject
86#endif
87
88
89void ToBigChar(char str[]){
90 int i;
91 for(i=0;TRUE;i++){
92 str[i]=(char)toupper((int)str[i]);
93 if(str[i]=='\0') break;
94 }
95}
96int GetWndNum(HWND hChild){
97 int i;
98 if(!IsWindow(hChild)) return -1;
99 for(i=0;i<MAX_WNDNUM;i++){
100 if(hChild==MdiInfo[i].hwnd) break;
101 }
102 if(i==MAX_WNDNUM) i=-1;
103 return i;
104}
105int GetNowWndNum(void){
106 return GetWndNum(GetWindow(hClient,GW_CHILD));
107}
108int GetFileNum(int WndNum){
109 int i;
110 char temporary[MAX_PATH];
111 for(i=0;i<ProjectInfo.pobj_DBFileInfo->iNum;i++){
112
113 ProjectInfo.pobj_DBFileInfo->ppobj_FileInfo[i]->GetFullPath(temporary);
114
115 if(lstrcmpi(MdiInfo[WndNum].path,temporary)==0) return i;
116 }
117 return -1;
118}
119
120void SendTextEditResizeEvent(HWND hwnd){
121 RECT rect;
122 GetClientRect(hwnd,&rect);
123 ResizeTextEditWnd(hwnd,rect.right,rect.bottom);
124}
125
126void RedrawAllWindow(void){
127 HWND hChild;
128 hChild=GetWindow(hClient,GW_CHILD);
129 if(hChild) ResetTextEditFont(GetWindow(hChild,GW_CHILD));
130 while(hChild){
131 int WndNum;
132 WndNum=GetWndNum(hChild);
133 if(WndNum==-1) break;
134
135 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
136 //コントロールタブスペースの幅と行番号の文字数を更新
137 MdiInfo[WndNum].pMdiTextEdit->iWidth_ControlTabSpace=
138 GetControlTabSpace(WndNum,&MdiInfo[WndNum].pMdiTextEdit->iLineNumberTextCount);
139
140 InvalidateRect(MdiInfo[WndNum].pMdiTextEdit->hEdit,NULL,0);
141 InvalidateRect(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,NULL,0);
142
143 SendTextEditResizeEvent(MdiInfo[WndNum].hwnd);
144 }
145 else{
146 HWND hEdit;
147 hEdit=GetWindow(hChild,GW_CHILD);
148 InvalidateRect(hEdit,NULL,0);
149 }
150
151 hChild=GetWindow(hChild,GW_HWNDNEXT);
152 }
153}
154
155int DocumentModifyCheck(HWND hChild){ //終了保存確認
156 int BoxID,WndNum,sw;
157 char str[MAX_PATH],temporary[MAX_PATH];
158
159 WndNum=GetWndNum(hChild);
160 sw=0;
161 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
162 if( MdiInfo[WndNum].pMdiTextEdit->IsModified() ) sw=1;
163 }
164 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
165 if(MdiInfo[WndNum].MdiIconEditInfo->bModify) sw=1;
166 }
167
168 if(sw){
169 GetWindowText(hChild,temporary,MAX_PATH);
170
171 //"\"%s\" ファイルは変更されています。保存しますか?"
172 sprintf(str,STRING_MODIFYCHECK_FILE,temporary);
173 BoxID=MessageBox(hOwner,str,APPLICATION_NAME,MB_YESNOCANCEL|MB_ICONINFORMATION);
174
175 if(BoxID==IDYES){
176 if(!SaveDocument(hChild,NULL)) return 0;
177 }
178 else if(BoxID==IDCANCEL) return 0;
179 }
180 return 1;
181}
182void SetStatusText(char *MenuText){
183 //////////////////////////
184 // ステータスバーの更新
185 //////////////////////////
186
187 int WndNum;
188 double BufSize;
189 char temporary[255];
190 HWND hChild;
191
192 if(MenuText){
193 SendMessage(hStatusBar,SB_SETTEXT,0,(long)MenuText);
194 if((char *)MenuText!=(char *)CmdMsg) CmdMsg[0]=0;
195 }
196
197 hChild=GetWindow(hClient,GW_CHILD);
198 WndNum=GetWndNum(hChild);
199 if(WndNum==-1) return;
200 hChild=GetWindow(hChild,GW_CHILD);
201 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
202 //////////////////////
203 // テキストエディタ
204 //////////////////////
205
206 //サイズ
207 BufSize=(double)lstrlen(MdiInfo[WndNum].pMdiTextEdit->buffer);
208 if(IsWindow(hChild)){
209 if(BufSize<1024) sprintf(temporary,"%s: %.0fByte",STRING_SIZE,BufSize);
210 else if(BufSize<1024*1024){
211 BufSize/=1024;
212 sprintf(temporary,"%s: %.2fKB",STRING_SIZE,BufSize);
213 }
214 else{
215 BufSize/=1024*1024;
216 sprintf(temporary,"%s: %.2fMB",STRING_SIZE,BufSize);
217 }
218 }
219 else temporary[0]=0;
220 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)temporary);
221
222 //行と桁
223 if(IsWindow(hChild)){
224#if defined(JPN)
225 //日本語
226 sprintf(temporary,"%d 行、%d 列",
227 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y+1,
228 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x+1);
229#else
230 //英語
231 sprintf(temporary,"%d : %d",
232 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y+1,
233 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x+1);
234#endif
235 }
236 else temporary[0]=0;
237 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)temporary);
238
239 //文字コード
240 nkf.GetCharCodeName(MdiInfo[WndNum].pMdiTextEdit->iCharCode,temporary);
241 SendMessage(hStatusBar,SB_SETTEXT,3,(LPARAM)temporary);
242
243 //文字コード
244 nkf.GetLfCodeName(MdiInfo[WndNum].pMdiTextEdit->iLfCode,temporary);
245 SendMessage(hStatusBar,SB_SETTEXT,4,(LPARAM)temporary);
246 }
247 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
248 ////////////////
249 // RADツール
250 ////////////////
251
252 int WndInfoNum;
253 WndInfoNum=GetWndInfoNum(MdiInfo[WndNum].path);
254 if(RadInfo.NowDragging>=FRAME_CHANGEPOS_START&&RadInfo.NowDragging<=FRAME_CHANGEPOS_END){
255 sprintf(temporary,"pos %d, %d",
256 RadInfo.DraggingRect[0].left-MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
257 RadInfo.DraggingRect[0].top-MdiInfo[WndNum].MdiRadInfo->ClientPos.y);
258 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)temporary);
259 sprintf(temporary,"size %d * %d",
260 RadInfo.DraggingRect[0].right-RadInfo.DraggingRect[0].left,
261 RadInfo.DraggingRect[0].bottom-RadInfo.DraggingRect[0].top);
262 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)temporary);
263 }
264 else if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW){
265 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)"pos 0, 0");
266 sprintf(temporary,"size %d * %d",ProjectInfo.pWindowInfo[WndInfoNum].size.cx,ProjectInfo.pWindowInfo[WndInfoNum].size.cy);
267 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)temporary);
268 }
269 else{
270 sprintf(temporary,"pos %d, %d",
271 ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.x,
272 ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.y);
273 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)temporary);
274 sprintf(temporary,"size %d * %d",
275 ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].size.cx,
276 ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].size.cy);
277 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)temporary);
278 }
279 }
280 else if(MdiInfo[WndNum].DocType==WNDTYPE_MENU){
281 //////////////////
282 // MENU エディタ
283 //////////////////
284
285 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)"");
286 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)"");
287 }
288 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
289 //////////////////
290 // ICON エディタ
291 //////////////////
292
293 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)"");
294 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)"");
295 }
296}
297void ResetState_UndoMenu(void){ //「元に戻す、やり直し」のメニュー表示制御
298 int i,i2;
299 HWND hChild;
300
301 hChild=GetWindow(hClient,GW_CHILD);
302 i=GetWndNum(hChild);
303 if(i==-1){
304 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
305 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
306 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
307 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
308 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
309 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
310 }
311 else if(IS_DOCUMENT_TEXT(MdiInfo[i].DocType)){
312 i2=MdiInfo[i].pMdiTextEdit->pTextEditUndoState->NowPos-1;
313 if(i2==-1) i2=MAX_UNDONUM-1;
314 if(!MdiInfo[i].pMdiTextEdit->pTextEditUndoState->Command[i2]){
315 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
316 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
317 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
318 }
319 else{
320 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
321 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
322 pobj_StandardToolbar->EnableItem(IDM_UNDO,1);
323 }
324 if(!MdiInfo[i].pMdiTextEdit->pTextEditUndoState->Command[MdiInfo[i].pMdiTextEdit->pTextEditUndoState->NowPos]){
325 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
326 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
327 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
328 }
329 else{
330 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
331 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
332 pobj_StandardToolbar->EnableItem(IDM_REDO,1);
333 }
334 }
335 else if(MdiInfo[i].DocType==WNDTYPE_RAD){
336 i2=MdiInfo[i].MdiRadInfo->undo.NowPos-1;
337 if(i2==-1) i2=MAX_UNDONUM-1;
338 if(!MdiInfo[i].MdiRadInfo->undo.Command[i2]){
339 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
340 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
341 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
342 }
343 else{
344 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
345 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
346 pobj_StandardToolbar->EnableItem(IDM_UNDO,1);
347 }
348 if(!MdiInfo[i].MdiRadInfo->undo.Command[MdiInfo[i].MdiRadInfo->undo.NowPos]){
349 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
350 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
351 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
352 }
353 else{
354 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
355 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
356 pobj_StandardToolbar->EnableItem(IDM_REDO,1);
357 }
358 }
359 else if(MdiInfo[i].DocType==WNDTYPE_MENU){
360 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
361 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
362 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
363
364 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
365 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
366 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
367 }
368 else if(MdiInfo[i].DocType==WNDTYPE_ICONEDIT){
369 i2=MdiInfo[i].MdiIconEditInfo->undo[MdiInfo[i].MdiIconEditInfo->SelectIconNum].NowPos-1;
370 if(i2==-1) i2=MAX_ICONEDIT_UNDONUM-1;
371 if(!MdiInfo[i].MdiIconEditInfo->undo[MdiInfo[i].MdiIconEditInfo->SelectIconNum].lpData[i2]){
372 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
373 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
374 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
375 }
376 else{
377 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
378 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
379 pobj_StandardToolbar->EnableItem(IDM_UNDO,1);
380 }
381 if(!MdiInfo[i].MdiIconEditInfo->undo[MdiInfo[i].MdiIconEditInfo->SelectIconNum].lpData[MdiInfo[i].MdiIconEditInfo->undo[MdiInfo[i].MdiIconEditInfo->SelectIconNum].NowPos]){
382 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
383 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
384 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
385 }
386 else{
387 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
388 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
389 pobj_StandardToolbar->EnableItem(IDM_REDO,1);
390 }
391 }
392}
393void ResetState_ConvMenu(BOOL bEnable){
394 int MenuMsg;
395 if(bEnable)
396 MenuMsg=MF_BYCOMMAND|MF_ENABLED;
397 else MenuMsg=MF_BYCOMMAND|MF_GRAYED;
398
399 pobj_MainMenu->EnableItem(IDM_CONV_ALPHA_SMALL,MenuMsg);
400 pobj_MainMenu->EnableItem(IDM_CONV_ALPHA_BIG,MenuMsg);
401 pobj_MainMenu->EnableItem(IDM_CONV_HALF,MenuMsg);
402 pobj_MainMenu->EnableItem(IDM_CONV_MULTI,MenuMsg);
403 pobj_MainMenu->EnableItem(IDM_CONV_KATAKANA,MenuMsg);
404 pobj_MainMenu->EnableItem(IDM_CONV_HIRAGANA,MenuMsg);
405 pobj_MainMenu->EnableItem(IDM_CONV_SPACE,MenuMsg);
406 pobj_MainMenu->EnableItem(IDM_CONV_TAB,MenuMsg);
407#ifdef THETEXT
408 pobj_MainMenu->EnableItem(IDM_CONV_HASRETURN,MenuMsg);
409 pobj_MainMenu->EnableItem(IDM_CONV_QUOTE,MenuMsg);
410#else
411 pobj_MainMenu->EnableItem(IDM_CODEFORMAT,MenuMsg);
412#endif
413}
414void ResetState_PrintMenu(void);
415void ResetState_EditMenu(void){ //編集メニューの表示制御
416 HWND hChild;
417 int WndNum;
418 long MenuMsg,ToolbarMsg;
419
420 //印刷メニューの状態を設定
421 ResetState_PrintMenu();
422
423 hChild=GetWindow(hClient,GW_CHILD);
424 if(!IsWindow(hChild)){
425 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_GRAYED);
426 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_GRAYED);
427#ifdef THETEXT
428 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_GRAYED);
429#endif
430 pobj_StandardToolbar->EnableItem(IDM_FIND,0);
431
432 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
433 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
434 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
435 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
436 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
437 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
438 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
439 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_GRAYED);
440 pobj_StandardToolbar->EnableItem(IDM_CUT,0);
441 pobj_StandardToolbar->EnableItem(IDM_COPY,0);
442 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
443
444 ResetState_ConvMenu(0);
445
446 ResetState_UndoMenu();
447 return;
448 }
449 WndNum=GetWndNum(hChild);
450 if(WndNum==-1) return;
451 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
452 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_ENABLED);
453 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_ENABLED);
454 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_ENABLED);
455#ifdef THETEXT
456 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_ENABLED);
457#endif
458 pobj_StandardToolbar->EnableItem(IDM_FIND,1);
459
460 BOOL bConvEnable;
461 hChild=GetWindow(hChild,GW_CHILD);
462 if(!(
463 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x==MdiInfo[WndNum].pMdiTextEdit->EndCaretPos.x&&
464 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y==MdiInfo[WndNum].pMdiTextEdit->EndCaretPos.y
465 )){
466 MenuMsg=MF_BYCOMMAND|MF_ENABLED;
467 ToolbarMsg=1;
468
469 bConvEnable=1;
470 }
471 else{
472 MenuMsg=MF_BYCOMMAND|MF_GRAYED;
473 ToolbarMsg=0;
474
475 bConvEnable=0;
476 }
477 pobj_MainMenu->EnableItem(IDM_CUT,MenuMsg);
478 pobj_MainMenu->EnableItem(IDM_COPY,MenuMsg);
479 pobj_MainMenu->EnableItem(IDM_DELETE,MenuMsg);
480 EnableMenuItem(hEditMenu,IDM_CUT,MenuMsg);
481 EnableMenuItem(hEditMenu,IDM_COPY,MenuMsg);
482 EnableMenuItem(hEditMenu,IDM_DELETE,MenuMsg);
483 pobj_StandardToolbar->EnableItem(IDM_CUT,ToolbarMsg);
484 pobj_StandardToolbar->EnableItem(IDM_COPY,ToolbarMsg);
485
486 if(IsClipboardFormatAvailable(CF_TEXT)){
487 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_ENABLED);
488 pobj_StandardToolbar->EnableItem(IDM_PASTE,1);
489 }
490 else{
491 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
492 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
493 }
494
495
496 //変換コマンド
497 ResetState_ConvMenu(bConvEnable);
498 }
499 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
500 //検索、置換、文字カウントを無効化
501 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_GRAYED);
502 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_GRAYED);
503#ifdef THETEXT
504 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_GRAYED);
505#endif
506 pobj_StandardToolbar->EnableItem(IDM_FIND,0);
507
508 if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW){
509 //切り取り、コピー、削除を有効化
510 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
511 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
512 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
513 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
514 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
515 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
516 pobj_StandardToolbar->EnableItem(IDM_CUT,0);
517 pobj_StandardToolbar->EnableItem(IDM_COPY,0);
518 }
519 else{
520 //切り取り、コピー、削除を無効化
521 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_ENABLED);
522 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_ENABLED);
523 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_ENABLED);
524 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_ENABLED);
525 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_ENABLED);
526 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_ENABLED);
527 pobj_StandardToolbar->EnableItem(IDM_CUT,1);
528 pobj_StandardToolbar->EnableItem(IDM_COPY,1);
529 }
530
531 //すべて選択を有効化
532 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_ENABLED);
533
534 if(IsClipboardFormatAvailable(dwRadClipboardID)){
535 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_ENABLED);
536 pobj_StandardToolbar->EnableItem(IDM_PASTE,1);
537 }
538 else{
539 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
540 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
541 }
542
543 ResetState_ConvMenu(0);
544 }
545 else if(MdiInfo[WndNum].DocType==WNDTYPE_MENU){
546 //検索、置換、文字カウントを無効化
547 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_GRAYED);
548 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_GRAYED);
549#ifdef THETEXT
550 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_GRAYED);
551#endif
552 pobj_StandardToolbar->EnableItem(IDM_FIND,0);
553
554 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
555 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
556 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
557 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
558 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
559 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
560 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
561 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_GRAYED);
562 pobj_StandardToolbar->EnableItem(IDM_CUT,0);
563 pobj_StandardToolbar->EnableItem(IDM_COPY,0);
564 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
565
566 ResetState_ConvMenu(0);
567 }
568 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
569 //検索、置換、文字カウントを無効化
570 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_GRAYED);
571 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_GRAYED);
572#ifdef THETEXT
573 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_GRAYED);
574#endif
575 pobj_StandardToolbar->EnableItem(IDM_FIND,0);
576
577 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==0){
578 //切り取り、コピー、削除を無効化
579 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
580 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
581 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
582 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
583 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
584 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
585 pobj_StandardToolbar->EnableItem(IDM_CUT,0);
586 pobj_StandardToolbar->EnableItem(IDM_COPY,0);
587 }
588 else{
589 //切り取り、コピー、削除を有効化
590 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_ENABLED);
591 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_ENABLED);
592 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_ENABLED);
593 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_ENABLED);
594 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_ENABLED);
595 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_ENABLED);
596 pobj_StandardToolbar->EnableItem(IDM_CUT,1);
597 pobj_StandardToolbar->EnableItem(IDM_COPY,1);
598 }
599
600 //すべて選択を有効化
601 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_ENABLED);
602
603 if(IsClipboardFormatAvailable(CF_BITMAP)){
604 //貼り付けを有効化
605 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_ENABLED);
606 pobj_StandardToolbar->EnableItem(IDM_PASTE,1);
607 }
608 else{
609 //貼り付けを無効化
610 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
611 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
612 }
613
614 ResetState_ConvMenu(0);
615 }
616
617 ResetState_UndoMenu();
618}
619void ResetState_ViewMenu(void){
620 // 表示 メニューの状態を設定
621
622
623#ifdef THETEXT
624 pobj_MainMenu->CheckMenu(IDM_RIGHT_TURN,pobj_nv->bRightTurn);
625#endif
626}
627void ResetState_PrintMenu(void){ //編集メニューの表示制御
628 HWND hChild;
629 int WndNum;
630 hChild=GetWindow(hClient,GW_CHILD);
631 if(!IsWindow(hChild)){
632 pobj_MainMenu->EnableItem(IDM_PAGESET,MF_BYCOMMAND|MF_GRAYED);
633
634 pobj_MainMenu->EnableItem(IDM_PREVIEW,MF_BYCOMMAND|MF_GRAYED);
635
636 pobj_MainMenu->EnableItem(IDM_PRINTOUT,MF_BYCOMMAND|MF_GRAYED);
637 return;
638 }
639 WndNum=GetWndNum(hChild);
640 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
641 pobj_MainMenu->EnableItem(IDM_PAGESET,MF_BYCOMMAND|MF_ENABLED);
642
643 pobj_MainMenu->EnableItem(IDM_PREVIEW,MF_BYCOMMAND|MF_ENABLED);
644
645 pobj_MainMenu->EnableItem(IDM_PRINTOUT,MF_BYCOMMAND|MF_ENABLED);
646 }
647 else{
648 pobj_MainMenu->EnableItem(IDM_PAGESET,MF_BYCOMMAND|MF_GRAYED);
649
650 pobj_MainMenu->EnableItem(IDM_PREVIEW,MF_BYCOMMAND|MF_GRAYED);
651
652 pobj_MainMenu->EnableItem(IDM_PRINTOUT,MF_BYCOMMAND|MF_GRAYED);
653 }
654}
655void ResetState_DocMenu(void){
656 long MenuMsg,ToolbarMsg;
657 HWND hChild;
658
659 hChild=GetWindow(hClient,GW_CHILD);
660
661
662 /////////////////////////////////////////
663 // 共通ドキュメント メニューの状態を設定
664 /////////////////////////////////////////
665
666 if(!IsWindow(hChild)){
667 MenuMsg=MF_GRAYED;
668 ToolbarMsg=0;
669 }
670 else{
671 MenuMsg=MF_ENABLED;
672 ToolbarMsg=1;
673 }
674 pobj_MainMenu->EnableItem(IDM_CLOSE,MenuMsg);
675 pobj_MainMenu->EnableItem(IDM_SAVE,MenuMsg);
676 pobj_MainMenu->EnableItem(IDM_NEWSAVE,MenuMsg);
677 pobj_MainMenu->EnableItem(IDM_CODE_SAVE,MenuMsg);
678 pobj_MainMenu->EnableItem(IDM_ALLSAVE,MenuMsg);
679
680 pobj_StandardToolbar->EnableItem(IDM_CLOSE,ToolbarMsg);
681 pobj_StandardToolbar->EnableItem(IDM_SAVE,ToolbarMsg);
682 pobj_StandardToolbar->EnableItem(IDM_ALLSAVE,ToolbarMsg);
683
684
685#ifndef THETEXT
686 /////////////////////////////////////////////////
687 // プロジェクトドキュメント メニューの状態を設定
688 /////////////////////////////////////////////////
689
690 if(ProjectInfo.name[0]){
691 pobj_MainMenu->EnableItem(IDM_ALLSAVE,MF_ENABLED);
692 pobj_StandardToolbar->EnableItem(IDM_ALLSAVE,1);
693
694 MenuMsg=MF_ENABLED;
695 ToolbarMsg=TBSTATE_ENABLED;
696 }
697 else{
698 MenuMsg=MF_GRAYED;
699 ToolbarMsg=TBSTATE_INDETERMINATE;
700 }
701 pobj_MainMenu->EnableItem(IDM_PROJECT_SAVE,MenuMsg);
702 pobj_MainMenu->EnableItem(IDM_PROJECT_CLOSE,MenuMsg);
703 pobj_MainMenu->EnableItem(IDM_PROJECT_FOLDER_OPEN,MenuMsg);
704 pobj_MainMenu->EnableItem(IDM_PROJECT_OPTION,MenuMsg);
705
706 //デバッガ メニューの状態を設定
707 pobj_Debugger->ResetCommandEnabled();
708#endif
709
710
711 //編集メニューの状態を設定
712 ResetState_EditMenu();
713
714 //表示メニューの状態を設定
715 ResetState_ViewMenu();
716}
717void DuplicateTitleCheck(char *lpszTitle){
718 int i;
719 for(i=0;i<MAX_WNDNUM;i++){
720 if(MdiInfo[i].hwnd){
721 if(lstrcmpi(MdiInfo[i].title,lpszTitle)==0){
722 lstrcat(lpszTitle,"_");
723 DuplicateTitleCheck(lpszTitle);
724 return;
725 }
726 }
727 }
728}
729HWND NewTextEditWindow(char *filepath,_int8 DocumentType,COLORREF TabColor){
730 int i;
731 char str[MAX_PATH],str2[32],*buffer;
732 HWND hChild,hEdit;
733 RECT rect;
734 int iCharCode=NKF_SHIFT_JIS;
735 int iLfCode=LFCODE_CRLF;
736
737 if(filepath){
738
739 //すでに指定されたファイルが開かれている場合
740 hChild=GetWindow(hClient,GW_CHILD);
741 while(hChild){
742 i=GetWndNum(hChild);
743 if(IS_DOCUMENT_TEXT(MdiInfo[i].DocType)){
744 if(lstrcmpi(MdiInfo[i].path,filepath)==0) break;
745 }
746 hChild=GetNextWindow(hChild,GW_HWNDNEXT);
747 }
748 if(hChild){
749 //前面に表示して終了
750 BringWindowToTop(hChild);
751 return hChild;
752 }
753
754
755 //////////////////////////////////////////////////////
756 //ファイル読み込み(正常に読み込めるかの確認も含む)
757 //////////////////////////////////////////////////////
758
759 HANDLE hFile;
760 hFile=CreateFile(filepath,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
761 if(hFile==INVALID_HANDLE_VALUE){
762 sprintf(str,STRING_ERROR_CANT_FILEOPEN,filepath);
763 MessageBox(hOwner,str,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
764 return 0;
765 }
766 int length;
767 length=GetFileSize(hFile,NULL);
768
769 char *temp;
770 temp=(char *)HeapAlloc(hHeap,0,length+1);
771 DWORD dw;
772 ReadFile(hFile,temp,length,&dw,NULL);
773 CloseHandle(hFile);
774 for(i=0;i<length;i++){
775 if(temp[i]=='\0') temp[i]=' ';
776 }
777 temp[length]=0;
778
779
780 ///////////////////////
781 // 改行コードを判別
782 ///////////////////////
783
784 char *temp2;
785 for(i=0;i<length;i++){
786 if(temp[i]=='\r'){
787 if(temp[i+1]=='\n')
788 iLfCode=LFCODE_CRLF;
789 else
790 iLfCode=LFCODE_CR;
791 break;
792 }
793 if(temp[i]=='\n'){
794 iLfCode=LFCODE_LF;
795 break;
796 }
797 }
798
799 //改行コードを変換
800 if(iLfCode==LFCODE_CR||iLfCode==LFCODE_LF){
801 temp2=nkf.ToCRLF(iLfCode,temp);
802 HeapDefaultFree(temp);
803 temp=temp2;
804
805 length=lstrlen(temp);
806 }
807
808
809 /////////////////////
810 // Shift-JISに変換
811 /////////////////////
812
813 buffer=(char *)HeapAlloc(hHeap,0,length*2+1);
814 nkf.pSetNkfOption("-sx"); //Shift-JISに変換(xは半角カタカナを全角に変換しないオプション)
815 nkf.pNkfConvert(buffer,temp);
816 buffer=(char *)HeapReAlloc(hHeap,0,buffer,lstrlen(buffer)+1);
817 HeapDefaultFree(temp);
818
819 //変換前の文字コードを判別
820 iCharCode=nkf.pNkfGetKanjiCode();
821 if(iCharCode<NKF_CODE_MIN||NKF_CODE_MAX<iCharCode){
822 //判別不能な場合は、Shift-JISにする
823 iCharCode=NKF_SHIFT_JIS;
824 }
825 else if(iCharCode==NKF_EUC||iCharCode==NKF_ISO_2022_JP){
826 //EUC、JISの場合で、判別不能な場合は、Shift-JISを優先
827 for(i=0;;i++){
828 if(buffer[i]=='\0'){
829 //半角コードのみ
830 iCharCode=NKF_SHIFT_JIS;
831 break;
832 }
833 if(IsDBCSLeadByte(buffer[i])) break;
834 }
835 }
836
837
838 //////////////////////////
839 // ファイルパスをセット
840 //////////////////////////
841
842 _splitpath(filepath,NULL,NULL,str,str2);
843 lstrcat(str,str2);
844 }
845 else{
846 buffer=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
847 DocumentCounter++;
848 sprintf(str,"Document[%d]",DocumentCounter);
849 }
850
851 MDICREATESTRUCT mdic;
852 mdic.szClass="MDIClientWindow_TextEdit";
853 mdic.hOwner=hInst;
854 mdic.x=CW_USEDEFAULT;
855 mdic.y=CW_USEDEFAULT;
856 mdic.cx=CW_USEDEFAULT;
857 mdic.cy=CW_USEDEFAULT;
858 mdic.szTitle=str;
859
860 hChild=GetWindow(hClient,GW_CHILD);
861 if(IsWindow(hChild)){
862 if(IsZoomed(hChild)) mdic.style=WS_MAXIMIZE;
863 else mdic.style=0;
864 }
865 else{
866 if(pobj_nv->bMDIZoomed) mdic.style=WS_MAXIMIZE;
867 else mdic.style=0;
868 }
869
870 //ファイルアイコンをセット
871 SHFILEINFO shfi;
872 if(filepath)
873 SHGetFileInfo(filepath, FILE_ATTRIBUTE_ARCHIVE, &shfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON );
874 else shfi.hIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);;
875 mdic.lParam=(LPARAM)shfi.hIcon;
876
877 mdic.style|=WS_CLIPCHILDREN;
878 hChild=(HWND)SendMessage(hClient,WM_MDICREATE,0,(long)&mdic); //ウィンドウ作成
879
880 //TextEditorコントロールを設置
881 GetClientRect(hChild,&rect);
882 hEdit=CreateWindow("TextEditor",NULL,
883 WS_CHILD|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE,
884 0,0,0,0,
885 hChild,NULL,hInst,NULL);
886
887 //ウィンドウのID登録
888 for(i=0;i<MAX_WNDNUM;i++){
889 if(MdiInfo[i].hwnd==0){
890 MdiInfo[i].hwnd=hChild;
891 MdiInfo[i].DocType=DocumentType;
892 DuplicateTitleCheck(str);
893 MdiInfo[i].title=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(str)+1);
894 lstrcpy(MdiInfo[i].title,str);
895 if(filepath){
896 MdiInfo[i].path=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(filepath)+1);
897 lstrcpy(MdiInfo[i].path,filepath);
898 }
899 else{
900 MdiInfo[i].path=(char *)GlobalAlloc(GPTR,1);
901 }
902
903 MdiInfo[i].pMdiTextEdit = new CMdiTextEdit( &MdiInfo[i] );
904
905 MdiInfo[i].pMdiTextEdit->hEdit=hEdit;
906 MdiInfo[i].pMdiTextEdit->pobj_WebResult=new CWebResult(hChild);
907 MdiInfo[i].pMdiTextEdit->pobj_Ruler=new CRuler(hChild,i);
908 MdiInfo[i].pMdiTextEdit->hIcon=shfi.hIcon;
909 MdiInfo[i].pMdiTextEdit->buffer=buffer;
910 MdiInfo[i].pMdiTextEdit->pColorRef=(COLORREF *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(COLORREF)*lstrlen(buffer));
911 MdiInfo[i].pMdiTextEdit->iUnderStart=-1;
912 MdiInfo[i].pMdiTextEdit->iUnderEnd=-1;
913 MdiInfo[i].pMdiTextEdit->StartCaretPos.x=0;
914 MdiInfo[i].pMdiTextEdit->StartCaretPos.y=0;
915 MdiInfo[i].pMdiTextEdit->EndCaretPos.x=0;
916 MdiInfo[i].pMdiTextEdit->EndCaretPos.y=0;
917 MdiInfo[i].pMdiTextEdit->Temp_UpDown_CaretXPos=-1;
918 MdiInfo[i].pMdiTextEdit->bAutoScroll=0;
919 MdiInfo[i].pMdiTextEdit->iWidth_ControlTabSpace=
920 GetControlTabSpace(i,&MdiInfo[i].pMdiTextEdit->iLineNumberTextCount);
921 MdiInfo[i].pMdiTextEdit->iCharCode=iCharCode;
922 MdiInfo[i].pMdiTextEdit->iLfCode=iLfCode;
923
924 MdiInfo[i].IndentStr=0;
925
926 int flag;
927 if(mdic.style&WS_MAXIMIZE) flag=SIZE_MAXIMIZED;
928 else flag=0;
929 SendTextEditResizeEvent(hChild);
930 break;
931 }
932 }
933
934 //ワードカラーをセット
935 if(IS_DOCUMENT_TEXT(DocumentType)) SetTextEditWordColor(i);
936
937 //Docコンボボックスに追加
938 extern HWND hDocCombo;
939 i=SendMessage(hDocCombo,CB_ADDSTRING,0,(long)str);
940 SendMessage(hDocCombo,CB_SETCURSEL,i,0);
941
942 //タブに追加
943 pobj_MainTab->InsertItem( str, true, TabColor );
944
945 SetFocus(hEdit);
946 SetStatusText(NULL);
947
948 //メニュー状態を設定
949 ResetState_DocMenu();
950
951 return hChild;
952}
953void CreateNewFile(void){
954
955#ifdef THETEXT
956 NewTextEditWindow(NULL,WNDTYPE_TEXT);
957 return;
958#else
959 int FileType;
960 BOOL bAddToProject;
961 char temporary[MAX_PATH];
962
963 FileType=DialogBox(hResInst,MAKEINTRESOURCE(IDD_NEWFILE),hOwner,DlgNewFile);
964 if(FileType==-1) return;
965
966 if(FileType&0x00008000){
967 bAddToProject=1;
968 FileType&=0x0FFF;
969 lstrcpy(temporary,NewFileName);
970 if(!strstr(temporary,".")) lstrcat(temporary,".ab");
971 GetFullPath(temporary,ProjectInfo.dir);
972 }
973 else bAddToProject=0;
974
975 switch(FileType){
976 case FT_BASICPROGRAM: //Basicプログラム
977 case FT_SUBPROGRAM:
978 if(bAddToProject){
979 WriteBuffer(temporary,0,0);
980 NewTextEditWindow(temporary,WNDTYPE_BASIC);
981 Project_File_Insert(temporary);
982 }
983 else NewTextEditWindow(NULL,WNDTYPE_BASIC);
984 break;
985
986 case FT_PROJECT:
987 DlgNewProjectWizard(hOwner);
988 break;
989
990 case FT_TEXT:
991 NewTextEditWindow(NULL,WNDTYPE_TEXT);
992 break;
993
994 case FT_HTML:
995 NewTextEditWindow(NULL,WNDTYPE_HTML);
996 break;
997
998 case FT_ICON:
999 NewIconEditWindow(NULL);
1000 break;
1001 }
1002#endif
1003}
1004void CloseDocWindow(int WndNum){
1005 int i2,i3;
1006
1007 MdiInfo[WndNum].hwnd=0;
1008
1009 //ドキュメントコンボボックスから文字列を消去
1010 extern HWND hDocCombo;
1011 i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[WndNum].title);
1012 SendMessage(hDocCombo,CB_DELETESTRING,i2,0);
1013
1014 //タブコントロールからアイテムを消去
1015 if(pobj_MainTab) pobj_MainTab->DeleteItem( MdiInfo[WndNum].title, true );
1016
1017
1018 GlobalFree(MdiInfo[WndNum].title);
1019 GlobalFree(MdiInfo[WndNum].path);
1020
1021 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
1022 ////////////////////////////
1023 // テキストエディタを閉じる
1024 ////////////////////////////
1025
1026 extern COMPLEMENT_WINDOW_INFO ComplementWndInfo;
1027 if(ComplementWndInfo.hWnd){
1028 //コード補完リストを破棄する
1029 DestroyWindow(ComplementWndInfo.hWnd);
1030 ComplementWndInfo.hWnd=0;
1031 }
1032
1033 HeapDefaultFree(MdiInfo[WndNum].pMdiTextEdit->buffer);
1034 HeapDefaultFree(MdiInfo[WndNum].pMdiTextEdit->pColorRef);
1035
1036 if(MdiInfo[WndNum].IndentStr) HeapDefaultFree(MdiInfo[WndNum].IndentStr);
1037
1038 //エディットコントロールを破棄
1039 DestroyWindow(MdiInfo[WndNum].pMdiTextEdit->hEdit);
1040
1041 //Web検索ウィンドウを破棄
1042 delete MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult;
1043 MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult=0;
1044
1045 //ルーラーウィンドウを破棄
1046 delete MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler;
1047 MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler=0;
1048
1049 //アイコンを破棄
1050 if(MdiInfo[WndNum].pMdiTextEdit->hIcon) DestroyIcon(MdiInfo[WndNum].pMdiTextEdit->hIcon);
1051
1052 delete MdiInfo[WndNum].pMdiTextEdit;
1053 MdiInfo[WndNum].pMdiTextEdit=0;
1054 }
1055 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
1056 /////////////////////
1057 // RADツールを閉じる
1058 /////////////////////
1059
1060 for(i2=0;i2<MAX_UNDONUM;i2++){
1061 if(MdiInfo[WndNum].MdiRadInfo->undo.Command[i2])
1062 Rad_DeleteUndoData(WndNum,i2);
1063 }
1064 DestroyWindow(MdiInfo[WndNum].MdiRadInfo->hTools);
1065 DestroyWindow(MdiInfo[WndNum].MdiRadInfo->hRad);
1066 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,MdiInfo[WndNum].MdiRadInfo->hOldBitmap);
1067 DeleteDC(MdiInfo[WndNum].MdiRadInfo->hMemDC);
1068 DeleteObject(MdiInfo[WndNum].MdiRadInfo->hBitmap);
1069 GlobalFree(MdiInfo[WndNum].MdiRadInfo);
1070 }
1071 else if(MdiInfo[WndNum].DocType==WNDTYPE_MENU){
1072 ////////////////////////////
1073 // メニューエディタを閉じる
1074 ////////////////////////////
1075
1076 DestroyWindow(MdiInfo[WndNum].MdiMenuInfo->hList);
1077 GlobalFree(MdiInfo[WndNum].MdiMenuInfo);
1078 }
1079 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
1080 ////////////////////////////
1081 // アイコンエディタを閉じる
1082 ////////////////////////////
1083
1084 for(i2=0;i2<MdiInfo[WndNum].MdiIconEditInfo->num;i2++){
1085 for(i3=0;i3<MAX_ICONEDIT_UNDONUM;i3++){
1086 if(MdiInfo[WndNum].MdiIconEditInfo->undo[i2].lpData[i3])
1087 HeapDefaultFree(MdiInfo[WndNum].MdiIconEditInfo->undo[i2].lpData[i3]);
1088 }
1089 }
1090
1091 DeleteDC(MdiInfo[WndNum].MdiIconEditInfo->memdc);
1092 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hMemBmp);
1093 DestroyWindow(MdiInfo[WndNum].MdiIconEditInfo->hMain);
1094 for(i2=0;i2<MdiInfo[WndNum].MdiIconEditInfo->num;i2++){
1095 HeapDefaultFree(MdiInfo[WndNum].MdiIconEditInfo->pIconImage[i2]);
1096 }
1097 HeapDefaultFree(MdiInfo[WndNum].MdiIconEditInfo);
1098 }
1099}
1100void ResizeTextEditWnd(HWND hwnd,int cx,int cy){
1101 int WndNum;
1102 WndNum=GetWndNum(hwnd);
1103 if(WndNum==-1) return;
1104
1105 int WebResultWndHeight;
1106 WebResultWndHeight=LINK_ITEM_HEIGHT;
1107 //未完成
1108 WebResultWndHeight=0;
1109
1110 int iHeightRuler;
1111 if(pobj_nv->bEditor_Ruler){
1112 //ルーラー
1113 MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->resize(
1114 0,
1115 0,
1116 cx,
1117 HEIGHT_RULER);
1118
1119 iHeightRuler=HEIGHT_RULER;
1120
1121 ShowWindow(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,SW_SHOW);
1122 }
1123 else{
1124 iHeightRuler=0;
1125
1126 ShowWindow(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,SW_HIDE);
1127 }
1128
1129 //エディットウィンドウ
1130 MoveWindow(MdiInfo[WndNum].pMdiTextEdit->hEdit,
1131 0,
1132 iHeightRuler,
1133 cx,
1134 cy-WebResultWndHeight-iHeightRuler,
1135 1);
1136
1137 //Web検索ウィンドウ
1138 MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult->resize(
1139 0,
1140 cy-WebResultWndHeight,
1141 cx,
1142 WebResultWndHeight);
1143}
1144LRESULT CALLBACK MDIClientWindow_TextEdit(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1145 int i,i2;
1146 HWND hEdit;
1147
1148 switch(message){
1149 case WM_CREATE:
1150 CREATESTRUCT *lpcs;
1151 lpcs=(CREATESTRUCT *)lParam;
1152 MDICREATESTRUCT *lpmcs;
1153 lpmcs=(MDICREATESTRUCT *)lpcs->lpCreateParams;
1154 SendMessage(hwnd,WM_SETICON,ICON_SMALL,(LPARAM)lpmcs->lParam);
1155 break;
1156 case WM_MDIACTIVATE:
1157 //以前のMDIウィンドウのパラメータ ヒントを破棄する
1158 if(MethodCheckInfo.hWnd){
1159 DestroyWindow(MethodCheckInfo.hWnd);
1160 MethodCheckInfo.hWnd=0;
1161 }
1162
1163 //以前のコード補完リストを破棄する
1164 if(ComplementWndInfo.hWnd){
1165 DestroyWindow(ComplementWndInfo.hWnd);
1166 ComplementWndInfo.hWnd=0;
1167 }
1168
1169 if(!lParam) return 0;
1170 i=GetWndNum((HWND)lParam);
1171 if(i==-1) return 0; //ウィンドウが初期状態の場合
1172
1173#ifndef THETEXT
1174 //デバッガ メニューの状態を設定
1175 pobj_Debugger->ResetCommandEnabled();
1176#endif
1177
1178 //ドキュメント セレクト コンボボックス
1179 extern HWND hDocCombo;
1180 i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[i].title);
1181 SendMessage(hDocCombo,CB_SETCURSEL,i2,0);
1182
1183 //タブコントロール
1184 pobj_MainTab->MdiActiveEvent(MdiInfo[i].title);
1185
1186 return 0;
1187 case WM_SETFOCUS:
1188 hEdit=GetWindow(hwnd,GW_CHILD);
1189 SetFocus(hEdit);
1190 SetStatusText(CmdMsg);
1191 ResetState_EditMenu();
1192 ResetState_ViewMenu();
1193 break;
1194 case WM_SIZE:
1195 ResizeTextEditWnd(hwnd,LOWORD(lParam),HIWORD(lParam));
1196 break;
1197 case WM_CLOSE:
1198 if(!DocumentModifyCheck(hwnd)) return 0;
1199 CloseDocWindow(GetWndNum(hwnd));
1200 pobj_nv->bMDIZoomed=IsZoomed(hwnd);
1201 i=DefMDIChildProc(hwnd,message,wParam,lParam);
1202
1203 //メニュー状態を設定
1204 ResetState_DocMenu();
1205
1206 return i;
1207 }
1208 return DefMDIChildProc(hwnd,message,wParam,lParam);
1209}
1210void ResizeOwnerWnd(void){
1211 int width_owner,height_owner;
1212 int height_Rebar;
1213 int height_MdiClient;
1214 RECT rect,StatusRect,RebarRect;
1215
1216 GetClientRect(hOwner,&rect);
1217 width_owner=rect.right;
1218 height_owner=rect.bottom;
1219
1220 //Rebar
1221 SendMessage(pobj_Rebar->hRebar,WM_SIZE,0,MAKELONG(width_owner,height_owner));
1222 UpdateWindow(pobj_Rebar->hRebar);
1223
1224 //Status bar
1225#define STATUSBAR_PARTS_NUM 5
1226 int sb_size[STATUSBAR_PARTS_NUM];
1227 sb_size[0]=width_owner-340;
1228 sb_size[1]=width_owner-220;
1229 sb_size[2]=width_owner-120;
1230 sb_size[3]=width_owner-50;
1231 sb_size[4]=width_owner;
1232 SendMessage(hStatusBar,SB_SETPARTS,STATUSBAR_PARTS_NUM,(LPARAM)sb_size);
1233 SendMessage(hStatusBar,WM_SIZE,0,MAKELONG(width_owner,height_owner));
1234 UpdateWindow(hStatusBar);
1235
1236 //Status bar
1237 int height_Statusbar;
1238 SendMessage(hStatusBar,SB_GETRECT,0,(long)&StatusRect);
1239 height_Statusbar=StatusRect.bottom;
1240
1241 GetWindowRect(pobj_Rebar->hRebar,&RebarRect);
1242 height_Rebar=RebarRect.bottom-RebarRect.top+2;
1243
1244 int height_dv; //Width of Debugger View
1245 int height_cv; //Width of Compiler View
1246 height_dv=0;
1247 height_cv=0;
1248#ifndef THETEXT
1249 if(bClipCompileView){
1250 if(pobj_Debugger->IsDebuggerView()){
1251 //デバッガビューが表示されているとき
1252 height_dv=pobj_nv->height_ClipDebuggerView+LEVER_THICK;
1253 }
1254 if(hCompileView){
1255 //コンパイラビューが表示されているとき
1256 height_cv=pobj_nv->height_ClipCompileView+LEVER_THICK;
1257 }
1258 }
1259#endif
1260
1261 int width_pjv=0; //Width of Project View
1262 if(pobj_nv->bClipProjectView){
1263 if(IsWindowVisible(hProjectView)){
1264 //プロジェクトビューが表示されているとき
1265 width_pjv=pobj_nv->width_ClipProjectView+LEVER_THICK;
1266 }
1267 }
1268
1269 int width_SideWeb=0;
1270 if(pobj_SideWeb->bShow){
1271 width_SideWeb=pobj_nv->width_WebSearchView+LEVER_THICK;
1272 }
1273
1274 //MDIクライアントの高さ
1275 height_MdiClient=height_owner-(
1276 height_Rebar+
1277 height_dv+
1278 height_cv+
1279 height_Statusbar
1280 );
1281
1282 //タブコントロール
1283 int tab_height;
1284 if(TabCtrl_GetItemCount(pobj_MainTab->hTab)==0) tab_height=0;
1285 else{
1286 RECT rc;
1287 TabCtrl_GetItemRect(pobj_MainTab->hTab,0,&rc);
1288 tab_height=rc.bottom-rc.top;
1289 }
1290 MoveWindow(pobj_MainTab->hTab,
1291 width_pjv,
1292 height_Rebar,
1293 width_owner-width_pjv-width_SideWeb,
1294 tab_height,
1295 1);
1296
1297 //MDIクライアント
1298 MoveWindow(hClient,
1299 width_pjv,
1300 height_Rebar+tab_height,
1301 width_owner-width_pjv-width_SideWeb,
1302 height_MdiClient-tab_height,
1303 1);
1304
1305 if(pobj_SideWeb->bShow){
1306 //SideWeb
1307 pobj_SideWeb->resize(
1308 width_owner - pobj_nv->width_WebSearchView,
1309 height_Rebar,
1310 pobj_nv->width_WebSearchView,
1311 height_MdiClient);
1312 }
1313 else pobj_SideWeb->resize(0,0,0,0);
1314
1315 if(width_pjv){
1316 //プロジェクトビュー
1317 MoveWindow(hProjectView,
1318 0,
1319 height_Rebar,
1320 pobj_nv->width_ClipProjectView,
1321 height_MdiClient,
1322 1);
1323 InvalidateRect(hProjectView,NULL,0);
1324 }
1325
1326 if(height_dv){
1327#ifndef THETEXT
1328 //デバッガビュー
1329 pobj_Debugger->resize(
1330 0,
1331 height_Rebar+height_MdiClient+LEVER_THICK,
1332 width_owner,
1333 pobj_nv->height_ClipDebuggerView);
1334#endif
1335 }
1336 if(height_cv){
1337 //コンパイラビュー
1338 MoveWindow(hCompileView,
1339 0,
1340 height_Rebar+height_MdiClient+height_dv+LEVER_THICK,
1341 width_owner,
1342 pobj_nv->height_ClipCompileView,
1343 1);
1344 }
1345}
1346LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1347 int i,i2,i3,WndNum;
1348 char str[MAX_PATH],temporary[1024],temp2[MAX_PATH],temp3[MAX_PATH],*pTemp;
1349 HWND hChild,hEdit;
1350 RECT rect;
1351 POINT pos;
1352 LPTOOLTIPTEXT TipText;
1353 LPNMHDR lpnmhdr;
1354 NMPGCALCSIZE *lpCalcSize;
1355 NMPGSCROLL *lpScroll;
1356 HDROP hDrop;
1357 HGLOBAL hGlobal;
1358 CHARRANGE CharRange;
1359 HANDLE hFile;
1360 BOOL bChecked;
1361
1362 static COLORREF colorUser=RGB(255,255,255);
1363
1364 if(message==WM_COMMAND&&IS_FILEHISTORY_COMMAND(LOWORD(wParam))){
1365 //「最近使ったファイル」メニューコマンド
1366 lstrcpy(str,pobj_nv->pobj_History->lpszPath[LOWORD(wParam)-100]);
1367 OpenFileWithExtension(str);
1368 return 0;
1369 }
1370
1371 if(message==WM_COMMAND&&200<=LOWORD(wParam)&&LOWORD(wParam)<=299){
1372 //「最近使ったプロジェクト」メニューコマンド
1373 lstrcpy(str,pobj_nv->pobj_ProjectHistory->lpszPath[LOWORD(wParam)-200]);
1374 OpenFileWithExtension(str);
1375 return 0;
1376 }
1377
1378 switch(message){
1379 case WM_CREATE:
1380 SetupWindow(hwnd);
1381
1382 //テキストエディタフォント設定
1383 ResetTextEditFont(hwnd);
1384
1385 //バックアップ用タイマーを設定(10秒に一回)
1386 SetTimer(hwnd,ID_TIMER_BACKUP,10000,NULL);
1387
1388 return 0;
1389
1390
1391 case WM_TIMER:
1392 //Pro版は自動バックアップ及び復元機能を有効にする
1393 _beginthread(backup,0,0);
1394
1395#ifndef THETEXT
1396 if(wParam==ID_DEBUGSAFTY){
1397 //BasicCompiler.exeが強制終了しているかどうかを検証
1398 pobj_Debugger->SaftyCheck();
1399 }
1400#endif
1401
1402 return 0;
1403
1404
1405 case WM_DRAWCLIPBOARD:
1406 ResetState_EditMenu();
1407 return 0;
1408
1409 case WM_MENUSELECT:
1410 MenuAdvice(wParam);
1411 return 0;
1412 case WM_INITMENU:
1413 pobj_nv->pobj_History->ResetFileMenu(pobj_FileHistoryMenu,1);
1414#ifndef THETEXT
1415 pobj_nv->pobj_ProjectHistory->ResetFileMenu(pobj_ProjectHistoryMenu,0);
1416#endif
1417 return 0;
1418 case WM_MEASUREITEM:
1419 LPMEASUREITEMSTRUCT lpMI;
1420 lpMI = (LPMEASUREITEMSTRUCT)lParam;
1421 if(lpMI->CtlType==ODT_MENU){
1422 SIZE size;
1423 CMenuItemData *pobj_MenuItemData;
1424 pobj_MenuItemData=(CMenuItemData *)lpMI->itemData;
1425 if(pobj_MenuItemData->pobj_ThisMenu->hMenu==pobj_MainMenu->hMenu){
1426 //メインメニューの親アイテム
1427 pobj_MainMenu->GetItemSize(pobj_MenuItemData->item_index,&size);
1428 lpMI->itemWidth = size.cx;
1429 lpMI->itemHeight = size.cy;
1430 }
1431 else{
1432 //メインメニューにぶらさがるサブメニュー
1433 pobj_MenuItemData->pobj_ThisMenu->GetItemSize(pobj_MenuItemData->item_index,&size);
1434 lpMI->itemWidth = size.cx;
1435 lpMI->itemHeight = size.cy;
1436 }
1437 }
1438 return 0;
1439
1440 case WM_DRAWITEM:
1441 DRAWITEMSTRUCT *pdis;
1442 pdis=(DRAWITEMSTRUCT *)lParam;
1443
1444 if(pdis->CtlType==ODT_MENU){
1445 if(!pobj_MainMenu) return 0;
1446
1447 CMenuItemData *pobj_MenuItemData;
1448 pobj_MenuItemData=(CMenuItemData *)pdis->itemData;
1449 if(pobj_MainMenu->hMenu==pobj_MenuItemData->pobj_ThisMenu->hMenu){
1450 //メインメニューの親アイテム
1451 pobj_MainMenu->OwnerDrawMenu(pdis->hDC,
1452 &pdis->rcItem,
1453 (pdis->itemState&ODS_SELECTED)!=0,
1454 pobj_MenuItemData->item_index);
1455 }
1456 else{
1457 //メインメニューにぶらさがるサブメニュー
1458 pobj_MainMenu->OwnerDrawSubMenu(pobj_MenuItemData->pobj_ThisMenu->hMenu,
1459 pdis->hDC,
1460 &pdis->rcItem,
1461 (pdis->itemState&ODS_SELECTED)!=0,
1462 pobj_MenuItemData->item_index);
1463 }
1464 }
1465 return 0;
1466
1467 case WM_NOTIFY:
1468 if(!lParam) return 0;
1469 TipText=(LPTOOLTIPTEXT)lParam;
1470 if(TipText->hdr.code==TTN_NEEDTEXT) ShowToolTipText(TipText);
1471 lpnmhdr=(LPNMHDR)lParam;
1472
1473 extern HWND hStandardToolbarPager;
1474 extern HWND hDebuggerToolbarPager;
1475 if(pobj_Rebar){
1476 //レバーオブジェクトが存在するとき
1477 if(lpnmhdr->hwndFrom==pobj_Rebar->hRebar&&lpnmhdr->code==RBN_HEIGHTCHANGE){
1478 ResizeOwnerWnd();
1479 return 0;
1480 }
1481 }
1482 if(lpnmhdr->hwndFrom==hStandardToolbarPager){
1483 if(lpnmhdr->code==PGN_CALCSIZE){
1484 lpCalcSize=(LPNMPGCALCSIZE)lParam;
1485 if(lpCalcSize->dwFlag==PGF_CALCWIDTH)
1486 lpCalcSize->iWidth=BMPNUM_STANDARDTOOLBAR*23+SEPNUM_STANDARDTOOLBAR*8;
1487 }
1488 else if(lpnmhdr->code==PGN_SCROLL){
1489 lpScroll=(LPNMPGSCROLL)lParam;
1490 lpScroll->iScroll=20;
1491 }
1492 }
1493 else if(lpnmhdr->hwndFrom==hDebuggerToolbarPager){
1494 if(lpnmhdr->code==PGN_CALCSIZE){
1495 lpCalcSize=(LPNMPGCALCSIZE)lParam;
1496 if(lpCalcSize->dwFlag==PGF_CALCWIDTH)
1497 lpCalcSize->iWidth=BMPNUM_DEBUGGERTOOLBAR*23+SEPNUM_DEBUGGERTOOLBAR*8;
1498 }
1499 else if(lpnmhdr->code==PGN_SCROLL){
1500 lpScroll=(LPNMPGSCROLL)lParam;
1501 lpScroll->iScroll=20;
1502 }
1503 }
1504
1505 NMHDR *hdr;
1506 hdr=(NMHDR *)lParam;
1507 if(pobj_MainTab){
1508 if(hdr->hwndFrom==pobj_MainTab->hTab){
1509 if(hdr->code==TCN_SELCHANGE)
1510 pobj_MainTab->SelChangeEvent();
1511
1512 if(hdr->code==NM_RCLICK){
1513
1514 TCHITTESTINFO tcHitTest;
1515 GetCursorPos(&tcHitTest.pt);
1516 ScreenToClient(pobj_MainTab->hTab,&tcHitTest.pt);
1517 i=TabCtrl_HitTest(pobj_MainTab->hTab,&tcHitTest);
1518 if(i==-1) return 0;
1519
1520 TabCtrl_SetCurSel(pobj_MainTab->hTab,i);
1521
1522 pobj_MainTab->SelChangeEvent();
1523
1524
1525 /////////////////////
1526 // メニューを表示
1527 /////////////////////
1528
1529 hChild=GetWindow(hClient,GW_CHILD);
1530 WndNum=GetWndNum(hChild);
1531
1532 //保存コマンドの文字列をセット
1533 MENUITEMINFO mii;
1534 mii.cbSize=sizeof(MENUITEMINFO);
1535 mii.fMask=MIIM_TYPE;
1536 mii.dwTypeData=temporary;
1537 mii.fType=MFT_STRING;
1538 if(MdiInfo[WndNum].path[0]){
1539 _splitpath(MdiInfo[WndNum].path,NULL,NULL,temporary,temp2);
1540 lstrcat(temporary,temp2);
1541 lstrcat(temporary," を保存(&S)");
1542 }
1543 else{
1544 lstrcpy(temporary,"保存(&S)");
1545 }
1546 SetMenuItemInfo(hTabMenu,IDM_SAVE,FALSE,&mii);
1547
1548 /*「絶対パスをコピー」「フォルダを開く」「ファイルを削除」
1549 コマンドを場合によって無効化にする */
1550 if(MdiInfo[WndNum].path[0]){
1551 EnableMenuItem(hTabMenu,IDM_PATH_COPY,MF_BYCOMMAND|MF_ENABLED);
1552 EnableMenuItem(hTabMenu,IDM_FOLDER_OPEN,MF_BYCOMMAND|MF_ENABLED);
1553 EnableMenuItem(hTabMenu,IDM_DELETE_FILE,MF_BYCOMMAND|MF_ENABLED);
1554 }
1555 else{
1556 EnableMenuItem(hTabMenu,IDM_PATH_COPY,MF_BYCOMMAND|MF_GRAYED);
1557 EnableMenuItem(hTabMenu,IDM_FOLDER_OPEN,MF_BYCOMMAND|MF_GRAYED);
1558 EnableMenuItem(hTabMenu,IDM_DELETE_FILE,MF_BYCOMMAND|MF_GRAYED);
1559 }
1560
1561 POINT MousePos;
1562 GetCursorPos(&MousePos);
1563 TrackPopupMenu(hTabMenu,TPM_LEFTALIGN|TPM_RIGHTBUTTON,MousePos.x,MousePos.y,0,hOwner,NULL);
1564 }
1565 }
1566 }
1567 if(pobj_SideWeb){
1568 if(hdr->hwndFrom==pobj_SideWeb->hTab&&hdr->code==TCN_SELCHANGE){
1569 pobj_SideWeb->SelChangeEvent();
1570 }
1571 }
1572
1573 return 0;
1574 case WM_COMMAND:
1575 switch(LOWORD(wParam)){
1576 case IDM_NEW:
1577 CreateNewFile();
1578 return 0;
1579 case IDM_OPEN:
1580 //"ファイルを指定してください"
1581 if(!GetFilePathDialog(hwnd,str,DefFileFilter,STRING_FILEOPENTITLE_DEFAULT,TRUE)) return 0;
1582
1583 OpenFileWithExtension(str);
1584 return 0;
1585 case IDM_CLOSE:
1586 hChild=GetWindow(hClient,GW_CHILD);
1587 if(IsWindow(hChild)) SendMessage(hChild,WM_CLOSE,0,0);
1588 return 0;
1589#ifndef THETEXT
1590 case IDM_PROJECT_OPEN:
1591 //"プロジェクト ファイルを指定して下さい"
1592 if(!GetFilePathDialog(hwnd,str,ProjectFileFilter,STRING_FILEOPENTITLE_PROJECT,TRUE)) return 0;
1593
1594 OpenProject(str);
1595 return 0;
1596 case IDM_PROJECT_SAVE:
1597 SaveProject();
1598 return 0;
1599 case IDM_PROJECT_CLOSE:
1600 CloseProject();
1601 return 0;
1602 case IDM_PROJECT_FOLDER_OPEN:
1603 ShellExecute(hwnd,"explore",ProjectInfo.dir,NULL,NULL,SW_SHOWNORMAL);
1604 return 0;
1605#endif
1606 case IDM_SAVE:
1607 SaveDocument(GetWindow(hClient,GW_CHILD),NULL);
1608 return 0;
1609 case IDM_NEWSAVE:
1610 //"保存先のファイルを指定してください"
1611 if(!GetFilePathDialog(hwnd,str,DefFileFilter,STRING_FILESAVETITLE_DEFAULT,FALSE)) return 0;
1612
1613 SaveDocument(GetWindow(hClient,GW_CHILD),str);
1614 return 0;
1615 case IDM_CODE_SAVE:
1616 //文字コードを指定して保存
1617 DialogBox(hResInst,MAKEINTRESOURCE(IDD_CODE_SAVE),hOwner,nkfDlgCodeSave);
1618 return 0;
1619 case IDM_ALLSAVE:
1620 for(i=0;i<MAX_WNDNUM;i++){
1621 if(MdiInfo[i].hwnd) SaveDocument(MdiInfo[i].hwnd,NULL);
1622 }
1623 if(ProjectInfo.name[0]) SaveProject();
1624 return 0;
1625
1626 case IDM_PAGESET:
1627 //ページ設定
1628 obj_Page.SetupDlg();
1629 return 0;
1630
1631 case IDM_PREVIEW:
1632 //プレビュー(Pro版のみ)
1633 Preview();
1634 return 0;
1635
1636 case IDM_PRINTOUT:
1637 //印刷
1638 Printout();
1639 return 0;
1640
1641 case IDM_EXIT:
1642 SendMessage(hwnd,WM_CLOSE,0,0);
1643 return 0;
1644 case IDM_UNDO:
1645 case (WORD)IDM_ACCEL_UNDO:
1646 hChild=GetWindow(hClient,GW_CHILD);
1647 if(!hChild) return 0;
1648 WndNum=GetWndNum(hChild);
1649 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType))
1650 TextEdit_UndoCommand(WndNum);
1651 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD)
1652 Rad_UndoCommand(WndNum);
1653 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT)
1654 IconEdit_UndoCommand(WndNum);
1655 return 0;
1656 case IDM_REDO:
1657 case (WORD)IDM_ACCEL_REDO:
1658 hChild=GetWindow(hClient,GW_CHILD);
1659 if(!hChild) return 0;
1660 WndNum=GetWndNum(hChild);
1661 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType))
1662 TextEdit_RedoCommand(WndNum);
1663 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD)
1664 Rad_RedoCommand(WndNum);
1665 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT)
1666 IconEdit_RedoCommand(WndNum);
1667 return 0;
1668 case IDM_CUT:
1669 hChild=GetWindow(hClient,GW_CHILD);
1670 WndNum=GetWndNum(hChild);
1671 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
1672 hEdit=GetWindow(hChild,GW_CHILD);
1673
1674 TextEdit_GetSel(WndNum,&CharRange);
1675
1676 hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
1677 pTemp=(char *)GlobalLock(hGlobal);
1678 memcpy(pTemp,MdiInfo[WndNum].pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
1679 pTemp[CharRange.cpMax-CharRange.cpMin]=0;
1680 GlobalUnlock(hGlobal);
1681
1682 //クリップボードに保存
1683 OpenClipboard(hwnd);
1684 EmptyClipboard();
1685 SetClipboardData(CF_TEXT,hGlobal);
1686 CloseClipboard();
1687
1688 //選択文字列を消去
1689 SendMessage(hEdit,WM_KEYDOWN,VK_DELETE,0);
1690 }
1691 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
1692 i2=GetWndInfoNum(MdiInfo[WndNum].path);
1693
1694 //クリップボードに格納するためのデータを用意する
1695 ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.x-=17;
1696 ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.y-=10;
1697 hGlobal=Rad_GetChildInfoClipboardData(WndNum,i2);
1698 ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.x+=17;
1699 ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.y+=10;
1700
1701 OpenClipboard(hwnd);
1702 EmptyClipboard();
1703 SetClipboardData(dwRadClipboardID,hGlobal);
1704 CloseClipboard();
1705
1706 SendMessage(MdiInfo[WndNum].MdiRadInfo->hRad,WM_COMMAND,IDM_RAD_ITEM_DELETE,0);
1707 }
1708 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
1709 //クリップボードに格納するためのデータを用意する
1710 hGlobal=IconEdit_GetChildInfoClipboardData(WndNum);
1711 if(hGlobal==0) return 0;
1712
1713 OpenClipboard(hwnd);
1714 EmptyClipboard();
1715 SetClipboardData(CF_BITMAP,hGlobal);
1716 CloseClipboard();
1717
1718 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
1719 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
1720
1721 IconEdit_EraseRect(WndNum,&MdiInfo[WndNum].MdiIconEditInfo->DraggingRect);
1722 }
1723 return 0;
1724 case IDM_COPY:
1725 hChild=GetWindow(hClient,GW_CHILD);
1726 WndNum=GetWndNum(hChild);
1727 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
1728 hEdit=GetWindow(hChild,GW_CHILD);
1729
1730 TextEdit_GetSel(WndNum,&CharRange);
1731
1732 hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
1733 pTemp=(char *)GlobalLock(hGlobal);
1734 memcpy(pTemp,MdiInfo[WndNum].pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
1735 pTemp[CharRange.cpMax-CharRange.cpMin]=0;
1736 GlobalUnlock(hGlobal);
1737
1738 //クリップボードに保存
1739 OpenClipboard(hwnd);
1740 EmptyClipboard();
1741 SetClipboardData(CF_TEXT,hGlobal);
1742 CloseClipboard();
1743 }
1744 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
1745 i2=GetWndInfoNum(MdiInfo[WndNum].path);
1746
1747 //クリップボードに格納するためのデータを用意する
1748 hGlobal=Rad_GetChildInfoClipboardData(WndNum,i2);
1749
1750 OpenClipboard(hwnd);
1751 EmptyClipboard();
1752 SetClipboardData(dwRadClipboardID,hGlobal);
1753 CloseClipboard();
1754 }
1755 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
1756 //クリップボードに格納するためのデータを用意する
1757 hGlobal=IconEdit_GetChildInfoClipboardData(WndNum);
1758
1759 OpenClipboard(hwnd);
1760 EmptyClipboard();
1761 SetClipboardData(CF_BITMAP,hGlobal);
1762 CloseClipboard();
1763 }
1764 return 0;
1765 case IDM_PASTE:
1766 hChild=GetWindow(hClient,GW_CHILD);
1767 WndNum=GetWndNum(hChild);
1768 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
1769 hEdit=GetWindow(hChild,GW_CHILD);
1770
1771 //クリップボードを開く
1772 OpenClipboard(hwnd);
1773 hGlobal=GetClipboardData(CF_TEXT);
1774 if(!hGlobal){
1775 CloseClipboard();
1776 return 0;
1777 }
1778
1779
1780 if(pobj_nv->bPasteIndent){
1781 //インデント整形
1782 pTemp=CodeFormatter((char *)GlobalLock(hGlobal));
1783 GlobalUnlock(hGlobal);
1784 }
1785 else pTemp=(char *)GlobalLock(hGlobal);
1786
1787
1788 //テキストエディタの文字列をリプレイス
1789 TextEdit_ReplaceUpdateUndoData(WndNum,
1790 pTemp,
1791 1,
1792 1);
1793
1794 if(pobj_nv->bPasteIndent)
1795 HeapDefaultFree(pTemp);
1796 else
1797 GlobalUnlock(hGlobal);
1798
1799 //クリップボードを閉じる
1800 CloseClipboard();
1801
1802
1803 //キャレット位置までスクロールする
1804 TextEdit_ScrollCaret(WndNum,0);
1805 ResetCaretPos(WndNum);
1806 }
1807 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
1808 OpenClipboard(hwnd);
1809 hGlobal=GetClipboardData(dwRadClipboardID);
1810 if(!hGlobal){
1811 CloseClipboard();
1812 return 0;
1813 }
1814 Rad_PasteChildInfoClipboardData(WndNum,hGlobal);
1815 CloseClipboard();
1816 }
1817 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
1818 OpenClipboard(hwnd);
1819 hGlobal=GetClipboardData(CF_BITMAP);
1820 if(!hGlobal){
1821 CloseClipboard();
1822 return 0;
1823 }
1824 IconEdit_PasteChildInfoClipboardData(WndNum,(HBITMAP)hGlobal);
1825 CloseClipboard();
1826 }
1827 return 0;
1828 case IDM_DELETE:
1829 hChild=GetWindow(hClient,GW_CHILD);
1830 WndNum=GetWndNum(hChild);
1831 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
1832 hEdit=GetWindow(hChild,GW_CHILD);
1833 TextEdit_ReplaceUpdateUndoData(WndNum,"",0,1);
1834 }
1835 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD)
1836 SendMessage(MdiInfo[WndNum].MdiRadInfo->hRad,WM_COMMAND,IDM_RAD_ITEM_DELETE,0);
1837 return 0;
1838 case IDM_ALLSELECT:
1839 hChild=GetWindow(hClient,GW_CHILD);
1840 WndNum=GetWndNum(hChild);
1841 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
1842 hEdit=GetWindow(hChild,GW_CHILD);
1843
1844 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x=0;
1845 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y=0;
1846
1847 GetCaretPosFromBufferIndex(
1848 MdiInfo[WndNum].pMdiTextEdit->buffer,
1849 lstrlen(MdiInfo[WndNum].pMdiTextEdit->buffer),
1850 &MdiInfo[WndNum].pMdiTextEdit->EndCaretPos);
1851
1852 InvalidateRect(hEdit,NULL,0);
1853
1854 ResetState_EditMenu();
1855 }
1856 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
1857 i2=GetWndInfoNum(MdiInfo[WndNum].path);
1858 for(i3=0;i3<ProjectInfo.pWindowInfo[i2].NumberOfChildWindows;i3++){
1859 MdiInfo[WndNum].MdiRadInfo->SelectingItem[i3]=i3;
1860 }
1861 DrawRadWindow(WndNum,&ProjectInfo.pWindowInfo[i2]);
1862 }
1863 return 0;
1864 case IDM_FIND:
1865 DialogBox(hResInst,MAKEINTRESOURCE(IDD_FIND),hOwner,DlgFind);
1866 return 0;
1867 case IDM_PERMUTATION:
1868 DialogBox(hResInst,MAKEINTRESOURCE(IDD_PERMUTATION),hOwner,DlgPermutation);
1869 return 0;
1870
1871
1872 ///////////////////////
1873 // 変換メニュー
1874 ///////////////////////
1875 case IDM_CONV_ALPHA_SMALL:
1876 case IDM_CONV_ALPHA_BIG:
1877 case IDM_CONV_HALF:
1878 case IDM_CONV_MULTI:
1879 case IDM_CONV_KATAKANA:
1880 case IDM_CONV_HIRAGANA:
1881 case IDM_CONV_SPACE:
1882 case IDM_CONV_TAB:
1883#ifdef THETEXT
1884 case IDM_CONV_HASRETURN:
1885 case IDM_CONV_QUOTE:
1886#else
1887 case IDM_CODEFORMAT:
1888#endif
1889 TextEdit_Convert(LOWORD(wParam));
1890 return 0;
1891
1892#ifdef THETEXT
1893 ///////////////////////
1894 // ツールメニュー
1895 ///////////////////////
1896 case IDM_STRING_COUNT:
1897 DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_STRING_COUNT),hOwner,DlgStringCount,0);
1898 return 0;
1899 case IDM_SEL_STRING_COUNT:
1900 DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_STRING_COUNT),hOwner,DlgStringCount,1);
1901 return 0;
1902#endif //THETEXT
1903
1904 case IDM_PROJECTVIEW:
1905 if(pobj_nv->bClipProjectView){
1906 if(IsWindowVisible(hProjectView)){
1907 ShowWindow(hProjectView,SW_HIDE);
1908 bChecked=0;
1909 }
1910 else{
1911 ShowWindow(hProjectView,SW_SHOW);
1912 bChecked=1;
1913 }
1914 }
1915 else{
1916 if(IsWindowVisible(hProjectView_ToolWindow)){
1917 ShowWindow(hProjectView_ToolWindow,SW_HIDE);
1918 bChecked=0;
1919 }
1920 else{
1921 ShowWindow(hProjectView_ToolWindow,SW_SHOW);
1922 ShowWindow(hProjectView,SW_SHOW);
1923 bChecked=1;
1924 }
1925 }
1926 pobj_MainMenu->CheckMenu(IDM_PROJECTVIEW,bChecked);
1927
1928 //再配置
1929 ResizeOwnerWnd();
1930
1931 ShowWindow(hClient,SW_SHOW);
1932 return 0;
1933 case IDM_PROJECT_OPTION:
1934 DlgProjectOptionSetting(hwnd);
1935 return 0;
1936 case IDM_TOPMOST:
1937 if(pobj_MainMenu->IsCheck(IDM_TOPMOST)){
1938 SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
1939 pobj_MainMenu->CheckMenu(IDM_TOPMOST,0);
1940 }
1941 else{
1942 SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
1943 pobj_MainMenu->CheckMenu(IDM_TOPMOST,1);
1944 }
1945 return 0;
1946
1947#ifdef THETEXT
1948 case IDM_RIGHT_TURN:
1949 pobj_nv->bRightTurn^=1;
1950 ResetState_ViewMenu();
1951
1952 //トップのウィンドウを再描画
1953 RedrawAllWindow();
1954
1955 return 0;
1956#endif
1957
1958 case IDM_SET:
1959 DlgOptionSetting(hwnd);
1960 return 0;
1961
1962#ifndef THETEXT
1963 case IDM_DEBUG:
1964 if(pobj_Debugger->IsDebugging()){
1965 pobj_Debugger->DebugContinue();
1966 return 0;
1967 }
1968
1969 hChild=GetWindow(hClient,GW_CHILD);
1970 if(ProjectInfo.name[0]){
1971 //プロジェクトが開かれている場合
1972 if(!SetProjectToRun()) return 0;
1973
1974 //デバッグ用のコマンドライン及び実行可能ファイル(DLLのみ)
1975 sprintf(temporary,"%s\r\n%s",ProjectInfo.szExePath,ProjectInfo.szCmdLine);
1976 sprintf(temp2,"%spgm.tmp",pj_editor_Dir);
1977 hFile=CreateFile(temp2,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_TEMPORARY,NULL);
1978 DWORD dwAccessBytes;
1979 WriteFile(hFile,temporary,lstrlen(temporary),&dwAccessBytes,NULL);
1980 CloseHandle(hFile);
1981
1982 //ソースファイル名をtemp2へ
1983 ProjectInfo.pobj_DBFileInfo->ppobj_FileInfo[0]->GetFullPath(temp2);
1984
1985 //出力ファイル名をtemp3へ
1986 lstrcpy(temp3,ProjectInfo.lpszOutput_Debug);
1987 GetFullPath(temp3,ProjectInfo.dir);
1988
1989 if(IsNeedCompileForProject(1))
1990 sprintf(temporary,"\"%s\" \"%s\" /debug /run /wnd:%08x",temp2,temp3,hwnd);
1991 else
1992 sprintf(temporary,"\"%s\" \"%s\" /run /wnd:%08x",temp2,temp3,hwnd);
1993
1994 //DLLオプション
1995 if(ProjectInfo.dwModuleType==MT_DLL) lstrcat(temporary," /dll");
1996
1997 //Unicodeオプション
1998 if(ProjectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
1999
2000 //ブレークポイントをセーブ
2001 ProjectInfo.pobj_DBBreakPoint->SaveToTempFile();
2002 }
2003 else{
2004 //単独ソースコード
2005 if(!SetRunning(hChild)) return 0;
2006 if(IsNeedCompile(MdiInfo[GetWndNum(hChild)].path,1))
2007 sprintf(temporary,"\"%s\" /debug /run /wnd:%08x",MdiInfo[GetWndNum(hChild)].path,hwnd);
2008 else
2009 sprintf(temporary,"\"%s\" /run /wnd:%08x",MdiInfo[GetWndNum(hChild)].path,hwnd);
2010
2011 //ブレークポイントをセーブ
2012 pobj_DBBreakPoint->SaveToTempFile();
2013 }
2014
2015 //コンパイルビューをクリップするかどうか
2016 if(bClipCompileView){
2017 lstrcat(temporary," /clip_compile_view");
2018
2019 //コンパイラビューを閉じる
2020 if(hCompileView==(HWND)-1) return 0;
2021 if(hCompileView){
2022 hChild=hCompileView;
2023 hCompileView=(HWND)-1;
2024 SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
2025 }
2026
2027 //重複起動防止のため
2028 hCompileView=(HWND)-1;
2029 }
2030
2031 sprintf(str,"%s%s",pj_editor_Dir,lpszCompilerName);
2032 ShellExecute(hwnd,"open",str,temporary,NULL,SW_SHOWNORMAL);
2033 return 0;
2034 case IDM_DEBUGCOMPILE:
2035 hChild=GetWindow(hClient,GW_CHILD);
2036 if(ProjectInfo.name[0]){
2037 //プロジェクトが開かれている場合
2038 if(!SetProjectToRun()) return 0;
2039
2040 //ソースファイル名をtemp2へ
2041 ProjectInfo.pobj_DBFileInfo->ppobj_FileInfo[0]->GetFullPath(temp2);
2042
2043 //出力ファイル名をtemp3へ
2044 lstrcpy(temp3,ProjectInfo.lpszOutput_Debug);
2045 GetFullPath(temp3,ProjectInfo.dir);
2046
2047 sprintf(temporary,"\"%s\" \"%s\" /debug /wnd:%08x",temp2,temp3,hwnd);
2048
2049 //DLLオプション
2050 if(ProjectInfo.dwModuleType==MT_DLL) lstrcat(temporary," /dll");
2051
2052 //Unicodeオプション
2053 if(ProjectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
2054 }
2055 else{
2056 //単独ソースコード
2057 if(!SetRunning(hChild)) return 0;
2058 sprintf(temporary,"\"%s\" /debug /wnd:%08x",MdiInfo[GetWndNum(hChild)].path,hwnd);
2059 }
2060
2061 //コンパイルビューをクリップするかどうか
2062 if(bClipCompileView){
2063 lstrcat(temporary," /clip_compile_view");
2064
2065 //コンパイラビューを閉じる
2066 if(hCompileView==(HWND)-1) return 0;
2067 if(hCompileView){
2068 hChild=hCompileView;
2069 hCompileView=(HWND)-1;
2070 SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
2071 }
2072
2073 //重複起動防止のため
2074 hCompileView=(HWND)-1;
2075 }
2076
2077 //インクルードディレクトリ
2078 sprintf(temp2," /include_dir:\"%s\"",pobj_nv->szIncludeDir);
2079 lstrcat(temporary,temp2);
2080
2081 sprintf(str,"%s%s",pj_editor_Dir,lpszCompilerName);
2082 ShellExecute(hwnd,"open",str,temporary,NULL,SW_SHOWNORMAL);
2083
2084 return 0;
2085 case IDM_ATTACH:
2086 int idProcess;
2087 DWORD dwPlatform;
2088 idProcess=DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_ATTACH),hwnd,DlgAttach,(LPARAM)&dwPlatform);
2089 if(idProcess==0) return 0;
2090
2091 sprintf(temporary,"/attach:%08x /wnd:%08x",idProcess,hwnd);
2092
2093 //コンパイルビューをクリップするかどうか
2094 if(bClipCompileView){
2095 lstrcat(temporary," /clip_compile_view");
2096
2097 //コンパイラビューを閉じる
2098 if(hCompileView==(HWND)-1) return 0;
2099 if(hCompileView){
2100 hChild=hCompileView;
2101 hCompileView=(HWND)-1;
2102 SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
2103 }
2104
2105 //重複起動防止のため
2106 hCompileView=(HWND)-1;
2107 }
2108
2109 //インクルードディレクトリ
2110 sprintf(temp2," /include_dir:\"%s\"",pobj_nv->szIncludeDir);
2111 lstrcat(temporary,temp2);
2112
2113 if(dwPlatform==IMAGE_FILE_MACHINE_I386)
2114 sprintf(str,"%s%s",pj_editor_Dir,WIN32_COMPILER_NAME);
2115 else if(dwPlatform==IMAGE_FILE_MACHINE_AMD64)
2116 sprintf(str,"%s%s",pj_editor_Dir,WIN64_COMPILER_NAME);
2117
2118 ShellExecute(hwnd,"open",str,temporary,NULL,SW_SHOWNORMAL);
2119 return 0;
2120 case IDM_RELEASECOMPILE:
2121 hChild=GetWindow(hClient,GW_CHILD);
2122 if(ProjectInfo.name[0]){
2123 //プロジェクトが開かれている場合
2124 if(!SetProjectToRun()) return 0;
2125
2126 //ソースファイル名をtemp2へ
2127 ProjectInfo.pobj_DBFileInfo->ppobj_FileInfo[0]->GetFullPath(temp2);
2128
2129 //出力ファイル名をtemp3へ
2130 lstrcpy(temp3,ProjectInfo.lpszOutput_Release);
2131 GetFullPath(temp3,ProjectInfo.dir);
2132
2133 sprintf(temporary,"\"%s\" \"%s\" /wnd:%08x",temp2,temp3,hwnd);
2134
2135 //DLLオプション
2136 if(ProjectInfo.dwModuleType==MT_DLL) lstrcat(temporary," /dll");
2137
2138 //Unicodeオプション
2139 if(ProjectInfo.dwOption & PJ_OP_UNICODE) lstrcat(temporary," /unicode");
2140 }
2141 else{
2142 //単独ソースコード
2143 if(!SetRunning(hChild)) return 0;
2144 sprintf(temporary,"\"%s\" /wnd:%08x",MdiInfo[GetWndNum(hChild)].path,hwnd);
2145 }
2146
2147 //コンパイルビューをクリップするかどうか
2148 if(bClipCompileView){
2149 lstrcat(temporary," /clip_compile_view");
2150
2151 //コンパイラビューを閉じる
2152 if(hCompileView==(HWND)-1) return 0;
2153 if(hCompileView){
2154 hChild=hCompileView;
2155 hCompileView=(HWND)-1;
2156 SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
2157 }
2158
2159 //重複起動防止のため
2160 hCompileView=(HWND)-1;
2161 }
2162
2163 //インクルードディレクトリ
2164 sprintf(temp2," /include_dir:\"%s\"",pobj_nv->szIncludeDir);
2165 lstrcat(temporary,temp2);
2166
2167 sprintf(str,"%s%s",pj_editor_Dir,lpszCompilerName);
2168 ShellExecute(hwnd,"open",str,temporary,NULL,SW_SHOWNORMAL);
2169 return 0;
2170 case IDM_RELEASERUN:
2171 hChild=GetWindow(hClient,GW_CHILD);
2172 if(ProjectInfo.name[0]){
2173/* //プロジェクトが開かれている場合
2174 if(!SetProjectToRun()) return 0;
2175
2176 //必要であればリリースコンパイル
2177 if(IsNeedCompileForProject(0))
2178 SendMessage(hwnd,WM_COMMAND,IDM_RELEASECOMPILE,0);*/
2179
2180 if(ProjectInfo.dwModuleType==MT_DLL){
2181 lstrcpy(temporary,ProjectInfo.szExePath);
2182 }
2183 else{
2184 lstrcpy(temporary,ProjectInfo.lpszOutput_Debug);
2185 GetFullPath(temporary,ProjectInfo.dir);
2186 }
2187 }
2188 else{
2189/* //必要であればリリースコンパイル
2190 if(!SetRunning(hChild)) return 0;
2191
2192 if(IsNeedCompile(MdiInfo[GetWndNum(hChild)].path,0))
2193 SendMessage(hwnd,WM_COMMAND,IDM_RELEASECOMPILE,0);*/
2194
2195 //単独ソースコード
2196 _splitpath(MdiInfo[GetWndNum(hChild)].path,temporary,temp2,temp3,NULL);
2197 lstrcat(temporary,temp2);
2198 lstrcat(temporary,temp3);
2199 lstrcat(temporary,".exe");
2200 }
2201
2202 //インクルードディレクトリ
2203 sprintf(temp2," /include_dir:\"%s\"",pobj_nv->szIncludeDir);
2204 lstrcat(temporary,temp2);
2205
2206 ShellExecute(hwnd,"open",temporary,NULL,NULL,SW_SHOWNORMAL);
2207 return 0;
2208
2209
2210 ////////////////////////
2211 // デバッグ コマンド
2212 ////////////////////////
2213
2214 case IDM_STEP_IN:
2215 pobj_Debugger->StepIn();
2216 break;
2217 case IDM_STEP_OVER:
2218 pobj_Debugger->StepOver();
2219 break;
2220 case IDM_STEP_CURSOR:
2221 pobj_Debugger->StepToCursor();
2222 break;
2223 case IDM_BREAKPOINT:
2224 if(ProjectInfo.name[0]){
2225 ProjectInfo.pobj_DBBreakPoint->Event_BreakPoint();
2226 }
2227 else{
2228 pobj_DBBreakPoint->Event_BreakPoint();
2229 }
2230 break;
2231 case IDM_DEBUG_STOP:
2232 pobj_Debugger->DebugStop();
2233 break;
2234 case IDM_DEBUG_PAUSE:
2235 pobj_Debugger->DebugPause();
2236 break;
2237
2238
2239 case IDM_COMMUNITY:
2240 ShellExecute(hwnd,"open","iexplore.exe",
2241 "http://www.activebasic.com/forum/",
2242 NULL,SW_SHOWNORMAL);
2243 return 0;
2244 case IDM_COMMU_SEARCH:
2245 ShellExecute(hwnd,"open","iexplore.exe",
2246 "http://www.activebasic.com/forum/search.php",
2247 NULL,SW_SHOWNORMAL);
2248 return 0;
2249 case IDM_COMMU_PM:
2250 ShellExecute(hwnd,"open","iexplore.exe",
2251 "http://www.activebasic.com/forum/privmsg.php?folder=inbox",
2252 NULL,SW_SHOWNORMAL);
2253 return 0;
2254 case ID_COMMU_FORUM1:
2255 ShellExecute(hwnd,"open","iexplore.exe",
2256 "http://www.activebasic.com/forum/viewforum.php?f=1",
2257 NULL,SW_SHOWNORMAL);
2258 return 0;
2259 case ID_COMMU_FORUM2:
2260 ShellExecute(hwnd,"open","iexplore.exe",
2261 "http://www.activebasic.com/forum/viewforum.php?f=2",
2262 NULL,SW_SHOWNORMAL);
2263 return 0;
2264 case ID_COMMU_FORUM3:
2265 ShellExecute(hwnd,"open","iexplore.exe",
2266 "http://www.activebasic.com/forum/viewforum.php?f=5",
2267 NULL,SW_SHOWNORMAL);
2268 return 0;
2269 case ID_COMMU_FORUM4:
2270 ShellExecute(hwnd,"open","iexplore.exe",
2271 "http://www.activebasic.com/forum/viewforum.php?f=3",
2272 NULL,SW_SHOWNORMAL);
2273 return 0;
2274 case ID_COMMU_FORUM5:
2275 ShellExecute(hwnd,"open","iexplore.exe",
2276 "http://www.activebasic.com/forum/viewforum.php?f=6",
2277 NULL,SW_SHOWNORMAL);
2278 return 0;
2279 case ID_COMMU_FORUM6:
2280 ShellExecute(hwnd,"open","iexplore.exe",
2281 "http://www.activebasic.com/forum/viewforum.php?f=8",
2282 NULL,SW_SHOWNORMAL);
2283 return 0;
2284 case ID_COMMU_FORUM7:
2285 ShellExecute(hwnd,"open","iexplore.exe",
2286 "http://www.activebasic.com/forum/viewforum.php?f=4",
2287 NULL,SW_SHOWNORMAL);
2288 return 0;
2289 case ID_COMMU_FORUM8:
2290 ShellExecute(hwnd,"open","iexplore.exe",
2291 "http://www.activebasic.com/forum/viewforum.php?f=7",
2292 NULL,SW_SHOWNORMAL);
2293 return 0;
2294#endif //THETEXT
2295
2296
2297 case IDM_TOPIC:
2298#ifdef THETEXT
2299 sprintf(str,"%sTopics\\index.html",pj_editor_Dir);
2300 ShellExecute(hwnd,"open",str,NULL,NULL,SW_SHOWNORMAL);
2301#else
2302 sprintf(str,"%sBasicHelp.chm",pj_editor_Dir);
2303 HtmlHelp(NULL,str,HH_DISPLAY_TOPIC,0);
2304#endif
2305 return 0;
2306
2307#ifdef THETEXT
2308 case IDM_DSHOMEPAGE:
2309 ShellExecute(hwnd,"open","http://www.discoversoft.net/",NULL,NULL,SW_SHOWNORMAL);
2310 return 0;
2311#else
2312 case IDM_AB_WEBSITE:
2313 ShellExecute(hwnd,"open","http://www.activebasic.com/",NULL,NULL,SW_SHOWNORMAL);
2314 return 0;
2315 case IDM_ACTBDL:
2316 ShellExecute(hwnd,"open","http://www.activebasic.com/activebasic5/download.htm",NULL,NULL,SW_SHOWNORMAL);
2317 return 0;
2318#endif
2319
2320 case IDM_ABOUT:
2321 DialogBox(hResInst,MAKEINTRESOURCE(IDD_ABOUT),hwnd,DialogAbout);
2322 return 0;
2323
2324 case IDM_WEB_SEARCH:
2325 hChild=GetWindow(hClient,GW_CHILD);
2326 WndNum=GetWndNum(hChild);
2327 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
2328 extern HWND hWebSearchCombo;
2329 SendMessage(GetWindow(hWebSearchCombo,GW_CHILD),WM_CHAR,VK_RETURN,0);
2330 }
2331 return 0;
2332
2333
2334
2335 //////////////////////////////////////////////////////
2336 // レバーコントロールのサブメニューコマンド(レバー追加)
2337 //////////////////////////////////////////////////////
2338
2339 case IDM_DOCSELECTBAND:
2340 pobj_Rebar->ChangeRebarBand(ID_DOCCOMBO);
2341 return 0;
2342 case IDM_STANDARDBAND:
2343 pobj_Rebar->ChangeRebarBand(ID_STANDARDTOOLBAR);
2344 return 0;
2345#ifndef THETEXT
2346 case IDM_RELEASEBAND:
2347 pobj_Rebar->ChangeRebarBand(ID_RELEASETOOLBAR);
2348 return 0;
2349 case IDM_DEBUGBAND:
2350 pobj_Rebar->ChangeRebarBand(ID_DEBUGGERTOOLBAR);
2351 return 0;
2352 case IDM_SELECTCOMPILERBAND:
2353 pobj_Rebar->ChangeRebarBand(ID_SELECTCOMPILERCOMBO);
2354 return 0;
2355#endif
2356 case IDM_BANDMENU_WEB_SEARCH:
2357 pobj_Rebar->ChangeRebarBand(ID_WEB_SEARCH);
2358 return 0;
2359 case IDM_NOGRIPPER:
2360 if(pobj_nv->bNoGripper) pobj_nv->bNoGripper=0;
2361 else pobj_nv->bNoGripper=1;
2362
2363 //レバーコントロールを再生成
2364 pobj_Rebar->ResetRebar();
2365
2366 //メニュー状態を設定
2367 ResetState_DocMenu();
2368 return 0;
2369 case IDM_RESET_REBAR:
2370 //"ツールバーの配置をすべて初期状態に戻します。\nよろしいですか?"
2371 if(IDCANCEL==MessageBox(hwnd,STRING_TOOLBAR_RESET,APPLICATION_NAME,MB_OKCANCEL|MB_ICONEXCLAMATION)) break;
2372
2373 //レバーコントロールを再生成
2374 pobj_Rebar->ResetInitRebar();
2375
2376 //メニュー状態を設定
2377 ResetState_DocMenu();
2378 return 0;
2379
2380
2381
2382 ////////////////////////////////////////////////////
2383 // メイン タブ コントロールのサブメニューコマンド
2384 ////////////////////////////////////////////////////
2385
2386 case IDM_ALLCLOSE_OMIT_MYSELF:
2387 //このウィンドウ以外をすべて閉じる(&A)
2388 hChild=GetWindow(hClient,GW_CHILD);
2389 WndNum=GetWndNum(hChild);
2390 for(i=0;i<MAX_WNDNUM;i++){
2391 if(i==WndNum) continue;
2392 if(MdiInfo[i].hwnd) SendMessage(MdiInfo[i].hwnd,WM_CLOSE,0,0);
2393 }
2394 return 0;
2395
2396 case IDM_PATH_COPY:
2397 hChild=GetWindow(hClient,GW_CHILD);
2398 WndNum=GetWndNum(hChild);
2399
2400 //絶対パスをコピー
2401 hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,lstrlen(MdiInfo[WndNum].path)+1);
2402 pTemp=(char *)GlobalLock(hGlobal);
2403 lstrcpy(pTemp,MdiInfo[WndNum].path);
2404 GlobalUnlock(hGlobal);
2405
2406 //クリップボードに保存
2407 OpenClipboard(hwnd);
2408 EmptyClipboard();
2409 SetClipboardData(CF_TEXT,hGlobal);
2410 CloseClipboard();
2411 return 0;
2412
2413 case IDM_FOLDER_OPEN:
2414 hChild=GetWindow(hClient,GW_CHILD);
2415 WndNum=GetWndNum(hChild);
2416
2417 _splitpath(MdiInfo[WndNum].path,temporary,temp2,NULL,NULL);
2418 lstrcat(temporary,temp2);
2419
2420 ShellExecute(hwnd,"explore",temporary,NULL,NULL,SW_SHOWNORMAL);
2421 return 0;
2422
2423 case IDM_DELETE_FILE:
2424 hChild=GetWindow(hClient,GW_CHILD);
2425 WndNum=GetWndNum(hChild);
2426
2427 _splitpath(MdiInfo[WndNum].path,NULL,NULL,temporary,temp2);
2428 lstrcat(temporary,temp2);
2429
2430 lstrcat(temporary," をごみ箱に移動して閉じます。よろしいですか?");
2431 if(MessageBox(hwnd,temporary,APPLICATION_NAME,MB_OKCANCEL|MB_ICONQUESTION)==IDCANCEL) return 0;
2432
2433 //ゴミ箱へ
2434 SHFILEOPSTRUCT fo;
2435 fo.hwnd=hwnd;
2436 fo.wFunc=FO_DELETE;
2437 fo.pFrom =MdiInfo[WndNum].path;
2438 fo.pTo="\0";
2439 fo.fFlags =FOF_ALLOWUNDO|FOF_NOCONFIRMATION;
2440 SHFileOperation(&fo);
2441
2442 //閉じる
2443 MdiInfo[WndNum].pMdiTextEdit->UnModify();
2444 SendMessage(MdiInfo[WndNum].hwnd,WM_CLOSE,0,0);
2445
2446 return 0;
2447
2448 case IDM_USER_COLOR:
2449 {
2450 CHOOSECOLOR cc;
2451 COLORREF CusColors[16]={
2452 RGB(255,255,255),
2453 RGB(0,0,0),
2454 RGB(128,128,128),
2455 RGB(192,192,192),
2456 RGB(128,0,0),
2457 RGB(255,0,0),
2458 RGB(128,128,0),
2459 RGB(255,255,0),
2460 RGB(0,128,0),
2461 RGB(0,255,0),
2462 RGB(0,128,128),
2463 RGB(0,255,255),
2464 RGB(0,0,128),
2465 RGB(0,0,255),
2466 RGB(128,0,128),
2467 RGB(255,0,255)};
2468 cc.lStructSize=sizeof(CHOOSECOLOR);
2469 cc.hwndOwner=hwnd;
2470 cc.rgbResult=colorUser;
2471 cc.lpCustColors=CusColors;
2472 cc.Flags=CC_RGBINIT|CC_FULLOPEN;
2473 if(!ChooseColor(&cc)){
2474 return 0;
2475 }
2476 colorUser=cc.rgbResult;
2477 }
2478 case IDM_GRAY:
2479 case IDM_WHITE:
2480 case IDM_RED:
2481 case IDM_GREEN:
2482 case IDM_BLUE:
2483 case IDM_YELLOW:
2484 hChild=GetWindow(hClient,GW_CHILD);
2485 WndNum=GetWndNum(hChild);
2486
2487 TC_ITEM tcItem;
2488 tcItem.mask=TCIF_PARAM;
2489 if(LOWORD(wParam)==IDM_GRAY) tcItem.lParam=TABCOLOR_GRAY;
2490 if(LOWORD(wParam)==IDM_WHITE) tcItem.lParam=TABCOLOR_WHITE;
2491 if(LOWORD(wParam)==IDM_RED) tcItem.lParam=TABCOLOR_RED;
2492 if(LOWORD(wParam)==IDM_GREEN) tcItem.lParam=TABCOLOR_GREEN;
2493 if(LOWORD(wParam)==IDM_BLUE) tcItem.lParam=TABCOLOR_BLUE;
2494 if(LOWORD(wParam)==IDM_YELLOW) tcItem.lParam=TABCOLOR_YELLOW;
2495 if(LOWORD(wParam)==IDM_USER_COLOR) tcItem.lParam=colorUser;
2496 TabCtrl_SetItem(pobj_MainTab->hTab,
2497 TabCtrl_GetCurSel(pobj_MainTab->hTab),
2498 &tcItem);
2499 InvalidateRect(pobj_MainTab->hTab,NULL,0);
2500 return 0;
2501
2502
2503
2504 //////////////////////////////////
2505 // SideWeb
2506 //////////////////////////////////
2507
2508 case IDC_CLIP:
2509 pobj_SideWeb->bShow=0;
2510 ResizeOwnerWnd();
2511 return 0;
2512 }
2513 break;
2514 case WM_DROPFILES:
2515 hDrop=(HDROP)wParam;
2516
2517 i2=DragQueryFile(hDrop,-1,0,0);
2518 for(i=0;i<i2;i++){
2519 DragQueryFile(hDrop,i,str,MAX_PATH);
2520 OpenFileWithExtension(str);
2521 }
2522 DragFinish(hDrop);
2523 return 0;
2524 case WM_SHOWERROR:
2525 //エラー部分を反転表示
2526 DWORD AccBytes;
2527 HANDLE fh;
2528 sprintf(temporary,"%spgm.tmp",pj_editor_Dir);
2529 fh=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
2530 ReadFile(fh,temporary,MAX_PATH,&AccBytes,NULL);
2531 CloseHandle(fh);
2532 temporary[AccBytes]=0;
2533 hChild=GetWindow(hClient,GW_CHILD);
2534 while(hChild){
2535 WndNum=GetWndNum(hChild);
2536 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
2537 if(lstrcmpi(MdiInfo[WndNum].path,temporary)==0) break;
2538 }
2539 hChild=GetNextWindow(hChild,GW_HWNDNEXT);
2540 }
2541 if(!hChild){
2542 hChild=OpenFileWithExtension(temporary);
2543 WndNum=GetWndNum(hChild);
2544 }
2545
2546 if(WndNum==-1) return 0;
2547
2548 //ウィンドウを最前面に表示
2549 BringWindowToTop(hChild);
2550 UpdateWindow(hChild);
2551
2552 pTemp=MdiInfo[WndNum].pMdiTextEdit->buffer;
2553
2554 //行の先頭インデックスを取得(取得する行の番号はwParamで渡される)
2555 for(i=0,i2=0;;i++){
2556 if(i2>=(int)wParam) break;
2557 if(pTemp[i]=='\0') break;
2558 if(pTemp[i]=='\r'&&pTemp[i+1]=='\n'){
2559 i++;
2560 i2++;
2561 }
2562 }
2563 pos.x=i;
2564
2565 //行の終端インデックスを取得
2566 for(;;i++){
2567 if(pTemp[i]=='\0') break;
2568 if(pTemp[i]=='\r'&&pTemp[i+1]=='\n') break;
2569 }
2570 pos.y=i;
2571
2572 //行を選択する
2573 TextEdit_SetSel(WndNum,pos.x,pos.y,TRUE);
2574
2575 return 0;
2576
2577#ifndef THETEXT
2578 case WM_SETCOMPILEVIEW:
2579 //コンパイラウィンドウ(埋め込み型)が表示されたとき
2580 hCompileView=(HWND)lParam;
2581 ResizeOwnerWnd();
2582 return 0;
2583 case WM_DESTROYCOMPILEVIEW:
2584 //コンパイラウィンドウ(埋め込み型)が破棄されたとき
2585 if((int)hCompileView==-1){
2586 //すぐに次のコンパイラウィンドウが起動するとき
2587 hCompileView=0;
2588 }
2589 else{
2590 //完全にコンパイラウィンドウを閉じたときはリサイズ
2591 hCompileView=0;
2592
2593 ResizeOwnerWnd();
2594 }
2595 return 0;
2596
2597 case WM_SETDEBUGGERBASE:
2598 //デバッガベースウィンドウ(埋め込み型)が表示されたとき
2599 pobj_Debugger->begin();
2600
2601 //BasicCompiler.exeの強制終了を考慮
2602 SetTimer(hOwner,ID_DEBUGSAFTY,1000,NULL);
2603
2604 return 0;
2605 case WM_DESTROYDEBUGGERBASE:
2606 //BasicCompiler.exeの強制終了を考慮
2607 KillTimer(hOwner,ID_DEBUGSAFTY);
2608
2609 //デバッガベースウィンドウ(埋め込み型)が破棄されたとき
2610 pobj_Debugger->end();
2611
2612 return 0;
2613
2614 case WM_SETDEBUGGERVIEW:
2615 //デバッガウィンドウ(埋め込み型)が表示されたとき
2616 pobj_Debugger->watch_start((HWND)lParam);
2617 ResizeOwnerWnd();
2618 return 0;
2619 case WM_DESTROYDEBUGGERVIEW:
2620 //デバッガウィンドウ(埋め込み型)が破棄されたとき
2621 pobj_Debugger->watch_quit();
2622 ResizeOwnerWnd();
2623 return 0;
2624#endif
2625
2626 case WM_SIZE:
2627 ResizeOwnerWnd();
2628 return 0;
2629
2630
2631 case WM_MOUSEMOVE:
2632 static DWORD dwDragLever;
2633 static POINT PrevMousePos;
2634 static int start;
2635
2636 pos.x=(long)(short)LOWORD(lParam);
2637 pos.y=(long)(short)HIWORD(lParam);
2638 ClientToScreen(hwnd,&pos);
2639
2640 if(dwDragLever){
2641 GetClientRect(hwnd,&rect);
2642
2643 if(dwDragLever==1){
2644 //プロジェクトビューをリサイズ中
2645 pobj_nv->width_ClipProjectView=start+pos.x-PrevMousePos.x;
2646 if(pobj_nv->width_ClipProjectView<100) pobj_nv->width_ClipProjectView=100;
2647 if(rect.right-100<pobj_nv->width_ClipProjectView) pobj_nv->width_ClipProjectView=rect.right-100;
2648 }
2649 else if(dwDragLever==2){
2650 //デバッガビューをリサイズ中
2651 pobj_nv->height_ClipDebuggerView=start+PrevMousePos.y-pos.y;
2652 if(pobj_nv->height_ClipDebuggerView<60) pobj_nv->height_ClipDebuggerView=60;
2653 if(rect.bottom-100<pobj_nv->height_ClipCompileView+pobj_nv->height_ClipDebuggerView)
2654 pobj_nv->height_ClipDebuggerView=rect.bottom-100-pobj_nv->height_ClipCompileView;
2655 }
2656 else if(dwDragLever==3){
2657 //コンパイラビューをリサイズ中
2658 pobj_nv->height_ClipCompileView=start+PrevMousePos.y-pos.y;
2659 if(pobj_nv->height_ClipCompileView<60) pobj_nv->height_ClipCompileView=60;
2660 if(rect.bottom-100<pobj_nv->height_ClipCompileView)
2661 pobj_nv->height_ClipCompileView=rect.bottom-100;
2662 }
2663 else if(dwDragLever==4){
2664 //SideWebをリサイズ中
2665 pobj_nv->width_WebSearchView=start+PrevMousePos.x-pos.x;
2666 if(pobj_nv->width_WebSearchView<100) pobj_nv->width_WebSearchView=100;
2667 if(rect.right-100<pobj_nv->width_WebSearchView) pobj_nv->width_WebSearchView=rect.right-100;
2668 }
2669
2670 ResizeOwnerWnd();
2671 UpdateWindow(hwnd);
2672 }
2673 if(pobj_nv->bClipProjectView&&IsWindowVisible(hProjectView)){
2674 //プロジェクトビューとMDIクライアントの境目のサイズ変更ライン
2675 GetWindowRect(hProjectView,&rect);
2676 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
2677 rect.right<=pos.x&&pos.x<=rect.right+LEVER_THICK){
2678 SetCursor(LoadCursor(0,IDC_SIZEWE));
2679 }
2680 }
2681#ifndef THETEXT
2682 if(bClipCompileView&&pobj_Debugger->IsDebuggerView()){
2683 //デバッガビューとMDIクライアントの境目のサイズ変更ライン
2684 GetWindowRect(pobj_Debugger->hwnd,&rect);
2685 if(rect.left<=pos.x&&pos.x<=rect.right&&
2686 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
2687 SetCursor(LoadCursor(0,IDC_SIZENS));
2688 }
2689 }
2690 if(bClipCompileView&&IsWindowVisible(hCompileView)){
2691 //コンパイラビューとMDIクライアントの境目のサイズ変更ライン
2692 GetWindowRect(hCompileView,&rect);
2693 if(rect.left<=pos.x&&pos.x<=rect.right&&
2694 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
2695 SetCursor(LoadCursor(0,IDC_SIZENS));
2696 }
2697 }
2698#endif
2699 if(pobj_SideWeb->bShow){
2700 //SideWebとMDIクライアントの境目のサイズ変更ライン
2701 pobj_SideWeb->GetRect(&rect);
2702 ClientToScreen(hwnd,&rect);
2703 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
2704 rect.left-LEVER_THICK<=pos.x&&pos.x<=rect.left){
2705 SetCursor(LoadCursor(0,IDC_SIZEWE));
2706 }
2707 }
2708 return 0;
2709 case WM_LBUTTONDOWN:
2710 pos.x=LOWORD(lParam);
2711 pos.y=HIWORD(lParam);
2712 ClientToScreen(hwnd,&pos);
2713
2714 if(pobj_nv->bClipProjectView&&IsWindowVisible(hProjectView)){
2715 //プロジェクトビューとMDIクライアントの境目のサイズ変更ライン
2716 GetWindowRect(hProjectView,&rect);
2717 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
2718 rect.right<=pos.x&&pos.x<=rect.right+LEVER_THICK){
2719 SetCursor(LoadCursor(0,IDC_SIZEWE));
2720
2721 dwDragLever=1;
2722 SetCapture(hwnd);
2723
2724 PrevMousePos=pos;
2725 start=pobj_nv->width_ClipProjectView;
2726 }
2727 }
2728#ifndef THETEXT
2729 if(bClipCompileView&&pobj_Debugger->IsDebuggerView()){
2730 //デバッガビューとMDIクライアントの境目のサイズ変更ライン
2731 GetWindowRect(pobj_Debugger->hwnd,&rect);
2732 if(rect.left<=pos.x&&pos.x<=rect.right&&
2733 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
2734 SetCursor(LoadCursor(0,IDC_SIZENS));
2735
2736 dwDragLever=2;
2737 SetCapture(hwnd);
2738
2739 PrevMousePos=pos;
2740 start=pobj_nv->height_ClipDebuggerView;
2741 }
2742 }
2743 if(bClipCompileView&&IsWindowVisible(hCompileView)){
2744 //コンパイラビューとMDIクライアントの境目のサイズ変更ライン
2745 GetWindowRect(hCompileView,&rect);
2746 if(rect.left<=pos.x&&pos.x<=rect.right&&
2747 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
2748 SetCursor(LoadCursor(0,IDC_SIZENS));
2749
2750 dwDragLever=3;
2751 SetCapture(hwnd);
2752
2753 PrevMousePos=pos;
2754 start=pobj_nv->height_ClipCompileView;
2755 }
2756 }
2757#endif
2758 if(pobj_SideWeb->bShow){
2759 //SideWebとMDIクライアントの境目のサイズ変更ライン
2760 pobj_SideWeb->GetRect(&rect);
2761 ClientToScreen(hwnd,&rect);
2762 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
2763 rect.left-LEVER_THICK<=pos.x&&pos.x<=rect.left){
2764 SetCursor(LoadCursor(0,IDC_SIZENS));
2765
2766 dwDragLever=4;
2767 SetCapture(hwnd);
2768
2769 PrevMousePos=pos;
2770 start=pobj_nv->width_WebSearchView;
2771 }
2772 }
2773 return 0;
2774 case WM_LBUTTONUP:
2775 if(dwDragLever){
2776 dwDragLever=0;
2777 ReleaseCapture();
2778 }
2779 return 0;
2780
2781
2782 case WM_SYSCOMMAND:
2783 //ウィンドウの最小化前にウィンドウ位置を保存
2784 if(wParam==SC_MINIMIZE){
2785 if(IsZoomed(hwnd)) pobj_nv->bWindowMax=1;
2786 else if(!IsIconic(hwnd)){
2787 pobj_nv->bWindowMax=0;
2788 GetWindowRect(hwnd,&pobj_nv->StartupWindowRect);
2789 }
2790 }
2791 break; //処理をDefFrameProcへ
2792 case WM_QUERYENDSESSION:
2793 case WM_CLOSE:
2794 extern BOOL bSearchingClasses;
2795 if(bSearchingClasses){
2796 pobj_ClassTreeView->bCloseSwitch=1;
2797 return 0;
2798 }
2799
2800 //コンパイラビューを閉じる
2801 if(hCompileView)
2802 SendMessage(hCompileView,WM_COMMAND,IDCANCEL,0);
2803
2804 //次回起動時にMDIウィンドウを最大化させるかを判定
2805 hChild=GetWindow(hClient,GW_CHILD);
2806 pobj_nv->bMDIZoomed=IsZoomed(hChild);
2807
2808 //プロジェクトを閉じる
2809 if(ProjectInfo.name[0]){
2810 if(!CloseProject()) return 0;
2811 }
2812
2813 //MDIウィンドウの保存確認
2814 hChild=GetWindow(hClient,GW_CHILD);
2815 while(hChild){
2816 i=GetWndNum(hChild);
2817 if(!DocumentModifyCheck(hChild)) return 0;
2818 hChild=GetNextWindow(hChild,GW_HWNDNEXT);
2819 }
2820
2821
2822 KillTimer(hwnd,ID_TIMER_BACKUP);
2823
2824
2825 //ProjectViewの位置を保存、ProjectViewを破棄
2826 GetWindowRect(hProjectView_ToolWindow,&pobj_nv->rectProjectView);
2827 DestroyWindow(hProjectView);
2828 DestroyWindow(hProjectView_ToolWindow);
2829
2830 //Rebarの位置を保存、Rebarを破棄
2831 delete pobj_Rebar;
2832 pobj_Rebar=0;
2833
2834 //タブコントロールを破棄
2835 delete pobj_MainTab;
2836 pobj_MainTab=0;
2837
2838 //SideWebを破棄
2839 delete pobj_SideWeb;
2840 pobj_SideWeb=0;
2841
2842 //メインウィンドウの最大化有無、座標を保存
2843 if(IsZoomed(hwnd)) pobj_nv->bWindowMax=1;
2844 else if(!IsIconic(hwnd)){
2845 pobj_nv->bWindowMax=0;
2846 GetWindowRect(hwnd,&pobj_nv->StartupWindowRect);
2847 }
2848
2849 hChild=GetWindow(hClient,GW_CHILD);
2850 while(hChild){
2851 CloseDocWindow(GetWndNum(hChild));
2852 DestroyWindow(hChild);
2853 hChild=GetWindow(hClient,GW_CHILD);
2854 }
2855
2856 EndProjectEditor(); //ProjectEditorの情報を保存
2857
2858 //エディタ用フォントを破棄
2859 extern HFONT hFont_TextEdit,hFont_HyperLink_TextEdit;
2860 if(hFont_TextEdit) DeleteObject(hFont_TextEdit);
2861 if(hFont_HyperLink_TextEdit) DeleteObject(hFont_HyperLink_TextEdit);
2862
2863 DestroyWindow(hwnd);
2864 return 0;
2865
2866 case WM_DESTROY:
2867 PostQuitMessage(0);
2868 return 0;
2869 }
2870 return DefFrameProc(hwnd,hClient,message,wParam,lParam);
2871}
2872
2873int RegWndClass(WNDPROC WndProc,char *lpClassName,HBRUSH hBackBrush,DWORD dwFlag){
2874 WNDCLASSEX wcl;
2875
2876 wcl.cbSize=sizeof(WNDCLASSEX);
2877 wcl.hInstance=hInst;
2878 wcl.lpszClassName=lpClassName;
2879 wcl.lpfnWndProc=WndProc;
2880
2881 if(dwFlag&FLAG_DBLCLK) wcl.style=CS_DBLCLKS;
2882 else wcl.style=0;
2883
2884 wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
2885 wcl.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
2886
2887 if(dwFlag&FLAG_BEAMCURSOR) wcl.hCursor=LoadCursor(NULL,IDC_IBEAM);
2888 else wcl.hCursor=LoadCursor(NULL,IDC_ARROW);
2889
2890 wcl.lpszMenuName=NULL;
2891 wcl.cbClsExtra=0;
2892 wcl.cbWndExtra=0;
2893 wcl.hbrBackground=hBackBrush;
2894
2895 return RegisterClassEx(&wcl);
2896}
2897int PASCAL WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int ShowCmd){
2898 int i,i2,IsStr;
2899 char str[MAX_PATH],str2[MAX_PATH],dummy[1024];
2900 MSG msg;
2901 HACCEL hAccel;
2902
2903 hInst=hThisInst;
2904 if(!SetupProjectEditor()) return 0;
2905
2906 HBRUSH hGrayBrush_LineNumber;
2907 hGrayBrush_LineNumber=CreateSolidBrush(RGB(220,220,220));
2908
2909 if(!RegWndClass(WindowFunc,"ProjectEditor",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2910 if(!RegWndClass(MDIClientWindow_TextEdit,"MDIClientWindow_TextEdit",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
2911 if(!RegWndClass(MethodCheckWindow,"MethodCheckWindow",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
2912 if(!RegWndClass(MDIClientWindow_Rad,"MDIClientWindow_Rad",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
2913 if(!RegWndClass(RadToolsWindow,"RadToolsWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2914 if(!RegWndClass(RadPropertyWindow,"RadPropertyWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2915 if(!RegWndClass(RadWindow,"RadWindow",(HBRUSH)GetStockObject(NULL_BRUSH),FLAG_DBLCLK)) return 0;
2916 if(!RegWndClass(TestWindowProc,"TestWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2917 if(!RegWndClass(MDIClientWindow_Menu,"MDIClientWindow_Menu",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
2918 if(!RegWndClass(MenuEditWindow,"MenuEditWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2919 if(!RegWndClass(MDIClientWindow_IconEdit,"MDIClientWindow_IconEdit",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2920 if(!RegWndClass(IconEditWindowProc,"IconEditWindowProc",(HBRUSH)GetStockObject(WHITE_BRUSH),0)) return 0;
2921 if(!RegWndClass(ProjectViewProc,"ProjectView",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2922 if(!RegWndClass(ProjectView_ToolWindowProc,"ProjectView_ToolWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2923 if(!RegWndClass(TextEditProc,"TextEditor",(HBRUSH)GetStockObject(NULL_BRUSH),FLAG_DBLCLK|FLAG_BEAMCURSOR)) return 0;
2924 if(!RegWndClass(ComplementWindow,"ComplementWindow",(HBRUSH)GetStockObject(BLACK_BRUSH),FLAG_DBLCLK)) return 0;
2925 if(!RegWndClass(PreviewWndProc,"PreviewWindow",(HBRUSH)GetStockObject(GRAY_BRUSH),FLAG_DBLCLK)) return 0;
2926
2927 //Web検索用のウィンドウクラス
2928 if(!RegWndClass(WebResultWndProc,"WebResult",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2929 if(!RegWndClass(OneTabProc,"OneTab",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2930 if(!RegWndClass(ResultListProc,"ResultList",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2931
2932 //ルーラーのウィンドウクラス
2933 if(!RegWndClass(RulerProc,"Ruler",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2934
2935 //SideWebのウィンドウクラス
2936 if(!RegWndClass(SideWebProc,"SideWeb",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2937
2938
2939
2940 hAccel=LoadAccelerators(hResInst,MAKEINTRESOURCE(IDR_ACCELERATOR1));
2941
2942 //メインウィンドウ
2943 RECT *prc;
2944 prc=&pobj_nv->StartupWindowRect;
2945 hOwner=CreateWindowEx(WS_EX_ACCEPTFILES,"ProjectEditor",APPLICATION_NAME,
2946 WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
2947 prc->left, prc->top,
2948 prc->right-prc->left, prc->bottom-prc->top,
2949 HWND_DESKTOP,pobj_MainMenu->hMenu,hInst,NULL);
2950
2951 SendMessage(hOwner,WM_SETICON,ICON_SMALL,(long)hOwnerIcon);
2952 SetClipboardViewer(hOwner);
2953
2954 if(pobj_nv->bWindowMax) ShowWindow(hOwner,SW_MAXIMIZE);
2955 else ShowWindow(hOwner,ShowCmd);
2956 UpdateWindow(hOwner);
2957
2958 int open_sw=0;
2959 if(lstrlen(lpCmdLine)>0){
2960 lstrcpy(dummy,lpCmdLine);
2961 for(i=0,i2=0,IsStr=0;;i++,i2++){
2962 if(dummy[i]=='\"'){
2963 if(IsStr==0) IsStr=1;
2964 else IsStr=0;
2965 i++;
2966 }
2967 if((dummy[i]==' '&&IsStr==0)||dummy[i]=='\0'){
2968 str[i2]=0;
2969 if(!(strstr(str,":")||strstr(str,"\\\\"))){
2970 lstrcpy(str2,str);
2971 GetCurrentDirectory(MAX_PATH,str);
2972 lstrcat(str,"\\");
2973 lstrcat(str,str2);
2974 }
2975 ShortPathToLongPath(str,str2);
2976 OpenFileWithExtension(str2);
2977 open_sw=1;
2978 if(dummy[i]=='\0') break;
2979 i2=-1;
2980 continue;
2981 }
2982 str[i2]=dummy[i];
2983 }
2984 }
2985
2986 BOOL bRestore=0;
2987
2988
2989 {
2990 //自動バックアップ及び復元機能
2991
2992 //必要であれば復元
2993 bRestore=restore();
2994 }
2995
2996
2997#ifdef THETEXT
2998 if(open_sw==0&&bRestore==0){
2999 //ファイルが開かれなかったとき
3000 NewTextEditWindow(NULL,WNDTYPE_TEXT);
3001 }
3002#endif
3003
3004
3005 while(GetMessage(&msg,NULL,0,0)){
3006
3007 if(!TranslateAccelerator(hOwner,hAccel,&msg)){
3008 if(ProjectInfo.name[0]){
3009 for(i=0,i2=0;i<MAX_WNDNUM;i++){
3010 if(MdiInfo[i].hwnd&&MdiInfo[i].DocType==WNDTYPE_RAD){
3011 if(IsDialogMessage(MdiInfo[i].MdiRadInfo->hProp_Dlg,&msg)) i2=1;
3012 }
3013 }
3014 if(i2==0){
3015 if(!TranslateMDISysAccel(hClient,&msg)){
3016 TranslateMessage(&msg);
3017 DispatchMessage(&msg);
3018 }
3019 }
3020 }
3021 else{
3022 if(!TranslateMDISysAccel(hClient,&msg)){
3023 TranslateMessage(&msg);
3024 DispatchMessage(&msg);
3025 }
3026 }
3027 }
3028 }
3029
3030 DeleteObject(hGrayBrush_LineNumber);
3031
3032#if defined HeapAlloc
3033 CheckHeapCheck();
3034#endif
3035
3036 return msg.wParam;
3037}
Note: See TracBrowser for help on using the repository browser.