source: dev/ProjectEditor/ProjectEditor.cpp@ 5

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