source: dev/trunk/ab5.0/abdev/abdev/abdev.cpp@ 619

Last change on this file since 619 was 619, checked in by dai_9181, 17 years ago

Projectクラスをリファクタリング中。

File size: 51.7 KB
Line 
1#include "stdafx.h"
2
3#include "abdev.h"
4
5
6#if defined HeapAlloc
7#define MEM_MAX 65536
8LPVOID pCheckMem[MEM_MAX];
9int now;
10#undef HeapAlloc
11#undef HeapReAlloc
12LPVOID CheckHeapAlloc(HANDLE hf,DWORD dwFlags,DWORD dwBytes){
13 LPVOID ret;
14 ret=HeapAlloc(hf,dwFlags,dwBytes);
15 pCheckMem[now]=ret;
16
17 //この部分にnowのチェックを挿入
18
19
20 now++;
21 if(now>=MEM_MAX){
22 MessageBox(0,"pCheckMemの最大値を超えました","Check",0);
23 }
24 return ret;
25}
26LPVOID CheckHeapReAlloc(HANDLE hf,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes){
27 int i;
28 LPVOID ret;
29 for(i=0;;i++){
30 if(lpMem==pCheckMem[i]) break;
31 if(i>=MEM_MAX){
32 MessageBox(0,"エラー","CheckHeapReAlloc",0);
33 break;
34 }
35 }
36 ret=HeapReAlloc(hf,dwFlags,lpMem,dwBytes);
37 pCheckMem[i]=ret;
38 return ret;
39}
40void HeapDefaultFree(LPVOID lpMem){
41 int i;
42 for(i=0;;i++){
43 if(lpMem==pCheckMem[i]) break;
44 if(i>=MEM_MAX){
45 MessageBox(0,"エラー","HeapDefaultFree",0);
46 break;
47 }
48 }
49 pCheckMem[i]=0;
50 HeapFree(hHeap,0,lpMem);
51}
52void CheckHeapCheck(){
53 int i,i2;
54 char temp[100];
55 temp[0]=0;
56 for(i=0,i2=0;i<MEM_MAX;i++){
57 if(pCheckMem[i]){
58 sprintf(temp+lstrlen(temp),"%d\r\n",i);
59 i2++;
60 if(i2==10){
61 lstrcat(temp,"これ以上の未解放が確認されています");
62 break;
63 }
64 }
65 }
66 if(temp[0]) MessageBox(0,temp,"Check - BasicCompiler.exe",0);
67}
68#define HeapAlloc CheckHeapAlloc
69#define HeapReAlloc CheckHeapReAlloc
70#else
71void HeapDefaultFree(LPVOID lpMem){
72 HeapFree(hHeap,0,lpMem);
73}
74#endif
75
76#ifdef DeleteObject
77#undef DeleteObject
78BOOL CheckDeleteObject(HGDIOBJ hObject){
79 BOOL bRet;
80 bRet=DeleteObject(hObject);
81
82 if(bRet==0){
83 MessageBox(0,"DeleteObject Error","Check",0);
84 }
85 return bRet;
86}
87#define DeleteObject CheckDeleteObject
88#endif
89
90
91void ToBigChar(char str[]){
92 int i;
93 for(i=0;TRUE;i++){
94 str[i]=(char)toupper((int)str[i]);
95 if(str[i]=='\0') break;
96 }
97}
98int GetWndNum(HWND hChild){
99 int i;
100 if(!IsWindow(hChild)) return -1;
101 for(i=0;i<MAX_WNDNUM;i++){
102 if(hChild==MdiInfo[i].hwnd) break;
103 }
104 if(i==MAX_WNDNUM) i=-1;
105 return i;
106}
107int GetNowWndNum(void){
108 return GetWndNum(GetWindow(hClient,GW_CHILD));
109}
110int GetFileNum(int WndNum){
111 if( !projectInfo.IsOpened() ){
112 return -1;
113 }
114
115 int i;
116 char temporary[MAX_PATH];
117 for(i=0;i<projectInfo.pobj_DBFileInfo->iNum;i++){
118
119 projectInfo.pobj_DBFileInfo->ppobj_FileInfo[i]->GetFullPath(temporary);
120
121 if(lstrcmpi(MdiInfo[WndNum].path,temporary)==0) return i;
122 }
123 return -1;
124}
125
126void SendTextEditResizeEvent(HWND hwnd){
127 RECT rect;
128 GetClientRect(hwnd,&rect);
129 ResizeTextEditWnd(hwnd,rect.right,rect.bottom);
130}
131
132void RedrawAllWindow(void){
133 HWND hChild;
134 hChild=GetWindow(hClient,GW_CHILD);
135 if(hChild) ResetTextEditFont(GetWindow(hChild,GW_CHILD));
136 while(hChild){
137 int WndNum;
138 WndNum=GetWndNum(hChild);
139 if(WndNum==-1) break;
140
141 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
142 //コントロールタブスペースの幅と行番号の文字数を更新
143 MdiInfo[WndNum].pMdiTextEdit->iWidth_ControlTabSpace=
144 GetControlTabSpace(WndNum,&MdiInfo[WndNum].pMdiTextEdit->iLineNumberTextCount);
145
146 InvalidateRect(MdiInfo[WndNum].pMdiTextEdit->hEdit,NULL,0);
147 InvalidateRect(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,NULL,0);
148
149 SendTextEditResizeEvent(MdiInfo[WndNum].hwnd);
150 }
151 else{
152 HWND hEdit;
153 hEdit=GetWindow(hChild,GW_CHILD);
154 InvalidateRect(hEdit,NULL,0);
155 }
156
157 hChild=GetWindow(hChild,GW_HWNDNEXT);
158 }
159}
160
161int DocumentModifyCheck(HWND hChild){ //終了保存確認
162 int BoxID,WndNum,sw;
163 char str[MAX_PATH],temporary[MAX_PATH];
164
165 WndNum=GetWndNum(hChild);
166 sw=0;
167 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
168 if( MdiInfo[WndNum].pMdiTextEdit->IsModified() ) sw=1;
169 }
170 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
171 if(MdiInfo[WndNum].MdiIconEditInfo->bModify) sw=1;
172 }
173
174 if(sw){
175 GetWindowText(hChild,temporary,MAX_PATH);
176
177 //"\"%s\" ファイルは変更されています。保存しますか?"
178 sprintf(str,STRING_MODIFYCHECK_FILE,temporary);
179 BoxID=MessageBox(hOwner,str,APPLICATION_NAME,MB_YESNOCANCEL|MB_ICONINFORMATION);
180
181 if(BoxID==IDYES){
182 if(!SaveDocument(hChild,NULL)) return 0;
183 }
184 else if(BoxID==IDCANCEL) return 0;
185 }
186 return 1;
187}
188void SetStatusText(char *MenuText){
189 //////////////////////////
190 // ステータスバーの更新
191 //////////////////////////
192
193 int WndNum;
194 double BufSize;
195 char temporary[255];
196 HWND hChild;
197
198 if(MenuText){
199 SendMessage(hStatusBar,SB_SETTEXT,0,(long)MenuText);
200 if((char *)MenuText!=(char *)CmdMsg) CmdMsg[0]=0;
201 }
202
203 hChild=GetWindow(hClient,GW_CHILD);
204 WndNum=GetWndNum(hChild);
205 if(WndNum==-1) return;
206 hChild=GetWindow(hChild,GW_CHILD);
207 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
208 //////////////////////
209 // テキストエディタ
210 //////////////////////
211
212 //サイズ
213 BufSize=(double)lstrlen(MdiInfo[WndNum].pMdiTextEdit->buffer);
214 if(IsWindow(hChild)){
215 if(BufSize<1024) sprintf(temporary,"%s: %.0fByte",STRING_SIZE,BufSize);
216 else if(BufSize<1024*1024){
217 BufSize/=1024;
218 sprintf(temporary,"%s: %.2fKB",STRING_SIZE,BufSize);
219 }
220 else{
221 BufSize/=1024*1024;
222 sprintf(temporary,"%s: %.2fMB",STRING_SIZE,BufSize);
223 }
224 }
225 else temporary[0]=0;
226 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)temporary);
227
228 //行と桁
229 if(IsWindow(hChild)){
230#if defined(JPN)
231 //日本語
232 sprintf(temporary,"%d 行、%d 列",
233 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y+1,
234 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x+1);
235#else
236 //英語
237 sprintf(temporary,"%d : %d",
238 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y+1,
239 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x+1);
240#endif
241 }
242 else temporary[0]=0;
243 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)temporary);
244
245 //文字コード
246 nkf.GetCharCodeName(MdiInfo[WndNum].pMdiTextEdit->iCharCode,temporary);
247 SendMessage(hStatusBar,SB_SETTEXT,3,(LPARAM)temporary);
248
249 //文字コード
250 nkf.GetLfCodeName(MdiInfo[WndNum].pMdiTextEdit->iLfCode,temporary);
251 SendMessage(hStatusBar,SB_SETTEXT,4,(LPARAM)temporary);
252 }
253 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
254 ////////////////
255 // RADツール
256 ////////////////
257
258 WindowInfo *pWindowInfo = GetWndInfo(MdiInfo[WndNum].path);
259 if(RadInfo.NowDragging>=FRAME_CHANGEPOS_START&&RadInfo.NowDragging<=FRAME_CHANGEPOS_END){
260 sprintf(temporary,"pos %d, %d",
261 RadInfo.DraggingRect[0].left-MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
262 RadInfo.DraggingRect[0].top-MdiInfo[WndNum].MdiRadInfo->ClientPos.y);
263 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)temporary);
264 sprintf(temporary,"size %d * %d",
265 RadInfo.DraggingRect[0].right-RadInfo.DraggingRect[0].left,
266 RadInfo.DraggingRect[0].bottom-RadInfo.DraggingRect[0].top);
267 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)temporary);
268 }
269 else if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW){
270 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)"pos 0, 0");
271 sprintf(temporary,"size %d * %d",pWindowInfo->size.cx,pWindowInfo->size.cy);
272 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)temporary);
273 }
274 else{
275 sprintf(temporary,"pos %d, %d",
276 pWindowInfo->childWindowInfos[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]]->pos.x,
277 pWindowInfo->childWindowInfos[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]]->pos.y);
278 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)temporary);
279 sprintf(temporary,"size %d * %d",
280 pWindowInfo->childWindowInfos[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]]->size.cx,
281 pWindowInfo->childWindowInfos[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]]->size.cy);
282 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)temporary);
283 }
284 }
285 else if(MdiInfo[WndNum].DocType==WNDTYPE_MENU){
286 //////////////////
287 // MENU エディタ
288 //////////////////
289
290 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)"");
291 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)"");
292 }
293 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
294 //////////////////
295 // ICON エディタ
296 //////////////////
297
298 SendMessage(hStatusBar,SB_SETTEXT,1,(LPARAM)"");
299 SendMessage(hStatusBar,SB_SETTEXT,2,(LPARAM)"");
300 }
301}
302void ResetState_UndoMenu(void){ //「元に戻す、やり直し」のメニュー表示制御
303 int i,i2;
304 HWND hChild;
305
306 hChild=GetWindow(hClient,GW_CHILD);
307 i=GetWndNum(hChild);
308 if(i==-1){
309 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
310 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
311 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
312 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
313 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
314 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
315 }
316 else if(IS_DOCUMENT_TEXT(MdiInfo[i].DocType)){
317 i2=MdiInfo[i].pMdiTextEdit->pTextEditUndoState->NowPos-1;
318 if(i2==-1) i2=MAX_UNDONUM-1;
319 if(!MdiInfo[i].pMdiTextEdit->pTextEditUndoState->Command[i2]){
320 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
321 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
322 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
323 }
324 else{
325 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
326 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
327 pobj_StandardToolbar->EnableItem(IDM_UNDO,1);
328 }
329 if(!MdiInfo[i].pMdiTextEdit->pTextEditUndoState->Command[MdiInfo[i].pMdiTextEdit->pTextEditUndoState->NowPos]){
330 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
331 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
332 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
333 }
334 else{
335 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
336 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
337 pobj_StandardToolbar->EnableItem(IDM_REDO,1);
338 }
339 }
340 else if(MdiInfo[i].DocType==WNDTYPE_RAD){
341 i2=MdiInfo[i].MdiRadInfo->undo.NowPos-1;
342 if(i2==-1) i2=MAX_UNDONUM-1;
343 if(!MdiInfo[i].MdiRadInfo->undo.Command[i2]){
344 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
345 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
346 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
347 }
348 else{
349 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
350 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
351 pobj_StandardToolbar->EnableItem(IDM_UNDO,1);
352 }
353 if(!MdiInfo[i].MdiRadInfo->undo.Command[MdiInfo[i].MdiRadInfo->undo.NowPos]){
354 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
355 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
356 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
357 }
358 else{
359 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
360 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
361 pobj_StandardToolbar->EnableItem(IDM_REDO,1);
362 }
363 }
364 else if(MdiInfo[i].DocType==WNDTYPE_MENU){
365 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
366 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
367 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
368
369 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
370 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
371 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
372 }
373 else if(MdiInfo[i].DocType==WNDTYPE_ICONEDIT){
374 i2=MdiInfo[i].MdiIconEditInfo->undo[MdiInfo[i].MdiIconEditInfo->SelectIconNum].NowPos-1;
375 if(i2==-1) i2=MAX_ICONEDIT_UNDONUM-1;
376 if(!MdiInfo[i].MdiIconEditInfo->undo[MdiInfo[i].MdiIconEditInfo->SelectIconNum].lpData[i2]){
377 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
378 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
379 pobj_StandardToolbar->EnableItem(IDM_UNDO,0);
380 }
381 else{
382 pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
383 EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_ENABLED);
384 pobj_StandardToolbar->EnableItem(IDM_UNDO,1);
385 }
386 if(!MdiInfo[i].MdiIconEditInfo->undo[MdiInfo[i].MdiIconEditInfo->SelectIconNum].lpData[MdiInfo[i].MdiIconEditInfo->undo[MdiInfo[i].MdiIconEditInfo->SelectIconNum].NowPos]){
387 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
388 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
389 pobj_StandardToolbar->EnableItem(IDM_REDO,0);
390 }
391 else{
392 pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
393 EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_ENABLED);
394 pobj_StandardToolbar->EnableItem(IDM_REDO,1);
395 }
396 }
397}
398void ResetState_ConvMenu(BOOL bEnable){
399 int MenuMsg;
400 if(bEnable)
401 MenuMsg=MF_BYCOMMAND|MF_ENABLED;
402 else MenuMsg=MF_BYCOMMAND|MF_GRAYED;
403
404 pobj_MainMenu->EnableItem(IDM_CONV_ALPHA_SMALL,MenuMsg);
405 pobj_MainMenu->EnableItem(IDM_CONV_ALPHA_BIG,MenuMsg);
406 pobj_MainMenu->EnableItem(IDM_CONV_HALF,MenuMsg);
407 pobj_MainMenu->EnableItem(IDM_CONV_MULTI,MenuMsg);
408 pobj_MainMenu->EnableItem(IDM_CONV_KATAKANA,MenuMsg);
409 pobj_MainMenu->EnableItem(IDM_CONV_HIRAGANA,MenuMsg);
410 pobj_MainMenu->EnableItem(IDM_CONV_SPACE,MenuMsg);
411 pobj_MainMenu->EnableItem(IDM_CONV_TAB,MenuMsg);
412#ifdef THETEXT
413 pobj_MainMenu->EnableItem(IDM_CONV_HASRETURN,MenuMsg);
414 pobj_MainMenu->EnableItem(IDM_CONV_QUOTE,MenuMsg);
415#else
416 pobj_MainMenu->EnableItem(IDM_CODEFORMAT,MenuMsg);
417#endif
418}
419void ResetState_PrintMenu(void);
420void ResetState_EditMenu(void){ //編集メニューの表示制御
421 HWND hChild;
422 int WndNum;
423 long MenuMsg,ToolbarMsg;
424
425 //印刷メニューの状態を設定
426 ResetState_PrintMenu();
427
428 hChild=GetWindow(hClient,GW_CHILD);
429 if(!IsWindow(hChild)){
430 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_GRAYED);
431 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_GRAYED);
432#ifdef THETEXT
433 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_GRAYED);
434#endif
435 pobj_StandardToolbar->EnableItem(IDM_FIND,0);
436
437 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
438 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
439 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
440 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
441 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
442 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
443 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
444 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_GRAYED);
445 pobj_StandardToolbar->EnableItem(IDM_CUT,0);
446 pobj_StandardToolbar->EnableItem(IDM_COPY,0);
447 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
448
449 ResetState_ConvMenu(0);
450
451 ResetState_UndoMenu();
452 return;
453 }
454 WndNum=GetWndNum(hChild);
455 if(WndNum==-1) return;
456 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
457 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_ENABLED);
458 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_ENABLED);
459 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_ENABLED);
460#ifdef THETEXT
461 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_ENABLED);
462#endif
463 pobj_StandardToolbar->EnableItem(IDM_FIND,1);
464
465 BOOL bConvEnable;
466 hChild=GetWindow(hChild,GW_CHILD);
467 if(!(
468 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x==MdiInfo[WndNum].pMdiTextEdit->EndCaretPos.x&&
469 MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y==MdiInfo[WndNum].pMdiTextEdit->EndCaretPos.y
470 )){
471 MenuMsg=MF_BYCOMMAND|MF_ENABLED;
472 ToolbarMsg=1;
473
474 bConvEnable=1;
475 }
476 else{
477 MenuMsg=MF_BYCOMMAND|MF_GRAYED;
478 ToolbarMsg=0;
479
480 bConvEnable=0;
481 }
482 pobj_MainMenu->EnableItem(IDM_CUT,MenuMsg);
483 pobj_MainMenu->EnableItem(IDM_COPY,MenuMsg);
484 pobj_MainMenu->EnableItem(IDM_DELETE,MenuMsg);
485 EnableMenuItem(hEditMenu,IDM_CUT,MenuMsg);
486 EnableMenuItem(hEditMenu,IDM_COPY,MenuMsg);
487 EnableMenuItem(hEditMenu,IDM_DELETE,MenuMsg);
488 pobj_StandardToolbar->EnableItem(IDM_CUT,ToolbarMsg);
489 pobj_StandardToolbar->EnableItem(IDM_COPY,ToolbarMsg);
490
491 if(IsClipboardFormatAvailable(CF_TEXT)){
492 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_ENABLED);
493 pobj_StandardToolbar->EnableItem(IDM_PASTE,1);
494 }
495 else{
496 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
497 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
498 }
499
500
501 //変換コマンド
502 ResetState_ConvMenu(bConvEnable);
503 }
504 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
505 //検索、置換、文字カウントを無効化
506 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_GRAYED);
507 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_GRAYED);
508#ifdef THETEXT
509 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_GRAYED);
510#endif
511 pobj_StandardToolbar->EnableItem(IDM_FIND,0);
512
513 if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW){
514 //切り取り、コピー、削除を有効化
515 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
516 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
517 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
518 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
519 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
520 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
521 pobj_StandardToolbar->EnableItem(IDM_CUT,0);
522 pobj_StandardToolbar->EnableItem(IDM_COPY,0);
523 }
524 else{
525 //切り取り、コピー、削除を無効化
526 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_ENABLED);
527 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_ENABLED);
528 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_ENABLED);
529 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_ENABLED);
530 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_ENABLED);
531 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_ENABLED);
532 pobj_StandardToolbar->EnableItem(IDM_CUT,1);
533 pobj_StandardToolbar->EnableItem(IDM_COPY,1);
534 }
535
536 //すべて選択を有効化
537 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_ENABLED);
538
539 if(IsClipboardFormatAvailable(dwRadClipboardID)){
540 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_ENABLED);
541 pobj_StandardToolbar->EnableItem(IDM_PASTE,1);
542 }
543 else{
544 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
545 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
546 }
547
548 ResetState_ConvMenu(0);
549 }
550 else if(MdiInfo[WndNum].DocType==WNDTYPE_MENU){
551 //検索、置換、文字カウントを無効化
552 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_GRAYED);
553 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_GRAYED);
554#ifdef THETEXT
555 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_GRAYED);
556#endif
557 pobj_StandardToolbar->EnableItem(IDM_FIND,0);
558
559 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
560 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
561 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
562 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
563 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
564 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
565 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
566 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_GRAYED);
567 pobj_StandardToolbar->EnableItem(IDM_CUT,0);
568 pobj_StandardToolbar->EnableItem(IDM_COPY,0);
569 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
570
571 ResetState_ConvMenu(0);
572 }
573 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
574 //検索、置換、文字カウントを無効化
575 pobj_MainMenu->EnableItem(IDM_FIND,MF_BYCOMMAND|MF_GRAYED);
576 pobj_MainMenu->EnableItem(IDM_PERMUTATION,MF_BYCOMMAND|MF_GRAYED);
577#ifdef THETEXT
578 pobj_MainMenu->EnableItem(IDM_STRING_COUNT,MF_BYCOMMAND|MF_GRAYED);
579#endif
580 pobj_StandardToolbar->EnableItem(IDM_FIND,0);
581
582 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==0){
583 //切り取り、コピー、削除を無効化
584 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
585 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
586 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
587 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_GRAYED);
588 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_GRAYED);
589 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_GRAYED);
590 pobj_StandardToolbar->EnableItem(IDM_CUT,0);
591 pobj_StandardToolbar->EnableItem(IDM_COPY,0);
592 }
593 else{
594 //切り取り、コピー、削除を有効化
595 pobj_MainMenu->EnableItem(IDM_CUT,MF_BYCOMMAND|MF_ENABLED);
596 pobj_MainMenu->EnableItem(IDM_COPY,MF_BYCOMMAND|MF_ENABLED);
597 pobj_MainMenu->EnableItem(IDM_DELETE,MF_BYCOMMAND|MF_ENABLED);
598 EnableMenuItem(hEditMenu,IDM_CUT,MF_BYCOMMAND|MF_ENABLED);
599 EnableMenuItem(hEditMenu,IDM_COPY,MF_BYCOMMAND|MF_ENABLED);
600 EnableMenuItem(hEditMenu,IDM_DELETE,MF_BYCOMMAND|MF_ENABLED);
601 pobj_StandardToolbar->EnableItem(IDM_CUT,1);
602 pobj_StandardToolbar->EnableItem(IDM_COPY,1);
603 }
604
605 //すべて選択を有効化
606 pobj_MainMenu->EnableItem(IDM_ALLSELECT,MF_BYCOMMAND|MF_ENABLED);
607
608 if(IsClipboardFormatAvailable(CF_BITMAP)){
609 //貼り付けを有効化
610 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_ENABLED);
611 pobj_StandardToolbar->EnableItem(IDM_PASTE,1);
612 }
613 else{
614 //貼り付けを無効化
615 pobj_MainMenu->EnableItem(IDM_PASTE,MF_BYCOMMAND|MF_GRAYED);
616 pobj_StandardToolbar->EnableItem(IDM_PASTE,0);
617 }
618
619 ResetState_ConvMenu(0);
620 }
621
622 ResetState_UndoMenu();
623}
624void ResetState_ViewMenu(void){
625 // 表示 メニューの状態を設定
626
627
628#ifdef THETEXT
629 pobj_MainMenu->CheckMenu(IDM_RIGHT_TURN,pobj_nv->bRightTurn);
630#endif
631}
632void ResetState_PrintMenu(void){ //編集メニューの表示制御
633 HWND hChild;
634 int WndNum;
635 hChild=GetWindow(hClient,GW_CHILD);
636 if(!IsWindow(hChild)){
637 pobj_MainMenu->EnableItem(IDM_PAGESET,MF_BYCOMMAND|MF_GRAYED);
638
639 pobj_MainMenu->EnableItem(IDM_PREVIEW,MF_BYCOMMAND|MF_GRAYED);
640
641 pobj_MainMenu->EnableItem(IDM_PRINTOUT,MF_BYCOMMAND|MF_GRAYED);
642 return;
643 }
644 WndNum=GetWndNum(hChild);
645 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
646 pobj_MainMenu->EnableItem(IDM_PAGESET,MF_BYCOMMAND|MF_ENABLED);
647
648 pobj_MainMenu->EnableItem(IDM_PREVIEW,MF_BYCOMMAND|MF_ENABLED);
649
650 pobj_MainMenu->EnableItem(IDM_PRINTOUT,MF_BYCOMMAND|MF_ENABLED);
651 }
652 else{
653 pobj_MainMenu->EnableItem(IDM_PAGESET,MF_BYCOMMAND|MF_GRAYED);
654
655 pobj_MainMenu->EnableItem(IDM_PREVIEW,MF_BYCOMMAND|MF_GRAYED);
656
657 pobj_MainMenu->EnableItem(IDM_PRINTOUT,MF_BYCOMMAND|MF_GRAYED);
658 }
659}
660void ResetState_DocMenu(void){
661 long MenuMsg,ToolbarMsg;
662 HWND hChild;
663
664 hChild=GetWindow(hClient,GW_CHILD);
665
666
667 /////////////////////////////////////////
668 // 共通ドキュメント メニューの状態を設定
669 /////////////////////////////////////////
670
671 if(!IsWindow(hChild)){
672 MenuMsg=MF_GRAYED;
673 ToolbarMsg=0;
674 }
675 else{
676 MenuMsg=MF_ENABLED;
677 ToolbarMsg=1;
678 }
679 pobj_MainMenu->EnableItem(IDM_CLOSE,MenuMsg);
680 pobj_MainMenu->EnableItem(IDM_SAVE,MenuMsg);
681 pobj_MainMenu->EnableItem(IDM_NEWSAVE,MenuMsg);
682 pobj_MainMenu->EnableItem(IDM_CODE_SAVE,MenuMsg);
683 pobj_MainMenu->EnableItem(IDM_ALLSAVE,MenuMsg);
684
685 pobj_StandardToolbar->EnableItem(IDM_CLOSE,ToolbarMsg);
686 pobj_StandardToolbar->EnableItem(IDM_SAVE,ToolbarMsg);
687 pobj_StandardToolbar->EnableItem(IDM_ALLSAVE,ToolbarMsg);
688
689
690#ifndef THETEXT
691 /////////////////////////////////////////////////
692 // プロジェクトドキュメント メニューの状態を設定
693 /////////////////////////////////////////////////
694
695 if( projectInfo.IsOpened() ){
696 pobj_MainMenu->EnableItem(IDM_ALLSAVE,MF_ENABLED);
697 pobj_StandardToolbar->EnableItem(IDM_ALLSAVE,1);
698
699 MenuMsg=MF_ENABLED;
700 ToolbarMsg=TBSTATE_ENABLED;
701 }
702 else{
703 MenuMsg=MF_GRAYED;
704 ToolbarMsg=TBSTATE_INDETERMINATE;
705 }
706 pobj_MainMenu->EnableItem(IDM_PROJECT_SAVE,MenuMsg);
707 pobj_MainMenu->EnableItem(IDM_PROJECT_CLOSE,MenuMsg);
708 pobj_MainMenu->EnableItem(IDM_PROJECT_FOLDER_OPEN,MenuMsg);
709 pobj_MainMenu->EnableItem(IDM_PROJECT_OPTION,MenuMsg);
710
711 //デバッガ メニューの状態を設定
712 pobj_Debugger->ResetCommandEnabled();
713#endif
714
715
716 //編集メニューの状態を設定
717 ResetState_EditMenu();
718
719 //表示メニューの状態を設定
720 ResetState_ViewMenu();
721}
722void DuplicateTitleCheck(char *lpszTitle){
723 int i;
724 for(i=0;i<MAX_WNDNUM;i++){
725 if(MdiInfo[i].hwnd){
726 if(lstrcmpi(MdiInfo[i].title,lpszTitle)==0){
727 lstrcat(lpszTitle,"_");
728 DuplicateTitleCheck(lpszTitle);
729 return;
730 }
731 }
732 }
733}
734HWND NewTextEditWindow(char *filepath,_int8 DocumentType,COLORREF TabColor){
735 int i;
736 char str[MAX_PATH],str2[32],*buffer;
737 HWND hChild,hEdit;
738 RECT rect;
739 int iCharCode=NKF_SHIFT_JIS;
740 int iLfCode=LFCODE_CRLF;
741
742 if(filepath){
743
744 //すでに指定されたファイルが開かれている場合
745 hChild=GetWindow(hClient,GW_CHILD);
746 while(hChild){
747 i=GetWndNum(hChild);
748 if(IS_DOCUMENT_TEXT(MdiInfo[i].DocType)){
749 if(lstrcmpi(MdiInfo[i].path,filepath)==0) break;
750 }
751 hChild=GetNextWindow(hChild,GW_HWNDNEXT);
752 }
753 if(hChild){
754 //前面に表示して終了
755 BringWindowToTop(hChild);
756 return hChild;
757 }
758
759
760 //////////////////////////////////////////////////////
761 //ファイル読み込み(正常に読み込めるかの確認も含む)
762 //////////////////////////////////////////////////////
763
764 HANDLE hFile;
765 hFile=CreateFile(filepath,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
766 if(hFile==INVALID_HANDLE_VALUE){
767 sprintf(str,STRING_ERROR_CANT_FILEOPEN,filepath);
768 MessageBox(hOwner,str,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
769 return 0;
770 }
771 int length;
772 length=GetFileSize(hFile,NULL);
773
774 char *temp;
775 temp=(char *)HeapAlloc(hHeap,0,length+1);
776 DWORD dw;
777 ReadFile(hFile,temp,length,&dw,NULL);
778 CloseHandle(hFile);
779 for(i=0;i<length;i++){
780 if(temp[i]=='\0') temp[i]=' ';
781 }
782 temp[length]=0;
783
784
785 ///////////////////////
786 // 改行コードを判別
787 ///////////////////////
788
789 char *temp2;
790 for(i=0;i<length;i++){
791 if(temp[i]=='\r'){
792 if(temp[i+1]=='\n')
793 iLfCode=LFCODE_CRLF;
794 else
795 iLfCode=LFCODE_CR;
796 break;
797 }
798 if(temp[i]=='\n'){
799 iLfCode=LFCODE_LF;
800 break;
801 }
802 }
803
804 //改行コードを変換
805 if(iLfCode==LFCODE_CR||iLfCode==LFCODE_LF){
806 temp2=nkf.ToCRLF(iLfCode,temp);
807 HeapDefaultFree(temp);
808 temp=temp2;
809
810 length=lstrlen(temp);
811 }
812
813
814 /////////////////////
815 // Shift-JISに変換
816 /////////////////////
817
818 buffer=(char *)HeapAlloc(hHeap,0,length*2+1);
819 nkf.pSetNkfOption("-sx"); //Shift-JISに変換(xは半角カタカナを全角に変換しないオプション)
820 nkf.pNkfConvert(buffer,temp);
821 buffer=(char *)HeapReAlloc(hHeap,0,buffer,lstrlen(buffer)+1);
822 HeapDefaultFree(temp);
823
824 //変換前の文字コードを判別
825 iCharCode=nkf.pNkfGetKanjiCode();
826 if(iCharCode<NKF_CODE_MIN||NKF_CODE_MAX<iCharCode){
827 //判別不能な場合は、Shift-JISにする
828 iCharCode=NKF_SHIFT_JIS;
829 }
830 else if(iCharCode==NKF_EUC||iCharCode==NKF_ISO_2022_JP){
831 //EUC、JISの場合で、判別不能な場合は、Shift-JISを優先
832 for(i=0;;i++){
833 if(buffer[i]=='\0'){
834 //半角コードのみ
835 iCharCode=NKF_SHIFT_JIS;
836 break;
837 }
838 if(IsDBCSLeadByte(buffer[i])) break;
839 }
840 }
841
842
843 //////////////////////////
844 // ファイルパスをセット
845 //////////////////////////
846
847 _splitpath(filepath,NULL,NULL,str,str2);
848 lstrcat(str,str2);
849 }
850 else{
851 buffer=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
852 DocumentCounter++;
853 sprintf(str,"Document[%d]",DocumentCounter);
854 }
855
856 MDICREATESTRUCT mdic;
857 mdic.szClass="MDIClientWindow_TextEdit";
858 mdic.hOwner=hInst;
859 mdic.x=CW_USEDEFAULT;
860 mdic.y=CW_USEDEFAULT;
861 mdic.cx=CW_USEDEFAULT;
862 mdic.cy=CW_USEDEFAULT;
863 mdic.szTitle=str;
864
865 hChild=GetWindow(hClient,GW_CHILD);
866 if(IsWindow(hChild)){
867 if(IsZoomed(hChild)) mdic.style=WS_MAXIMIZE;
868 else mdic.style=0;
869 }
870 else{
871 if(pobj_nv->bMDIZoomed) mdic.style=WS_MAXIMIZE;
872 else mdic.style=0;
873 }
874
875 //ファイルアイコンをセット
876 SHFILEINFO shfi;
877 if(filepath)
878 SHGetFileInfo(filepath, FILE_ATTRIBUTE_ARCHIVE, &shfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON );
879 else shfi.hIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);;
880 mdic.lParam=(LPARAM)shfi.hIcon;
881
882 mdic.style|=WS_CLIPCHILDREN;
883 hChild=(HWND)SendMessage(hClient,WM_MDICREATE,0,(long)&mdic); //ウィンドウ作成
884
885 //TextEditorコントロールを設置
886 GetClientRect(hChild,&rect);
887 hEdit=CreateWindow("TextEditor",NULL,
888 WS_CHILD|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE,
889 0,0,0,0,
890 hChild,NULL,hInst,NULL);
891
892 //ウィンドウのID登録
893 for(i=0;i<MAX_WNDNUM;i++){
894 if(MdiInfo[i].hwnd==0){
895 MdiInfo[i].hwnd=hChild;
896 MdiInfo[i].DocType=DocumentType;
897 DuplicateTitleCheck(str);
898 MdiInfo[i].title=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(str)+1);
899 lstrcpy(MdiInfo[i].title,str);
900 if(filepath){
901 MdiInfo[i].path=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(filepath)+1);
902 lstrcpy(MdiInfo[i].path,filepath);
903 }
904 else{
905 MdiInfo[i].path=(char *)GlobalAlloc(GPTR,1);
906 }
907
908 MdiInfo[i].pMdiTextEdit = new CMdiTextEdit( &MdiInfo[i] );
909
910 MdiInfo[i].pMdiTextEdit->hEdit=hEdit;
911 MdiInfo[i].pMdiTextEdit->pobj_WebResult=new CWebResult(hChild);
912 MdiInfo[i].pMdiTextEdit->pobj_Ruler=new CRuler(hChild,i);
913 MdiInfo[i].pMdiTextEdit->hIcon=shfi.hIcon;
914 MdiInfo[i].pMdiTextEdit->buffer=buffer;
915 MdiInfo[i].pMdiTextEdit->pColorRef=(COLORREF *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(COLORREF)*lstrlen(buffer));
916 MdiInfo[i].pMdiTextEdit->iUnderStart=-1;
917 MdiInfo[i].pMdiTextEdit->iUnderEnd=-1;
918 MdiInfo[i].pMdiTextEdit->StartCaretPos.x=0;
919 MdiInfo[i].pMdiTextEdit->StartCaretPos.y=0;
920 MdiInfo[i].pMdiTextEdit->EndCaretPos.x=0;
921 MdiInfo[i].pMdiTextEdit->EndCaretPos.y=0;
922 MdiInfo[i].pMdiTextEdit->Temp_UpDown_CaretXPos=-1;
923 MdiInfo[i].pMdiTextEdit->bAutoScroll=0;
924 MdiInfo[i].pMdiTextEdit->iWidth_ControlTabSpace=
925 GetControlTabSpace(i,&MdiInfo[i].pMdiTextEdit->iLineNumberTextCount);
926 MdiInfo[i].pMdiTextEdit->iCharCode=iCharCode;
927 MdiInfo[i].pMdiTextEdit->iLfCode=iLfCode;
928
929 MdiInfo[i].IndentStr=0;
930
931 int flag;
932 if(mdic.style&WS_MAXIMIZE) flag=SIZE_MAXIMIZED;
933 else flag=0;
934 SendTextEditResizeEvent(hChild);
935 break;
936 }
937 }
938
939 //ワードカラーをセット
940 if(IS_DOCUMENT_TEXT(DocumentType)) SetTextEditWordColor(i);
941
942 //Docコンボボックスに追加
943 extern HWND hDocCombo;
944 i=SendMessage(hDocCombo,CB_ADDSTRING,0,(long)str);
945 SendMessage(hDocCombo,CB_SETCURSEL,i,0);
946
947 //タブに追加
948 pobj_MainTab->InsertItem( str, true, TabColor );
949
950 SetFocus(hEdit);
951 SetStatusText(NULL);
952
953 //メニュー状態を設定
954 ResetState_DocMenu();
955
956 if( DocumentType == WNDTYPE_BASIC && !projectInfo.IsOpened() ){
957 // 単体ソースコードを開いたとき
958 if( !IsWindowVisible( hProjectView ) ){
959 // クラスビューを表示する
960 SendMessage(hOwner,WM_COMMAND,IDM_PROJECTVIEW,0);
961 ShowClassView();
962
963 // クラスビューを更新
964 ResetClassTree(-1);
965 }
966 }
967
968 return hChild;
969}
970void CloseDocWindow(int WndNum){
971 int i2,i3;
972
973 MdiInfo[WndNum].hwnd=0;
974
975 //ドキュメントコンボボックスから文字列を消去
976 extern HWND hDocCombo;
977 i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[WndNum].title);
978 SendMessage(hDocCombo,CB_DELETESTRING,i2,0);
979
980 //タブコントロールからアイテムを消去
981 if(pobj_MainTab) pobj_MainTab->DeleteItem( MdiInfo[WndNum].title, true );
982
983
984 GlobalFree(MdiInfo[WndNum].title);
985 GlobalFree(MdiInfo[WndNum].path);
986
987 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
988 ////////////////////////////
989 // テキストエディタを閉じる
990 ////////////////////////////
991
992 extern COMPLEMENT_WINDOW_INFO ComplementWndInfo;
993 if(ComplementWndInfo.hWnd){
994 //コード補完リストを破棄する
995 DestroyWindow(ComplementWndInfo.hWnd);
996 ComplementWndInfo.hWnd=0;
997 }
998
999 HeapDefaultFree(MdiInfo[WndNum].pMdiTextEdit->buffer);
1000 HeapDefaultFree(MdiInfo[WndNum].pMdiTextEdit->pColorRef);
1001
1002 if(MdiInfo[WndNum].IndentStr) HeapDefaultFree(MdiInfo[WndNum].IndentStr);
1003
1004 //エディットコントロールを破棄
1005 DestroyWindow(MdiInfo[WndNum].pMdiTextEdit->hEdit);
1006
1007 //Web検索ウィンドウを破棄
1008 delete MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult;
1009 MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult=0;
1010
1011 //ルーラーウィンドウを破棄
1012 delete MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler;
1013 MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler=0;
1014
1015 //アイコンを破棄
1016 if(MdiInfo[WndNum].pMdiTextEdit->hIcon) DestroyIcon(MdiInfo[WndNum].pMdiTextEdit->hIcon);
1017
1018 delete MdiInfo[WndNum].pMdiTextEdit;
1019 MdiInfo[WndNum].pMdiTextEdit=0;
1020 }
1021 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
1022 /////////////////////
1023 // RADツールを閉じる
1024 /////////////////////
1025
1026 for(i2=0;i2<MAX_UNDONUM;i2++){
1027 if(MdiInfo[WndNum].MdiRadInfo->undo.Command[i2])
1028 Rad_DeleteUndoData(WndNum,i2);
1029 }
1030 DestroyWindow(MdiInfo[WndNum].MdiRadInfo->hTools);
1031 DestroyWindow(MdiInfo[WndNum].MdiRadInfo->hRad);
1032 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,MdiInfo[WndNum].MdiRadInfo->hOldBitmap);
1033 DeleteDC(MdiInfo[WndNum].MdiRadInfo->hMemDC);
1034 DeleteObject(MdiInfo[WndNum].MdiRadInfo->hBitmap);
1035 GlobalFree(MdiInfo[WndNum].MdiRadInfo);
1036 }
1037 else if(MdiInfo[WndNum].DocType==WNDTYPE_MENU){
1038 ////////////////////////////
1039 // メニューエディタを閉じる
1040 ////////////////////////////
1041
1042 DestroyWindow(MdiInfo[WndNum].MdiMenuInfo->hList);
1043 GlobalFree(MdiInfo[WndNum].MdiMenuInfo);
1044 }
1045 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
1046 ////////////////////////////
1047 // アイコンエディタを閉じる
1048 ////////////////////////////
1049
1050 for(i2=0;i2<MdiInfo[WndNum].MdiIconEditInfo->num;i2++){
1051 for(i3=0;i3<MAX_ICONEDIT_UNDONUM;i3++){
1052 if(MdiInfo[WndNum].MdiIconEditInfo->undo[i2].lpData[i3])
1053 HeapDefaultFree(MdiInfo[WndNum].MdiIconEditInfo->undo[i2].lpData[i3]);
1054 }
1055 }
1056
1057 DeleteDC(MdiInfo[WndNum].MdiIconEditInfo->memdc);
1058 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hMemBmp);
1059 DestroyWindow(MdiInfo[WndNum].MdiIconEditInfo->hMain);
1060 for(i2=0;i2<MdiInfo[WndNum].MdiIconEditInfo->num;i2++){
1061 HeapDefaultFree(MdiInfo[WndNum].MdiIconEditInfo->pIconImage[i2]);
1062 }
1063 HeapDefaultFree(MdiInfo[WndNum].MdiIconEditInfo);
1064 }
1065}
1066void ResizeTextEditWnd(HWND hwnd,int cx,int cy){
1067 int WndNum;
1068 WndNum=GetWndNum(hwnd);
1069 if(WndNum==-1) return;
1070
1071 int WebResultWndHeight;
1072 WebResultWndHeight=LINK_ITEM_HEIGHT;
1073 //未完成
1074 WebResultWndHeight=0;
1075
1076 int iHeightRuler;
1077 if(pobj_nv->bEditor_Ruler){
1078 //ルーラー
1079 MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->resize(
1080 0,
1081 0,
1082 cx,
1083 HEIGHT_RULER);
1084
1085 iHeightRuler=HEIGHT_RULER;
1086
1087 ShowWindow(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,SW_SHOW);
1088 }
1089 else{
1090 iHeightRuler=0;
1091
1092 ShowWindow(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,SW_HIDE);
1093 }
1094
1095 //エディットウィンドウ
1096 MoveWindow(MdiInfo[WndNum].pMdiTextEdit->hEdit,
1097 0,
1098 iHeightRuler,
1099 cx,
1100 cy-WebResultWndHeight-iHeightRuler,
1101 1);
1102
1103 //Web検索ウィンドウ
1104 MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult->resize(
1105 0,
1106 cy-WebResultWndHeight,
1107 cx,
1108 WebResultWndHeight);
1109}
1110LRESULT CALLBACK MDIClientWindow_TextEdit(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1111 int i,i2;
1112 HWND hEdit;
1113
1114 switch(message){
1115 case WM_CREATE:
1116 CREATESTRUCT *lpcs;
1117 lpcs=(CREATESTRUCT *)lParam;
1118 MDICREATESTRUCT *lpmcs;
1119 lpmcs=(MDICREATESTRUCT *)lpcs->lpCreateParams;
1120 SendMessage(hwnd,WM_SETICON,ICON_SMALL,(LPARAM)lpmcs->lParam);
1121 break;
1122 case WM_MDIACTIVATE:
1123 //以前のMDIウィンドウのパラメータ ヒントを破棄する
1124 if(MethodCheckInfo.hWnd){
1125 DestroyWindow(MethodCheckInfo.hWnd);
1126 MethodCheckInfo.hWnd=0;
1127 }
1128
1129 //以前のコード補完リストを破棄する
1130 if(ComplementWndInfo.hWnd){
1131 DestroyWindow(ComplementWndInfo.hWnd);
1132 ComplementWndInfo.hWnd=0;
1133 }
1134
1135 if(!lParam) return 0;
1136 i=GetWndNum((HWND)lParam);
1137 if(i==-1) return 0; //ウィンドウが初期状態の場合
1138
1139#ifndef THETEXT
1140 //デバッガ メニューの状態を設定
1141 pobj_Debugger->ResetCommandEnabled();
1142#endif
1143
1144 //ドキュメント セレクト コンボボックス
1145 extern HWND hDocCombo;
1146 i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[i].title);
1147 SendMessage(hDocCombo,CB_SETCURSEL,i2,0);
1148
1149 //タブコントロール
1150 pobj_MainTab->MdiActiveEvent(MdiInfo[i].title);
1151
1152 if( !projectInfo.IsOpened() ){
1153 ResetClassTree(-1);
1154 }
1155
1156 return 0;
1157 case WM_SETFOCUS:
1158 hEdit=GetWindow(hwnd,GW_CHILD);
1159 SetFocus(hEdit);
1160 SetStatusText(CmdMsg);
1161 ResetState_EditMenu();
1162 ResetState_ViewMenu();
1163 break;
1164 case WM_SIZE:
1165 ResizeTextEditWnd(hwnd,LOWORD(lParam),HIWORD(lParam));
1166 break;
1167 case WM_CLOSE:
1168 if(!DocumentModifyCheck(hwnd)) return 0;
1169 CloseDocWindow(GetWndNum(hwnd));
1170 pobj_nv->bMDIZoomed=IsZoomed(hwnd);
1171 i=DefMDIChildProc(hwnd,message,wParam,lParam);
1172
1173 //メニュー状態を設定
1174 ResetState_DocMenu();
1175
1176 return i;
1177 }
1178 return DefMDIChildProc(hwnd,message,wParam,lParam);
1179}
1180void ResizeOwnerWnd(void){
1181 int width_owner,height_owner;
1182 int height_Rebar;
1183 int height_MdiClient;
1184 RECT rect,StatusRect,RebarRect;
1185
1186 GetClientRect(hOwner,&rect);
1187 width_owner=rect.right;
1188 height_owner=rect.bottom;
1189
1190 //Rebar
1191 SendMessage(pobj_Rebar->hRebar,WM_SIZE,0,MAKELONG(width_owner,height_owner));
1192 UpdateWindow(pobj_Rebar->hRebar);
1193
1194 //Status bar
1195#define STATUSBAR_PARTS_NUM 5
1196 int sb_size[STATUSBAR_PARTS_NUM];
1197 sb_size[0]=width_owner-340;
1198 sb_size[1]=width_owner-220;
1199 sb_size[2]=width_owner-120;
1200 sb_size[3]=width_owner-50;
1201 sb_size[4]=width_owner;
1202 SendMessage(hStatusBar,SB_SETPARTS,STATUSBAR_PARTS_NUM,(LPARAM)sb_size);
1203 SendMessage(hStatusBar,WM_SIZE,0,MAKELONG(width_owner,height_owner));
1204 UpdateWindow(hStatusBar);
1205
1206 //Status bar
1207 int height_Statusbar;
1208 SendMessage(hStatusBar,SB_GETRECT,0,(long)&StatusRect);
1209 height_Statusbar=StatusRect.bottom;
1210
1211 GetWindowRect(pobj_Rebar->hRebar,&RebarRect);
1212 height_Rebar=RebarRect.bottom-RebarRect.top+2;
1213
1214 int height_dv; //Width of Debugger View
1215 int height_cv; //Width of Compiler View
1216 height_dv=0;
1217 height_cv=0;
1218#ifndef THETEXT
1219 if(bClipCompileView){
1220 if(pobj_Debugger->IsDebuggerView()){
1221 //デバッガビューが表示されているとき
1222 height_dv=pobj_nv->height_ClipDebuggerView+LEVER_THICK;
1223 }
1224 if(hCompileView){
1225 //コンパイラビューが表示されているとき
1226 height_cv=pobj_nv->height_ClipCompileView+LEVER_THICK;
1227 }
1228 }
1229#endif
1230
1231 int width_pjv=0; //Width of Project View
1232 if(pobj_nv->bClipProjectView){
1233 if(IsWindowVisible(hProjectView)){
1234 //プロジェクトビューが表示されているとき
1235 width_pjv=pobj_nv->width_ClipProjectView+LEVER_THICK;
1236 }
1237 }
1238
1239 int width_SideWeb=0;
1240 if( pobj_SideWeb )
1241 {
1242 if(pobj_SideWeb->bShow){
1243 width_SideWeb=pobj_nv->width_WebSearchView+LEVER_THICK;
1244 }
1245 }
1246
1247 //MDIクライアントの高さ
1248 height_MdiClient=height_owner-(
1249 height_Rebar+
1250 height_dv+
1251 height_cv+
1252 height_Statusbar
1253 );
1254
1255 //タブコントロール
1256 int tab_height;
1257 if(TabCtrl_GetItemCount(pobj_MainTab->hTab)==0) tab_height=0;
1258 else{
1259 RECT rc;
1260 TabCtrl_GetItemRect(pobj_MainTab->hTab,0,&rc);
1261 tab_height=rc.bottom-rc.top;
1262 }
1263 MoveWindow(pobj_MainTab->hTab,
1264 width_pjv,
1265 height_Rebar,
1266 width_owner-width_pjv-width_SideWeb,
1267 tab_height,
1268 1);
1269
1270 //MDIクライアント
1271 MoveWindow(hClient,
1272 width_pjv,
1273 height_Rebar+tab_height,
1274 width_owner-width_pjv-width_SideWeb,
1275 height_MdiClient-tab_height,
1276 1);
1277
1278 if( pobj_SideWeb )
1279 {
1280 if(pobj_SideWeb->bShow){
1281 //SideWeb
1282 pobj_SideWeb->resize(
1283 width_owner - pobj_nv->width_WebSearchView,
1284 height_Rebar,
1285 pobj_nv->width_WebSearchView,
1286 height_MdiClient);
1287 }
1288 else pobj_SideWeb->resize(0,0,0,0);
1289 }
1290
1291 if(width_pjv){
1292 //プロジェクトビュー
1293 MoveWindow(hProjectView,
1294 0,
1295 height_Rebar,
1296 pobj_nv->width_ClipProjectView,
1297 height_MdiClient,
1298 1);
1299 InvalidateRect(hProjectView,NULL,0);
1300 }
1301
1302 if(height_dv){
1303#ifndef THETEXT
1304 //デバッガビュー
1305 pobj_Debugger->resize(
1306 0,
1307 height_Rebar+height_MdiClient+LEVER_THICK,
1308 width_owner,
1309 pobj_nv->height_ClipDebuggerView);
1310#endif
1311 }
1312 if(height_cv){
1313 //コンパイラビュー
1314 MoveWindow(hCompileView,
1315 0,
1316 height_Rebar+height_MdiClient+height_dv+LEVER_THICK,
1317 width_owner,
1318 pobj_nv->height_ClipCompileView,
1319 1);
1320 }
1321}
1322
1323WNDPROC oldMainFrameWndProc;
1324LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1325 char str[MAX_PATH];
1326 RECT rect;
1327 POINT pos;
1328
1329 if(message==WM_COMMAND&&IS_FILEHISTORY_COMMAND(LOWORD(wParam))){
1330 //「最近使ったファイル」メニューコマンド
1331 lstrcpy(str,pobj_nv->pobj_History->lpszPath[LOWORD(wParam)-100]);
1332 OpenFileWithExtension(str);
1333 return 0;
1334 }
1335
1336 if(message==WM_COMMAND&&200<=LOWORD(wParam)&&LOWORD(wParam)<=299){
1337 //「最近使ったプロジェクト」メニューコマンド
1338 lstrcpy(str,pobj_nv->pobj_ProjectHistory->lpszPath[LOWORD(wParam)-200]);
1339 OpenFileWithExtension(str);
1340 return 0;
1341 }
1342
1343 switch(message)
1344 {
1345
1346#ifndef THETEXT
1347 case WM_SETCOMPILEVIEW:
1348 //コンパイラウィンドウ(埋め込み型)が表示されたとき
1349 hCompileView=(HWND)lParam;
1350 ResizeOwnerWnd();
1351 return 0;
1352 case WM_DESTROYCOMPILEVIEW:
1353 //コンパイラウィンドウ(埋め込み型)が破棄されたとき
1354 if((int)hCompileView==-1){
1355 //すぐに次のコンパイラウィンドウが起動するとき
1356 hCompileView=0;
1357 }
1358 else{
1359 //完全にコンパイラウィンドウを閉じたときはリサイズ
1360 hCompileView=0;
1361
1362 ResizeOwnerWnd();
1363 }
1364 return 0;
1365
1366 case WM_SETDEBUGGERBASE:
1367 //デバッガベースウィンドウ(埋め込み型)が表示されたとき
1368 pobj_Debugger->begin();
1369
1370 //BasicCompiler.exeの強制終了を考慮
1371 SetTimer(hOwner,ID_DEBUGSAFTY,1000,NULL);
1372
1373 return 0;
1374 case WM_DESTROYDEBUGGERBASE:
1375 //BasicCompiler.exeの強制終了を考慮
1376 KillTimer(hOwner,ID_DEBUGSAFTY);
1377
1378 //デバッガベースウィンドウ(埋め込み型)が破棄されたとき
1379 pobj_Debugger->end();
1380
1381 return 0;
1382
1383 case WM_SETDEBUGGERVIEW:
1384 //デバッガウィンドウ(埋め込み型)が表示されたとき
1385 pobj_Debugger->watch_start((HWND)lParam);
1386 ResizeOwnerWnd();
1387 return 0;
1388 case WM_DESTROYDEBUGGERVIEW:
1389 //デバッガウィンドウ(埋め込み型)が破棄されたとき
1390 pobj_Debugger->watch_quit();
1391 ResizeOwnerWnd();
1392 return 0;
1393#endif
1394
1395 case WM_SIZE:
1396 ResizeOwnerWnd();
1397 return 0;
1398
1399
1400 case WM_MOUSEMOVE:
1401 static DWORD dwDragLever;
1402 static POINT PrevMousePos;
1403 static int start;
1404
1405 pos.x=(long)(short)LOWORD(lParam);
1406 pos.y=(long)(short)HIWORD(lParam);
1407 ClientToScreen(hwnd,&pos);
1408
1409 if(dwDragLever){
1410 GetClientRect(hwnd,&rect);
1411
1412 if(dwDragLever==1){
1413 //プロジェクトビューをリサイズ中
1414 pobj_nv->width_ClipProjectView=start+pos.x-PrevMousePos.x;
1415 if(pobj_nv->width_ClipProjectView<100) pobj_nv->width_ClipProjectView=100;
1416 if(rect.right-100<pobj_nv->width_ClipProjectView) pobj_nv->width_ClipProjectView=rect.right-100;
1417 }
1418 else if(dwDragLever==2){
1419 //デバッガビューをリサイズ中
1420 pobj_nv->height_ClipDebuggerView=start+PrevMousePos.y-pos.y;
1421 if(pobj_nv->height_ClipDebuggerView<60) pobj_nv->height_ClipDebuggerView=60;
1422 if(rect.bottom-100<pobj_nv->height_ClipCompileView+pobj_nv->height_ClipDebuggerView)
1423 pobj_nv->height_ClipDebuggerView=rect.bottom-100-pobj_nv->height_ClipCompileView;
1424 }
1425 else if(dwDragLever==3){
1426 //コンパイラビューをリサイズ中
1427 pobj_nv->height_ClipCompileView=start+PrevMousePos.y-pos.y;
1428 if(pobj_nv->height_ClipCompileView<60) pobj_nv->height_ClipCompileView=60;
1429 if(rect.bottom-100<pobj_nv->height_ClipCompileView)
1430 pobj_nv->height_ClipCompileView=rect.bottom-100;
1431 }
1432 else if(dwDragLever==4){
1433 //SideWebをリサイズ中
1434 pobj_nv->width_WebSearchView=start+PrevMousePos.x-pos.x;
1435 if(pobj_nv->width_WebSearchView<100) pobj_nv->width_WebSearchView=100;
1436 if(rect.right-100<pobj_nv->width_WebSearchView) pobj_nv->width_WebSearchView=rect.right-100;
1437 }
1438
1439 ResizeOwnerWnd();
1440 UpdateWindow(hwnd);
1441 }
1442 if(pobj_nv->bClipProjectView&&IsWindowVisible(hProjectView)){
1443 //プロジェクトビューとMDIクライアントの境目のサイズ変更ライン
1444 GetWindowRect(hProjectView,&rect);
1445 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
1446 rect.right<=pos.x&&pos.x<=rect.right+LEVER_THICK){
1447 SetCursor(LoadCursor(0,IDC_SIZEWE));
1448 }
1449 }
1450#ifndef THETEXT
1451 if(bClipCompileView&&pobj_Debugger->IsDebuggerView()){
1452 //デバッガビューとMDIクライアントの境目のサイズ変更ライン
1453 GetWindowRect(pobj_Debugger->hwnd,&rect);
1454 if(rect.left<=pos.x&&pos.x<=rect.right&&
1455 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
1456 SetCursor(LoadCursor(0,IDC_SIZENS));
1457 }
1458 }
1459 if(bClipCompileView&&IsWindowVisible(hCompileView)){
1460 //コンパイラビューとMDIクライアントの境目のサイズ変更ライン
1461 GetWindowRect(hCompileView,&rect);
1462 if(rect.left<=pos.x&&pos.x<=rect.right&&
1463 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
1464 SetCursor(LoadCursor(0,IDC_SIZENS));
1465 }
1466 }
1467#endif
1468 if( pobj_SideWeb )
1469 {
1470 if(pobj_SideWeb->bShow){
1471 //SideWebとMDIクライアントの境目のサイズ変更ライン
1472 pobj_SideWeb->GetRect(&rect);
1473 ClientToScreen(hwnd,&rect);
1474 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
1475 rect.left-LEVER_THICK<=pos.x&&pos.x<=rect.left){
1476 SetCursor(LoadCursor(0,IDC_SIZEWE));
1477 }
1478 }
1479 }
1480 return 0;
1481 case WM_LBUTTONDOWN:
1482 pos.x=LOWORD(lParam);
1483 pos.y=HIWORD(lParam);
1484 ClientToScreen(hwnd,&pos);
1485
1486 if(pobj_nv->bClipProjectView&&IsWindowVisible(hProjectView)){
1487 //プロジェクトビューとMDIクライアントの境目のサイズ変更ライン
1488 GetWindowRect(hProjectView,&rect);
1489 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
1490 rect.right<=pos.x&&pos.x<=rect.right+LEVER_THICK){
1491 SetCursor(LoadCursor(0,IDC_SIZEWE));
1492
1493 dwDragLever=1;
1494 SetCapture(hwnd);
1495
1496 PrevMousePos=pos;
1497 start=pobj_nv->width_ClipProjectView;
1498 }
1499 }
1500#ifndef THETEXT
1501 if(bClipCompileView&&pobj_Debugger->IsDebuggerView()){
1502 //デバッガビューとMDIクライアントの境目のサイズ変更ライン
1503 GetWindowRect(pobj_Debugger->hwnd,&rect);
1504 if(rect.left<=pos.x&&pos.x<=rect.right&&
1505 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
1506 SetCursor(LoadCursor(0,IDC_SIZENS));
1507
1508 dwDragLever=2;
1509 SetCapture(hwnd);
1510
1511 PrevMousePos=pos;
1512 start=pobj_nv->height_ClipDebuggerView;
1513 }
1514 }
1515 if(bClipCompileView&&IsWindowVisible(hCompileView)){
1516 //コンパイラビューとMDIクライアントの境目のサイズ変更ライン
1517 GetWindowRect(hCompileView,&rect);
1518 if(rect.left<=pos.x&&pos.x<=rect.right&&
1519 rect.top-LEVER_THICK<=pos.y&&pos.y<=rect.top){
1520 SetCursor(LoadCursor(0,IDC_SIZENS));
1521
1522 dwDragLever=3;
1523 SetCapture(hwnd);
1524
1525 PrevMousePos=pos;
1526 start=pobj_nv->height_ClipCompileView;
1527 }
1528 }
1529#endif
1530 if( pobj_SideWeb && pobj_SideWeb->bShow){
1531 //SideWebとMDIクライアントの境目のサイズ変更ライン
1532 pobj_SideWeb->GetRect(&rect);
1533 ClientToScreen(hwnd,&rect);
1534 if(rect.top<=pos.y&&pos.y<=rect.bottom&&
1535 rect.left-LEVER_THICK<=pos.x&&pos.x<=rect.left){
1536 SetCursor(LoadCursor(0,IDC_SIZENS));
1537
1538 dwDragLever=4;
1539 SetCapture(hwnd);
1540
1541 PrevMousePos=pos;
1542 start=pobj_nv->width_WebSearchView;
1543 }
1544 }
1545 return 0;
1546 case WM_LBUTTONUP:
1547 if(dwDragLever){
1548 dwDragLever=0;
1549 ReleaseCapture();
1550 }
1551 return 0;
1552
1553
1554 case WM_SYSCOMMAND:
1555 //ウィンドウの最小化前にウィンドウ位置を保存
1556 if(wParam==SC_MINIMIZE){
1557 if(IsZoomed(hwnd)) pobj_nv->bWindowMax=1;
1558 else if(!IsIconic(hwnd)){
1559 pobj_nv->bWindowMax=0;
1560 GetWindowRect(hwnd,&pobj_nv->StartupWindowRect);
1561 }
1562 }
1563 break; //処理をDefFrameProcへ
1564 }
1565
1566 return CallWindowProc( oldMainFrameWndProc, hwnd, message, wParam, lParam );
1567}
1568
1569int RegWndClass(WNDPROC WndProc,char *lpClassName,HBRUSH hBackBrush,DWORD dwFlag){
1570 WNDCLASSEX wcl;
1571
1572 wcl.cbSize=sizeof(WNDCLASSEX);
1573 wcl.hInstance=hInst;
1574 wcl.lpszClassName=lpClassName;
1575 wcl.lpfnWndProc=WndProc;
1576
1577 if(dwFlag&FLAG_DBLCLK) wcl.style=CS_DBLCLKS;
1578 else wcl.style=0;
1579
1580 wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
1581 wcl.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
1582
1583 if(dwFlag&FLAG_BEAMCURSOR) wcl.hCursor=LoadCursor(NULL,IDC_IBEAM);
1584 else wcl.hCursor=LoadCursor(NULL,IDC_ARROW);
1585
1586 wcl.lpszMenuName=NULL;
1587 wcl.cbClsExtra=0;
1588 wcl.cbWndExtra=0;
1589 wcl.hbrBackground=hBackBrush;
1590
1591 return RegisterClassEx(&wcl);
1592}
1593int PASCAL WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int ShowCmd){
1594 int i,i2,IsStr;
1595 char str[MAX_PATH],str2[MAX_PATH],dummy[1024];
1596 MSG msg;
1597 HACCEL hAccel;
1598
1599 hInst=hThisInst;
1600 if(!SetupProjectEditor()) return 0;
1601
1602 HBRUSH hGrayBrush_LineNumber;
1603 hGrayBrush_LineNumber=CreateSolidBrush(RGB(220,220,220));
1604
1605 //if(!RegWndClass(WindowFunc,"ProjectEditorClass",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
1606 if(!RegWndClass(MDIClientWindow_TextEdit,"MDIClientWindow_TextEdit",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
1607 if(!RegWndClass(MethodCheckWindow,"MethodCheckWindow",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
1608 if(!RegWndClass(MDIClientWindow_Rad,"MDIClientWindow_Rad",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
1609 if(!RegWndClass(RadToolsWindow,"RadToolsWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
1610 if(!RegWndClass(RadPropertyWindow,"RadPropertyWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
1611 if(!RegWndClass(RadWindow,"RadWindow",(HBRUSH)GetStockObject(NULL_BRUSH),FLAG_DBLCLK)) return 0;
1612 if(!RegWndClass(TestWindowProc,"TestWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
1613 if(!RegWndClass(MDIClientWindow_Menu,"MDIClientWindow_Menu",(HBRUSH)GetStockObject(WHITE_BRUSH),FLAG_DBLCLK)) return 0;
1614 if(!RegWndClass(MenuEditWindow,"MenuEditWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
1615 if(!RegWndClass(MDIClientWindow_IconEdit,"MDIClientWindow_IconEdit",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
1616 if(!RegWndClass(IconEditWindowProc,"IconEditWindowProc",(HBRUSH)GetStockObject(WHITE_BRUSH),0)) return 0;
1617 if(!RegWndClass(ProjectViewProc,"ProjectView",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
1618 if(!RegWndClass(ProjectView_ToolWindowProc,"ProjectView_ToolWindow",h3DFaceBackBrush,FLAG_DBLCLK)) return 0;
1619 if(!RegWndClass(TextEditProc,"TextEditor",(HBRUSH)GetStockObject(NULL_BRUSH),FLAG_DBLCLK|FLAG_BEAMCURSOR)) return 0;
1620 if(!RegWndClass(ComplementWindow,"ComplementWindow",(HBRUSH)GetStockObject(BLACK_BRUSH),FLAG_DBLCLK)) return 0;
1621 if(!RegWndClass(PreviewWndProc,"PreviewWindow",(HBRUSH)GetStockObject(GRAY_BRUSH),FLAG_DBLCLK)) return 0;
1622
1623 //Web検索用のウィンドウクラス
1624 if(!RegWndClass(WebResultWndProc,"WebResult",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
1625 if(!RegWndClass(OneTabProc,"OneTab",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
1626 if(!RegWndClass(ResultListProc,"ResultList",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
1627
1628 //ルーラーのウィンドウクラス
1629 if(!RegWndClass(RulerProc,"Ruler",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
1630
1631 //SideWebのウィンドウクラス
1632 if(!RegWndClass(SideWebProc,"SideWeb",(HBRUSH)COLOR_APPWORKSPACE+1,FLAG_DBLCLK)) return 0;
1633
1634 ActiveBasic::IDE::Program::Main();
1635
1636 //return 0;
1637
1638
1639 hAccel=LoadAccelerators(hResInst,MAKEINTRESOURCE(IDR_ACCELERATOR1));
1640
1641 //メインウィンドウ
1642 RECT *prc;
1643 prc=&pobj_nv->StartupWindowRect;
1644 /*
1645 hOwner=CreateWindowEx(WS_EX_ACCEPTFILES,"ProjectEditorClass",APPLICATION_NAME,
1646 WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
1647 prc->left, prc->top,
1648 prc->right-prc->left, prc->bottom-prc->top,
1649 HWND_DESKTOP,pobj_MainMenu->hMenu,hInst,NULL);
1650 */
1651
1652 //バックアップ用タイマーを設定(10秒に一回)
1653 SetTimer(hOwner,ID_TIMER_BACKUP,10000,NULL);
1654
1655 SendMessage(hOwner,WM_SETICON,ICON_SMALL,(long)hOwnerIcon);
1656 SetClipboardViewer(hOwner);
1657
1658 if(pobj_nv->bWindowMax) ShowWindow(hOwner,SW_MAXIMIZE);
1659 else ShowWindow(hOwner,ShowCmd);
1660 UpdateWindow(hOwner);
1661
1662 int open_sw=0;
1663 if(lstrlen(lpCmdLine)>0){
1664 lstrcpy(dummy,lpCmdLine);
1665 for(i=0,i2=0,IsStr=0;;i++,i2++){
1666 if(dummy[i]=='\"'){
1667 if(IsStr==0) IsStr=1;
1668 else IsStr=0;
1669 i++;
1670 }
1671 if((dummy[i]==' '&&IsStr==0)||dummy[i]=='\0'){
1672 str[i2]=0;
1673 if(!(strstr(str,":")||strstr(str,"\\\\"))){
1674 lstrcpy(str2,str);
1675 GetCurrentDirectory(MAX_PATH,str);
1676 lstrcat(str,"\\");
1677 lstrcat(str,str2);
1678 }
1679 ShortPathToLongPath(str,str2);
1680 OpenFileWithExtension(str2);
1681 open_sw=1;
1682 if(dummy[i]=='\0') break;
1683 i2=-1;
1684 continue;
1685 }
1686 str[i2]=dummy[i];
1687 }
1688 }
1689
1690 BOOL bRestore=0;
1691
1692
1693 {
1694 //自動バックアップ及び復元機能
1695
1696 //必要であれば復元
1697 bRestore=restore();
1698 }
1699
1700
1701#ifdef THETEXT
1702 if(open_sw==0&&bRestore==0){
1703 //ファイルが開かれなかったとき
1704 NewTextEditWindow(NULL,WNDTYPE_TEXT);
1705 }
1706#endif
1707
1708
1709 while(GetMessage(&msg,NULL,0,0)){
1710
1711 if(!TranslateAccelerator(hOwner,hAccel,&msg)){
1712 if( projectInfo.IsOpened() ){
1713 for(i=0,i2=0;i<MAX_WNDNUM;i++){
1714 if(MdiInfo[i].hwnd&&MdiInfo[i].DocType==WNDTYPE_RAD){
1715 if(IsDialogMessage(MdiInfo[i].MdiRadInfo->hProp_Dlg,&msg)) i2=1;
1716 }
1717 }
1718 if(i2==0){
1719 if(!TranslateMDISysAccel(hClient,&msg)){
1720 TranslateMessage(&msg);
1721 DispatchMessage(&msg);
1722 }
1723 }
1724 }
1725 else{
1726 if(!TranslateMDISysAccel(hClient,&msg)){
1727 TranslateMessage(&msg);
1728 DispatchMessage(&msg);
1729 }
1730 }
1731 }
1732 }
1733
1734 DeleteObject(hGrayBrush_LineNumber);
1735
1736#if defined HeapAlloc
1737 CheckHeapCheck();
1738#endif
1739
1740 return msg.wParam;
1741}
Note: See TracBrowser for help on using the repository browser.