1 | #include "Common.h"
|
---|
2 |
|
---|
3 |
|
---|
4 | void ScreenToClient(HWND hwnd,RECT *pRect){
|
---|
5 | ScreenToClient(hwnd,(POINT *)pRect);
|
---|
6 | ScreenToClient(hwnd,(POINT *)(((long)(void *)pRect)+sizeof(POINT)));
|
---|
7 | }
|
---|
8 | void ClientToScreen(HWND hwnd,RECT *pRect){
|
---|
9 | ClientToScreen(hwnd,(POINT *)pRect);
|
---|
10 | ClientToScreen(hwnd,(POINT *)(((long)(void *)pRect)+sizeof(POINT)));
|
---|
11 | }
|
---|
12 |
|
---|
13 |
|
---|
14 | typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE hProcess,PBOOL Wow64Process);
|
---|
15 | BOOL IsWow64(void){
|
---|
16 | ///////////////////////////////////////////////////////////
|
---|
17 | // ProjectEditor.exeがWOW64技術で動作しているのかどうか
|
---|
18 | ///////////////////////////////////////////////////////////
|
---|
19 | BOOL bIsWow64 = FALSE;
|
---|
20 | LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"),"IsWow64Process");
|
---|
21 |
|
---|
22 | if (NULL != fnIsWow64Process)
|
---|
23 | {
|
---|
24 | if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
|
---|
25 | {
|
---|
26 | // handle error
|
---|
27 | bIsWow64 = FALSE;
|
---|
28 | }
|
---|
29 | }
|
---|
30 | return bIsWow64;
|
---|
31 | }
|
---|
32 |
|
---|
33 | void URLEncode(LPSTR pszSrc){
|
---|
34 | char *temp;
|
---|
35 | temp=(char *)malloc(65535);
|
---|
36 |
|
---|
37 | int i,i2;
|
---|
38 | for (i = 0,i2=0; ; i++,i2++)
|
---|
39 | {
|
---|
40 | if(pszSrc[i]=='\0'){
|
---|
41 | temp[i2] = 0;
|
---|
42 | break;
|
---|
43 | }
|
---|
44 |
|
---|
45 | // 英数字 _ . - は変換しないでそのまま
|
---|
46 | if (isalnum((BYTE)pszSrc[i]) || pszSrc[i] == '_' || pszSrc[i] == '.' || pszSrc[i] == '-'){
|
---|
47 | temp[i2] = pszSrc[i];
|
---|
48 | }
|
---|
49 | // それ以外は %3B のような形式に変換
|
---|
50 | else{
|
---|
51 | sprintf(temp+i2,"%%%02X", (BYTE)pszSrc[i]);
|
---|
52 | i2+=lstrlen(temp+i2);
|
---|
53 | i2--;
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | lstrcpy(pszSrc,temp);
|
---|
58 | free(temp);
|
---|
59 | }
|
---|
60 |
|
---|
61 | void Digit(int num,char *buffer){
|
---|
62 | char temporary[255];
|
---|
63 | int i,iPos;
|
---|
64 |
|
---|
65 | sprintf(temporary,"%d",abs(num));
|
---|
66 |
|
---|
67 | //カンマが不要の場合は抜ける
|
---|
68 | if(lstrlen(temporary)<=3){
|
---|
69 | wsprintf(buffer,"%d",num);
|
---|
70 | return;
|
---|
71 | }
|
---|
72 |
|
---|
73 | //合計の文字数からバッファを確保
|
---|
74 | if(num<0){
|
---|
75 | buffer[0]='-';
|
---|
76 | iPos=1;
|
---|
77 | }
|
---|
78 | else{
|
---|
79 | buffer[0]=0;
|
---|
80 | iPos=0;
|
---|
81 | }
|
---|
82 |
|
---|
83 | //3桁毎にカンマを加えながら文字列をコピーする
|
---|
84 | int iFirst;
|
---|
85 | iFirst=lstrlen(temporary)%3;
|
---|
86 | if(iFirst==0) iFirst=3;
|
---|
87 | memcpy(buffer+iPos,temporary,iFirst);
|
---|
88 | iPos+=iFirst;
|
---|
89 |
|
---|
90 | int i2;
|
---|
91 | i2=(lstrlen(temporary)-4)/3;
|
---|
92 |
|
---|
93 | for(i=0;i<=i2;i++){
|
---|
94 | buffer[iPos]=',';
|
---|
95 | iPos++;
|
---|
96 | memcpy(buffer+iPos,temporary+i*3+iFirst,3);
|
---|
97 | iPos+=3;
|
---|
98 | buffer[iPos]=0;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | void RectNaturalFormat(RECT *ReadRect,RECT *CopyRect){
|
---|
103 | if(ReadRect->left > ReadRect->right){
|
---|
104 | CopyRect->left=ReadRect->right;
|
---|
105 | CopyRect->right=ReadRect->left;
|
---|
106 | }
|
---|
107 | else{
|
---|
108 | CopyRect->left=ReadRect->left;
|
---|
109 | CopyRect->right=ReadRect->right;
|
---|
110 | }
|
---|
111 | if(ReadRect->top > ReadRect->bottom){
|
---|
112 | CopyRect->top=ReadRect->bottom;
|
---|
113 | CopyRect->bottom=ReadRect->top;
|
---|
114 | }
|
---|
115 | else{
|
---|
116 | CopyRect->top=ReadRect->top;
|
---|
117 | CopyRect->bottom=ReadRect->bottom;
|
---|
118 | }
|
---|
119 | }
|
---|
120 | void RectNaturalFormat(int *x1,int *y1,int *x2,int *y2){
|
---|
121 | int temp;
|
---|
122 | if(*x1>*x2){
|
---|
123 | temp=*x1;
|
---|
124 | *x1=*x2;
|
---|
125 | *x2=temp;
|
---|
126 | }
|
---|
127 | if(*y1>*y2){
|
---|
128 | temp=*y1;
|
---|
129 | *y1=*y2;
|
---|
130 | *y2=temp;
|
---|
131 | }
|
---|
132 | }
|
---|
133 | void KillSpaces(char *str1,char *str2){
|
---|
134 | int i,i2,IsStr;
|
---|
135 | for(i=0,i2=0,IsStr=0;;i++,i2++){
|
---|
136 | while((str1[i]==' '||str1[i]=='\t')&&IsStr==0&&str1[i]!='\0') i++;
|
---|
137 | if(str1[i]=='\"') IsStr^=1;
|
---|
138 | str2[i2]=str1[i];
|
---|
139 | if(str1[i]=='\0') break;
|
---|
140 | }
|
---|
141 | }
|
---|
142 | void RemoveStringQuotes(char *str){
|
---|
143 | int i;
|
---|
144 | if(str[0]!='\"') return;
|
---|
145 | for(i=0;;i++){
|
---|
146 | str[i]=str[i+1];
|
---|
147 | if(str[i]=='\"') break;
|
---|
148 | }
|
---|
149 | str[i]=0;
|
---|
150 | }
|
---|
151 | void SlideString(char *buffer, int slide){
|
---|
152 | char *temp;
|
---|
153 | temp=(char *)malloc(lstrlen(buffer)+1);
|
---|
154 | lstrcpy(temp,buffer);
|
---|
155 | lstrcpy(buffer+slide,temp);
|
---|
156 | free(temp);
|
---|
157 | }
|
---|
158 | void SlideBuffer(char *buffer,int length,int slide){
|
---|
159 | void *temp;
|
---|
160 | temp=malloc(length+1);
|
---|
161 | memcpy(temp,buffer,length);
|
---|
162 | memcpy(buffer+slide,temp,length);
|
---|
163 | free(temp);
|
---|
164 | }
|
---|
165 | BOOL IsVariableTopChar(char c){
|
---|
166 | if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||c=='_') return 1;
|
---|
167 | return 0;
|
---|
168 | }
|
---|
169 | bool IsNumberChar( char c ){
|
---|
170 | if(c>='0'&&c<='9'){
|
---|
171 | return true;
|
---|
172 | }
|
---|
173 | return false;
|
---|
174 | }
|
---|
175 | BOOL IsVariableChar(char c){
|
---|
176 | if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||
|
---|
177 | c=='_'||c=='.'||c=='$') return 1;
|
---|
178 | return 0;
|
---|
179 | }
|
---|
180 |
|
---|
181 | BOOL IsCommandBackDelimitation(char *buffer,int pos){
|
---|
182 | if(buffer[pos]=='\n'||buffer[pos]==':') return 1;
|
---|
183 | return 0;
|
---|
184 | }
|
---|
185 | BOOL IsCommandDelimitation(char *buffer,int p){
|
---|
186 | if(buffer[p]=='\r'&&buffer[p+1]=='\n') return 2;
|
---|
187 | if(buffer[p]=='\n'||buffer[p]==':'||buffer[p]=='\0') return 1;
|
---|
188 | return 0;
|
---|
189 | }
|
---|
190 |
|
---|
191 | char *ComparisonString( char *str1, char *str2, bool isBigSmall, bool isWordUnit ){
|
---|
192 | char *temp1 = (char *)malloc( lstrlen( str1 ) +1 );
|
---|
193 | char *temp2 = (char *)malloc( lstrlen( str2 ) +1 );
|
---|
194 |
|
---|
195 | lstrcpy( temp1, str1 );
|
---|
196 | lstrcpy( temp2, str2 );
|
---|
197 |
|
---|
198 | if( isBigSmall == false ){
|
---|
199 | // 大文字小文字を区別しない場合
|
---|
200 | // すべて大文字にしておく
|
---|
201 | CharUpper( temp1 );
|
---|
202 | CharUpper( temp2 );
|
---|
203 | }
|
---|
204 |
|
---|
205 | int len2 = lstrlen( temp2 );
|
---|
206 |
|
---|
207 | const char *temp3 = strstr( temp1, temp2 );
|
---|
208 | while( temp3 ){
|
---|
209 | if( isWordUnit ){
|
---|
210 | int pos = (int)temp3 - (int)temp1;
|
---|
211 | if( pos == 0 ){
|
---|
212 | if( !( IsVariableTopChar( temp1[len2] ) || IsNumberChar( temp1[len2] ) ) ){
|
---|
213 | break;
|
---|
214 | }
|
---|
215 | }
|
---|
216 | else{
|
---|
217 | if( !( IsVariableTopChar( temp1[pos-1] ) || IsNumberChar( temp1[pos-1] ) )
|
---|
218 | && !( IsVariableTopChar( temp1[pos+len2] ) || IsNumberChar( temp1[pos+len2] ) )
|
---|
219 | ){
|
---|
220 | break;
|
---|
221 | }
|
---|
222 | }
|
---|
223 | }
|
---|
224 | else{
|
---|
225 | break;
|
---|
226 | }
|
---|
227 |
|
---|
228 | temp3 = strstr( temp3 + 1, temp2 );
|
---|
229 | }
|
---|
230 |
|
---|
231 | char *result = NULL;
|
---|
232 | if( temp3 ){
|
---|
233 | int pos = (int)temp3 - (int)temp1;
|
---|
234 | result = str1 + pos;
|
---|
235 | }
|
---|
236 |
|
---|
237 | free( temp1 );
|
---|
238 | free( temp2 );
|
---|
239 |
|
---|
240 | return result;
|
---|
241 | }
|
---|
242 | int GetOneParameter(char *Parameter,int pos,char *retAns){
|
---|
243 | int i,i2,IsStr,PareNum;
|
---|
244 | for(i=pos,i2=0,IsStr=0,PareNum=0;;i++,i2++){
|
---|
245 | if(IsDBCSLeadByte(Parameter[i])){
|
---|
246 | retAns[i2]=Parameter[i];
|
---|
247 | retAns[++i2]=Parameter[++i];
|
---|
248 | continue;
|
---|
249 | }
|
---|
250 | if(Parameter[i]=='\"') IsStr^=1;
|
---|
251 | if(Parameter[i]=='('&&IsStr==0) PareNum++;
|
---|
252 | if(Parameter[i]==')'&&IsStr==0) PareNum--;
|
---|
253 | if(Parameter[i]==','&&IsStr==0&&PareNum==0){
|
---|
254 | retAns[i2]=0;
|
---|
255 | break;
|
---|
256 | }
|
---|
257 | retAns[i2]=Parameter[i];
|
---|
258 | if(Parameter[i]=='\0'||Parameter[i]=='\r'&&Parameter[i+1]=='\n'){
|
---|
259 | retAns[i2]=0;
|
---|
260 | break;
|
---|
261 | }
|
---|
262 | }
|
---|
263 | if(Parameter[i]==',') i++;
|
---|
264 | return i;
|
---|
265 | }
|
---|
266 | int GetStringInPare(char *buffer,char *ReadBuffer){
|
---|
267 | int i,IsStr,PareNum;
|
---|
268 | for(i=0,IsStr=0,PareNum=0;;i++){
|
---|
269 | buffer[i]=ReadBuffer[i];
|
---|
270 | if(ReadBuffer[i]=='\"') IsStr^=1;
|
---|
271 | else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;
|
---|
272 | else if(ReadBuffer[i]==')'&&IsStr==0){
|
---|
273 | PareNum--;
|
---|
274 | if(PareNum==0){
|
---|
275 | i++;
|
---|
276 | buffer[i]=0;
|
---|
277 | break;
|
---|
278 | }
|
---|
279 | }
|
---|
280 | else if(ReadBuffer[i]=='\0') return 0;
|
---|
281 | }
|
---|
282 | return i;
|
---|
283 | }
|
---|
284 | int GetStringInBracket(char *buffer,char *ReadBuffer){
|
---|
285 | int i,IsStr,PareNum;
|
---|
286 | for(i=0,IsStr=0,PareNum=0;;i++){
|
---|
287 | buffer[i]=ReadBuffer[i];
|
---|
288 | if(IsDBCSLeadByte(ReadBuffer[i])){
|
---|
289 | i++;
|
---|
290 | buffer[i]=ReadBuffer[i];
|
---|
291 | continue;
|
---|
292 | }
|
---|
293 | if(ReadBuffer[i]=='\"') IsStr^=1;
|
---|
294 | else if(ReadBuffer[i]=='['&&IsStr==0) PareNum++;
|
---|
295 | else if(ReadBuffer[i]==']'&&IsStr==0){
|
---|
296 | PareNum--;
|
---|
297 | if(PareNum==0){
|
---|
298 | i++;
|
---|
299 | buffer[i]=0;
|
---|
300 | break;
|
---|
301 | }
|
---|
302 | }
|
---|
303 | else if(ReadBuffer[i]=='\0') return 0;
|
---|
304 | }
|
---|
305 | return i;
|
---|
306 | }
|
---|
307 | void JumpBlank(char *pBuf,int *piPos){
|
---|
308 | int i;
|
---|
309 | i=*piPos;
|
---|
310 |
|
---|
311 | while(1){
|
---|
312 | while(pBuf[i]==' '||pBuf[i]=='\t') i++;
|
---|
313 | if(pBuf[i]=='\0') break;
|
---|
314 | if(pBuf[i]=='\''){
|
---|
315 | //注釈文(一行)
|
---|
316 | for(i++;;i++){
|
---|
317 | if(pBuf[i]=='\0') break;
|
---|
318 | if(pBuf[i]=='\r'&&pBuf[i+1]=='\n'){
|
---|
319 | i+=2;
|
---|
320 | break;
|
---|
321 | }
|
---|
322 | }
|
---|
323 | while(pBuf[i]==' '||pBuf[i]=='\t') i++;
|
---|
324 | }
|
---|
325 | if(pBuf[i]=='/'&&pBuf[i+1]=='*'){
|
---|
326 | //注釈文(複数行)
|
---|
327 | i+=2;
|
---|
328 | while(!(pBuf[i]=='*'&&pBuf[i+1]=='/')){
|
---|
329 | i++;
|
---|
330 | if(pBuf[i]=='\0') break;
|
---|
331 | }
|
---|
332 | if(pBuf[i]){
|
---|
333 | i+=2;
|
---|
334 | }
|
---|
335 | }
|
---|
336 | while(pBuf[i]=='\r'&&pBuf[i+1]=='\n') i+=2;
|
---|
337 |
|
---|
338 | if(!(
|
---|
339 | pBuf[i]==' '||
|
---|
340 | pBuf[i]=='\t'||
|
---|
341 | pBuf[i]=='\''||
|
---|
342 | (pBuf[i]=='/'&&pBuf[i+1]=='*')
|
---|
343 | )) break;
|
---|
344 | }
|
---|
345 |
|
---|
346 | *piPos=i;
|
---|
347 | }
|
---|
348 |
|
---|
349 | BOOL CheckParenthesis(char *buffer){
|
---|
350 | int i,IsStr,PareNum,sw;
|
---|
351 | _int8 bracket[1024];
|
---|
352 |
|
---|
353 | for(i=0,IsStr=0,PareNum=0,sw=0;;i++){
|
---|
354 | if(buffer[i]=='\"'){
|
---|
355 | IsStr^=1;
|
---|
356 | continue;
|
---|
357 | }
|
---|
358 |
|
---|
359 | else if(buffer[i]=='('&&IsStr==0){
|
---|
360 | bracket[PareNum]=0;
|
---|
361 | PareNum++;
|
---|
362 | }
|
---|
363 | else if(buffer[i]=='['&&IsStr==0){
|
---|
364 | bracket[PareNum]=1;
|
---|
365 | PareNum++;
|
---|
366 | }
|
---|
367 |
|
---|
368 | else if(buffer[i]==')'&&IsStr==0){
|
---|
369 | PareNum--;
|
---|
370 | if(bracket[PareNum]!=0||PareNum<0){
|
---|
371 | //"カッコ \'( )\'"
|
---|
372 | return 0;
|
---|
373 | }
|
---|
374 | }
|
---|
375 | else if(buffer[i]==']'&&IsStr==0){
|
---|
376 | PareNum--;
|
---|
377 | if(bracket[PareNum]!=1||PareNum<0){
|
---|
378 | //"カッコ \'( )\'"
|
---|
379 | return 0;
|
---|
380 | }
|
---|
381 | }
|
---|
382 |
|
---|
383 | else if(buffer[i]=='\n'||buffer[i]=='\0'){
|
---|
384 |
|
---|
385 | //"カッコ \'( )\'"
|
---|
386 | if(buffer[i]=='\0'){
|
---|
387 | if(PareNum!=0){
|
---|
388 | return 0;
|
---|
389 | }
|
---|
390 |
|
---|
391 | if(IsStr!=0){
|
---|
392 | return 0;
|
---|
393 | }
|
---|
394 | }
|
---|
395 | if(buffer[i]=='\0') break;
|
---|
396 |
|
---|
397 | sw=0;
|
---|
398 | }
|
---|
399 | }
|
---|
400 | return 1;
|
---|
401 | }
|
---|
402 |
|
---|
403 | DWORD GetValue(char *value){
|
---|
404 | unsigned long ans;
|
---|
405 | if(value[0]=='&'){
|
---|
406 | if(value[1]=='o'||value[1]=='O') sscanf(value+2,"%o",&ans);
|
---|
407 | if(value[1]=='h'||value[1]=='H') sscanf(value+2,"%x",&ans);
|
---|
408 | }
|
---|
409 | else ans=atol(value);
|
---|
410 | return ans;
|
---|
411 | }
|
---|
412 | BOOL IsManagementCommand(int ComNum){
|
---|
413 | switch(ComNum){
|
---|
414 | case -1:
|
---|
415 | case COM_ABSTRACT:
|
---|
416 | case COM_CLASS:
|
---|
417 | case COM_CONST:
|
---|
418 | case COM_DEBUG:
|
---|
419 | case COM_DECLARE:
|
---|
420 | case COM_DEF:
|
---|
421 | case COM_DIM:
|
---|
422 | case COM_DO:
|
---|
423 | case COM_END:
|
---|
424 | case COM_ENUM:
|
---|
425 | case COM_FOR:
|
---|
426 | case COM_FUNCTION:
|
---|
427 | case COM_GOSUB:
|
---|
428 | case COM_GOTO:
|
---|
429 | case COM_IF:
|
---|
430 | case COM_INHERITS:
|
---|
431 | case COM_INTERFACE:
|
---|
432 | case COM_LOOP:
|
---|
433 | case COM_NAMESPACE:
|
---|
434 | case COM_NEXT:
|
---|
435 | case COM_PRIVATE:
|
---|
436 | case COM_PROTECTED:
|
---|
437 | case COM_PUBLIC:
|
---|
438 | case COM_RETURN:
|
---|
439 | case COM_SELECT:
|
---|
440 | case COM_SUB:
|
---|
441 | case COM_TYPE:
|
---|
442 | case COM_TYPEDEF:
|
---|
443 | case COM_VIRTUAL:
|
---|
444 | case COM_OVERRIDE:
|
---|
445 | case COM_WEND:
|
---|
446 | case COM_WHILE:
|
---|
447 | case COM_WITH:
|
---|
448 | return 1;
|
---|
449 | default:
|
---|
450 | break;
|
---|
451 | }
|
---|
452 | return 0;
|
---|
453 | }
|
---|
454 | int IsBasicReservedWord(char *str){
|
---|
455 | if(str[0]=='a'||str[0]=='A'){
|
---|
456 | if(lstrcmpi(str,"Abstract")==0) return COM_ABSTRACT;
|
---|
457 | if(lstrcmpi(str,"As")==0) return -1;
|
---|
458 | }
|
---|
459 | else if(str[0]=='b'||str[0]=='B'){
|
---|
460 | if(lstrcmpi(str,"Beep")==0) return COM_BEEP;
|
---|
461 | if(lstrcmp(str,"Boolean")==0) return -1;
|
---|
462 | if(lstrcmpi(str,"ByRef")==0) return -1;
|
---|
463 | if(lstrcmpi(str,"ByVal")==0) return -1;
|
---|
464 | if(lstrcmp(str,"Byte")==0) return -1;
|
---|
465 | }
|
---|
466 | else if(str[0]=='c'||str[0]=='C'){
|
---|
467 | if(lstrcmpi(str,"Case")==0) return -1;
|
---|
468 | if(lstrcmp(str,"Char")==0) return -1;
|
---|
469 | if(lstrcmpi(str,"ChDir")==0) return COM_CHDIR;
|
---|
470 | if(lstrcmpi(str,"Circle")==0) return COM_CIRCLE;
|
---|
471 | if(lstrcmpi(str,"Class")==0) return COM_CLASS;
|
---|
472 | if(lstrcmpi(str,"Close")==0) return COM_CLOSE;
|
---|
473 | if(lstrcmpi(str,"Cls")==0) return COM_CLS;
|
---|
474 | if(lstrcmpi(str,"Color")==0) return COM_COLOR;
|
---|
475 | if(lstrcmpi(str,"Const")==0) return COM_CONST;
|
---|
476 | if(lstrcmpi(str,"Continue")==0) return -1;
|
---|
477 | }
|
---|
478 | else if(str[0]=='d'||str[0]=='D'){
|
---|
479 | if(lstrcmpi(str,"Debug")==0) return COM_DEBUG;
|
---|
480 | if(lstrcmpi(str,"Declare")==0) return COM_DECLARE;
|
---|
481 | if(lstrcmpi(str,"Def")==0) return COM_DEF;
|
---|
482 | if(lstrcmpi(str,"Delete")==0) return -1;
|
---|
483 | if(lstrcmpi(str,"DelWnd")==0) return COM_DELWND;
|
---|
484 | if(lstrcmpi(str,"Dim")==0) return COM_DIM;
|
---|
485 | if(lstrcmpi(str,"Do")==0) return COM_DO;
|
---|
486 | if(lstrcmp(str,"Double")==0) return -1;
|
---|
487 | if(lstrcmp(str,"DWord")==0) return -1;
|
---|
488 | }
|
---|
489 | else if(str[0]=='e'||str[0]=='E'){
|
---|
490 | if(lstrcmpi(str,"Else")==0) return -1;
|
---|
491 | if(lstrcmpi(str,"ElseIf")==0) return -1;
|
---|
492 | if(lstrcmpi(str,"End")==0) return COM_END;
|
---|
493 | if(lstrcmpi(str,"EndIf")==0) return -1;
|
---|
494 | if(lstrcmpi(str,"EndFunction")==0) return -1;
|
---|
495 | if(lstrcmpi(str,"EndSub")==0) return -1;
|
---|
496 | if(lstrcmpi(str,"EndType")==0) return -1;
|
---|
497 | if(lstrcmpi(str,"EndSelect")==0) return -1;
|
---|
498 | if(lstrcmpi(str,"EndWith")==0) return -1;
|
---|
499 | if(lstrcmpi(str,"Enum")==0) return COM_ENUM;
|
---|
500 | if(lstrcmpi(str,"Exit")==0) return -1;
|
---|
501 | if(lstrcmpi(str,"ExitDo")==0) return -1;
|
---|
502 | if(lstrcmpi(str,"ExitFor")==0) return -1;
|
---|
503 | if(lstrcmpi(str,"ExitFunction")==0) return -1;
|
---|
504 | if(lstrcmpi(str,"ExitSub")==0) return -1;
|
---|
505 | if(lstrcmpi(str,"ExitWhile")==0) return -1;
|
---|
506 | }
|
---|
507 | else if(str[0]=='f'||str[0]=='F'){
|
---|
508 | if(lstrcmp(str,"False")==0) return -1;
|
---|
509 | if(lstrcmpi(str,"Field")==0) return COM_FIELD;
|
---|
510 | if(lstrcmpi(str,"For")==0) return COM_FOR;
|
---|
511 | if(lstrcmpi(str,"Function")==0) return COM_FUNCTION;
|
---|
512 | }
|
---|
513 | else if(str[0]=='g'||str[0]=='G'){
|
---|
514 | if(lstrcmpi(str,"Get")==0) return COM_GET;
|
---|
515 | if(lstrcmpi(str,"GoSub")==0) return COM_GOSUB;
|
---|
516 | if(lstrcmpi(str,"Goto")==0) return COM_GOTO;
|
---|
517 | }
|
---|
518 | else if(str[0]=='i'||str[0]=='I'){
|
---|
519 | if(lstrcmpi(str,"If")==0) return COM_IF;
|
---|
520 | if(lstrcmpi(str,"Imports")==0) return -1;
|
---|
521 | if(lstrcmpi(str,"Inherits")==0) return COM_INHERITS;
|
---|
522 | if(lstrcmpi(str,"Input")==0) return COM_INPUT;
|
---|
523 | if(lstrcmp(str,"Int64")==0) return -1;
|
---|
524 | if(lstrcmp(str,"Integer")==0) return -1;
|
---|
525 | if(lstrcmpi(str,"Interface")==0) return COM_INTERFACE;
|
---|
526 | }
|
---|
527 | else if(str[0]=='k'||str[0]=='K'){
|
---|
528 | if(lstrcmpi(str,"Kill")==0) return COM_KILL;
|
---|
529 | }
|
---|
530 | else if(str[0]=='l'||str[0]=='L'){
|
---|
531 | if(lstrcmpi(str,"Let")==0) return COM_LET;
|
---|
532 | if(lstrcmpi(str,"Line")==0) return COM_LINE;
|
---|
533 | if(lstrcmpi(str,"Locate")==0) return COM_LOCATE;
|
---|
534 | if(lstrcmp(str,"Long")==0) return -1;
|
---|
535 | if(lstrcmpi(str,"Loop")==0) return COM_LOOP;
|
---|
536 | }
|
---|
537 | else if(str[0]=='m'||str[0]=='M'){
|
---|
538 | if(lstrcmpi(str,"MkDir")==0) return COM_MKDIR;
|
---|
539 | if(lstrcmpi(str,"MsgBox")==0) return COM_MSGBOX;
|
---|
540 | }
|
---|
541 | else if(str[0]=='n'||str[0]=='N'){
|
---|
542 | if(lstrcmpi(str,"Namespace")==0) return COM_NAMESPACE;
|
---|
543 | if(lstrcmpi(str,"Next")==0) return COM_NEXT;
|
---|
544 | if(lstrcmpi(str,"New")==0) return -1;
|
---|
545 | if(lstrcmpi(str,"Nothing")==0) return -1;
|
---|
546 | }
|
---|
547 | else if(str[0]=='o'||str[0]=='O'){
|
---|
548 | if(lstrcmp(str,"Object")==0) return -1;
|
---|
549 | if(lstrcmpi(str,"Open")==0) return COM_OPEN;
|
---|
550 | if(lstrcmpi(str,"Operator")==0) return -1;
|
---|
551 | if(lstrcmpi(str,"Override")==0) return COM_OVERRIDE;
|
---|
552 | }
|
---|
553 | else if(str[0]=='p'||str[0]=='P'){
|
---|
554 | if(lstrcmpi(str,"Paint")==0) return COM_PAINT;
|
---|
555 | if(lstrcmpi(str,"Print")==0) return COM_PRINT;
|
---|
556 | if(lstrcmpi(str,"Private")==0) return COM_PRIVATE;
|
---|
557 | if(lstrcmpi(str,"Protected")==0) return COM_PROTECTED;
|
---|
558 | if(lstrcmpi(str,"PSet")==0) return COM_PSET;
|
---|
559 | if(lstrcmpi(str,"Put")==0) return COM_PUT;
|
---|
560 | if(lstrcmpi(str,"Public")==0) return COM_PUBLIC;
|
---|
561 | }
|
---|
562 | else if(str[0]=='q'||str[0]=='Q'){
|
---|
563 | if(lstrcmp(str,"QWord")==0) return -1;
|
---|
564 | }
|
---|
565 | else if(str[0]=='r'||str[0]=='R'){
|
---|
566 | if(lstrcmpi(str,"Randomize")==0) return COM_RANDOMIZE;
|
---|
567 | if(lstrcmpi(str,"Rem")==0) return COM_REM;
|
---|
568 | if(lstrcmpi(str,"Return")==0) return COM_RETURN;
|
---|
569 | }
|
---|
570 | else if(str[0]=='s'||str[0]=='S'){
|
---|
571 | if(lstrcmp(str,"SByte")==0) return -1;
|
---|
572 | if(lstrcmpi(str,"Select")==0) return COM_SELECT;
|
---|
573 | if(lstrcmpi(str,"SelectCase")==0) return COM_SELECT;
|
---|
574 | if(lstrcmp(str,"Single")==0) return -1;
|
---|
575 | if(lstrcmpi(str,"Sleep")==0) return COM_SLEEP;
|
---|
576 | if(lstrcmp(str,"Static")==0) return -1;
|
---|
577 | if(lstrcmp(str,"String")==0) return -1;
|
---|
578 | if(lstrcmpi(str,"Sub")==0) return COM_SUB;
|
---|
579 | if(lstrcmpi(str,"Super")==0) return -1;
|
---|
580 | }
|
---|
581 | else if(str[0]=='t'||str[0]=='T'){
|
---|
582 | if(lstrcmpi(str,"Then")==0) return -1;
|
---|
583 | if(lstrcmpi(str,"This")==0) return -1;
|
---|
584 | if(lstrcmp(str,"True")==0) return -1;
|
---|
585 | if(lstrcmpi(str,"Type")==0) return COM_TYPE;
|
---|
586 | if(lstrcmpi(str,"TypeDef")==0) return COM_TYPEDEF;
|
---|
587 | }
|
---|
588 | else if(str[0]=='u'||str[0]=='U'){
|
---|
589 | if(lstrcmpi(str,"Until")==0) return -1;
|
---|
590 | }
|
---|
591 | else if(str[0]=='v'||str[0]=='V'){
|
---|
592 | if(lstrcmpi(str,"Virtual")==0) return COM_VIRTUAL;
|
---|
593 | }
|
---|
594 | else if(str[0]=='w'||str[0]=='W'){
|
---|
595 | if(lstrcmpi(str,"Wend")==0) return COM_WEND;
|
---|
596 | if(lstrcmpi(str,"While")==0) return COM_WHILE;
|
---|
597 | if(lstrcmpi(str,"Window")==0) return COM_WINDOW;
|
---|
598 | if(lstrcmpi(str,"With")==0) return COM_WITH;
|
---|
599 | if(lstrcmp(str,"Word")==0) return -1;
|
---|
600 | if(lstrcmpi(str,"Write")==0) return COM_WRITE;
|
---|
601 | }
|
---|
602 | else if(str[0]=='#'){
|
---|
603 | if(lstrcmpi(str,"#include")==0) return -1;
|
---|
604 | if(lstrcmpi(str,"#strict")==0) return -1;
|
---|
605 | if(lstrcmpi(str,"#console")==0) return -1;
|
---|
606 | if(lstrcmpi(str,"#prompt")==0) return -1;
|
---|
607 | if(lstrcmpi(str,"#N88BASIC")==0) return -1;
|
---|
608 | if(lstrcmpi(str,"#define")==0) return -1;
|
---|
609 | if(lstrcmpi(str,"#ifdef")==0) return -1;
|
---|
610 | if(lstrcmpi(str,"#ifndef")==0) return -1;
|
---|
611 | if(lstrcmpi(str,"#else")==0) return -1;
|
---|
612 | if(lstrcmpi(str,"#endif")==0) return -1;
|
---|
613 | }
|
---|
614 | return 0;
|
---|
615 | }
|
---|
616 |
|
---|
617 | HBITMAP CreateGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
|
---|
618 | //グラデーションビットマップを生成
|
---|
619 |
|
---|
620 | BITMAPINFO BitmapInfo;
|
---|
621 | memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
|
---|
622 | BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
|
---|
623 | BitmapInfo.bmiHeader.biWidth=pSize->cx;
|
---|
624 | BitmapInfo.bmiHeader.biHeight=pSize->cy;
|
---|
625 | BitmapInfo.bmiHeader.biPlanes=1;
|
---|
626 | BitmapInfo.bmiHeader.biBitCount=24;
|
---|
627 |
|
---|
628 | HDC hdc;
|
---|
629 | hdc=GetDC(GetDesktopWindow());
|
---|
630 |
|
---|
631 | HBITMAP hBitmap;
|
---|
632 | BYTE *pByte;
|
---|
633 | hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
|
---|
634 |
|
---|
635 | int i,i2,x,y;
|
---|
636 | COLORREF rgb;
|
---|
637 | i=BitmapInfo.bmiHeader.biWidth*3;
|
---|
638 | if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
|
---|
639 | for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
|
---|
640 | if(y<BitmapInfo.bmiHeader.biHeight/2-2) rgb=color2;
|
---|
641 | else if(y>BitmapInfo.bmiHeader.biHeight/2+2) rgb=color1;
|
---|
642 | else{
|
---|
643 | double ratio;
|
---|
644 | ratio=((double)y-((double)BitmapInfo.bmiHeader.biHeight/(double)2-(double)2))/(double)4;
|
---|
645 | //ratio=(double)y/(double)BitmapInfo.bmiHeader.biHeight;
|
---|
646 | rgb=RGB(
|
---|
647 | LOBYTE(LOWORD(color2))+(int)(double)(LOBYTE(LOWORD(color1))-LOBYTE(LOWORD(color2)))*(ratio), //赤要素
|
---|
648 | HIBYTE(LOWORD(color2))+(int)(double)(HIBYTE(LOWORD(color1))-HIBYTE(LOWORD(color2)))*(ratio), //緑要素
|
---|
649 | LOBYTE(HIWORD(color2))+(int)(double)(LOBYTE(HIWORD(color1))-LOBYTE(HIWORD(color2)))*(ratio) //青要素
|
---|
650 | );
|
---|
651 | }
|
---|
652 | for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
|
---|
653 | i2=y*i+x*3;
|
---|
654 | pByte[i2+2]=LOBYTE(LOWORD(rgb));
|
---|
655 | pByte[i2+1]=HIBYTE(LOWORD(rgb));
|
---|
656 | pByte[i2]=LOBYTE(HIWORD(rgb));
|
---|
657 | }
|
---|
658 | }
|
---|
659 |
|
---|
660 | ReleaseDC(GetDesktopWindow(),hdc);
|
---|
661 |
|
---|
662 | return hBitmap;
|
---|
663 | }
|
---|
664 | HBITMAP CreateVertGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
|
---|
665 | //グラデーションビットマップを生成
|
---|
666 |
|
---|
667 | BITMAPINFO BitmapInfo;
|
---|
668 | memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
|
---|
669 | BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
|
---|
670 | BitmapInfo.bmiHeader.biWidth=pSize->cx;
|
---|
671 | BitmapInfo.bmiHeader.biHeight=pSize->cy;
|
---|
672 | BitmapInfo.bmiHeader.biPlanes=1;
|
---|
673 | BitmapInfo.bmiHeader.biBitCount=24;
|
---|
674 |
|
---|
675 | HDC hdc;
|
---|
676 | hdc=GetDC(GetDesktopWindow());
|
---|
677 |
|
---|
678 | HBITMAP hBitmap;
|
---|
679 | BYTE *pByte;
|
---|
680 | hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
|
---|
681 |
|
---|
682 | int i,i2,x,y;
|
---|
683 | COLORREF rgb;
|
---|
684 | i=BitmapInfo.bmiHeader.biWidth*3;
|
---|
685 | if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
|
---|
686 | for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
|
---|
687 | if(y<BitmapInfo.bmiHeader.biHeight/2-2) rgb=color2;
|
---|
688 | else if(y>BitmapInfo.bmiHeader.biHeight/2+2) rgb=color1;
|
---|
689 | else{
|
---|
690 | double ratio;
|
---|
691 | ratio=(double)y/(double)BitmapInfo.bmiHeader.biHeight;
|
---|
692 | rgb=RGB(
|
---|
693 | LOBYTE(LOWORD(color2))+(int)(double)(LOBYTE(LOWORD(color1))-LOBYTE(LOWORD(color2)))*(ratio), //赤要素
|
---|
694 | HIBYTE(LOWORD(color2))+(int)(double)(HIBYTE(LOWORD(color1))-HIBYTE(LOWORD(color2)))*(ratio), //緑要素
|
---|
695 | LOBYTE(HIWORD(color2))+(int)(double)(LOBYTE(HIWORD(color1))-LOBYTE(HIWORD(color2)))*(ratio) //青要素
|
---|
696 | );
|
---|
697 | }
|
---|
698 | for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
|
---|
699 | i2=y*i+x*3;
|
---|
700 | pByte[i2+2]=LOBYTE(LOWORD(rgb));
|
---|
701 | pByte[i2+1]=HIBYTE(LOWORD(rgb));
|
---|
702 | pByte[i2]=LOBYTE(HIWORD(rgb));
|
---|
703 | }
|
---|
704 | }
|
---|
705 |
|
---|
706 | ReleaseDC(GetDesktopWindow(),hdc);
|
---|
707 |
|
---|
708 | return hBitmap;
|
---|
709 | }
|
---|
710 | HBITMAP CreateHorzGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
|
---|
711 | //グラデーションビットマップを生成
|
---|
712 |
|
---|
713 | BITMAPINFO BitmapInfo;
|
---|
714 | memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
|
---|
715 | BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
|
---|
716 | BitmapInfo.bmiHeader.biWidth=pSize->cx;
|
---|
717 | BitmapInfo.bmiHeader.biHeight=pSize->cy;
|
---|
718 | BitmapInfo.bmiHeader.biPlanes=1;
|
---|
719 | BitmapInfo.bmiHeader.biBitCount=24;
|
---|
720 |
|
---|
721 | HDC hdc;
|
---|
722 | hdc=GetDC(GetDesktopWindow());
|
---|
723 |
|
---|
724 | HBITMAP hBitmap;
|
---|
725 | BYTE *pByte;
|
---|
726 | hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
|
---|
727 |
|
---|
728 | int i,i2,x,y;
|
---|
729 | COLORREF rgb;
|
---|
730 | i=BitmapInfo.bmiHeader.biWidth*3;
|
---|
731 | if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
|
---|
732 | for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
|
---|
733 | double ratio;
|
---|
734 | ratio=(double)x/(double)BitmapInfo.bmiHeader.biWidth;
|
---|
735 | rgb=RGB(
|
---|
736 | LOBYTE(LOWORD(color1))+(int)(double)(LOBYTE(LOWORD(color2))-LOBYTE(LOWORD(color1)))*(ratio), //赤要素
|
---|
737 | HIBYTE(LOWORD(color1))+(int)(double)(HIBYTE(LOWORD(color2))-HIBYTE(LOWORD(color1)))*(ratio), //緑要素
|
---|
738 | LOBYTE(HIWORD(color1))+(int)(double)(LOBYTE(HIWORD(color2))-LOBYTE(HIWORD(color1)))*(ratio) //青要素
|
---|
739 | );
|
---|
740 | for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
|
---|
741 | i2=y*i+x*3;
|
---|
742 | pByte[i2+2]=LOBYTE(LOWORD(rgb));
|
---|
743 | pByte[i2+1]=HIBYTE(LOWORD(rgb));
|
---|
744 | pByte[i2]=LOBYTE(HIWORD(rgb));
|
---|
745 | }
|
---|
746 | }
|
---|
747 |
|
---|
748 | ReleaseDC(GetDesktopWindow(),hdc);
|
---|
749 |
|
---|
750 | return hBitmap;
|
---|
751 | }
|
---|
752 | HICON CreateGrayIcon(HICON hBaseIcon){
|
---|
753 | ////////////////////////
|
---|
754 | // 淡色アイコンを生成
|
---|
755 | ////////////////////////
|
---|
756 |
|
---|
757 | HICON hGrayIcon;
|
---|
758 |
|
---|
759 | ICONINFO IconInfo;
|
---|
760 | GetIconInfo(hBaseIcon,&IconInfo);
|
---|
761 |
|
---|
762 |
|
---|
763 | //ビットマップを加工
|
---|
764 | BITMAP Bitmap;
|
---|
765 | GetObject(IconInfo.hbmColor,sizeof(Bitmap),&Bitmap);
|
---|
766 |
|
---|
767 | BITMAPINFO BitmapInfo;
|
---|
768 | memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
|
---|
769 | BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
|
---|
770 | BitmapInfo.bmiHeader.biWidth=Bitmap.bmWidth;
|
---|
771 | BitmapInfo.bmiHeader.biHeight=Bitmap.bmHeight;
|
---|
772 | BitmapInfo.bmiHeader.biPlanes=1;
|
---|
773 | BitmapInfo.bmiHeader.biBitCount=24;
|
---|
774 | BitmapInfo.bmiHeader.biCompression=BI_RGB;
|
---|
775 |
|
---|
776 | HDC hdc;
|
---|
777 | hdc=GetDC(GetDesktopWindow());
|
---|
778 |
|
---|
779 | BYTE *pByte;
|
---|
780 | pByte=(BYTE *)HeapAlloc(hHeap,0,Bitmap.bmWidth*Bitmap.bmHeight*sizeof(COLORREF));
|
---|
781 | GetDIBits(hdc,
|
---|
782 | IconInfo.hbmColor,
|
---|
783 | 0,
|
---|
784 | Bitmap.bmHeight,
|
---|
785 | (void *)pByte,
|
---|
786 | &BitmapInfo,
|
---|
787 | DIB_RGB_COLORS);
|
---|
788 |
|
---|
789 | int i,i2,x,y;
|
---|
790 | i=BitmapInfo.bmiHeader.biWidth*3;
|
---|
791 | if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
|
---|
792 | for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
|
---|
793 | for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
|
---|
794 | i2=y*i+x*3;
|
---|
795 | if(pByte[i2+2]==0&&pByte[i2+1]==0&&pByte[i2]==0){
|
---|
796 | //透明色
|
---|
797 | //何もしない
|
---|
798 | }
|
---|
799 | else{
|
---|
800 | double ratio=0.5; //明るさ
|
---|
801 |
|
---|
802 | pByte[i2+2]+=(BYTE)((double)(255-pByte[i2+2])*ratio);
|
---|
803 | pByte[i2+1]+=(BYTE)((double)(255-pByte[i2+1])*ratio);
|
---|
804 | pByte[i2]+=(BYTE)((double)(255-pByte[i2])*ratio);
|
---|
805 |
|
---|
806 | pByte[i2+2]=(BYTE)(((int)pByte[i2+2]+(int)pByte[i2+1]+(int)pByte[i2])/3);
|
---|
807 | pByte[i2+1]=pByte[i2+2];
|
---|
808 | pByte[i2]=pByte[i2+2];
|
---|
809 | }
|
---|
810 | }
|
---|
811 | }
|
---|
812 |
|
---|
813 | SetDIBits(hdc,
|
---|
814 | IconInfo.hbmColor,
|
---|
815 | 0,
|
---|
816 | Bitmap.bmHeight,
|
---|
817 | (void *)pByte,
|
---|
818 | &BitmapInfo,
|
---|
819 | DIB_RGB_COLORS);
|
---|
820 |
|
---|
821 | HeapDefaultFree(pByte);
|
---|
822 |
|
---|
823 | ReleaseDC(GetDesktopWindow(),hdc);
|
---|
824 |
|
---|
825 |
|
---|
826 | hGrayIcon=CreateIconIndirect(&IconInfo);
|
---|
827 |
|
---|
828 | //不要なビットマップを破棄
|
---|
829 | DeleteObject(IconInfo.hbmMask);
|
---|
830 | DeleteObject(IconInfo.hbmColor);
|
---|
831 |
|
---|
832 | return hGrayIcon;
|
---|
833 | }
|
---|
834 | void GetSize(SIZE *pSize,RECT *pRect){
|
---|
835 | pSize->cx=pRect->right-pRect->left;
|
---|
836 | pSize->cy=pRect->bottom-pRect->top;
|
---|
837 | }
|
---|
838 | BOOL HitTest(RECT *pRect,POINT *pPos){
|
---|
839 | if(pRect->left<=pPos->x&&pPos->x<pRect->right&&
|
---|
840 | pRect->top<=pPos->y&&pPos->y<pRect->bottom) return 1;
|
---|
841 | return 0;
|
---|
842 | }
|
---|
843 | BOOL Rectangle(HDC hdc,RECT *pRect){
|
---|
844 | return Rectangle(hdc,pRect->left,pRect->top,pRect->right,pRect->bottom);
|
---|
845 | }
|
---|
846 |
|
---|
847 | void ComboBox_SetSelText(HWND hCombo,char *lpszText){
|
---|
848 | SendMessage(hCombo,CB_SETCURSEL,
|
---|
849 | SendMessage(hCombo,CB_FINDSTRINGEXACT,0,(LPARAM)lpszText),
|
---|
850 | 0);
|
---|
851 | }
|
---|
852 |
|
---|
853 | void SetCursorByState(int state){
|
---|
854 | if(state==FRAME_UPPER_LEFT||state==FRAME_LOWER_RIGHT) SetCursor(LoadCursor(0,IDC_SIZENWSE));
|
---|
855 | else if(state==FRAME_UPPER_RIGHT||state==FRAME_LOWER_LEFT) SetCursor(LoadCursor(0,IDC_SIZENESW));
|
---|
856 | else if(state==FRAME_LEFT||state==FRAME_RIGHT) SetCursor(LoadCursor(0,IDC_SIZEWE));
|
---|
857 | else if(state==FRAME_UPPER||state==FRAME_LOWER) SetCursor(LoadCursor(0,IDC_SIZENS));
|
---|
858 | else if(state==FRAME_INSIDE) SetCursor(LoadCursor(0,IDC_SIZEALL));
|
---|
859 | else SetCursor(LoadCursor(0,IDC_ARROW));
|
---|
860 | }
|
---|
861 |
|
---|
862 | void SetTextEditColorDesign(TEXTEDIT_COLOR_INFO *pColorInfo,CTheme *pobj_Theme,BOOL bRedraw){
|
---|
863 | pColorInfo->rgbDefault=pobj_Theme->TextColorInfo.rgbDefault;
|
---|
864 | pColorInfo->rgbComment=pobj_Theme->TextColorInfo.rgbComment;
|
---|
865 | pColorInfo->rgbStatement=pobj_Theme->TextColorInfo.rgbStatement;
|
---|
866 | pColorInfo->rgbString=pobj_Theme->TextColorInfo.rgbString;
|
---|
867 | pColorInfo->rgbCursorBack=pobj_Theme->TextColorInfo.rgbCursorBack;
|
---|
868 | pColorInfo->rgbBackground=pobj_Theme->TextColorInfo.rgbBackground;
|
---|
869 |
|
---|
870 | //アクティブテーマにセット
|
---|
871 | lstrcpy(pobj_nv->szActiveTheme,pobj_Theme->m_name);
|
---|
872 |
|
---|
873 | //テーマ依存の描画リソースを取得
|
---|
874 | pobj_DBTheme->unlock();
|
---|
875 | pobj_DBTheme->lock();
|
---|
876 |
|
---|
877 | if(bRedraw){
|
---|
878 | //再描画
|
---|
879 | extern MDIINFO MdiInfo[MAX_WNDNUM];
|
---|
880 | int i;
|
---|
881 | for(i=0;i<MAX_WNDNUM;i++){
|
---|
882 | if(MdiInfo[i].hwnd){
|
---|
883 | if(IS_DOCUMENT_TEXT(MdiInfo[i].DocType)){
|
---|
884 | SetTextEditWordColor(i);
|
---|
885 | InvalidateRect(MdiInfo[i].pMdiTextEdit->hEdit,NULL,0);
|
---|
886 | }
|
---|
887 | }
|
---|
888 | }
|
---|
889 | }
|
---|
890 | }
|
---|
891 |
|
---|
892 | BOOL SetupProjectEditor(void){
|
---|
893 | extern HINSTANCE hInst;
|
---|
894 | int i;
|
---|
895 | char str[MAX_PATH],temporary[MAX_PATH];
|
---|
896 |
|
---|
897 |
|
---|
898 | //リソース用DLLをマッピング
|
---|
899 | #if defined(JPN)
|
---|
900 | //日本語リソース
|
---|
901 | sprintf(temporary,"%sSubOperation\\res.dll",pj_editor_Dir);
|
---|
902 | #else
|
---|
903 | //英語リソース
|
---|
904 | sprintf(temporary,"%sSubOperation\\res_e.dll",pj_editor_Dir);
|
---|
905 | #endif
|
---|
906 | hResInst=LoadLibrary(temporary);
|
---|
907 |
|
---|
908 | //アイコンリソースDLLをマッピング
|
---|
909 | sprintf(temporary,"%sSubOperation\\icon_res.dll",pj_editor_Dir);
|
---|
910 | hIconResInst=LoadLibrary(temporary);
|
---|
911 |
|
---|
912 | //LuxCtrl.dllをマッピング
|
---|
913 | sprintf(temporary,"%sSubOperation\\LuxCtrl.dll",pj_editor_Dir);
|
---|
914 | hLib_LuxCtrl=LoadLibrary(temporary);
|
---|
915 | if(!hLib_LuxCtrl){
|
---|
916 | MessageBox(0,"LuxCtrl.dllの読み込みに失敗しました。",APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION);
|
---|
917 | return 0;
|
---|
918 | }
|
---|
919 | LuxToolbar_CreateInstance=
|
---|
920 | (PROC_LuxToolbar_CreateInstance)GetProcAddress(hLib_LuxCtrl,"LuxToolbar_CreateInstance");
|
---|
921 |
|
---|
922 |
|
---|
923 | //モジュールディレクトリを取得
|
---|
924 | GetModuleFileName(hInst,temporary,MAX_PATH);
|
---|
925 | _splitpath(temporary,pj_editor_Dir,str,NULL,NULL);
|
---|
926 | lstrcat(pj_editor_Dir,str);
|
---|
927 |
|
---|
928 | //ヒープオブジェクトを作成
|
---|
929 | extern HANDLE hHeap;
|
---|
930 | hHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0,0);
|
---|
931 |
|
---|
932 |
|
---|
933 | //自動バックアップ用のディレクトリを生成
|
---|
934 | CreateBackupDir();
|
---|
935 |
|
---|
936 |
|
---|
937 | //COMを初期化
|
---|
938 | CoInitialize(0);
|
---|
939 |
|
---|
940 | //スクリーンサイズを取得
|
---|
941 | ScreenX=GetSystemMetrics(SM_CXSCREEN);
|
---|
942 | ScreenY=GetSystemMetrics(SM_CYSCREEN);
|
---|
943 |
|
---|
944 | //コンパイラ名をセット(デフォルトはWin32)
|
---|
945 | extern char *lpszCompilerName;
|
---|
946 | lpszCompilerName=WIN32_COMPILER_NAME;
|
---|
947 |
|
---|
948 | //不揮発性のデータを取得
|
---|
949 | pobj_nv=new CNonVolatile;
|
---|
950 | pobj_nv->load();
|
---|
951 |
|
---|
952 |
|
---|
953 | //アルファブレンド用のAPIを取得
|
---|
954 | extern FWINLAYER pSetLayeredWindowAttributes;
|
---|
955 | extern HINSTANCE hUser32Lib;
|
---|
956 | hUser32Lib=LoadLibrary("user32.dll");
|
---|
957 | pSetLayeredWindowAttributes=(FWINLAYER)GetProcAddress(hUser32Lib,"pSetLayeredWindowAttributes");
|
---|
958 |
|
---|
959 |
|
---|
960 |
|
---|
961 |
|
---|
962 | /////////////////////
|
---|
963 | // フォントを定義
|
---|
964 | /////////////////////
|
---|
965 |
|
---|
966 | //パラメータ ヒント フォント
|
---|
967 | extern METHODCHECKINFO MethodCheckInfo;
|
---|
968 | MethodCheckInfo.hFont=CreateFontIndirect(&MethodCheckInfo.LogFont);
|
---|
969 | i=MethodCheckInfo.LogFont.lfWeight;
|
---|
970 | MethodCheckInfo.LogFont.lfWeight=FW_BOLD;
|
---|
971 | MethodCheckInfo.hBoldFont=CreateFontIndirect(&MethodCheckInfo.LogFont);
|
---|
972 | MethodCheckInfo.LogFont.lfWeight=i;
|
---|
973 |
|
---|
974 | //ステータスバー フォント
|
---|
975 | LOGFONT LogFont;
|
---|
976 | extern HFONT hStatusFont;
|
---|
977 | LogFont.lfHeight=-12;
|
---|
978 | LogFont.lfWidth=0;
|
---|
979 | LogFont.lfEscapement=0;
|
---|
980 | LogFont.lfOrientation=0;
|
---|
981 | LogFont.lfWeight=FW_REGULAR;
|
---|
982 | LogFont.lfItalic=NULL;
|
---|
983 | LogFont.lfUnderline=NULL;
|
---|
984 | LogFont.lfStrikeOut=NULL;
|
---|
985 | LogFont.lfCharSet=SHIFTJIS_CHARSET;
|
---|
986 | LogFont.lfOutPrecision=OUT_STRING_PRECIS;
|
---|
987 | LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
|
---|
988 | LogFont.lfQuality=DRAFT_QUALITY;
|
---|
989 | LogFont.lfPitchAndFamily=VARIABLE_PITCH;
|
---|
990 | sprintf(LogFont.lfFaceName,"MS Pゴシック");
|
---|
991 | hStatusFont=CreateFontIndirect(&LogFont);
|
---|
992 |
|
---|
993 | //ハイパーリンク フォント
|
---|
994 | extern HFONT hHyperLinkFont;
|
---|
995 | LogFont.lfHeight=-12;
|
---|
996 | LogFont.lfWidth=0;
|
---|
997 | LogFont.lfEscapement=0;
|
---|
998 | LogFont.lfOrientation=0;
|
---|
999 | LogFont.lfWeight=FW_REGULAR;
|
---|
1000 | LogFont.lfItalic=NULL;
|
---|
1001 | LogFont.lfUnderline=TRUE;
|
---|
1002 | LogFont.lfStrikeOut=NULL;
|
---|
1003 | LogFont.lfCharSet=SHIFTJIS_CHARSET;
|
---|
1004 | LogFont.lfOutPrecision=OUT_STRING_PRECIS;
|
---|
1005 | LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
|
---|
1006 | LogFont.lfQuality=DRAFT_QUALITY;
|
---|
1007 | LogFont.lfPitchAndFamily=VARIABLE_PITCH;
|
---|
1008 | sprintf(LogFont.lfFaceName,"MS Pゴシック");
|
---|
1009 | hHyperLinkFont=CreateFontIndirect(&LogFont);
|
---|
1010 |
|
---|
1011 | //ルーラー フォント
|
---|
1012 | extern HFONT hRulerFont;
|
---|
1013 | LogFont.lfHeight=-10;
|
---|
1014 | LogFont.lfWidth=0;
|
---|
1015 | LogFont.lfEscapement=0;
|
---|
1016 | LogFont.lfOrientation=0;
|
---|
1017 | LogFont.lfWeight=FW_REGULAR;
|
---|
1018 | LogFont.lfItalic=NULL;
|
---|
1019 | LogFont.lfUnderline=0;
|
---|
1020 | LogFont.lfStrikeOut=NULL;
|
---|
1021 | LogFont.lfCharSet=SHIFTJIS_CHARSET;
|
---|
1022 | LogFont.lfOutPrecision=OUT_STRING_PRECIS;
|
---|
1023 | LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
|
---|
1024 | LogFont.lfQuality=DRAFT_QUALITY;
|
---|
1025 | LogFont.lfPitchAndFamily=VARIABLE_PITCH;
|
---|
1026 | sprintf(LogFont.lfFaceName,"MS ゴシック");
|
---|
1027 | hRulerFont=CreateFontIndirect(&LogFont);
|
---|
1028 |
|
---|
1029 | //行番号の描画用
|
---|
1030 | extern HFONT hFont_LineNumber;
|
---|
1031 | LogFont.lfHeight=-11;
|
---|
1032 | LogFont.lfWidth=0;
|
---|
1033 | LogFont.lfEscapement=0;
|
---|
1034 | LogFont.lfOrientation=0;
|
---|
1035 | LogFont.lfWeight=FW_BOLD;
|
---|
1036 | LogFont.lfItalic=NULL;
|
---|
1037 | LogFont.lfUnderline=NULL;
|
---|
1038 | LogFont.lfStrikeOut=NULL;
|
---|
1039 | LogFont.lfCharSet=ANSI_CHARSET;
|
---|
1040 | LogFont.lfOutPrecision=OUT_STRING_PRECIS;
|
---|
1041 | LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
|
---|
1042 | LogFont.lfQuality=DRAFT_QUALITY;
|
---|
1043 | LogFont.lfPitchAndFamily=VARIABLE_PITCH;
|
---|
1044 | sprintf(LogFont.lfFaceName,"Courier New");
|
---|
1045 | hFont_LineNumber=CreateFontIndirect(&LogFont);
|
---|
1046 |
|
---|
1047 | //メニューフォント
|
---|
1048 | NONCLIENTMETRICS NCMetrics;
|
---|
1049 | NCMetrics.cbSize = sizeof( NONCLIENTMETRICS );
|
---|
1050 | SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( NONCLIENTMETRICS ), &NCMetrics, 0 );
|
---|
1051 | hMenuFont=CreateFontIndirect(&NCMetrics.lfMenuFont);
|
---|
1052 |
|
---|
1053 |
|
---|
1054 |
|
---|
1055 | //背景ブラシ
|
---|
1056 | extern HBRUSH h3DFaceBackBrush;
|
---|
1057 | h3DFaceBackBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
|
---|
1058 |
|
---|
1059 | //アイコン
|
---|
1060 | extern HICON hOwnerIcon,hBasicProgramIcon,hTextDocumentIcon,hWindowDocumentIcon;
|
---|
1061 | hOwnerIcon=(HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
|
---|
1062 | hBasicProgramIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_BASICPROGRAM),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
|
---|
1063 | hTextDocumentIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
|
---|
1064 | hWindowDocumentIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_WINDOW),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
|
---|
1065 |
|
---|
1066 |
|
---|
1067 |
|
---|
1068 |
|
---|
1069 | //メインメニュー
|
---|
1070 | pobj_MainMenu=new CMenuEx(LoadMenu(hResInst,MAKEINTRESOURCE(IDR_MAINMENU)));
|
---|
1071 |
|
---|
1072 | pobj_MainMenu->InitOwnerDraw(1); //オーナー描画の初期化
|
---|
1073 |
|
---|
1074 | CSubMenuEx *pobj_FileMenu;
|
---|
1075 | pobj_FileMenu=pobj_MainMenu->ppobj_MenuItemData[0]->pobj_SubMenu;
|
---|
1076 |
|
---|
1077 | //未完成
|
---|
1078 | extern HMENU hFirstMainMenu;
|
---|
1079 | hFirstMainMenu=0;
|
---|
1080 |
|
---|
1081 | //「最近使ったファイル」サブメニューを取得(と同時にも正規のメニュー文字列を指定)
|
---|
1082 | for(i=0;i<pobj_FileMenu->iMenuItemNum;i++){
|
---|
1083 | if(pobj_FileMenu->ppobj_MenuItemData[i]->str){
|
---|
1084 | if(lstrcmp(pobj_FileMenu->ppobj_MenuItemData[i]->str,"FileHistory")==0){
|
---|
1085 | pobj_FileMenu->RenameMenuItem(i,"最近使ったファイル(&F)");
|
---|
1086 |
|
---|
1087 | extern CSubMenuEx *pobj_FileHistoryMenu;
|
---|
1088 | pobj_FileHistoryMenu=pobj_FileMenu->ppobj_MenuItemData[i]->pobj_SubMenu;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | #ifndef THETEXT
|
---|
1092 | //「最近使ったプロジェクト」サブメニューを取得(と同時にも正規のメニュー文字列を指定)
|
---|
1093 | //※ProjectEditorのみ
|
---|
1094 | if(lstrcmp(pobj_FileMenu->ppobj_MenuItemData[i]->str,"ProjectHistory")==0){
|
---|
1095 | pobj_FileMenu->RenameMenuItem(i,"最近使ったプロジェクト(&J)");
|
---|
1096 |
|
---|
1097 | extern CSubMenuEx *pobj_ProjectHistoryMenu;
|
---|
1098 | pobj_ProjectHistoryMenu=pobj_FileMenu->ppobj_MenuItemData[i]->pobj_SubMenu;
|
---|
1099 | }
|
---|
1100 | #endif
|
---|
1101 | }
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 | #define ICONSET(itemID,iconID) pobj_MainMenu->SetIcon(itemID,(HICON)LoadImage(hIconResInst,MAKEINTRESOURCE(iconID),IMAGE_ICON,16,16,0));
|
---|
1105 | //メニューアイコンをセット
|
---|
1106 |
|
---|
1107 | //ファイル
|
---|
1108 | ICONSET(IDM_NEW,IDI_NEW);
|
---|
1109 | ICONSET(IDM_OPEN,IDI_OPEN);
|
---|
1110 | ICONSET(IDM_SAVE,IDI_SAVE);
|
---|
1111 | ICONSET(IDM_ALLSAVE,IDI_ALLSAVE);
|
---|
1112 | ICONSET(IDM_PREVIEW,IDI_PREVIEW);
|
---|
1113 | ICONSET(IDM_PRINTOUT,IDI_PRINT);
|
---|
1114 |
|
---|
1115 | //編集
|
---|
1116 | ICONSET(IDM_CUT,IDI_CUT);
|
---|
1117 | ICONSET(IDM_COPY,IDI_COPY);
|
---|
1118 | ICONSET(IDM_PASTE,IDI_PASTE);
|
---|
1119 | ICONSET(IDM_UNDO,IDI_UNDO);
|
---|
1120 | ICONSET(IDM_REDO,IDI_REDO);
|
---|
1121 | ICONSET(IDM_FIND,IDI_FIND);
|
---|
1122 |
|
---|
1123 | //表示
|
---|
1124 | ICONSET(IDM_SET,IDI_OPTION);
|
---|
1125 |
|
---|
1126 | //変換
|
---|
1127 | ICONSET(IDM_CONV_ALPHA_SMALL,IDI_CONV_ALPHA_SMALL);
|
---|
1128 | ICONSET(IDM_CONV_ALPHA_BIG,IDI_CONV_ALPHA_BIG);
|
---|
1129 | ICONSET(IDM_CONV_HALF,IDI_CONV_HALF);
|
---|
1130 | ICONSET(IDM_CONV_MULTI,IDI_CONV_MULTI);
|
---|
1131 | ICONSET(IDM_CONV_KATAKANA,IDI_CONV_KATAKANA);
|
---|
1132 | ICONSET(IDM_CONV_HIRAGANA,IDI_CONV_HIRAGANA);
|
---|
1133 |
|
---|
1134 | //ヘルプ
|
---|
1135 | ICONSET(IDM_TOPIC,IDI_HELP);
|
---|
1136 |
|
---|
1137 | #ifdef THETEXT
|
---|
1138 | //TheTextのみの機能
|
---|
1139 | ICONSET(IDM_STRING_COUNT,IDI_STRINGCOUNT);
|
---|
1140 | #else
|
---|
1141 | //ProjectEditorのみの機能
|
---|
1142 |
|
---|
1143 | //リリース
|
---|
1144 | ICONSET(IDM_RELEASECOMPILE,IDI_RELEASECOMPILE);
|
---|
1145 | ICONSET(IDM_RELEASERUN,IDI_RELEASERUN);
|
---|
1146 |
|
---|
1147 | //デバッグ
|
---|
1148 | ICONSET(IDM_ATTACH,IDI_ATTACH);
|
---|
1149 | ICONSET(IDM_DEBUGCOMPILE,IDI_DEBUGCOMPILE);
|
---|
1150 | ICONSET(IDM_DEBUG,IDI_DEBUGRUN);
|
---|
1151 | ICONSET(IDM_BREAKPOINT,IDI_BREAKPOINT);
|
---|
1152 | ICONSET(IDM_STEP_IN,IDI_STEPIN);
|
---|
1153 | ICONSET(IDM_STEP_OVER,IDI_STEPOVER);
|
---|
1154 | ICONSET(IDM_STEP_CURSOR,IDI_STEPTOCURSOR);
|
---|
1155 | ICONSET(IDM_DEBUG_PAUSE,IDI_DEBUGPAUSE);
|
---|
1156 | ICONSET(IDM_DEBUG_STOP,IDI_DEBUGSTOP);
|
---|
1157 |
|
---|
1158 | //コミュニティ
|
---|
1159 | ICONSET(IDM_COMMUNITY,IDI_COMMUNITY_MAIN);
|
---|
1160 | ICONSET(IDM_COMMU_SEARCH,IDI_COMMUNITY_FIND);
|
---|
1161 | ICONSET(IDM_COMMU_PM,IDI_COMMUNITY_PRIVATEMSG);
|
---|
1162 | ICONSET(ID_COMMU_FORUM1,IDI_COMMUNITY_FORUM);
|
---|
1163 | ICONSET(ID_COMMU_FORUM2,IDI_COMMUNITY_FORUM);
|
---|
1164 | ICONSET(ID_COMMU_FORUM3,IDI_COMMUNITY_FORUM);
|
---|
1165 | ICONSET(ID_COMMU_FORUM4,IDI_COMMUNITY_FORUM);
|
---|
1166 | ICONSET(ID_COMMU_FORUM5,IDI_COMMUNITY_FORUM);
|
---|
1167 | ICONSET(ID_COMMU_FORUM6,IDI_COMMUNITY_FORUM_SECRET);
|
---|
1168 | ICONSET(ID_COMMU_FORUM7,IDI_COMMUNITY_FORUM);
|
---|
1169 | ICONSET(ID_COMMU_FORUM8,IDI_COMMUNITY_FORUM);
|
---|
1170 | #endif
|
---|
1171 |
|
---|
1172 | #undef ICONSET
|
---|
1173 |
|
---|
1174 |
|
---|
1175 |
|
---|
1176 |
|
---|
1177 | extern HMENU hEditMenuBase,hEditMenu;
|
---|
1178 | hEditMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_EDITMENU));
|
---|
1179 | hEditMenu=GetSubMenu(hEditMenuBase,0);
|
---|
1180 |
|
---|
1181 | extern HMENU hRebarMenuBase,hRebarMenu;
|
---|
1182 | hRebarMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_REBARMENU));
|
---|
1183 | hRebarMenu=GetSubMenu(hRebarMenuBase,0);
|
---|
1184 |
|
---|
1185 | extern HMENU hTabMenuBase,hTabMenu,hTabColorMenu;
|
---|
1186 | hTabMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_TABMENU));
|
---|
1187 | hTabMenu=GetSubMenu(hTabMenuBase,0);
|
---|
1188 | hTabColorMenu=GetSubMenu(hTabMenu,0);
|
---|
1189 |
|
---|
1190 | extern HMENU hFileTreeMenuBase;
|
---|
1191 | hFileTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_FILETREEMENU));
|
---|
1192 |
|
---|
1193 | extern HMENU hProcedureTreeMenuBase;
|
---|
1194 | hProcedureTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_PROCEDURETREEMENU));
|
---|
1195 |
|
---|
1196 | extern HMENU hMaterialTreeMenuBase;
|
---|
1197 | hMaterialTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_MATERIALTREEMENU));
|
---|
1198 |
|
---|
1199 | extern HMENU hRadMenuBase;
|
---|
1200 | hRadMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_RADCONTEXTMENU));
|
---|
1201 |
|
---|
1202 | //クリップボードのデータ形式(RAD用)を新規登録
|
---|
1203 | extern DWORD dwRadClipboardID;
|
---|
1204 | dwRadClipboardID=RegisterClipboardFormat("ProjectEditor-RAD");
|
---|
1205 |
|
---|
1206 | //256色の標準パレットを読み込む
|
---|
1207 | extern RGBQUAD DefaultColorTable256[256];
|
---|
1208 | HANDLE hFile;
|
---|
1209 | DWORD dw;
|
---|
1210 | sprintf(temporary,"%sSubOperation\\8bit.plt",pj_editor_Dir);
|
---|
1211 | hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
---|
1212 | if(hFile==INVALID_HANDLE_VALUE){
|
---|
1213 | //"\"%s\" ファイルの読み込みに失敗しました。"
|
---|
1214 | sprintf(str,STRING_ERROR_CANT_FILEOPEN,temporary);
|
---|
1215 | MessageBox(NULL,str,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
|
---|
1216 | return 0;
|
---|
1217 | }
|
---|
1218 | ReadFile(hFile,DefaultColorTable256,sizeof(RGBQUAD)*256,&dw,NULL);
|
---|
1219 | CloseHandle(hFile);
|
---|
1220 |
|
---|
1221 |
|
---|
1222 |
|
---|
1223 | //デザインテーマオブジェクトを生成
|
---|
1224 | pobj_DBTheme=new CDBTheme();
|
---|
1225 |
|
---|
1226 |
|
---|
1227 | /////////////////////////
|
---|
1228 | // カラーデザインを設定
|
---|
1229 | CTheme *pobj_Theme;
|
---|
1230 | pobj_Theme=pobj_DBTheme->GetActiveTheme();
|
---|
1231 | if(!pobj_Theme) pobj_Theme=pobj_DBTheme->ppobj_Theme[0];
|
---|
1232 |
|
---|
1233 | SetTextEditColorDesign(&tci,pobj_Theme,0);
|
---|
1234 |
|
---|
1235 |
|
---|
1236 | #ifndef THETEXT
|
---|
1237 | /////////////////////////////////////////////////////
|
---|
1238 | // ProjectEditorのみ
|
---|
1239 | /////////////////////////////////////////////////////
|
---|
1240 |
|
---|
1241 |
|
---|
1242 | //クラスビュー管理オブジェクトを生成
|
---|
1243 | pobj_ClassTreeView=new CClassTreeView();
|
---|
1244 |
|
---|
1245 |
|
---|
1246 | /////////////////////////
|
---|
1247 | // basic.sbpの内容を取得
|
---|
1248 | /////////////////////////
|
---|
1249 |
|
---|
1250 | extern char *pHeaderBuf;
|
---|
1251 | sprintf(temporary,"%sbasic.sbp",pobj_nv->szIncludeDir);
|
---|
1252 | GetFullPath( temporary, pj_editor_Dir );
|
---|
1253 | pHeaderBuf=ReadBuffer(temporary);
|
---|
1254 |
|
---|
1255 | if( !pHeaderBuf ){
|
---|
1256 | pHeaderBuf=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
|
---|
1257 | }
|
---|
1258 |
|
---|
1259 | //ファイルをインクルード
|
---|
1260 | pHeaderBuf=IncludeFiles(pHeaderBuf);
|
---|
1261 |
|
---|
1262 |
|
---|
1263 | //デバッガ管理オブジェクトを生成
|
---|
1264 | pobj_Debugger=new CDebugger();
|
---|
1265 | #endif
|
---|
1266 |
|
---|
1267 |
|
---|
1268 | //ブレークポイント管理オブジェクトを生成
|
---|
1269 | extern CDBBreakPoint *pobj_DBBreakPoint;
|
---|
1270 | pobj_DBBreakPoint=new CDBBreakPoint();
|
---|
1271 |
|
---|
1272 |
|
---|
1273 | return 1;
|
---|
1274 | }
|
---|
1275 | void EndProjectEditor(void){
|
---|
1276 |
|
---|
1277 | #ifndef THETEXT
|
---|
1278 | /////////////////////////////////////////////////////
|
---|
1279 | // ProjectEditorのみ
|
---|
1280 | /////////////////////////////////////////////////////
|
---|
1281 |
|
---|
1282 |
|
---|
1283 | //クラスビュー管理オブジェクトを破棄
|
---|
1284 | delete pobj_ClassTreeView;
|
---|
1285 | pobj_ClassTreeView=0;
|
---|
1286 |
|
---|
1287 | //basic.sbpのソースコードバッファを解放
|
---|
1288 | extern char *pHeaderBuf;
|
---|
1289 | HeapDefaultFree(pHeaderBuf);
|
---|
1290 |
|
---|
1291 | //デバッガ管理オブジェクトを破棄
|
---|
1292 | delete pobj_Debugger;
|
---|
1293 | #endif
|
---|
1294 |
|
---|
1295 | //ブレークポイント管理オブジェクトを破棄
|
---|
1296 | extern CDBBreakPoint *pobj_DBBreakPoint;
|
---|
1297 | delete pobj_DBBreakPoint;
|
---|
1298 |
|
---|
1299 | //デザインテーマオブジェクトを破棄
|
---|
1300 | delete pobj_DBTheme;
|
---|
1301 |
|
---|
1302 | //不揮発性のデータを保存
|
---|
1303 | pobj_nv->save();
|
---|
1304 | delete pobj_nv;
|
---|
1305 | pobj_nv=0;
|
---|
1306 |
|
---|
1307 | //メインメニューオブジェクトを破棄
|
---|
1308 | delete pobj_MainMenu;
|
---|
1309 | pobj_MainMenu=0;
|
---|
1310 |
|
---|
1311 | extern HFONT hStatusFont;
|
---|
1312 | DeleteObject(hStatusFont);
|
---|
1313 | extern HFONT hHyperLinkFont;
|
---|
1314 | DeleteObject(hHyperLinkFont);
|
---|
1315 | extern HFONT hRulerFont;
|
---|
1316 | DeleteObject(hRulerFont);
|
---|
1317 | extern HFONT hFont_LineNumber;
|
---|
1318 | DeleteObject(hFont_LineNumber);
|
---|
1319 | extern METHODCHECKINFO MethodCheckInfo;
|
---|
1320 | DeleteObject(MethodCheckInfo.hFont);
|
---|
1321 | DeleteObject(MethodCheckInfo.hBoldFont);
|
---|
1322 | extern HICON hOwnerIcon,hBasicProgramIcon,hTextDocumentIcon,hWindowDocumentIcon;
|
---|
1323 | DestroyIcon(hOwnerIcon);
|
---|
1324 | DestroyIcon(hBasicProgramIcon);
|
---|
1325 | DestroyIcon(hTextDocumentIcon);
|
---|
1326 | DestroyIcon(hWindowDocumentIcon);
|
---|
1327 | extern HMENU hEditMenuBase,hRebarMenuBase,hTabMenuBase;
|
---|
1328 | DestroyMenu(hEditMenuBase);
|
---|
1329 | DestroyMenu(hRebarMenuBase);
|
---|
1330 | DestroyMenu(hTabMenuBase);
|
---|
1331 | extern HMENU hFileTreeMenuBase;
|
---|
1332 | DestroyMenu(hFileTreeMenuBase);
|
---|
1333 | extern HMENU hProcedureTreeMenuBase;
|
---|
1334 | DestroyMenu(hProcedureTreeMenuBase);
|
---|
1335 | extern HMENU hMaterialTreeMenuBase;
|
---|
1336 | DestroyMenu(hMaterialTreeMenuBase);
|
---|
1337 | extern HMENU hRadMenuBase;
|
---|
1338 | DestroyMenu(hRadMenuBase);
|
---|
1339 |
|
---|
1340 | //背景ブラシ
|
---|
1341 | extern HBRUSH h3DFaceBackBrush;
|
---|
1342 | DeleteObject(h3DFaceBackBrush);
|
---|
1343 |
|
---|
1344 | //スタンダードツールバーを破棄
|
---|
1345 | if(pobj_StandardToolbar){
|
---|
1346 | pobj_StandardToolbar->Release();
|
---|
1347 | pobj_StandardToolbar=0;
|
---|
1348 | }
|
---|
1349 |
|
---|
1350 | //ビルドツールバーを破棄
|
---|
1351 | if(pobj_ReleaseToolbar){
|
---|
1352 | pobj_ReleaseToolbar->Release();
|
---|
1353 | pobj_ReleaseToolbar=0;
|
---|
1354 | }
|
---|
1355 |
|
---|
1356 | //デバッガ用ツールバーを破棄
|
---|
1357 | if(pobj_DebuggerToolbar){
|
---|
1358 | pobj_DebuggerToolbar->Release();
|
---|
1359 | pobj_DebuggerToolbar=0;
|
---|
1360 | }
|
---|
1361 |
|
---|
1362 | //ヒープオブジェクトを解放
|
---|
1363 | extern HANDLE hHeap;
|
---|
1364 | HeapDestroy(hHeap);
|
---|
1365 |
|
---|
1366 | //DLLを解放
|
---|
1367 | FreeLibrary(hResInst);
|
---|
1368 | FreeLibrary(hIconResInst);
|
---|
1369 | FreeLibrary(hLib_LuxCtrl);
|
---|
1370 |
|
---|
1371 | //アルファブレンド用のAPIを解放
|
---|
1372 | extern HINSTANCE hUser32Lib;
|
---|
1373 | FreeLibrary(hUser32Lib);
|
---|
1374 |
|
---|
1375 |
|
---|
1376 |
|
---|
1377 |
|
---|
1378 | //////////////////////////////////////
|
---|
1379 | // バックアップ用ファイルを削除
|
---|
1380 | //////////////////////////////////////
|
---|
1381 | extern char szBackupDirPath[MAX_PATH];
|
---|
1382 | RemoveDirectoryStrong(szBackupDirPath);
|
---|
1383 |
|
---|
1384 | }
|
---|
1385 |
|
---|
1386 | //各ウィンドウ生成
|
---|
1387 | void SetupWindow(HWND hwnd){
|
---|
1388 | extern HINSTANCE hInst;
|
---|
1389 | extern HMENU hFirstMainMenu;
|
---|
1390 | RECT rect;
|
---|
1391 | CLIENTCREATESTRUCT ccs;
|
---|
1392 |
|
---|
1393 | INITCOMMONCONTROLSEX InitCommCtrl;
|
---|
1394 | InitCommCtrl.dwSize=sizeof(INITCOMMONCONTROLSEX);
|
---|
1395 | InitCommCtrl.dwICC=ICC_COOL_CLASSES|ICC_PAGESCROLLER_CLASS|ICC_WIN95_CLASSES|ICC_TAB_CLASSES;
|
---|
1396 | InitCommonControlsEx(&InitCommCtrl);
|
---|
1397 |
|
---|
1398 | //タブウィンドウ
|
---|
1399 | pobj_MainTab=new CMainTab(hwnd);
|
---|
1400 |
|
---|
1401 | //MDIの親ウィンドウ(クライアントウィンドウ)を作成
|
---|
1402 | ccs.hWindowMenu=hFirstMainMenu;
|
---|
1403 | ccs.idFirstChild=ID_FIRSTCHILD;
|
---|
1404 | GetClientRect(hwnd,&rect);
|
---|
1405 | hClient=CreateWindowEx(WS_EX_CLIENTEDGE,"MDICLIENT",NULL,
|
---|
1406 | WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VISIBLE,
|
---|
1407 | 0,0,0,0,
|
---|
1408 | hwnd,(HMENU)1,hInst,(LPSTR)&ccs);
|
---|
1409 |
|
---|
1410 | //レバーオブジェクトを生成
|
---|
1411 | pobj_Rebar=new CMainRebar(hwnd);
|
---|
1412 |
|
---|
1413 | //ステータスバー
|
---|
1414 | extern HWND hStatusBar;
|
---|
1415 | extern HFONT hStatusFont;
|
---|
1416 | hStatusBar=CreateStatusWindow(
|
---|
1417 | WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBARS_SIZEGRIP|CCS_BOTTOM,
|
---|
1418 | NULL,hwnd,NULL);
|
---|
1419 | SendMessage(hStatusBar,WM_SETFONT,(long)hStatusFont,0);
|
---|
1420 |
|
---|
1421 | //プロジェクト ビュー
|
---|
1422 | extern HWND hProjectView;
|
---|
1423 | extern HWND hProjectView_ToolWindow;
|
---|
1424 | RECT *prc;
|
---|
1425 | prc=&pobj_nv->rectProjectView;
|
---|
1426 | hProjectView_ToolWindow=CreateWindowEx(WS_EX_TOOLWINDOW,"ProjectView_ToolWindow","ProjectView",
|
---|
1427 | WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_CLIPCHILDREN,
|
---|
1428 | prc->left,prc->top,prc->right-prc->left,prc->bottom-prc->top,
|
---|
1429 | hwnd,0,hInst,0);
|
---|
1430 | hProjectView=CreateWindowEx(WS_EX_STATICEDGE,"ProjectView","ProjectView",
|
---|
1431 | WS_CHILD|WS_CLIPCHILDREN,
|
---|
1432 | 0,0,0,0,
|
---|
1433 | hwnd,0,hInst,0);
|
---|
1434 | if(pobj_nv->bClipProjectView==0){
|
---|
1435 | SetWindowLong(hProjectView,GWL_EXSTYLE,0);
|
---|
1436 | SetParent(hProjectView,hProjectView_ToolWindow);
|
---|
1437 | ResizeProjectView_ToolWindow();
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | //メニュー状態を設定
|
---|
1441 | ResetState_DocMenu();
|
---|
1442 |
|
---|
1443 |
|
---|
1444 | //SideWebを生成
|
---|
1445 | pobj_SideWeb=new CSideWeb(hwnd);
|
---|
1446 | }
|
---|
1447 |
|
---|
1448 | //実行コマンド
|
---|
1449 | BOOL SetRunning(HWND hChild){
|
---|
1450 | extern MDIINFO MdiInfo[MAX_WNDNUM];
|
---|
1451 | extern LPSTR DefFileFilter;
|
---|
1452 | int WndNum;
|
---|
1453 | char temporary[MAX_PATH],temp2[MAX_PATH];
|
---|
1454 | HANDLE hFind;
|
---|
1455 | WIN32_FIND_DATA wfd;
|
---|
1456 |
|
---|
1457 | extern char *lpszCompilerName;
|
---|
1458 | sprintf(temporary,"%s%s",pj_editor_Dir,lpszCompilerName);
|
---|
1459 | hFind=FindFirstFile(temporary,&wfd);
|
---|
1460 | if(hFind==INVALID_HANDLE_VALUE){
|
---|
1461 | //"BasicCompiler.exe が見つかりません"
|
---|
1462 | MessageBox(hOwner,STRING_ERROR_NOBASICCOMPILER,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
|
---|
1463 | return FALSE;
|
---|
1464 | }
|
---|
1465 | FindClose(hFind);
|
---|
1466 |
|
---|
1467 | WndNum=GetWndNum(hChild);
|
---|
1468 | if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
|
---|
1469 | if(MdiInfo[WndNum].path[0]=='\0'){
|
---|
1470 | //"保存先のファイルを指定してください"
|
---|
1471 | if(!GetFilePathDialog(hOwner,temp2,DefFileFilter,STRING_FILESAVETITLE_DEFAULT,0)) return FALSE;
|
---|
1472 |
|
---|
1473 | if(!SaveDocument(hChild,temp2)) return 0;
|
---|
1474 | }
|
---|
1475 | else{
|
---|
1476 | if( MdiInfo[WndNum].pMdiTextEdit->IsModified() ){
|
---|
1477 | if(!SaveDocument(hChild,NULL)) return 0;
|
---|
1478 | }
|
---|
1479 | else{
|
---|
1480 | if(hFind=FindFirstFile(MdiInfo[WndNum].path,&wfd)){
|
---|
1481 | if(hFind==INVALID_HANDLE_VALUE){
|
---|
1482 | if(!SaveDocument(hChild,NULL)) return 0;
|
---|
1483 | }
|
---|
1484 | else FindClose(hFind);
|
---|
1485 | }
|
---|
1486 | }
|
---|
1487 | }
|
---|
1488 | }
|
---|
1489 | return 1;
|
---|
1490 | }
|
---|
1491 |
|
---|
1492 | BOOL IsNeedCompile(char *FileName,BOOL bDebug){
|
---|
1493 | char temporary[MAX_PATH],temp2[MAX_PATH],temp3[MAX_PATH];
|
---|
1494 | HANDLE hFind,hFile;
|
---|
1495 | WIN32_FIND_DATA wfd;
|
---|
1496 | FILETIME SourceTime,ExeTime;
|
---|
1497 |
|
---|
1498 | _splitpath(FileName,temporary,temp2,temp3,NULL);
|
---|
1499 | lstrcat(temporary,temp2);
|
---|
1500 | lstrcat(temporary,temp3);
|
---|
1501 | if(bDebug) lstrcat(temporary,"_debug.exe");
|
---|
1502 | else lstrcat(temporary,".exe");
|
---|
1503 |
|
---|
1504 | hFind=FindFirstFile(temporary,&wfd);
|
---|
1505 | if(hFind==INVALID_HANDLE_VALUE) return 1;
|
---|
1506 | FindClose(hFind);
|
---|
1507 |
|
---|
1508 | hFile=CreateFile(FileName,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
---|
1509 | GetFileTime(hFile,NULL,NULL,&SourceTime);
|
---|
1510 | CloseHandle(hFile);
|
---|
1511 |
|
---|
1512 | hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
---|
1513 | GetFileTime(hFile,NULL,NULL,&ExeTime);
|
---|
1514 | CloseHandle(hFile);
|
---|
1515 |
|
---|
1516 | if(SourceTime.dwHighDateTime<ExeTime.dwHighDateTime) return 0;
|
---|
1517 | else if(SourceTime.dwHighDateTime==ExeTime.dwHighDateTime&&
|
---|
1518 | SourceTime.dwLowDateTime<=ExeTime.dwLowDateTime) return 0;
|
---|
1519 | return 1;
|
---|
1520 | }
|
---|
1521 |
|
---|
1522 | string GetLastErrorString(){
|
---|
1523 | char *lpMsgBuf;
|
---|
1524 |
|
---|
1525 | FormatMessage(
|
---|
1526 | FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
---|
1527 | FORMAT_MESSAGE_FROM_SYSTEM |
|
---|
1528 | FORMAT_MESSAGE_IGNORE_INSERTS,
|
---|
1529 | NULL,
|
---|
1530 | GetLastError(),
|
---|
1531 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // デフォルト言語
|
---|
1532 | (LPTSTR) &lpMsgBuf,
|
---|
1533 | 0,
|
---|
1534 | NULL
|
---|
1535 | );
|
---|
1536 |
|
---|
1537 | string result = lpMsgBuf;
|
---|
1538 |
|
---|
1539 | LocalFree( lpMsgBuf );
|
---|
1540 |
|
---|
1541 | return result;
|
---|
1542 | }
|
---|