source: dev/trunk/abdev/ProjectEditor/MessageCallOperation.cpp@ 271

Last change on this file since 271 was 24, checked in by dai_9181, 18 years ago

保存されていないドキュメントのタブに(*)をつける機能に対応。
MDITEXTEDITINFOをCMdiTextEditに変更。今後、オブジェクト指向化を進める。

File size: 29.7 KB
Line 
1#include "Common.h"
2
3////////////////////////////////////////////////////////////////////////////
4//このソースファイルではイベントプロシージャの管理を行う(MainWnd.abなど)
5////////////////////////////////////////////////////////////////////////////
6
7int NowMenuNum;
8
9int GetItemMessageInfo(int WndInfoNum,char *buffer,char *EventName){
10 extern PROJECTINFO ProjectInfo;
11 int i;
12
13 for(i=lstrlen(buffer);i>=0;i--){
14 if(buffer[i]=='_') break;
15 }
16 if(i==-1) return 0;
17 lstrcpy(EventName,buffer+i+1);
18 buffer[i]=0;
19 if(lstrcmp(EventName,"MenuClick")==0) return CT_MENU;
20 for(i=0;i<ProjectInfo.pWindowInfo[WndInfoNum].NumberOfChildWindows;i++){
21 if(lstrcmp(buffer,ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[i].IdName)==0) break;
22 }
23 if(i==ProjectInfo.pWindowInfo[WndInfoNum].NumberOfChildWindows) return 0;
24
25 return ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[i].Control;
26}
27char **GetProcedureNamesOfMessageCall(int WndInfoNum,ITEMEVENTINFO **ppItemEventInfo,int *num,BOOL *pbAlways){
28 extern HANDLE hHeap;
29 extern PROJECTINFO ProjectInfo;
30 int i,i2,i3,i4,i5,i6,NameLen,CallBackNameLen;
31 char *buffer,**ppNames,temporary[MAX_PATH],temp2[MAX_PATH];
32
33 NameLen=lstrlen(ProjectInfo.pWindowInfo[WndInfoNum].name);
34 CallBackNameLen=lstrlen(ProjectInfo.pWindowInfo[WndInfoNum].CallBackName);
35
36 sprintf(temporary,"%s%s",ProjectInfo.dir,ProjectInfo.pWindowInfo[WndInfoNum].filepath);
37 buffer=ReadBuffer(temporary);
38
39 *num=0;
40 ppNames=(char **)HeapAlloc(hHeap,0,1);
41
42 *pbAlways=0;
43
44 //メッセージ
45 *ppItemEventInfo=(ITEMEVENTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(ITEMEVENTINFO));
46 for(i=0,i4=0;;i++){
47 if(buffer[i]=='\0') break;
48
49 //注釈(複数行)
50 if(buffer[i]=='/'&&buffer[i+1]=='*'){
51 i+=2;
52 while(!(buffer[i]=='*'&&buffer[i+1]=='/')){
53 if(buffer[i]=='\0'){
54 i--;
55 break;
56 }
57 i++;
58 }
59 continue;
60 }
61
62 if((buffer[i]=='\r'&&buffer[i+1]=='\n'&&buffer[i+2]!='\0')||i==0){
63 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i2=i+2;
64 else i2=i;
65 while(buffer[i2]>='0'&&buffer[i2]<='9') i2++;
66 while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
67 if(memicmp(buffer+i2,"Sub",3)==0&&(buffer[i2+3]==' '||buffer[i2+3]=='\t')){
68 i2+=4;
69 while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
70 strncpy(temporary,buffer+i2,NameLen);
71 temporary[NameLen]=0;
72 if(lstrcmp(temporary,ProjectInfo.pWindowInfo[WndInfoNum].name)==0&&buffer[i2+NameLen]=='_'){
73 for(i2+=NameLen+1,i3=0;;i2++,i3++){
74 if(!IsVariableChar(buffer[i2])){
75 temporary[i3]=0;
76 break;
77 }
78 temporary[i3]=buffer[i2];
79 }
80 i6=GetItemMessageInfo(WndInfoNum,temporary,temp2);
81 if(i6){
82 //アイテムメッセージ(WM_COMMAND、WM_NOTIFY)
83 for(i5=0;;i5++){
84 if((*ppItemEventInfo)[i5].IdName==0){
85 *ppItemEventInfo=(ITEMEVENTINFO *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,*ppItemEventInfo,(i4+2)*sizeof(ITEMEVENTINFO));
86 (*ppItemEventInfo)[i4].IdName=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
87 lstrcpy((*ppItemEventInfo)[i4].IdName,temporary);
88 (*ppItemEventInfo)[i4].pEventNames=(char **)HeapAlloc(hHeap,0,1);
89 (*ppItemEventInfo)[i4].ClassID=i6;
90 i4++;
91 break;
92 }
93 if(lstrcmp((*ppItemEventInfo)[i5].IdName,temporary)==0) break;
94 }
95 (*ppItemEventInfo)[i5].pEventNames=(char **)HeapReAlloc(hHeap,0,(*ppItemEventInfo)[i5].pEventNames,((*ppItemEventInfo)[i5].EventNum+1)*sizeof(char *));
96 (*ppItemEventInfo)[i5].pEventNames[(*ppItemEventInfo)[i5].EventNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temp2)+1);
97 lstrcpy((*ppItemEventInfo)[i5].pEventNames[(*ppItemEventInfo)[i5].EventNum],temp2);
98 (*ppItemEventInfo)[i5].EventNum++;
99 }
100 else if(temporary[0]){
101 //一般メッセージ
102 ppNames=(char **)HeapReAlloc(hHeap,0,ppNames,(*num+1)*sizeof(char *));
103 ppNames[*num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
104 lstrcpy(ppNames[*num],temporary);
105 (*num)++;
106 }
107 }
108 }
109 if(memicmp(buffer+i2,"Function",8)==0&&(buffer[i2+8]==' '||buffer[i2+8]=='\t')){
110 //[WndName]_WindowProcのみFunction定義
111 i2+=9;
112 while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
113 if(memicmp(buffer+i2,ProjectInfo.pWindowInfo[WndInfoNum].CallBackName,CallBackNameLen)==0&&
114 (buffer[i2+CallBackNameLen]==' '||buffer[i2+CallBackNameLen]=='\t'||buffer[i2+CallBackNameLen]=='(')){
115 *pbAlways=1;
116 }
117 }
118 }
119 }
120 HeapDefaultFree(buffer);
121
122 return ppNames;
123}
124void SelectProcedureOfMessageCall(int WndInfoNum,char *ProcedureName,char *Parameter){
125 extern MDIINFO MdiInfo[MAX_WNDNUM];
126 extern PROJECTINFO ProjectInfo;
127 int i,i2,i3,WndNum;
128 char temporary[MAX_PATH],*pBuf;
129 HWND hChild;
130 POINT pos;
131
132 sprintf(temporary,"%s%s",ProjectInfo.dir,ProjectInfo.pWindowInfo[WndInfoNum].filepath);
133 hChild=OpenFileWithExtension(temporary);
134 if(!hChild) return;
135 WndNum=GetWndNum(hChild);
136
137 pBuf=MdiInfo[WndNum].pMdiTextEdit->buffer;
138
139 for(i=0;;i++){
140 if(pBuf[i]=='\0') break;
141 if((pBuf[i]=='\r'&&pBuf[i+1]=='\n'&&pBuf[i+2]!='\0')||i==0){
142 if(i) i2=i+2;
143 else i2=i;
144 while(pBuf[i2]>='0'&&pBuf[i2]<='9') i2++;
145 while(pBuf[i2]==' '||pBuf[i2]=='\t') i2++;
146 strncpy(temporary,pBuf+i2,3);
147 temporary[3]=0;
148 if(lstrcmpi(temporary,"Sub")==0&&(pBuf[i2+3]==' '||pBuf[i2+3]=='\t')){
149 pos.x=i2;
150 i2+=4;
151 while(pBuf[i2]==' '||pBuf[i2]=='\t') i2++;
152 for(i3=0;;i2++,i3++){
153 if(!IsVariableChar(pBuf[i2])){
154 temporary[i3]=0;
155 break;
156 }
157 temporary[i3]=pBuf[i2];
158 }
159 if(lstrcmpi(temporary,ProcedureName)==0){
160 for(;;i2++){
161 if(pBuf[i2]=='\r'||pBuf[i2]=='\0'){
162 if(pBuf[i2]=='\r'){
163 if(pBuf[i2+1]!='\n') continue;
164 }
165 pos.y=i2;
166 break;
167 }
168 }
169 break;
170 }
171 }
172 }
173 }
174 if(pBuf[i]){
175 //プロシージャが見つかったとき
176 TextEdit_SetSel(WndNum,pos.x,pos.y);
177 }
178 else{
179 //プロシージャがないときは生成する
180
181 //挿入位置にキャレットを移動
182 TextEdit_SetSel(WndNum,i,i);
183
184 //挿入
185 sprintf(temporary,"\r\nSub %s(%s)",ProcedureName,Parameter);
186 i2=lstrlen(temporary);
187 lstrcat(temporary,"\r\n\r\nEnd Sub\r\n");
188 TextEdit_ReplaceUpdateUndoData(WndNum,temporary,1,1);
189
190 TextEdit_SetSel(WndNum,i+2,i+i2);
191 }
192 SetFocus(MdiInfo[WndNum].pMdiTextEdit->hEdit);
193}
194void InsertEventToList(HWND hList,int ItemNum,char *EventName,char *MessageName,char *OutLine){
195 LV_ITEM item;
196
197 item.mask=LVIF_TEXT;
198 item.pszText=EventName;
199 item.iItem=ItemNum;
200 item.iSubItem=0;
201 ListView_InsertItem(hList,&item);
202 item.pszText=MessageName;
203 item.iItem=ItemNum;
204 item.iSubItem=1;
205 ListView_SetItem(hList,&item);
206 item.pszText=OutLine;
207 item.iItem=ItemNum;
208 item.iSubItem=2;
209 ListView_SetItem(hList,&item);
210}
211BOOL GetEventProcedureNameFromListView(HWND hList,int WndNum,int WndInfoNum,char *EventName,char *Parameter,DWORD dwEventType){
212 extern PROJECTINFO ProjectInfo;
213 extern MDIINFO MdiInfo[MAX_WNDNUM];
214 int i,MaxCount;
215 char temporary[MAX_PATH];
216
217 MaxCount=ListView_GetItemCount(hList);
218 if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW){
219 if(dwEventType==EVENTTYPE_DEFAULT){
220 for(i=0;i<MaxCount;i++){
221 if(ListView_GetItemState(hList,i,LVIS_SELECTED)){
222 ListView_GetItemText(hList,i,0,temporary,MAX_PATH);
223 sprintf(EventName,"%s_%s",
224 ProjectInfo.pWindowInfo[WndInfoNum].name,
225 temporary);
226 break;
227 }
228 }
229 if(i==MaxCount) return 0;
230
231 if(i==0) lstrcpy(Parameter,"state As Integer, minimized As Integer");
232 else if(i==1) lstrcpy(Parameter,"ByRef CreateStruct As CREATESTRUCT");
233 else if(i==2) Parameter[0]=0;
234 else if(i==3) lstrcpy(Parameter,"hDrop As HDROP");
235 else if(i==4) lstrcpy(Parameter,"nScrollCode As Long, nPos As Integer, hwndScrollBar As HWND");
236 else if(i==5) lstrcpy(Parameter,"KeyCode As Long, flags As Long");
237 else if(i==6) lstrcpy(Parameter,"KeyCode As Long, flags As Long");
238 else if(i==7) lstrcpy(Parameter,"KeyCode As Long, flags As Long");
239 else if(i==8) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
240 else if(i==9) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
241 else if(i==10) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
242 else if(i==11) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
243 else if(i==12) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
244 else if(i==13) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
245 else if(i==14) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
246 else if(i==15) lstrcpy(Parameter,"x As Integer, y As Integer");
247 else if(i==16) lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
248 else if(i==17) lstrcpy(Parameter,"hDC As HDC");
249 else if(i==18) lstrcpy(Parameter,"ByRef cancel As Integer");
250 else if(i==19) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
251 else if(i==20) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
252 else if(i==21) lstrcpy(Parameter,"flags As Long, x As Integer, y As Integer");
253 else if(i==22) lstrcpy(Parameter,"SizeType As Long, cx As Integer, cy As Integer");
254 else if(i==23) Parameter[0]=0;
255 else if(i==24) lstrcpy(Parameter,"TimerID As DWord");
256 else if(i==25) lstrcpy(Parameter,"nScrollCode As Long, nPos As Integer, hwndScrollBar As HWND");
257 }
258 else if(dwEventType==EVENTTYPE_MENU){
259 for(i=0;i<MaxCount;i++){
260 if(ListView_GetItemState(hList,i,LVIS_SELECTED)){
261 ListView_GetItemText(hList,i,0,temporary,MAX_PATH);
262 sprintf(EventName,"%s_%s_MenuClick",
263 ProjectInfo.pWindowInfo[WndInfoNum].name,
264 temporary);
265 break;
266 }
267 }
268 if(i==MaxCount) return 0;
269
270 Parameter[0]=0;
271 }
272 else if(dwEventType==EVENTTYPE_MMSYS){
273 for(i=0;i<MaxCount;i++){
274 if(ListView_GetItemState(hList,i,LVIS_SELECTED)){
275 ListView_GetItemText(hList,i,0,temporary,MAX_PATH);
276 sprintf(EventName,"%s_%s",
277 ProjectInfo.pWindowInfo[WndInfoNum].name,
278 temporary);
279 break;
280 }
281 }
282 if(i==MaxCount) return 0;
283
284 if(i==0) lstrcpy(Parameter,"flags As Long, DevID As DWord");
285 }
286 }
287 else{
288 for(i=0;i<MaxCount;i++){
289 if(ListView_GetItemState(hList,i,LVIS_SELECTED)){
290 ListView_GetItemText(hList,i,0,temporary,MAX_PATH);
291 sprintf(EventName,"%s_%s_%s",
292 ProjectInfo.pWindowInfo[WndInfoNum].name,
293 ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].IdName,
294 temporary);
295 break;
296 }
297 }
298 if(i==MaxCount) return 0;
299
300 if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_LISTVIEW){
301 //ListView
302 if(i==0) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
303 else if(i==1) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
304 else if(i==2) lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
305 else if(i==3) lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
306 else if(i==4) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
307 else if(i==5) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
308 else if(i==6) lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
309 else if(i==7) lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
310 else if(i==8) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
311 else if(i==9) lstrcpy(Parameter,"ByRef nmLVDispInfo As NMLVDISPINFO");
312 else if(i==10) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
313 else if(i==11) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
314 else if(i==12) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
315 else if(i==13) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
316 else if(i==14) lstrcpy(Parameter,"ByRef nmLVDispInfo As NMLVDISPINFO");
317 else if(i==15) lstrcpy(Parameter,"ByRef nmLVDispInfo As NMLVDISPINFO");
318 else if(i==16) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
319 else if(i==17) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
320 else if(i==18) lstrcpy(Parameter,"ByRef nmListView As NMLISTVIEW");
321 else if(i==19) lstrcpy(Parameter,"ByRef nmLVKeyDown As NMLVKEYDOWN");
322 else if(i==20) lstrcpy(Parameter,"ByRef nmLVDispInfo As NMLVDISPINFO");
323 }
324 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_PROGRESSBAR){
325 //ProgressBar
326 lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
327 }
328 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_TRACKBAR){
329 //TrackBar
330 lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
331 }
332 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_TREEVIEW){
333 //TreeView
334 if(0<=i&&i<=7) lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
335 else lstrcpy(Parameter,"ByRef nmTreeView As NMTREEVIEW");
336 }
337 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_UPDOWN){
338 //UpDown
339 if(i==0) lstrcpy(Parameter,"ByRef nmHdr As NMHDR");
340 else if(i==1) lstrcpy(Parameter,"ByRef nmUpDown As NMUPDOWN");
341 }
342 else Parameter[0]=0;
343 }
344
345 return 1;
346}
347int SetDefaultNotifyMessagesInList(HWND hList,int ClassID){
348 int i;
349 i=0;
350 InsertEventToList(hList,i++,"Click","NM_CLICK","コントロール内でマウスの左ボタンがクリックされた時");
351 InsertEventToList(hList,i++,"DblClick","NM_DBLCLK","コントロール内でマウスの左ボタンがダブル クリックされた時");
352 InsertEventToList(hList,i++,"KillFocus","NM_KILLFOCUS","入力フォーカスを失った時");
353 InsertEventToList(hList,i++,"OutOfMemory","NM_OUTOFMEMORY","メモリ不足でコントロールの動作が完了できない時");
354 InsertEventToList(hList,i++,"RClick","NM_RCLICK","コントロール内でマウスの右ボタンがクリックされた時");
355 InsertEventToList(hList,i++,"RDblClick","NM_RDBLCLK","コントロール内でマウスの右ボタンがダブル クリックされた時");
356 InsertEventToList(hList,i++,"Return","NM_RETURN","コントロールに入力フォーカスがあるときにEnterキーが押された時");
357 InsertEventToList(hList,i++,"SetFocus","NM_SETFOCUS","入力フォーカスを取得した時");
358 if(ClassID==CT_LISTVIEW){
359 InsertEventToList(hList,i++,"BeginDrag","LVN_BEGINDRAG","マウスの左ボタンでドラッグ&ドロップを始める時");
360 InsertEventToList(hList,i++,"BeginLabelEdit","LVN_BEGINLABELEDIT","アイテムのラベルの編集が開始された時");
361 InsertEventToList(hList,i++,"BeginRDrag","LVN_BEGINRDRAG","マウスの右ボタンでドラッグ&ドロップを始める時");
362 InsertEventToList(hList,i++,"ColumnClick","LVN_COLUMNCLICK","カラムの1つがクリックされた時");
363 InsertEventToList(hList,i++,"DeleteAllItems","LVN_DELETEALLITEMS","ビュー内のすべてのアイテムが削除された時");
364 InsertEventToList(hList,i++,"DeleteItem","LVN_DELETEITEM","ビュー内のアイテムが削除された時");
365 InsertEventToList(hList,i++,"EndLabelEdit","LVN_ENDLABELEDIT","アイテムのラベルの編集が終了した時");
366 InsertEventToList(hList,i++,"GetDispInfo","LVN_GETDISPINFO","親ウィンドウがディスプレイに関する情報を供給した時");
367 InsertEventToList(hList,i++,"InsertItem","LVN_INSERTITEM","ビュー内にアイテムが挿入された時");
368 InsertEventToList(hList,i++,"ItemChanged","LVN_ITEMCHANGED","ビュー内のアイテムが変更された時");
369 InsertEventToList(hList,i++,"ItemChanging","LVN_ITEMCHANGING","ビュー内のアイテムを変更する時");
370 InsertEventToList(hList,i++,"KeyDown","LVN_KEYDOWN","キーが押された時");
371 InsertEventToList(hList,i++,"SetDispInfo","LVN_SETDISPINFO","親ウィンドウがアイテムに対して情報を更新する必要がある時");
372 }
373 else if(ClassID==CT_TREEVIEW){
374 //未完成
375 }
376 return i;
377}
378void SetMenuEventToList(HWND hList,MENU_INFO *pMenuInfo,int *pListNum,int *pPos){
379 int i;
380 for(i=0;i<pMenuInfo->NumberOfMenu;i++){
381 if((!pMenuInfo->pMenuInfo[i].pMenuInfo)&&pMenuInfo->pMenuInfo[i].type==MFT_STRING)
382 InsertEventToList(hList,(*pListNum)++,pMenuInfo->pMenuInfo[i].IdName,"WM_COMMAND",pMenuInfo->pMenuInfo[i].caption);
383 (*pPos)++;
384 if(pMenuInfo->pMenuInfo[i].pMenuInfo)
385 SetMenuEventToList(hList,&pMenuInfo->pMenuInfo[i],pListNum,pPos);
386 }
387}
388void SetEventToList(HWND hDlg,DWORD dwEventType){
389 extern MDIINFO MdiInfo[MAX_WNDNUM];
390 extern PROJECTINFO ProjectInfo;
391 int i,i2,WndNum,WndInfoNum;
392 HWND hList;
393
394 hList=GetDlgItem(hDlg,IDC_EVENTLIST);
395 ListView_DeleteAllItems(hList);
396 SetDlgItemText(hDlg,IDC_PROCEDURENAME,"");
397
398 WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
399 WndInfoNum=GetWndInfoNum(MdiInfo[WndNum].path);
400 i=0;
401 if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]==SELECT_WINDOW){
402 EnableWindow(GetDlgItem(hDlg,IDC_DEFAULT),1);
403 EnableWindow(GetDlgItem(hDlg,IDC_MENU),1);
404 EnableWindow(GetDlgItem(hDlg,IDC_MMSYS),1);
405 if(dwEventType==EVENTTYPE_DEFAULT){
406 SendDlgItemMessage(hDlg,IDC_DEFAULT,BM_SETCHECK,BST_CHECKED,0);
407 InsertEventToList(hList,i++,"Activate","WM_ACTIVATE","ウィンドウがアクティブ、または非アクティブになった時");
408 InsertEventToList(hList,i++,"Create","WM_CREATE","ウィンドウ作成時");
409 InsertEventToList(hList,i++,"Destroy","WM_DESTROY","ウィンドウ破棄時");
410 InsertEventToList(hList,i++,"DropFiles","WM_DROPFILES","ウィンドウにファイルがドロップされた時");
411 InsertEventToList(hList,i++,"HScroll","WM_HSCROLL","水平スクロール バー・トラック バーが移動した時");
412 InsertEventToList(hList,i++,"KeyDown","WM_KEYDOWN","キーが押された時");
413 InsertEventToList(hList,i++,"KeyPress","WM_CHAR","ANSI文字キーを押して離した時");
414 InsertEventToList(hList,i++,"KeyUp","WM_KEYUP","キーが離された時");
415 InsertEventToList(hList,i++,"LButtonDblClick","WM_LBUTTONDBLCLK","マウスの左ボタンがダブル クリックされた時");
416 InsertEventToList(hList,i++,"LButtonDown","WM_LBUTTONDOWN","マウスの左ボタンが押された時");
417 InsertEventToList(hList,i++,"LButtonUp","WM_LBUTTONUP","マウスの左ボタンが離された時");
418 InsertEventToList(hList,i++,"MButtonDblClick","WM_MBUTTONDBLCLK","マウスの中央ボタンがダブル クリックされた時");
419 InsertEventToList(hList,i++,"MButtonDown","WM_MBUTTONDOWN","マウスの中央ボタンが押された時");
420 InsertEventToList(hList,i++,"MButtonUp","WM_MBUTTONUP","マウスの中央ボタンが離された時");
421 InsertEventToList(hList,i++,"MouseMove","WM_MOUSEMOVE","マウスが移動した時");
422 InsertEventToList(hList,i++,"Move","WM_MOVE","ウィンドウが移動した時");
423 InsertEventToList(hList,i++,"Notify","WM_NOTIFY","コモンコントロールからメッセージが通知された時");
424 InsertEventToList(hList,i++,"Paint","WM_PAINT","再描画要求が出された時");
425 InsertEventToList(hList,i++,"QueryClose","WM_CLOSE","ウィンドウの終了ボタンが押された時");
426 InsertEventToList(hList,i++,"RButtonDblClick","WM_RBUTTONDBLCLK","マウスの右ボタンがダブル クリックされた時");
427 InsertEventToList(hList,i++,"RButtonDown","WM_RBUTTONDOWN","マウスの右ボタンが押された時");
428 InsertEventToList(hList,i++,"RButtonUp","WM_RBUTTONUP","マウスの右ボタンが離された時");
429 InsertEventToList(hList,i++,"Resize","WM_SIZE","ウィンドウの大きさが変更された時");
430 InsertEventToList(hList,i++,"SetFocus","WM_SETFOCUS","キーボード フォーカスを受け取った時");
431 InsertEventToList(hList,i++,"Timer","WM_TIMER","設定したタイマーのタイム アウト時");
432 InsertEventToList(hList,i++,"VScroll","WM_VSCROLL","垂直スクロール バー・トラック バーが移動した時");
433 }
434 else if(dwEventType==EVENTTYPE_MENU){
435 //メニュー イベント
436 SendDlgItemMessage(hDlg,IDC_MENU,BM_SETCHECK,BST_CHECKED,0);
437 if(ProjectInfo.pWindowInfo[WndInfoNum].MenuID){
438 int MenuInfoNum;
439 MenuInfoNum=GetMenuInfoNum(ProjectInfo.pWindowInfo[WndInfoNum].MenuID);
440 i=0;
441 i2=0;
442
443 SetMenuEventToList(hList,&ProjectInfo.pMenuInfo[MenuInfoNum],&i,&i2);
444 }
445 }
446 else if(dwEventType==EVENTTYPE_MMSYS){
447 SendDlgItemMessage(hDlg,IDC_MMSYS,BM_SETCHECK,BST_CHECKED,0);
448 InsertEventToList(hList,i++,"MciNotify","MM_MCINOTIFY","MCIコマンドが完了したり異常終了した場合");
449 }
450 }
451 else{
452 EnableWindow(GetDlgItem(hDlg,IDC_DEFAULT),1);
453 EnableWindow(GetDlgItem(hDlg,IDC_MENU),0);
454 EnableWindow(GetDlgItem(hDlg,IDC_MMSYS),0);
455 SendDlgItemMessage(hDlg,IDC_DEFAULT,BM_SETCHECK,BST_CHECKED,0);
456 if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_BUTTON){
457 //Button
458 InsertEventToList(hList,i++,"Click","BN_CLICKED","ボタンがクリックされた時");
459 InsertEventToList(hList,i++,"DblClick","BN_DBLCLK","ボタンがダブル クリックされた時");
460 }
461 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_CHECKBOX){
462 //CheckBox
463 InsertEventToList(hList,i++,"Click","BN_CLICKED","チェック ボックスがクリックされた時");
464 InsertEventToList(hList,i++,"DblClick","BN_DBLCLK","チェック ボックスがダブル クリックされた時");
465 }
466 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_COMBOBOX){
467 //ComboBox
468 InsertEventToList(hList,i++,"CloseUp","CBN_CLOSEUP","リスト ボックスが非表示になる時");
469 InsertEventToList(hList,i++,"DblClick","CBN_DBLCLK","リスト内のアイテムがダブル クリックされた時");
470 InsertEventToList(hList,i++,"DropDown","CBN_DROPDOWN","リスト ボックスがドロップ ダウンされる時");
471 InsertEventToList(hList,i++,"EditChange","CBN_EDITCHANGE","エディット ボックスの内容が変化した時(後処理)");
472 InsertEventToList(hList,i++,"EditUpdate","CBN_EDITUPDATE","リスト ボックスが非表示になった時");
473 InsertEventToList(hList,i++,"ErrSpace","CBN_ERRSPACE","メモリ割り当てに失敗した時");
474 InsertEventToList(hList,i++,"KillFocus","CBN_KILLFOCUS","入力フォーカスを失った時");
475 InsertEventToList(hList,i++,"SelChange","CBN_SELCHANGE","リスト内の選択が変更された時");
476 InsertEventToList(hList,i++,"SelEndCancel","CBN_SELENDCANCEL","コンボ ボックスの選択を取り消した時");
477 InsertEventToList(hList,i++,"SelEndOk","CBN_SELENDOK","選択した項目が有効である時");
478 InsertEventToList(hList,i++,"SetFocus","CBN_SETFOCUS","入力フォーカスを取得した時");
479 }
480 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_EDIT){
481 //Edit
482 InsertEventToList(hList,i++,"Change","EN_CHANGE","エディット ボックスの内容が変更された時(後処理)");
483 InsertEventToList(hList,i++,"ErrSpace","EN_ERRSPACE","メモリ割り当てに失敗した時");
484 InsertEventToList(hList,i++,"HScroll","EN_HSCROLL","水平スクロールを行った時");
485 InsertEventToList(hList,i++,"KillFocus","EN_KILLFOCUS","入力フォーカスを失った時");
486 InsertEventToList(hList,i++,"MaxText","EN_MAXTEXT","文字数が上限を超えた時");
487 InsertEventToList(hList,i++,"SetFocus","EN_SETFOCUS","入力フォーカスを取得した時");
488 InsertEventToList(hList,i++,"Update","EN_UPDATE","エディット ボックスの内容が変更される時(前処理)");
489 InsertEventToList(hList,i++,"VScroll","EN_VSCROLL","垂直スクロールを行った時");
490 }
491 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_IMAGEBOX){
492 //ImageBox
493 InsertEventToList(hList,i++,"Click","STN_CLICKED","イメージ ボックスがクリックされた時");
494 InsertEventToList(hList,i++,"DblClick","STN_DBLCLK","イメージ ボックスがダブル クリックされた時");
495 }
496 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_LISTBOX){
497 //ListBox
498 InsertEventToList(hList,i++,"SelChange","LBN_SELCHANGE","リスト内の選択が変更された時");
499 InsertEventToList(hList,i++,"DblClick","LBN_DBLCLK","リスト内の文字列がダブル クリックされた時");
500 InsertEventToList(hList,i++,"ErrSpace","LBN_ERRSPACE","リストのメモリ割り当てに失敗した時");
501 InsertEventToList(hList,i++,"KillFocus","LBN_KILLFOCUS","入力フォーカスを失った時");
502 InsertEventToList(hList,i++,"SelCancel","LBN_SELCANCEL","リスト内の選択が取り消された時");
503 InsertEventToList(hList,i++,"SetFocus","LBN_SETFOCUS","入力フォーカスを取得した時");
504 }
505 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_LISTVIEW){
506 //ListView
507 i=SetDefaultNotifyMessagesInList(hList,CT_LISTVIEW);
508 }
509 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_PROGRESSBAR){
510 //ProgressBar
511 InsertEventToList(hList,i++,"OutOfMemory","NM_OUTOFMEMORY","メモリ不足でコントロールの動作が完了できない時");
512 }
513 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_RADIOBUTTON){
514 //RadioButton
515 InsertEventToList(hList,i++,"Click","BN_CLICKED","ラジオ ボタンがクリックされた時");
516 InsertEventToList(hList,i++,"DblClick","BN_DBLCLK","ラジオ ボタンがダブル クリックされた時");
517 }
518 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_STATIC){
519 //Static
520 InsertEventToList(hList,i++,"Click","STN_CLICKED","スタティック テキストがクリックされた時");
521 InsertEventToList(hList,i++,"DblClick","STN_DBLCLK","スタティック テキストがダブル クリックされた時");
522 }
523 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_TRACKBAR){
524 //TrackBar
525 InsertEventToList(hList,i++,"OutOfMemory","NM_OUTOFMEMORY","メモリ不足でコントロールの動作が完了できない時");
526 InsertEventToList(hList,i++,"ReleasedCapture","NM_RELEASEDCAPTURE ","マウス キャプチャ リリースの通知");
527 InsertEventToList(hList,i++,"CustomDraw","NM_CUSTOMDRAW ","カスタム描画操作の通知");
528 }
529 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_TREEVIEW){
530 //TreeView
531 i=SetDefaultNotifyMessagesInList(hList,CT_TREEVIEW);
532 }
533 else if(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].Control==CT_UPDOWN){
534 //UpDown
535 InsertEventToList(hList,i++,"OutOfMemory","NM_OUTOFMEMORY","メモリ不足でコントロールの動作が完了できない時");
536 InsertEventToList(hList,i++,"Deltapos","UDN_DELTAPOS","コントロールの位置が変えられようとしている時");
537 }
538 }
539}
540void Popup_SelectMenu(HWND hDlg){
541 extern PROJECTINFO ProjectInfo;
542 int i;
543 POINT pos;
544 HMENU hMenu;
545
546 if(ProjectInfo.NumberOfMenu==0) return;
547
548 GetCursorPos(&pos);
549
550 hMenu=CreatePopupMenu();
551
552 MENUITEMINFO mii;
553 mii.cbSize=sizeof(MENUITEMINFO);
554 for(i=0;i<ProjectInfo.NumberOfMenu;i++){
555 if(NowMenuNum==i){
556 mii.fMask=MIIM_TYPE|MIIM_ID|MIIM_STATE;
557 mii.fState=MFS_CHECKED;
558 }
559 else mii.fMask=MIIM_TYPE|MIIM_ID;
560 mii.fType=MFT_STRING;
561 mii.wID=100+i;
562 mii.dwTypeData=ProjectInfo.pMenuInfo[i].IdName;
563 InsertMenuItem(hMenu,i,1,&mii);
564 }
565
566 extern HMENU hRadMenuBase;
567 TrackPopupMenu(hMenu,TPM_LEFTALIGN,pos.x,pos.y,0,hDlg,0);
568
569 DestroyMenu(hMenu);
570}
571
572WNDPROC OldEventListViewProc;
573LRESULT CALLBACK EventListViewProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
574 if(message==WM_RBUTTONDOWN){
575 if(SendDlgItemMessage(GetParent(hwnd),IDC_MENU,BM_GETCHECK,0,0))
576 Popup_SelectMenu(GetParent(hwnd));
577 return 0;
578 }
579 return CallWindowProc(OldEventListViewProc,hwnd,message,wParam,lParam);
580}
581BOOL CALLBACK DlgEventCode(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
582 extern MDIINFO MdiInfo[MAX_WNDNUM];
583 extern PROJECTINFO ProjectInfo;
584 int WndNum,WndInfoNum,i,i2;
585 char temporary[MAX_PATH],temp2[MAX_PATH];
586 HWND hList;
587 DWORD dwStyle;
588 RECT rect;
589 LV_COLUMN ListView_Column;
590
591 static DWORD dwEventType;
592
593 if(message==WM_COMMAND&&100<=wParam&&wParam<200){
594 hList=GetDlgItem(hwnd,IDC_EVENTLIST);
595 WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
596 WndInfoNum=GetWndInfoNum(MdiInfo[WndNum].path);
597
598 ListView_DeleteAllItems(hList);
599 SetDlgItemText(hwnd,IDC_PROCEDURENAME,"");
600 i=0;
601 i2=0;
602
603 NowMenuNum=wParam-100;
604 SetMenuEventToList(hList,&ProjectInfo.pMenuInfo[wParam-100],&i,&i2);
605 }
606
607 switch(message){
608 case WM_INITDIALOG:
609 SetPosCenter(hwnd);
610 SetFocus(GetDlgItem(hwnd,IDC_EVENTLIST));
611
612 hList=GetDlgItem(hwnd,IDC_EVENTLIST);
613 GetClientRect(hList,&rect);
614 dwStyle=ListView_GetExtendedListViewStyle(hList);
615 dwStyle|=LVS_EX_FULLROWSELECT;
616 ListView_SetExtendedListViewStyle(hList,dwStyle);
617
618 ListView_Column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
619 ListView_Column.fmt=LVCFMT_LEFT;
620
621 ListView_Column.cx=100;
622 ListView_Column.pszText="イベント";
623 ListView_Column.iSubItem=0;
624 ListView_InsertColumn(hList,0,&ListView_Column);
625
626 ListView_Column.cx=120;
627 ListView_Column.pszText="対応メッセージ";
628 ListView_Column.iSubItem=1;
629 ListView_InsertColumn(hList,1,&ListView_Column);
630
631 ListView_Column.cx=rect.right-240;
632 ListView_Column.pszText="概要";
633 ListView_Column.iSubItem=2;
634 ListView_InsertColumn(hList,2,&ListView_Column);
635
636 dwEventType=lParam;
637 SetEventToList(hwnd,dwEventType);
638 EnableWindow(GetDlgItem(hwnd,IDOK),0);
639
640 OldEventListViewProc=(WNDPROC)GetWindowLong(GetDlgItem(hwnd,IDC_EVENTLIST),GWL_WNDPROC);
641 SetWindowLong(GetDlgItem(hwnd,IDC_EVENTLIST),GWL_WNDPROC,(long)EventListViewProc);
642
643 WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
644 WndInfoNum=GetWndInfoNum(MdiInfo[WndNum].path);
645 NowMenuNum=GetMenuInfoNum(ProjectInfo.pWindowInfo[WndInfoNum].MenuID);
646 break;
647 case WM_COMMAND:
648 switch(LOWORD(wParam)){
649 case IDC_DEFAULT:
650 dwEventType=EVENTTYPE_DEFAULT;
651 SetEventToList(hwnd,dwEventType);
652 EnableWindow(GetDlgItem(hwnd,IDOK),0);
653 break;
654 case IDC_MENU:
655 dwEventType=EVENTTYPE_MENU;
656 SetEventToList(hwnd,dwEventType);
657 EnableWindow(GetDlgItem(hwnd,IDOK),0);
658
659 //「対象メニュー」選択メニューを表示
660 Popup_SelectMenu(hwnd);
661 break;
662 case IDC_MMSYS:
663 dwEventType=EVENTTYPE_MMSYS;
664 SetEventToList(hwnd,dwEventType);
665 EnableWindow(GetDlgItem(hwnd,IDOK),0);
666 break;
667 case IDOK:
668 hList=GetDlgItem(hwnd,IDC_EVENTLIST);
669 WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
670 WndInfoNum=GetWndInfoNum(MdiInfo[WndNum].path);
671 if(GetEventProcedureNameFromListView(hList,WndNum,WndInfoNum,temporary,temp2,dwEventType)){
672 SelectProcedureOfMessageCall(WndInfoNum,temporary,temp2);
673 EndDialog(hwnd,0);
674 }
675 return 1;
676 case IDCANCEL:
677 EndDialog(hwnd,0);
678 return 1;
679 }
680 break;
681 case WM_NOTIFY:
682 NMLISTVIEW *nmListView;
683 nmListView=(NMLISTVIEW *)lParam;
684 if(nmListView->hdr.idFrom==IDC_EVENTLIST){
685 if(nmListView->hdr.code==LVN_ITEMCHANGED){
686 hList=GetDlgItem(hwnd,IDC_EVENTLIST);
687 WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
688 WndInfoNum=GetWndInfoNum(MdiInfo[WndNum].path);
689 if(GetEventProcedureNameFromListView(hList,WndNum,WndInfoNum,temporary,temp2,dwEventType)){
690 sprintf(temporary+lstrlen(temporary),"(%s)",temp2);
691 EnableWindow(GetDlgItem(hwnd,IDOK),1);
692 }
693 else{
694 temporary[0]=0;
695 EnableWindow(GetDlgItem(hwnd,IDOK),0);
696 }
697 SetDlgItemText(hwnd,IDC_PROCEDURENAME,temporary);
698 return 1;
699 }
700 else if(nmListView->hdr.code==NM_DBLCLK)
701 SendMessage(hwnd,WM_COMMAND,IDOK,0);
702 }
703 break;
704 }
705 return 0;
706}
Note: See TracBrowser for help on using the repository browser.