source: dev/ProjectEditor/RadSupport.cpp@ 54

Last change on this file since 54 was 3, checked in by dai_9181, 18 years ago
File size: 11.9 KB
Line 
1#include "common.h"
2
3#if defined(JPN)
4//日本語
5#include "rad_msg_jpn.h"
6#else
7//英語
8#include "rad_msg_eng.h"
9#endif
10
11int bSupportDlg_NoChange;
12
13LRESULT CALLBACK TestWindowProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
14 switch(message){
15 case WM_CREATE:
16 SetPosCenter(hwnd);
17 break;
18 case WM_KEYDOWN:
19 if(wParam==VK_ESCAPE) DestroyWindow(hwnd);
20 break;
21 case WM_PAINT:
22 break;
23 case WM_CLOSE:
24 DestroyWindow(hwnd);
25 break;
26 case WM_DESTROY:
27 PostQuitMessage(0);
28 break;
29 }
30 return DefWindowProc(hwnd,message,wParam,lParam);
31}
32
33void ShowTestWindow(int WndInfoNum){
34 extern HINSTANCE hInst;
35 extern HANDLE hHeap;
36 extern PROJECTINFO ProjectInfo;
37 static HWND hWnd;
38 WINDOW_INFO *pWindowInfo;
39 HWND hChild;
40 HFONT *lphFont;
41 HANDLE *lphImage;
42 int i2,i3;
43 char temporary[MAX_PATH];
44
45 if(hWnd){
46 OpenIcon(hWnd);
47
48 _endthread();
49 return;
50 }
51
52 pWindowInfo=&ProjectInfo.pWindowInfo[WndInfoNum];
53
54 if(pWindowInfo->style&WS_CHILD){
55 //"チャイルドウィンドウをテスト表示することはできません"
56 MessageBox(hOwner,STRING_RAD_ERROR_CANT_CHILDTEST,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
57
58 _endthread();
59 return;
60 }
61
62 lphFont=(HFONT *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,pWindowInfo->NumberOfChildWindows*sizeof(DWORD));
63 lphImage=(HANDLE *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,pWindowInfo->NumberOfChildWindows*sizeof(DWORD));
64
65 //テスト用のメインウィンドウを作成
66 hWnd=CreateWindowEx(pWindowInfo->ExStyle,
67 "TestWindow",
68 pWindowInfo->name,
69 pWindowInfo->style|WS_VISIBLE,
70 CW_USEDEFAULT,CW_USEDEFAULT,
71 pWindowInfo->size.cx,pWindowInfo->size.cy,
72 hOwner,NULL,hInst,NULL);
73
74 //子ウィンドウ作成
75 for(i2=0;i2<pWindowInfo->NumberOfChildWindows;i2++){
76 if(pWindowInfo->pChildInfo[i2].Control==CT_UPDOWN){
77 CreateUpDownControl(
78 pWindowInfo->pChildInfo[i2].style,
79 pWindowInfo->pChildInfo[i2].pos.x,pWindowInfo->pChildInfo[i2].pos.y,
80 pWindowInfo->pChildInfo[i2].size.cx,pWindowInfo->pChildInfo[i2].size.cy,
81 hWnd,0,hInst,
82 0,0,100,0);
83 }
84 else{
85 GetItemClassName(temporary,pWindowInfo->pChildInfo[i2].Control);
86 hChild=CreateWindowEx(
87 pWindowInfo->pChildInfo[i2].ExStyle,
88 temporary,
89 pWindowInfo->pChildInfo[i2].caption,
90 pWindowInfo->pChildInfo[i2].style,
91 pWindowInfo->pChildInfo[i2].pos.x,
92 pWindowInfo->pChildInfo[i2].pos.y,
93 pWindowInfo->pChildInfo[i2].size.cx,
94 pWindowInfo->pChildInfo[i2].size.cy,
95 hWnd,0,hInst,0);
96
97 lphFont[i2]=CreateFontIndirect(&pWindowInfo->LogFont);
98 SendMessage(hChild,WM_SETFONT,(long)lphFont[i2],0);
99
100 if(pWindowInfo->pChildInfo[i2].Control==CT_IMAGEBOX){
101 ///////////////////////////
102 // イメージ ボックスの場合
103 ///////////////////////////
104 if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_ICON){
105 if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_FILE)
106 lstrcpy(temporary,pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path);
107 else{
108 for(i3=0;i3<ProjectInfo.res.NumberOfIconRes;i3++){
109 if(lstrcmp(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,
110 ProjectInfo.res.pIconResInfo[i3].IdName)==0) break;
111 }
112 if(i3==ProjectInfo.res.NumberOfIconRes) temporary[0]=0;
113 else lstrcpy(temporary,ProjectInfo.res.pIconResInfo[i3].path);
114 }
115 if(temporary[0]){
116 GetFullPath(temporary,ProjectInfo.dir);
117 lphImage[i2]=LoadImage(hInst,temporary,IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
118
119 SendMessage(hChild,STM_SETICON,(long)lphImage[i2],0);
120 }
121 }
122 else if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_BITMAP){
123 if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_FILE)
124 lstrcpy(temporary,pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path);
125 else{
126 for(i3=0;i3<ProjectInfo.res.NumberOfBitmapRes;i3++){
127 if(lstrcmp(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,
128 ProjectInfo.res.pBitmapResInfo[i3].IdName)==0) break;
129 }
130 if(i3==ProjectInfo.res.NumberOfBitmapRes) temporary[0]=0;
131 else lstrcpy(temporary,ProjectInfo.res.pBitmapResInfo[i3].path);
132 }
133 if(temporary[0]){
134 GetFullPath(temporary,ProjectInfo.dir);
135 lphImage[i2]=LoadImage(hInst,temporary,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
136
137 SendMessage(hChild,STM_SETIMAGE,IMAGE_BITMAP,(long)lphImage[i2]);
138 }
139 }
140 }
141 }
142 }
143
144 MSG msg;
145 while(GetMessage(&msg,NULL,0,0)){
146 if(IsDialogMessage(hWnd,&msg)) continue;
147 TranslateMessage(&msg);
148 DispatchMessage(&msg);
149 }
150
151 //フォントハンドルを破棄
152 for(i2=0;i2<pWindowInfo->NumberOfChildWindows;i2++){
153 if(lphFont[i2]) DeleteObject(lphFont[i2]);
154 }
155 HeapDefaultFree(lphFont);
156
157 //イメージハンドルを破棄
158 for(i2=0;i2<pWindowInfo->NumberOfChildWindows;i2++){
159 if(lphImage[i2]){
160 if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_ICON)
161 DestroyIcon((HICON)lphImage[i2]);
162 else if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_BITMAP)
163 DeleteObject(lphImage[i2]);
164 }
165 }
166 HeapDefaultFree(lphImage);
167
168 hWnd=0;
169
170 _endthread();
171}
172
173void SetSupportDlgData(int WndNum,int WndInfoNum){
174 ////////////////////////////////////
175 // サポートダイアログの内容をセット
176 ////////////////////////////////////
177 extern PROJECTINFO ProjectInfo;
178 extern MDIINFO MdiInfo[MAX_WNDNUM];
179 extern RADINFO RadInfo;
180 char temporary[255];
181 HWND hSupport;
182
183 bSupportDlg_NoChange=1;
184
185 hSupport=MdiInfo[WndNum].MdiRadInfo->hSupport;
186
187 if(RadInfo.NowDragging>=FRAME_CHANGEPOS_START&&RadInfo.NowDragging<=FRAME_CHANGEPOS_END&&
188 (!(MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]!=-1&&MdiInfo[WndNum].MdiRadInfo->SelectingItem[1]!=-1))){
189 sprintf(temporary,"%d",RadInfo.DraggingRect[0].left-MdiInfo[WndNum].MdiRadInfo->ClientPos.x);
190 SetDlgItemText(hSupport,IDC_XPOS,temporary);
191
192 sprintf(temporary,"%d",RadInfo.DraggingRect[0].top-MdiInfo[WndNum].MdiRadInfo->ClientPos.y);
193 SetDlgItemText(hSupport,IDC_YPOS,temporary);
194
195 sprintf(temporary,"%d",RadInfo.DraggingRect[0].right-RadInfo.DraggingRect[0].left);
196 SetDlgItemText(hSupport,IDC_WIDTH,temporary);
197
198 sprintf(temporary,"%d",RadInfo.DraggingRect[0].bottom-RadInfo.DraggingRect[0].top);
199 SetDlgItemText(hSupport,IDC_HEIGHT,temporary);
200 }
201 else if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW){
202 EnableWindow(GetDlgItem(hSupport,IDC_XPOS),0);
203 EnableWindow(GetDlgItem(hSupport,IDC_YPOS),0);
204 EnableWindow(GetDlgItem(hSupport,IDC_SPIN1),0);
205 EnableWindow(GetDlgItem(hSupport,IDC_SPIN2),0);
206 EnableWindow(GetDlgItem(hSupport,IDC_SPIN3),1);
207 EnableWindow(GetDlgItem(hSupport,IDC_SPIN4),1);
208
209 SetDlgItemText(hSupport,IDC_XPOS,"");
210 SetDlgItemText(hSupport,IDC_YPOS,"");
211
212 sprintf(temporary,"%d",ProjectInfo.pWindowInfo[WndInfoNum].size.cx);
213 SetDlgItemText(hSupport,IDC_WIDTH,temporary);
214
215 sprintf(temporary,"%d",ProjectInfo.pWindowInfo[WndInfoNum].size.cy);
216 SetDlgItemText(hSupport,IDC_HEIGHT,temporary);
217 }
218 else{
219 EnableWindow(GetDlgItem(hSupport,IDC_XPOS),1);
220 EnableWindow(GetDlgItem(hSupport,IDC_YPOS),1);
221
222 if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[1]!=-1){
223 EnableWindow(GetDlgItem(hSupport,IDC_SPIN1),0);
224 EnableWindow(GetDlgItem(hSupport,IDC_SPIN2),0);
225 EnableWindow(GetDlgItem(hSupport,IDC_SPIN3),0);
226 EnableWindow(GetDlgItem(hSupport,IDC_SPIN4),0);
227
228 SetDlgItemText(hSupport,IDC_XPOS,"");
229 SetDlgItemText(hSupport,IDC_YPOS,"");
230 SetDlgItemText(hSupport,IDC_WIDTH,"");
231 SetDlgItemText(hSupport,IDC_HEIGHT,"");
232 }
233 else{
234 EnableWindow(GetDlgItem(hSupport,IDC_SPIN1),1);
235 EnableWindow(GetDlgItem(hSupport,IDC_SPIN2),1);
236 EnableWindow(GetDlgItem(hSupport,IDC_SPIN3),1);
237 EnableWindow(GetDlgItem(hSupport,IDC_SPIN4),1);
238
239 sprintf(temporary,"%d",ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.x);
240 SetDlgItemText(hSupport,IDC_XPOS,temporary);
241
242 sprintf(temporary,"%d",ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.y);
243 SetDlgItemText(hSupport,IDC_YPOS,temporary);
244
245 sprintf(temporary,"%d",ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].size.cx);
246 SetDlgItemText(hSupport,IDC_WIDTH,temporary);
247
248 sprintf(temporary,"%d",ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].size.cy);
249 SetDlgItemText(hSupport,IDC_HEIGHT,temporary);
250 }
251 }
252
253 bSupportDlg_NoChange=0;
254}
255
256BOOL CALLBACK DlgRadSupport(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
257 extern PROJECTINFO ProjectInfo;
258 extern MDIINFO MdiInfo[MAX_WNDNUM];
259 static BOOL bTimer;
260 int i,i2,i3;
261 char temporary[255];
262 POINTANDSIZE PointAndSize;
263 RECT rect;
264
265 switch(message){
266 case WM_INITDIALOG:
267 SendDlgItemMessage(hwnd,IDC_SPIN1,UDM_SETBUDDY,(long)GetDlgItem(hwnd,IDC_XPOS),0);
268 SendDlgItemMessage(hwnd,IDC_SPIN2,UDM_SETBUDDY,(long)GetDlgItem(hwnd,IDC_YPOS),0);
269 SendDlgItemMessage(hwnd,IDC_SPIN3,UDM_SETBUDDY,(long)GetDlgItem(hwnd,IDC_WIDTH),0);
270 SendDlgItemMessage(hwnd,IDC_SPIN4,UDM_SETBUDDY,(long)GetDlgItem(hwnd,IDC_HEIGHT),0);
271
272 SendDlgItemMessage(hwnd,IDC_SPIN1,UDM_SETRANGE32,0,0x7FFF);
273 SendDlgItemMessage(hwnd,IDC_SPIN2,UDM_SETRANGE32,0,0x7FFF);
274 SendDlgItemMessage(hwnd,IDC_SPIN3,UDM_SETRANGE32,0,0x7FFF);
275 SendDlgItemMessage(hwnd,IDC_SPIN4,UDM_SETRANGE32,0,0x7FFF);
276 return 0;
277 case WM_COMMAND:
278 switch(LOWORD(wParam)){
279 case IDC_TEST:
280 _beginthread(
281 (void (__cdecl *)(void *))ShowTestWindow,
282 0,
283 (void *)GetWndInfoNum(MdiInfo[GetWndNum(GetParent(hwnd))].path));
284 return 1;
285 case IDC_XPOS:
286 case IDC_YPOS:
287 case IDC_WIDTH:
288 case IDC_HEIGHT:
289 if(HIWORD(wParam)==EN_UPDATE){
290 if(bSupportDlg_NoChange) return 1;
291
292 if(bTimer) KillTimer(hwnd,0);
293
294 bTimer=1;
295 SetTimer(hwnd,0,650,NULL);
296 }
297 return 1;
298 }
299 break;
300 case WM_TIMER:
301 KillTimer(hwnd,0);
302 bTimer=0;
303
304 i=GetWndNum(GetParent(hwnd));
305 i2=GetWndInfoNum(MdiInfo[i].path);
306
307 for(i3=0;;i3++){
308 if(MdiInfo[i].MdiRadInfo->SelectingItem[i3]==-1) break;
309 PointAndSize.pos=ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[i].MdiRadInfo->SelectingItem[i3]].pos;
310 PointAndSize.size=ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[i].MdiRadInfo->SelectingItem[i3]].size;
311 Rad_NoticeChanging(i,RAD_UNDO_POSITION,MdiInfo[i].MdiRadInfo->SelectingItem[i3],(DWORD)&PointAndSize);
312 }
313
314 GetDlgItemText(hwnd,IDC_XPOS,temporary,255);
315 if(temporary[0]){
316 for(i3=0;;i3++){
317 if(MdiInfo[i].MdiRadInfo->SelectingItem[i3]==-1) break;
318 ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[i].MdiRadInfo->SelectingItem[i3]].pos.x=atol(temporary);
319 }
320 }
321
322 GetDlgItemText(hwnd,IDC_YPOS,temporary,255);
323 if(temporary[0]){
324 for(i3=0;;i3++){
325 if(MdiInfo[i].MdiRadInfo->SelectingItem[i3]==-1) break;
326 ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[i].MdiRadInfo->SelectingItem[i3]].pos.y=atol(temporary);
327 }
328 }
329
330 GetDlgItemText(hwnd,IDC_WIDTH,temporary,255);
331 if(temporary[0]){
332 if(MdiInfo[i].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW)
333 ProjectInfo.pWindowInfo[i2].size.cx=atol(temporary);
334 else{
335 for(i3=0;;i3++){
336 if(MdiInfo[i].MdiRadInfo->SelectingItem[i3]==-1) break;
337 ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[i].MdiRadInfo->SelectingItem[i3]].size.cx=atol(temporary);
338 }
339 }
340 }
341
342 GetDlgItemText(hwnd,IDC_HEIGHT,temporary,255);
343 if(temporary[0]){
344 if(MdiInfo[i].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW)
345 ProjectInfo.pWindowInfo[i2].size.cy=atol(temporary);
346 else{
347 for(i3=0;;i3++){
348 if(MdiInfo[i].MdiRadInfo->SelectingItem[i3]==-1) break;
349 ProjectInfo.pWindowInfo[i2].pChildInfo[MdiInfo[i].MdiRadInfo->SelectingItem[i3]].size.cy=atol(temporary);
350 }
351 }
352 }
353
354 //描画
355 DrawRadWindow(i,&ProjectInfo.pWindowInfo[i2]);
356
357 //スクロールバーをリセット
358 GetClientRect(MdiInfo[i].MdiRadInfo->hRad,&rect);
359 ResetScrollbarOfRadEditor(i,rect.right,rect.bottom);
360
361 return 1;
362 }
363 return 0;
364}
Note: See TracBrowser for help on using the repository browser.