source: dev/ProjectEditor/ProjectEditor.cpp@ 39

Last change on this file since 39 was 37, checked in by dai_9181, 18 years ago

ドキュメントを閉じたときのチラツキを解消。
Write命令とWriteメソッドを切り分けられるようにした。

File size: 89.4 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 //ブレークポイントをセーブ
1998 ProjectInfo.pobj_DBBreakPoint->SaveToTempFile();
1999 }
2000 else{
2001 //単独ソースコード
2002 if(!SetRunning(hChild)) return 0;
2003 if(IsNeedCompile(MdiInfo[GetWndNum(hChild)].path,1))
2004 sprintf(temporary,"\"%s\" /debug /run /wnd:%08x",MdiInfo[GetWndNum(hChild)].path,hwnd);
2005 else
2006 sprintf(temporary,"\"%s\" /run /wnd:%08x",MdiInfo[GetWndNum(hChild)].path,hwnd);
2007
2008 //ブレークポイントをセーブ
2009 pobj_DBBreakPoint->SaveToTempFile();
2010 }
2011
2012 //コンパイルビューをクリップするかどうか
2013 if(bClipCompileView){
2014 lstrcat(temporary," /clip_compile_view");
2015
2016 //コンパイラビューを閉じる
2017 if(hCompileView==(HWND)-1) return 0;
2018 if(hCompileView){
2019 hChild=hCompileView;
2020 hCompileView=(HWND)-1;
2021 SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
2022 }
2023
2024 //重複起動防止のため
2025 hCompileView=(HWND)-1;
2026 }
2027
2028 sprintf(str,"%s%s",pj_editor_Dir,lpszCompilerName);
2029 ShellExecute(hwnd,"open",str,temporary,NULL,SW_SHOWNORMAL);
2030 return 0;
2031 case IDM_DEBUGCOMPILE:
2032 hChild=GetWindow(hClient,GW_CHILD);
2033 if(ProjectInfo.name[0]){
2034 //プロジェクトが開かれている場合
2035 if(!SetProjectToRun()) return 0;
2036
2037 //ソースファイル名をtemp2へ
2038 ProjectInfo.pobj_DBFileInfo->ppobj_FileInfo[0]->GetFullPath(temp2);
2039
2040 //出力ファイル名をtemp3へ
2041 lstrcpy(temp3,ProjectInfo.lpszOutput_Debug);
2042 GetFullPath(temp3,ProjectInfo.dir);
2043
2044 sprintf(temporary,"\"%s\" \"%s\" /debug /wnd:%08x",temp2,temp3,hwnd);
2045
2046 //DLLオプション
2047 if(ProjectInfo.dwModuleType==MT_DLL) lstrcat(temporary," /dll");
2048 }
2049 else{
2050 //単独ソースコード
2051 if(!SetRunning(hChild)) return 0;
2052 sprintf(temporary,"\"%s\" /debug /wnd:%08x",MdiInfo[GetWndNum(hChild)].path,hwnd);
2053 }
2054
2055 //コンパイルビューをクリップするかどうか
2056 if(bClipCompileView){
2057 lstrcat(temporary," /clip_compile_view");
2058
2059 //コンパイラビューを閉じる
2060 if(hCompileView==(HWND)-1) return 0;
2061 if(hCompileView){
2062 hChild=hCompileView;
2063 hCompileView=(HWND)-1;
2064 SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
2065 }
2066
2067 //重複起動防止のため
2068 hCompileView=(HWND)-1;
2069 }
2070
2071 //インクルードディレクトリ
2072 sprintf(temp2," /include_dir:\"%s\"",pobj_nv->szIncludeDir);
2073 lstrcat(temporary,temp2);
2074
2075 sprintf(str,"%s%s",pj_editor_Dir,lpszCompilerName);
2076 ShellExecute(hwnd,"open",str,temporary,NULL,SW_SHOWNORMAL);
2077
2078 return 0;
2079 case IDM_ATTACH:
2080 int idProcess;
2081 DWORD dwPlatform;
2082 idProcess=DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_ATTACH),hwnd,DlgAttach,(LPARAM)&dwPlatform);
2083 if(idProcess==0) return 0;
2084
2085 sprintf(temporary,"/attach:%08x /wnd:%08x",idProcess,hwnd);
2086
2087 //コンパイルビューをクリップするかどうか
2088 if(bClipCompileView){
2089 lstrcat(temporary," /clip_compile_view");
2090
2091 //コンパイラビューを閉じる
2092 if(hCompileView==(HWND)-1) return 0;
2093 if(hCompileView){
2094 hChild=hCompileView;
2095 hCompileView=(HWND)-1;
2096 SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
2097 }
2098
2099 //重複起動防止のため
2100 hCompileView=(HWND)-1;
2101 }
2102
2103 //インクルードディレクトリ
2104 sprintf(temp2," /include_dir:\"%s\"",pobj_nv->szIncludeDir);
2105 lstrcat(temporary,temp2);
2106
2107 if(dwPlatform==IMAGE_FILE_MACHINE_I386)
2108 sprintf(str,"%s%s",pj_editor_Dir,WIN32_COMPILER_NAME);
2109 else if(dwPlatform==IMAGE_FILE_MACHINE_AMD64)
2110 sprintf(str,"%s%s",pj_editor_Dir,WIN64_COMPILER_NAME);
2111
2112 ShellExecute(hwnd,"open",str,temporary,NULL,SW_SHOWNORMAL);
2113 return 0;
2114 case IDM_RELEASECOMPILE:
2115 hChild=GetWindow(hClient,GW_CHILD);
2116 if(ProjectInfo.name[0]){
2117 //プロジェクトが開かれている場合
2118 if(!SetProjectToRun()) return 0;
2119
2120 //ソースファイル名をtemp2へ
2121 ProjectInfo.pobj_DBFileInfo->ppobj_FileInfo[0]->GetFullPath(temp2);
2122
2123 //出力ファイル名をtemp3へ
2124 lstrcpy(temp3,ProjectInfo.lpszOutput_Release);
2125 GetFullPath(temp3,ProjectInfo.dir);
2126
2127 sprintf(temporary,"\"%s\" \"%s\" /wnd:%08x",temp2,temp3,hwnd);
2128
2129 //DLLオプション
2130 if(ProjectInfo.dwModuleType==MT_DLL) lstrcat(temporary," /dll");
2131 }
2132 else{
2133 //単独ソースコード
2134 if(!SetRunning(hChild)) return 0;
2135 sprintf(temporary,"\"%s\" /wnd:%08x",MdiInfo[GetWndNum(hChild)].path,hwnd);
2136 }
2137
2138 //コンパイルビューをクリップするかどうか
2139 if(bClipCompileView){
2140 lstrcat(temporary," /clip_compile_view");
2141
2142 //コンパイラビューを閉じる
2143 if(hCompileView==(HWND)-1) return 0;
2144 if(hCompileView){
2145 hChild=hCompileView;
2146 hCompileView=(HWND)-1;
2147 SendMessage(hChild,WM_COMMAND,IDCANCEL,0);
2148 }
2149
2150 //重複起動防止のため
2151 hCompileView=(HWND)-1;
2152 }
2153
2154 //インクルードディレクトリ
2155 sprintf(temp2," /include_dir:\"%s\"",pobj_nv->szIncludeDir);
2156 lstrcat(temporary,temp2);
2157
2158 sprintf(str,"%s%s",pj_editor_Dir,lpszCompilerName);
2159 ShellExecute(hwnd,"open",str,temporary,NULL,SW_SHOWNORMAL);
2160 return 0;
2161 case IDM_RELEASERUN:
2162 hChild=GetWindow(hClient,GW_CHILD);
2163 if(ProjectInfo.name[0]){
2164/* //プロジェクトが開かれている場合
2165 if(!SetProjectToRun()) return 0;
2166
2167 //必要であればリリースコンパイル
2168 if(IsNeedCompileForProject(0))
2169 SendMessage(hwnd,WM_COMMAND,IDM_RELEASECOMPILE,0);*/
2170
2171 if(ProjectInfo.dwModuleType==MT_DLL){
2172 lstrcpy(temporary,ProjectInfo.szExePath);
2173 }
2174 else{
2175 lstrcpy(temporary,ProjectInfo.lpszOutput_Debug);
2176 GetFullPath(temporary,ProjectInfo.dir);
2177 }
2178 }
2179 else{
2180/* //必要であればリリースコンパイル
2181 if(!SetRunning(hChild)) return 0;
2182
2183 if(IsNeedCompile(MdiInfo[GetWndNum(hChild)].path,0))
2184 SendMessage(hwnd,WM_COMMAND,IDM_RELEASECOMPILE,0);*/
2185
2186 //単独ソースコード
2187 _splitpath(MdiInfo[GetWndNum(hChild)].path,temporary,temp2,temp3,NULL);
2188 lstrcat(temporary,temp2);
2189 lstrcat(temporary,temp3);
2190 lstrcat(temporary,".exe");
2191 }
2192
2193 //インクルードディレクトリ
2194 sprintf(temp2," /include_dir:\"%s\"",pobj_nv->szIncludeDir);
2195 lstrcat(temporary,temp2);
2196
2197 ShellExecute(hwnd,"open",temporary,NULL,NULL,SW_SHOWNORMAL);
2198 return 0;
2199
2200
2201 ////////////////////////
2202 // デバッグ コマンド
2203 ////////////////////////
2204
2205 case IDM_STEP_IN:
2206 pobj_Debugger->StepIn();
2207 break;
2208 case IDM_STEP_OVER:
2209 pobj_Debugger->StepOver();
2210 break;
2211 case IDM_STEP_CURSOR:
2212 pobj_Debugger->StepToCursor();
2213 break;
2214 case IDM_BREAKPOINT:
2215 if(ProjectInfo.name[0]){
2216 ProjectInfo.pobj_DBBreakPoint->Event_BreakPoint();
2217 }
2218 else{
2219 pobj_DBBreakPoint->Event_BreakPoint();
2220 }
2221 break;
2222 case IDM_DEBUG_STOP:
2223 pobj_Debugger->DebugStop();
2224 break;
2225 case IDM_DEBUG_PAUSE:
2226 pobj_Debugger->DebugPause();
2227 break;
2228
2229
2230 case IDM_COMMUNITY:
2231 ShellExecute(hwnd,"open","iexplore.exe",
2232 "http://www.activebasic.com/forum/",
2233 NULL,SW_SHOWNORMAL);
2234 return 0;
2235 case IDM_COMMU_SEARCH:
2236 ShellExecute(hwnd,"open","iexplore.exe",
2237 "http://www.activebasic.com/forum/search.php",
2238 NULL,SW_SHOWNORMAL);
2239 return 0;
2240 case IDM_COMMU_PM:
2241 ShellExecute(hwnd,"open","iexplore.exe",
2242 "http://www.activebasic.com/forum/privmsg.php?folder=inbox",
2243 NULL,SW_SHOWNORMAL);
2244 return 0;
2245 case ID_COMMU_FORUM1:
2246 ShellExecute(hwnd,"open","iexplore.exe",
2247 "http://www.activebasic.com/forum/viewforum.php?f=1",
2248 NULL,SW_SHOWNORMAL);
2249 return 0;
2250 case ID_COMMU_FORUM2:
2251 ShellExecute(hwnd,"open","iexplore.exe",
2252 "http://www.activebasic.com/forum/viewforum.php?f=2",
2253 NULL,SW_SHOWNORMAL);
2254 return 0;
2255 case ID_COMMU_FORUM3:
2256 ShellExecute(hwnd,"open","iexplore.exe",
2257 "http://www.activebasic.com/forum/viewforum.php?f=5",
2258 NULL,SW_SHOWNORMAL);
2259 return 0;
2260 case ID_COMMU_FORUM4:
2261 ShellExecute(hwnd,"open","iexplore.exe",
2262 "http://www.activebasic.com/forum/viewforum.php?f=3",
2263 NULL,SW_SHOWNORMAL);
2264 return 0;
2265 case ID_COMMU_FORUM5:
2266 ShellExecute(hwnd,"open","iexplore.exe",
2267 "http://www.activebasic.com/forum/viewforum.php?f=6",
2268 NULL,SW_SHOWNORMAL);
2269 return 0;
2270 case ID_COMMU_FORUM6:
2271 ShellExecute(hwnd,"open","iexplore.exe",
2272 "http://www.activebasic.com/forum/viewforum.php?f=8",
2273 NULL,SW_SHOWNORMAL);
2274 return 0;
2275 case ID_COMMU_FORUM7:
2276 ShellExecute(hwnd,"open","iexplore.exe",
2277 "http://www.activebasic.com/forum/viewforum.php?f=4",
2278 NULL,SW_SHOWNORMAL);
2279 return 0;
2280 case ID_COMMU_FORUM8:
2281 ShellExecute(hwnd,"open","iexplore.exe",
2282 "http://www.activebasic.com/forum/viewforum.php?f=7",
2283 NULL,SW_SHOWNORMAL);
2284 return 0;
2285#endif //THETEXT
2286
2287
2288 case IDM_TOPIC:
2289#ifdef THETEXT
2290 sprintf(str,"%sTopics\\index.html",pj_editor_Dir);
2291 ShellExecute(hwnd,"open",str,NULL,NULL,SW_SHOWNORMAL);
2292#else
2293 sprintf(str,"%sBasicHelp.chm",pj_editor_Dir);
2294 HtmlHelp(NULL,str,HH_DISPLAY_TOPIC,0);
2295#endif
2296 return 0;
2297
2298#ifdef THETEXT
2299 case IDM_DSHOMEPAGE:
2300 ShellExecute(hwnd,"open","http://www.discoversoft.net/",NULL,NULL,SW_SHOWNORMAL);
2301 return 0;
2302#else
2303 case IDM_AB_WEBSITE:
2304 ShellExecute(hwnd,"open","http://www.activebasic.com/",NULL,NULL,SW_SHOWNORMAL);
2305 return 0;
2306 case IDM_ACTBDL:
2307 ShellExecute(hwnd,"open","http://www.activebasic.com/activebasic5/download.htm",NULL,NULL,SW_SHOWNORMAL);
2308 return 0;
2309#endif
2310
2311 case IDM_ABOUT:
2312 DialogBox(hResInst,MAKEINTRESOURCE(IDD_ABOUT),hwnd,DialogAbout);
2313 return 0;
2314
2315 case IDM_WEB_SEARCH:
2316 hChild=GetWindow(hClient,GW_CHILD);
2317 WndNum=GetWndNum(hChild);
2318 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
2319 extern HWND hWebSearchCombo;
2320 SendMessage(GetWindow(hWebSearchCombo,GW_CHILD),WM_CHAR,VK_RETURN,0);
2321 }
2322 return 0;
2323
2324
2325
2326 //////////////////////////////////////////////////////
2327 // レバーコントロールのサブメニューコマンド(レバー追加)
2328 //////////////////////////////////////////////////////
2329
2330 case IDM_DOCSELECTBAND:
2331 pobj_Rebar->ChangeRebarBand(ID_DOCCOMBO);
2332 return 0;
2333 case IDM_STANDARDBAND:
2334 pobj_Rebar->ChangeRebarBand(ID_STANDARDTOOLBAR);
2335 return 0;
2336#ifndef THETEXT
2337 case IDM_RELEASEBAND:
2338 pobj_Rebar->ChangeRebarBand(ID_RELEASETOOLBAR);
2339 return 0;
2340 case IDM_DEBUGBAND:
2341 pobj_Rebar->ChangeRebarBand(ID_DEBUGGERTOOLBAR);
2342 return 0;
2343 case IDM_SELECTCOMPILERBAND:
2344 pobj_Rebar->ChangeRebarBand(ID_SELECTCOMPILERCOMBO);
2345 return 0;
2346#endif
2347 case IDM_BANDMENU_WEB_SEARCH:
2348 pobj_Rebar->ChangeRebarBand(ID_WEB_SEARCH);
2349 return 0;
2350 case IDM_NOGRIPPER:
2351 if(pobj_nv->bNoGripper) pobj_nv->bNoGripper=0;
2352 else pobj_nv->bNoGripper=1;
2353
2354 //レバーコントロールを再生成
2355 pobj_Rebar->ResetRebar();
2356
2357 //メニュー状態を設定
2358 ResetState_DocMenu();
2359 return 0;
2360 case IDM_RESET_REBAR:
2361 //"ツールバーの配置をすべて初期状態に戻します。\nよろしいですか?"
2362 if(IDCANCEL==MessageBox(hwnd,STRING_TOOLBAR_RESET,APPLICATION_NAME,MB_OKCANCEL|MB_ICONEXCLAMATION)) break;
2363
2364 //レバーコントロールを再生成
2365 pobj_Rebar->ResetInitRebar();
2366
2367 //メニュー状態を設定
2368 ResetState_DocMenu();
2369 return 0;
2370
2371
2372
2373 ////////////////////////////////////////////////////
2374 // メイン タブ コントロールのサブメニューコマンド
2375 ////////////////////////////////////////////////////
2376
2377 case IDM_ALLCLOSE_OMIT_MYSELF:
2378 //このウィンドウ以外をすべて閉じる(&A)
2379 hChild=GetWindow(hClient,GW_CHILD);
2380 WndNum=GetWndNum(hChild);
2381 for(i=0;i<MAX_WNDNUM;i++){
2382 if(i==WndNum) continue;
2383 if(MdiInfo[i].hwnd) SendMessage(MdiInfo[i].hwnd,WM_CLOSE,0,0);
2384 }
2385 return 0;
2386
2387 case IDM_PATH_COPY:
2388 hChild=GetWindow(hClient,GW_CHILD);
2389 WndNum=GetWndNum(hChild);
2390
2391 //絶対パスをコピー
2392 hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,lstrlen(MdiInfo[WndNum].path)+1);
2393 pTemp=(char *)GlobalLock(hGlobal);
2394 lstrcpy(pTemp,MdiInfo[WndNum].path);
2395 GlobalUnlock(hGlobal);
2396
2397 //クリップボードに保存
2398 OpenClipboard(hwnd);
2399 EmptyClipboard();
2400 SetClipboardData(CF_TEXT,hGlobal);
2401 CloseClipboard();
2402 return 0;
2403
2404 case IDM_FOLDER_OPEN:
2405 hChild=GetWindow(hClient,GW_CHILD);
2406 WndNum=GetWndNum(hChild);
2407
2408 _splitpath(MdiInfo[WndNum].path,temporary,temp2,NULL,NULL);
2409 lstrcat(temporary,temp2);
2410
2411 ShellExecute(hwnd,"explore",temporary,NULL,NULL,SW_SHOWNORMAL);
2412 return 0;
2413
2414 case IDM_DELETE_FILE:
2415 hChild=GetWindow(hClient,GW_CHILD);
2416 WndNum=GetWndNum(hChild);
2417
2418 _splitpath(MdiInfo[WndNum].path,NULL,NULL,temporary,temp2);
2419 lstrcat(temporary,temp2);
2420
2421 lstrcat(temporary," をごみ箱に移動して閉じます。よろしいですか?");
2422 if(MessageBox(hwnd,temporary,APPLICATION_NAME,MB_OKCANCEL|MB_ICONQUESTION)==IDCANCEL) return 0;
2423
2424 //ゴミ箱へ
2425 SHFILEOPSTRUCT fo;
2426 fo.hwnd=hwnd;
2427 fo.wFunc=FO_DELETE;
2428 fo.pFrom =MdiInfo[WndNum].path;
2429 fo.pTo="\0";
2430 fo.fFlags =FOF_ALLOWUNDO|FOF_NOCONFIRMATION;
2431 SHFileOperation(&fo);
2432
2433 //閉じる
2434 MdiInfo[WndNum].pMdiTextEdit->UnModify();
2435 SendMessage(MdiInfo[WndNum].hwnd,WM_CLOSE,0,0);
2436
2437 return 0;
2438
2439 case IDM_USER_COLOR:
2440 {
2441 CHOOSECOLOR cc;
2442 COLORREF CusColors[16]={
2443 RGB(255,255,255),
2444 RGB(0,0,0),
2445 RGB(128,128,128),
2446 RGB(192,192,192),
2447 RGB(128,0,0),
2448 RGB(255,0,0),
2449 RGB(128,128,0),
2450 RGB(255,255,0),
2451 RGB(0,128,0),
2452 RGB(0,255,0),
2453 RGB(0,128,128),
2454 RGB(0,255,255),
2455 RGB(0,0,128),
2456 RGB(0,0,255),
2457 RGB(128,0,128),
2458 RGB(255,0,255)};
2459 cc.lStructSize=sizeof(CHOOSECOLOR);
2460 cc.hwndOwner=hwnd;
2461 cc.rgbResult=colorUser;
2462 cc.lpCustColors=CusColors;
2463 cc.Flags=CC_RGBINIT|CC_FULLOPEN;
2464 if(!ChooseColor(&cc)){
2465 return 0;
2466 }
2467 colorUser=cc.rgbResult;
2468 }
2469 case IDM_GRAY:
2470 case IDM_WHITE:
2471 case IDM_RED:
2472 case IDM_GREEN:
2473 case IDM_BLUE:
2474 case IDM_YELLOW:
2475 hChild=GetWindow(hClient,GW_CHILD);
2476 WndNum=GetWndNum(hChild);
2477
2478 TC_ITEM tcItem;
2479 tcItem.mask=TCIF_PARAM;
2480 if(LOWORD(wParam)==IDM_GRAY) tcItem.lParam=TABCOLOR_GRAY;
2481 if(LOWORD(wParam)==IDM_WHITE) tcItem.lParam=TABCOLOR_WHITE;
2482 if(LOWORD(wParam)==IDM_RED) tcItem.lParam=TABCOLOR_RED;
2483 if(LOWORD(wParam)==IDM_GREEN) tcItem.lParam=TABCOLOR_GREEN;
2484 if(LOWORD(wParam)==IDM_BLUE) tcItem.lParam=TABCOLOR_BLUE;
2485 if(LOWORD(wParam)==IDM_YELLOW) tcItem.lParam=TABCOLOR_YELLOW;
2486 if(LOWORD(wParam)==IDM_USER_COLOR) tcItem.lParam=colorUser;
2487 TabCtrl_SetItem(pobj_MainTab->hTab,
2488 TabCtrl_GetCurSel(pobj_MainTab->hTab),
2489 &tcItem);
2490 InvalidateRect(pobj_MainTab->hTab,NULL,0);
2491 return 0;
2492
2493
2494
2495 //////////////////////////////////
2496 // SideWeb
2497 //////////////////////////////////
2498
2499 case IDC_CLIP:
2500 pobj_SideWeb->bShow=0;
2501 ResizeOwnerWnd();
2502 return 0;
2503 }
2504 break;
2505 case WM_DROPFILES:
2506 hDrop=(HDROP)wParam;
2507
2508 i2=DragQueryFile(hDrop,-1,0,0);
2509 for(i=0;i<i2;i++){
2510 DragQueryFile(hDrop,i,str,MAX_PATH);
2511 OpenFileWithExtension(str);
2512 }
2513 DragFinish(hDrop);
2514 return 0;
2515 case WM_SHOWERROR:
2516 //エラー部分を反転表示
2517 DWORD AccBytes;
2518 HANDLE fh;
2519 sprintf(temporary,"%spgm.tmp",pj_editor_Dir);
2520 fh=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
2521 ReadFile(fh,temporary,MAX_PATH,&AccBytes,NULL);
2522 CloseHandle(fh);
2523 temporary[AccBytes]=0;
2524 hChild=GetWindow(hClient,GW_CHILD);
2525 while(hChild){
2526 WndNum=GetWndNum(hChild);
2527 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
2528 if(lstrcmpi(MdiInfo[WndNum].path,temporary)==0) break;
2529 }
2530 hChild=GetNextWindow(hChild,GW_HWNDNEXT);
2531 }
2532 if(!hChild){
2533 hChild=OpenFileWithExtension(temporary);
2534 WndNum=GetWndNum(hChild);
2535 }
2536
2537 if(WndNum==-1) return 0;
2538
2539 //ウィンドウを最前面に表示
2540 BringWindowToTop(hChild);
2541 UpdateWindow(hChild);
2542
2543 pTemp=MdiInfo[WndNum].pMdiTextEdit->buffer;
2544
2545 //行の先頭インデックスを取得(取得する行の番号はwParamで渡される)
2546 for(i=0,i2=0;;i++){
2547 if(i2>=(int)wParam) break;
2548 if(pTemp[i]=='\0') break;
2549 if(pTemp[i]=='\r'&&pTemp[i+1]=='\n'){
2550 i++;
2551 i2++;
2552 }
2553 }
2554 pos.x=i;
2555
2556 //行の終端インデックスを取得
2557 for(;;i++){
2558 if(pTemp[i]=='\0') break;
2559 if(pTemp[i]=='\r'&&pTemp[i+1]=='\n') break;
2560 }
2561 pos.y=i;
2562
2563 //行を選択する
2564 TextEdit_SetSel(WndNum,pos.x,pos.y,TRUE);
2565
2566 return 0;
2567
2568#ifndef THETEXT
2569 case WM_SETCOMPILEVIEW:
2570 //コンパイラウィンドウ(埋め込み型)が表示されたとき
2571 hCompileView=(HWND)lParam;
2572 ResizeOwnerWnd();
2573 return 0;
2574 case WM_DESTROYCOMPILEVIEW:
2575 //コンパイラウィンドウ(埋め込み型)が破棄されたとき
2576 if((int)hCompileView==-1){
2577 //すぐに次のコンパイラウィンドウが起動するとき
2578 hCompileView=0;
2579 }
2580 else{
2581 //完全にコンパイラウィンドウを閉じたときはリサイズ
2582 hCompileView=0;
2583
2584 ResizeOwnerWnd();
2585 }
2586 return 0;
2587
2588 case WM_SETDEBUGGERBASE:
2589 //デバッガベースウィンドウ(埋め込み型)が表示されたとき
2590 pobj_Debugger->begin();
2591
2592 //BasicCompiler.exeの強制終了を考慮
2593 SetTimer(hOwner,ID_DEBUGSAFTY,1000,NULL);
2594
2595 return 0;
2596 case WM_DESTROYDEBUGGERBASE:
2597 //BasicCompiler.exeの強制終了を考慮
2598 KillTimer(hOwner,ID_DEBUGSAFTY);
2599
2600 //デバッガベースウィンドウ(埋め込み型)が破棄されたとき
2601 pobj_Debugger->end();
2602
2603 return 0;
2604
2605 case WM_SETDEBUGGERVIEW:
2606 //デバッガウィンドウ(埋め込み型)が表示されたとき
2607 pobj_Debugger->watch_start((HWND)lParam);
2608 ResizeOwnerWnd();
2609 return 0;
2610 case WM_DESTROYDEBUGGERVIEW:
2611 //デバッガウィンドウ(埋め込み型)が破棄されたとき
2612 pobj_Debugger->watch_quit();
2613 ResizeOwnerWnd();
2614 return 0;
2615#endif
2616
2617 case WM_SIZE:
2618 ResizeOwnerWnd();
2619 return 0;
2620
2621
2622 case WM_MOUSEMOVE:
2623 static DWORD dwDragLever;
2624 static POINT PrevMousePos;
2625 static int start;
2626
2627 pos.x=(long)(short)LOWORD(lParam);
2628 pos.y=(long)(short)HIWORD(lParam);
2629 ClientToScreen(hwnd,&pos);
2630
2631 if(dwDragLever){
2632 GetClientRect(hwnd,&rect);
2633
2634 if(dwDragLever==1){
2635 //プロジェクトビューをリサイズ中
2636 pobj_nv->width_ClipProjectView=start+pos.x-PrevMousePos.x;
2637 if(pobj_nv->width_ClipProjectView<100) pobj_nv->width_ClipProjectView=100;
2638 if(rect.right-100<pobj_nv->width_ClipProjectView) pobj_nv->width_ClipProjectView=rect.right-100;
2639 }
2640 else if(dwDragLever==2){
2641 //デバッガビューをリサイズ中
2642 pobj_nv->height_ClipDebuggerView=start+PrevMousePos.y-pos.y;
2643 if(pobj_nv->height_ClipDebuggerView<60) pobj_nv->height_ClipDebuggerView=60;
2644 if(rect.bottom-100<pobj_nv->height_ClipCompileView+pobj_nv->height_ClipDebuggerView)
2645 pobj_nv->height_ClipDebuggerView=rect.bottom-100-pobj_nv->height_ClipCompileView;
2646 }
2647 else if(dwDragLever==3){
2648 //コンパイラビューをリサイズ中
2649 pobj_nv->height_ClipCompileView=start+PrevMousePos.y-pos.y;
2650 if(pobj_nv->height_ClipCompileView<60) pobj_nv->height_ClipCompileView=60;
2651 if(rect.bottom-100<pobj_nv->height_ClipCompileView)
2652 pobj_nv->height_ClipCompileView=rect.bottom-100;
2653 }
2654 else if(dwDragLever==4){
2655 //SideWebをリサイズ中
2656 pobj_nv->width_WebSearchView=start+PrevMousePos.x-pos.x;
2657 if(pobj_nv->width_WebSearchView<100) pobj_nv->width_WebSearchView=100;
2658 if(rect.right-100<pobj_nv->width_WebSearchView) pobj_nv->width_WebSearchView=rect.right-100;
2659 }
2660
2661 ResizeOwnerWnd();
2662 UpdateWindow(hwnd);
2663 }
2664 if(pobj_nv->bClipProjectView&&IsWindowVisible(hProjectView)){
2665 //プロジェクトビューとMDIクライアントの境目のサイズ変更ライン
2666 GetWindowRect(hProjectView,&rect);
2667 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
2668 rect.right<=pos.x&&pos.x<=rect.right+LEVER_THICK){
2669 SetCursor(LoadCursor(0,IDC_SIZEWE));
2670 }
2671 }
2672#ifndef THETEXT
2673 if(bClipCompileView&&pobj_Debugger->IsDebuggerView()){
2674 //デバッガビューとMDIクライアントの境目のサイズ変更ライン
2675 GetWindowRect(pobj_Debugger->hwnd,&rect);
2676 if(rect.left<=pos.x&&pos.x<=rect.right&&
2677 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
2678 SetCursor(LoadCursor(0,IDC_SIZENS));
2679 }
2680 }
2681 if(bClipCompileView&&IsWindowVisible(hCompileView)){
2682 //コンパイラビューとMDIクライアントの境目のサイズ変更ライン
2683 GetWindowRect(hCompileView,&rect);
2684 if(rect.left<=pos.x&&pos.x<=rect.right&&
2685 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
2686 SetCursor(LoadCursor(0,IDC_SIZENS));
2687 }
2688 }
2689#endif
2690 if(pobj_SideWeb->bShow){
2691 //SideWebとMDIクライアントの境目のサイズ変更ライン
2692 pobj_SideWeb->GetRect(&rect);
2693 ClientToScreen(hwnd,&rect);
2694 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
2695 rect.left-LEVER_THICK<=pos.x&&pos.x<=rect.left){
2696 SetCursor(LoadCursor(0,IDC_SIZEWE));
2697 }
2698 }
2699 return 0;
2700 case WM_LBUTTONDOWN:
2701 pos.x=LOWORD(lParam);
2702 pos.y=HIWORD(lParam);
2703 ClientToScreen(hwnd,&pos);
2704
2705 if(pobj_nv->bClipProjectView&&IsWindowVisible(hProjectView)){
2706 //プロジェクトビューとMDIクライアントの境目のサイズ変更ライン
2707 GetWindowRect(hProjectView,&rect);
2708 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
2709 rect.right<=pos.x&&pos.x<=rect.right+LEVER_THICK){
2710 SetCursor(LoadCursor(0,IDC_SIZEWE));
2711
2712 dwDragLever=1;
2713 SetCapture(hwnd);
2714
2715 PrevMousePos=pos;
2716 start=pobj_nv->width_ClipProjectView;
2717 }
2718 }
2719#ifndef THETEXT
2720 if(bClipCompileView&&pobj_Debugger->IsDebuggerView()){
2721 //デバッガビューとMDIクライアントの境目のサイズ変更ライン
2722 GetWindowRect(pobj_Debugger->hwnd,&rect);
2723 if(rect.left<=pos.x&&pos.x<=rect.right&&
2724 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
2725 SetCursor(LoadCursor(0,IDC_SIZENS));
2726
2727 dwDragLever=2;
2728 SetCapture(hwnd);
2729
2730 PrevMousePos=pos;
2731 start=pobj_nv->height_ClipDebuggerView;
2732 }
2733 }
2734 if(bClipCompileView&&IsWindowVisible(hCompileView)){
2735 //コンパイラビューとMDIクライアントの境目のサイズ変更ライン
2736 GetWindowRect(hCompileView,&rect);
2737 if(rect.left<=pos.x&&pos.x<=rect.right&&
2738 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
2739 SetCursor(LoadCursor(0,IDC_SIZENS));
2740
2741 dwDragLever=3;
2742 SetCapture(hwnd);
2743
2744 PrevMousePos=pos;
2745 start=pobj_nv->height_ClipCompileView;
2746 }
2747 }
2748#endif
2749 if(pobj_SideWeb->bShow){
2750 //SideWebとMDIクライアントの境目のサイズ変更ライン
2751 pobj_SideWeb->GetRect(&rect);
2752 ClientToScreen(hwnd,&rect);
2753 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
2754 rect.left-LEVER_THICK<=pos.x&&pos.x<=rect.left){
2755 SetCursor(LoadCursor(0,IDC_SIZENS));
2756
2757 dwDragLever=4;
2758 SetCapture(hwnd);
2759
2760 PrevMousePos=pos;
2761 start=pobj_nv->width_WebSearchView;
2762 }
2763 }
2764 return 0;
2765 case WM_LBUTTONUP:
2766 if(dwDragLever){
2767 dwDragLever=0;
2768 ReleaseCapture();
2769 }
2770 return 0;
2771
2772
2773 case WM_SYSCOMMAND:
2774 //ウィンドウの最小化前にウィンドウ位置を保存
2775 if(wParam==SC_MINIMIZE){
2776 if(IsZoomed(hwnd)) pobj_nv->bWindowMax=1;
2777 else if(!IsIconic(hwnd)){
2778 pobj_nv->bWindowMax=0;
2779 GetWindowRect(hwnd,&pobj_nv->StartupWindowRect);
2780 }
2781 }
2782 break; //処理をDefFrameProcへ
2783 case WM_QUERYENDSESSION:
2784 case WM_CLOSE:
2785 extern BOOL bSearchingClasses;
2786 if(bSearchingClasses){
2787 pobj_ClassTreeView->bCloseSwitch=1;
2788 return 0;
2789 }
2790
2791 //コンパイラビューを閉じる
2792 if(hCompileView)
2793 SendMessage(hCompileView,WM_COMMAND,IDCANCEL,0);
2794
2795 //次回起動時にMDIウィンドウを最大化させるかを判定
2796 hChild=GetWindow(hClient,GW_CHILD);
2797 pobj_nv->bMDIZoomed=IsZoomed(hChild);
2798
2799 //プロジェクトを閉じる
2800 if(ProjectInfo.name[0]){
2801 if(!CloseProject()) return 0;
2802 }
2803
2804 //MDIウィンドウの保存確認
2805 hChild=GetWindow(hClient,GW_CHILD);
2806 while(hChild){
2807 i=GetWndNum(hChild);
2808 if(!DocumentModifyCheck(hChild)) return 0;
2809 hChild=GetNextWindow(hChild,GW_HWNDNEXT);
2810 }
2811
2812
2813 KillTimer(hwnd,ID_TIMER_BACKUP);
2814
2815
2816 //ProjectViewの位置を保存、ProjectViewを破棄
2817 GetWindowRect(hProjectView_ToolWindow,&pobj_nv->rectProjectView);
2818 DestroyWindow(hProjectView);
2819 DestroyWindow(hProjectView_ToolWindow);
2820
2821 //Rebarの位置を保存、Rebarを破棄
2822 delete pobj_Rebar;
2823 pobj_Rebar=0;
2824
2825 //タブコントロールを破棄
2826 delete pobj_MainTab;
2827 pobj_MainTab=0;
2828
2829 //SideWebを破棄
2830 delete pobj_SideWeb;
2831 pobj_SideWeb=0;
2832
2833 //メインウィンドウの最大化有無、座標を保存
2834 if(IsZoomed(hwnd)) pobj_nv->bWindowMax=1;
2835 else if(!IsIconic(hwnd)){
2836 pobj_nv->bWindowMax=0;
2837 GetWindowRect(hwnd,&pobj_nv->StartupWindowRect);
2838 }
2839
2840 hChild=GetWindow(hClient,GW_CHILD);
2841 while(hChild){
2842 CloseDocWindow(GetWndNum(hChild));
2843 DestroyWindow(hChild);
2844 hChild=GetWindow(hClient,GW_CHILD);
2845 }
2846
2847 EndProjectEditor(); //ProjectEditorの情報を保存
2848
2849 //エディタ用フォントを破棄
2850 extern HFONT hFont_TextEdit,hFont_HyperLink_TextEdit;
2851 if(hFont_TextEdit) DeleteObject(hFont_TextEdit);
2852 if(hFont_HyperLink_TextEdit) DeleteObject(hFont_HyperLink_TextEdit);
2853
2854 DestroyWindow(hwnd);
2855 return 0;
2856
2857 case WM_DESTROY:
2858 PostQuitMessage(0);
2859 return 0;
2860 }
2861 return DefFrameProc(hwnd,hClient,message,wParam,lParam);
2862}
2863
2864int RegWndClass(WNDPROC WndProc,char *lpClassName,HBRUSH hBackBrush,DWORD dwFlag){
2865 WNDCLASSEX wcl;
2866
2867 wcl.cbSize=sizeof(WNDCLASSEX);
2868 wcl.hInstance=hInst;
2869 wcl.lpszClassName=lpClassName;
2870 wcl.lpfnWndProc=WndProc;
2871
2872 if(dwFlag&FLAG_DBLCLK) wcl.style=CS_DBLCLKS;
2873 else wcl.style=0;
2874
2875 wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
2876 wcl.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
2877
2878 if(dwFlag&FLAG_BEAMCURSOR) wcl.hCursor=LoadCursor(NULL,IDC_IBEAM);
2879 else wcl.hCursor=LoadCursor(NULL,IDC_ARROW);
2880
2881 wcl.lpszMenuName=NULL;
2882 wcl.cbClsExtra=0;
2883 wcl.cbWndExtra=0;
2884 wcl.hbrBackground=hBackBrush;
2885
2886 return RegisterClassEx(&wcl);
2887}
2888int PASCAL WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int ShowCmd){
2889 int i,i2,IsStr;
2890 char str[MAX_PATH],str2[MAX_PATH],dummy[1024];
2891 MSG msg;
2892 HACCEL hAccel;
2893
2894 hInst=hThisInst;
2895 if(!SetupProjectEditor()) return 0;
2896
2897 HBRUSH hGrayBrush_LineNumber;
2898 hGrayBrush_LineNumber=CreateSolidBrush(RGB(220,220,220));
2899
2900 if(!RegWndClass(WindowFunc,"ProjectEditor",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2901 if(!RegWndClass(MDIClientWindow_TextEdit,"MDIClientWindow_TextEdit",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
2902 if(!RegWndClass(MethodCheckWindow,"MethodCheckWindow",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
2903 if(!RegWndClass(MDIClientWindow_Rad,"MDIClientWindow_Rad",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
2904 if(!RegWndClass(RadToolsWindow,"RadToolsWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2905 if(!RegWndClass(RadPropertyWindow,"RadPropertyWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2906 if(!RegWndClass(RadWindow,"RadWindow",(HBRUSH)GetStockObject(NULL_BRUSH),FLAG_DBLCLK)) return 0;
2907 if(!RegWndClass(TestWindowProc,"TestWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2908 if(!RegWndClass(MDIClientWindow_Menu,"MDIClientWindow_Menu",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
2909 if(!RegWndClass(MenuEditWindow,"MenuEditWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2910 if(!RegWndClass(MDIClientWindow_IconEdit,"MDIClientWindow_IconEdit",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2911 if(!RegWndClass(IconEditWindowProc,"IconEditWindowProc",(HBRUSH)GetStockObject(WHITE_BRUSH),0)) return 0;
2912 if(!RegWndClass(ProjectViewProc,"ProjectView",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2913 if(!RegWndClass(ProjectView_ToolWindowProc,"ProjectView_ToolWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
2914 if(!RegWndClass(TextEditProc,"TextEditor",(HBRUSH)GetStockObject(NULL_BRUSH),FLAG_DBLCLK|FLAG_BEAMCURSOR)) return 0;
2915 if(!RegWndClass(ComplementWindow,"ComplementWindow",(HBRUSH)GetStockObject(BLACK_BRUSH),FLAG_DBLCLK)) return 0;
2916 if(!RegWndClass(PreviewWndProc,"PreviewWindow",(HBRUSH)GetStockObject(GRAY_BRUSH),FLAG_DBLCLK)) return 0;
2917
2918 //Web検索用のウィンドウクラス
2919 if(!RegWndClass(WebResultWndProc,"WebResult",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2920 if(!RegWndClass(OneTabProc,"OneTab",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2921 if(!RegWndClass(ResultListProc,"ResultList",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2922
2923 //ルーラーのウィンドウクラス
2924 if(!RegWndClass(RulerProc,"Ruler",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2925
2926 //SideWebのウィンドウクラス
2927 if(!RegWndClass(SideWebProc,"SideWeb",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
2928
2929
2930
2931 hAccel=LoadAccelerators(hResInst,MAKEINTRESOURCE(IDR_ACCELERATOR1));
2932
2933 //メインウィンドウ
2934 RECT *prc;
2935 prc=&pobj_nv->StartupWindowRect;
2936 hOwner=CreateWindowEx(WS_EX_ACCEPTFILES,"ProjectEditor",APPLICATION_NAME,
2937 WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
2938 prc->left, prc->top,
2939 prc->right-prc->left, prc->bottom-prc->top,
2940 HWND_DESKTOP,pobj_MainMenu->hMenu,hInst,NULL);
2941
2942 SendMessage(hOwner,WM_SETICON,ICON_SMALL,(long)hOwnerIcon);
2943 SetClipboardViewer(hOwner);
2944
2945 if(pobj_nv->bWindowMax) ShowWindow(hOwner,SW_MAXIMIZE);
2946 else ShowWindow(hOwner,ShowCmd);
2947 UpdateWindow(hOwner);
2948
2949 int open_sw=0;
2950 if(lstrlen(lpCmdLine)>0){
2951 lstrcpy(dummy,lpCmdLine);
2952 for(i=0,i2=0,IsStr=0;;i++,i2++){
2953 if(dummy[i]=='\"'){
2954 if(IsStr==0) IsStr=1;
2955 else IsStr=0;
2956 i++;
2957 }
2958 if((dummy[i]==' '&&IsStr==0)||dummy[i]=='\0'){
2959 str[i2]=0;
2960 if(!(strstr(str,":")||strstr(str,"\\\\"))){
2961 lstrcpy(str2,str);
2962 GetCurrentDirectory(MAX_PATH,str);
2963 lstrcat(str,"\\");
2964 lstrcat(str,str2);
2965 }
2966 ShortPathToLongPath(str,str2);
2967 OpenFileWithExtension(str2);
2968 open_sw=1;
2969 if(dummy[i]=='\0') break;
2970 i2=-1;
2971 continue;
2972 }
2973 str[i2]=dummy[i];
2974 }
2975 }
2976
2977 BOOL bRestore=0;
2978
2979
2980 {
2981 //自動バックアップ及び復元機能
2982
2983 //必要であれば復元
2984 bRestore=restore();
2985 }
2986
2987
2988#ifdef THETEXT
2989 if(open_sw==0&&bRestore==0){
2990 //ファイルが開かれなかったとき
2991 NewTextEditWindow(NULL,WNDTYPE_TEXT);
2992 }
2993#endif
2994
2995
2996 while(GetMessage(&msg,NULL,0,0)){
2997
2998 if(!TranslateAccelerator(hOwner,hAccel,&msg)){
2999 if(ProjectInfo.name[0]){
3000 for(i=0,i2=0;i<MAX_WNDNUM;i++){
3001 if(MdiInfo[i].hwnd&&MdiInfo[i].DocType==WNDTYPE_RAD){
3002 if(IsDialogMessage(MdiInfo[i].MdiRadInfo->hProp_Dlg,&msg)) i2=1;
3003 }
3004 }
3005 if(i2==0){
3006 if(!TranslateMDISysAccel(hClient,&msg)){
3007 TranslateMessage(&msg);
3008 DispatchMessage(&msg);
3009 }
3010 }
3011 }
3012 else{
3013 if(!TranslateMDISysAccel(hClient,&msg)){
3014 TranslateMessage(&msg);
3015 DispatchMessage(&msg);
3016 }
3017 }
3018 }
3019 }
3020
3021 DeleteObject(hGrayBrush_LineNumber);
3022
3023#if defined HeapAlloc
3024 CheckHeapCheck();
3025#endif
3026
3027 return msg.wParam;
3028}
Note: See TracBrowser for help on using the repository browser.