source: dev/trunk/abdev/ProjectEditor/ProjectEditor.cpp@ 348

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