#include "stdafx.h" #include "Common.h" using namespace ActiveBasic::IDE; #if defined(JPN) //日本語 #include "pj_msg_jpn.h" #else //英語 #include "pj_msg_eng.h" #endif int GetWndInfoNum(char *name){ extern PROJECTINFO ProjectInfo; int i; for(i=0;iSelectingItem[i3]==-1) break; } hGlobal=GlobalAlloc(GMEM_MOVEABLE,sizeof(int)); pByte=(BYTE *)GlobalLock(hGlobal); *((int *)pByte)=i3; GlobalUnlock(hGlobal); i2=sizeof(int); MemSize=i2; for(i3--;i3>=0;i3--){ pChildInfo=&ProjectInfo.windowInfos[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[i3]]; MemSize+=lstrlen(pChildInfo->IdName)+1+ sizeof(POINT)+ sizeof(SIZE)+ lstrlen(pChildInfo->caption)+1+ sizeof(DWORD)+ sizeof(DWORD)+ sizeof(int)+ sizeof(int)+ lstrlen(pChildInfo->ImageCtrlInfo.path)+1; hGlobal=GlobalReAlloc(hGlobal,MemSize,0); pByte=(BYTE *)GlobalLock(hGlobal); lstrcpy((char *)pByte+i2,pChildInfo->IdName); i2+=lstrlen(pChildInfo->IdName)+1; memcpy(pByte+i2,&pChildInfo->pos,sizeof(POINT)); i2+=sizeof(POINT); memcpy(pByte+i2,&pChildInfo->size,sizeof(SIZE)); i2+=sizeof(SIZE); lstrcpy((char *)pByte+i2,pChildInfo->caption); i2+=lstrlen(pChildInfo->caption)+1; memcpy(pByte+i2,&pChildInfo->style,sizeof(DWORD)); i2+=sizeof(DWORD); memcpy(pByte+i2,&pChildInfo->ExStyle,sizeof(DWORD)); i2+=sizeof(DWORD); memcpy(pByte+i2,&pChildInfo->Control,sizeof(int)); i2+=sizeof(int); memcpy(pByte+i2,&pChildInfo->ImageCtrlInfo.type,sizeof(int)); i2+=sizeof(int); if(!pChildInfo->ImageCtrlInfo.path){ lstrcpy((char *)pByte+i2,""); i2++; } else{ lstrcpy((char *)pByte+i2,pChildInfo->ImageCtrlInfo.path); i2+=lstrlen(pChildInfo->ImageCtrlInfo.path)+1; } GlobalUnlock(hGlobal); } return hGlobal; } void Rad_PasteChildInfoClipboardData(int WndNum,HGLOBAL hGlobal){ //hGlobalに格納されているクリップボードデータをRAD画面に挿入する extern MDIINFO MdiInfo[MAX_WNDNUM]; BYTE *pByte; int i2,i3,WndInfoNum; CHILDINFO ChildInfo; char temporary[255]; for(i2=1;i2SelectingItem[i2]=-1; WndInfoNum=GetWndInfoNum(MdiInfo[WndNum].path); pByte=(BYTE *)GlobalLock(hGlobal); i3=*((int *)pByte); i2=sizeof(int); for(i3--;i3>=0;i3--){ //IdNameメンバは変更される可能性がある ChildInfo.IdName=(char *)temporary; lstrcpy(ChildInfo.IdName,(char *)pByte+i2); i2+=lstrlen(ChildInfo.IdName)+1; memcpy(&ChildInfo.pos,pByte+i2,sizeof(POINT)); i2+=sizeof(POINT); memcpy(&ChildInfo.size,pByte+i2,sizeof(SIZE)); i2+=sizeof(SIZE); ChildInfo.caption=(char *)pByte+i2; i2+=lstrlen(ChildInfo.caption)+1; memcpy(&ChildInfo.style,pByte+i2,sizeof(DWORD)); i2+=sizeof(DWORD); memcpy(&ChildInfo.ExStyle,pByte+i2,sizeof(DWORD)); i2+=sizeof(DWORD); memcpy(&ChildInfo.Control,pByte+i2,sizeof(int)); i2+=sizeof(int); memcpy(&ChildInfo.ImageCtrlInfo.type,pByte+i2,sizeof(int)); i2+=sizeof(int); ChildInfo.ImageCtrlInfo.path=(char *)pByte+i2; if(lstrlen(ChildInfo.ImageCtrlInfo.path)==0){ ChildInfo.ImageCtrlInfo.path=0; i2++; } else i2+=lstrlen(ChildInfo.ImageCtrlInfo.path)+1; ChildInfo.pos.x+=17; ChildInfo.pos.y+=10; MdiInfo[WndNum].MdiRadInfo->SelectingItem[i3]=InsertDlgItem(WndNum, WndInfoNum, -1, &ChildInfo.pos, &ChildInfo.size, ChildInfo.IdName, ChildInfo.caption, ChildInfo.style, ChildInfo.ExStyle, ChildInfo.Control, ChildInfo.ImageCtrlInfo.type, ChildInfo.ImageCtrlInfo.path, 2); } GlobalUnlock(hGlobal); ChangePropertyWindow(WndNum,WndInfoNum); } char *FormatCaption(char *caption){ extern HANDLE hHeap; int i2,i3,BufSize; char *buffer; BufSize=256*2; buffer=(char *)HeapAlloc(hHeap,0,BufSize); for(i2=0,i3=0;;i2++,i3++){ if(i2+256>=BufSize){ BufSize+=256; buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufSize); } if(caption[i3]=='\"'){ lstrcpy(buffer+i2,"\"+Chr$(34)+\""); i2+=lstrlen(buffer+i2); i2--; continue; } buffer[i2]=caption[i3]; if(caption[i3]=='\0') break; } return buffer; } char *SetCaptionSequence(char *caption){ extern HANDLE hHeap; int i2,i3,BufSize; char *buffer; BufSize=256*2; buffer=(char *)HeapAlloc(hHeap,0,BufSize); for(i2=0,i3=0;;i2++,i3++){ if(i2+256>=BufSize){ BufSize+=256; buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufSize); } buffer[i2]=caption[i3]; if(caption[i3]=='\"'){ buffer[i2++]='\\'; buffer[i2]='1'; } else if(caption[i3]=='\\'){ buffer[i2++]='\\'; buffer[i2]='\\'; } else if(caption[i3]=='\0') break; } return buffer; } void RestoreCaptionSequence(char *caption){ int i2,i3; for(i2=0,i3=0;;i2++,i3++){ caption[i2]=caption[i3]; if(caption[i3]=='\\'){ i3++; if(caption[i3]=='1') caption[i2]='\"'; else caption[i2]=caption[i3]; } else if(caption[i3]=='\0') break; } } //テンプレートソースファイルに値をセットする char *PermutationWndPgmTemplate(char *pBuf,char *pPjName, char *pWndName, char *pHandleName, char *pProcName){ extern HANDLE hHeap; int i,i2; for(i=0;;i++){ if(pBuf[i]=='\0') break; if(memicmp(pBuf+i,"#name#",6)==0){ //プロジェクト名を置換 i2=lstrlen(pPjName); if(i2>6) pBuf=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pBuf,lstrlen(pBuf)+(i2-6)+1); SlideString(pBuf+i+6,i2-6); memcpy(pBuf+i,pPjName,i2); } if(memicmp(pBuf+i,"#window#",8)==0){ //ウィンドウ名を置換 i2=lstrlen(pWndName); if(i2>6) pBuf=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pBuf,lstrlen(pBuf)+(i2-8)+1); SlideString(pBuf+i+8,i2-8); memcpy(pBuf+i,pWndName,i2); } if(memicmp(pBuf+i,"#handle#",8)==0){ //ハンドル名を置換 i2=lstrlen(pHandleName); if(i2>6) pBuf=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pBuf,lstrlen(pBuf)+(i2-8)+1); SlideString(pBuf+i+8,i2-8); memcpy(pBuf+i,pHandleName,i2); } if(memicmp(pBuf+i,"#procedure#",11)==0){ //プロシージャ名を置換 i2=lstrlen(pProcName); if(i2>6) pBuf=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pBuf,lstrlen(pBuf)+(i2-11)+1); SlideString(pBuf+i+11,i2-11); memcpy(pBuf+i,pProcName,i2); } } return pBuf; } BOOL GetItemNotifyMessageNameByEvent(char *buffer,int ClassID,const char *EventName){ if(lstrcmp(EventName,"Click")==0) lstrcpy(buffer,"NM_CLICK"); else if(lstrcmp(EventName,"CustomDraw")==0) lstrcpy(buffer,"NM_CUSTOMDRAW"); else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"NM_DBLCLK"); else if(lstrcmp(EventName,"KillFocus")==0) lstrcpy(buffer,"NM_KILLFOCUS"); else if(lstrcmp(EventName,"OutOfMemory")==0) lstrcpy(buffer,"NM_OUTOFMEMORY"); else if(lstrcmp(EventName,"RClick")==0) lstrcpy(buffer,"NM_RCLICK"); else if(lstrcmp(EventName,"RDblClick")==0) lstrcpy(buffer,"NM_RDBLCLK"); else if(lstrcmp(EventName,"ReleasedCapture")==0) lstrcpy(buffer,"NM_RELEASEDCAPTURE"); else if(lstrcmp(EventName,"Return")==0) lstrcpy(buffer,"NM_RETURN"); else if(lstrcmp(EventName,"SetFocus")==0) lstrcpy(buffer,"NM_SETFOCUS"); else{ if(ClassID==CT_LISTVIEW){ if(lstrcmp(EventName,"BeginDrag")==0) lstrcpy(buffer,"LVN_BEGINDRAG"); else if(lstrcmp(EventName,"BeginLabelEdit")==0) lstrcpy(buffer,"LVN_BEGINLABELEDIT"); else if(lstrcmp(EventName,"BeginRDrag")==0) lstrcpy(buffer,"LVN_BEGINRDRAG"); else if(lstrcmp(EventName,"ColumnClick")==0) lstrcpy(buffer,"LVN_COLUMNCLICK"); else if(lstrcmp(EventName,"DeleteAllItems")==0) lstrcpy(buffer,"LVN_DELETEALLITEMS"); else if(lstrcmp(EventName,"DeleteItem")==0) lstrcpy(buffer,"LVN_DELETEITEM"); else if(lstrcmp(EventName,"EndLabelEdit")==0) lstrcpy(buffer,"LVN_ENDLABELEDIT"); else if(lstrcmp(EventName,"GetDispInfo")==0) lstrcpy(buffer,"LVN_GETDISPINFO"); else if(lstrcmp(EventName,"InsertItem")==0) lstrcpy(buffer,"LVN_INSERTITEM"); else if(lstrcmp(EventName,"ItemChanged")==0) lstrcpy(buffer,"LVN_ITEMCHANGED"); else if(lstrcmp(EventName,"ItemChanging")==0) lstrcpy(buffer,"LVN_ITEMCHANGING"); else if(lstrcmp(EventName,"KeyDown")==0) lstrcpy(buffer,"LVN_KEYDOWN"); else if(lstrcmp(EventName,"SetDispInfo")==0) lstrcpy(buffer,"LVN_SETDISPINFO"); else return 0; } else if(ClassID==CT_UPDOWN){ if(lstrcmp(EventName,"Deltapos")==0) lstrcpy(buffer,"UDN_DELTAPOS"); else return 0; } else return 0; //未完成 } return 1; } BOOL GetNotifyCommandByItemMessage(WINDOW_INFO *pWindowInfo,ITEMEVENTINFO *pItemEventInfo,char *Command,char *spaces){ int i,i2,i3,sw; char temporary[MAX_PATH]; i2=0; sw=0; for(i=0;;i++){ if(pItemEventInfo[i].IdName==0) break; if(pItemEventInfo[i].ClassID==CT_LISTVIEW|| pItemEventInfo[i].ClassID==CT_TREEVIEW|| pItemEventInfo[i].ClassID==CT_UPDOWN|| pItemEventInfo[i].ClassID==CT_PROGRESSBAR|| pItemEventInfo[i].ClassID==CT_TRACKBAR){ //コモン コントロール(WM_NOTIFY) sw=1; sprintf(Command+i2,"%sCase %s\r\n",spaces,pItemEventInfo[i].IdName); i2+=lstrlen(Command+i2); sprintf(Command+i2,"%s\tSelect Case pnmHdr->code\r\n",spaces); i2+=lstrlen(Command+i2); for(i3=0;i3name,pItemEventInfo[i].IdName,pItemEventInfo[i].pEventNames[i3]); i2+=lstrlen(Command+i2); } } sprintf(Command+i2,"%s\tEnd Select\r\n",spaces); i2+=lstrlen(Command+i2); } } return sw; } void GetItemMessageNameByEvent(char *buffer,int ClassID,const char *EventName){ if(ClassID==CT_BUTTON|| ClassID==CT_CHECKBOX|| ClassID==CT_RADIOBUTTON){ if(lstrcmp(EventName,"Click")==0) lstrcpy(buffer,"BN_CLICKED"); else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"BN_DBLCLK"); } else if(ClassID==CT_COMBOBOX){ if(lstrcmp(EventName,"CloseUp")==0) lstrcpy(buffer,"CBN_CLOSEUP"); else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"CBN_DBLCLK"); else if(lstrcmp(EventName,"DropDown")==0) lstrcpy(buffer,"CBN_DROPDOWN"); else if(lstrcmp(EventName,"EditChange")==0) lstrcpy(buffer,"CBN_EDITCHANGE"); else if(lstrcmp(EventName,"EditUpdate")==0) lstrcpy(buffer,"CBN_EDITUPDATE"); else if(lstrcmp(EventName,"ErrSpace")==0) lstrcpy(buffer,"CBN_ERRSPACE"); else if(lstrcmp(EventName,"KillFocus")==0) lstrcpy(buffer,"CBN_KILLFOCUS"); else if(lstrcmp(EventName,"SelChange")==0) lstrcpy(buffer,"CBN_SELCHANGE"); else if(lstrcmp(EventName,"SelEndCancel")==0) lstrcpy(buffer,"CBN_SELENDCANCEL"); else if(lstrcmp(EventName,"SelEndOk")==0) lstrcpy(buffer,"CBN_SELENDOK"); else if(lstrcmp(EventName,"SetFocus")==0) lstrcpy(buffer,"CBN_SETFOCUS"); } else if(ClassID==CT_EDIT){ if(lstrcmp(EventName,"Change")==0) lstrcpy(buffer,"EN_CHANGE"); else if(lstrcmp(EventName,"ErrSpace")==0) lstrcpy(buffer,"EN_ERRSPACE"); else if(lstrcmp(EventName,"HScroll")==0) lstrcpy(buffer,"EN_HSCROLL"); else if(lstrcmp(EventName,"KillFocus")==0) lstrcpy(buffer,"EN_KILLFOCUS"); else if(lstrcmp(EventName,"MaxText")==0) lstrcpy(buffer,"EN_MAXTEXT"); else if(lstrcmp(EventName,"SetFocus")==0) lstrcpy(buffer,"EN_SETFOCUS"); else if(lstrcmp(EventName,"Update")==0) lstrcpy(buffer,"EN_UPDATE"); else if(lstrcmp(EventName,"VScroll")==0) lstrcpy(buffer,"EN_VSCROLL"); } else if(ClassID==CT_IMAGEBOX|| ClassID==CT_STATIC){ if(lstrcmp(EventName,"Click")==0) lstrcpy(buffer,"STN_CLICKED"); else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"STN_DBLCLK"); } else if(ClassID==CT_LISTBOX){ if(lstrcmp(EventName,"SelChange")==0) lstrcpy(buffer,"LBN_SELCHANGE"); else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"LBN_DBLCLK"); else if(lstrcmp(EventName,"ErrSpace")==0) lstrcpy(buffer,"LBN_ERRSPACE"); else if(lstrcmp(EventName,"KillFocus")==0) lstrcpy(buffer,"LBN_KILLFOCUS"); else if(lstrcmp(EventName,"SelCancel")==0) lstrcpy(buffer,"LBN_SELCANCEL"); else if(lstrcmp(EventName,"SetFocus")==0) lstrcpy(buffer,"LBN_SETFOCUS"); } } void GetCommandByItemMessage(WINDOW_INFO *pWindowInfo,ITEMEVENTINFO *pItemEventInfo,char *Command,char *spaces){ extern HANDLE hHeap; int i,i2,i3; char temporary[MAX_PATH]; i2=0; for(i=0;;i++){ if(pItemEventInfo[i].IdName==0) break; if(pItemEventInfo[i].ClassID!=CT_LISTVIEW&& pItemEventInfo[i].ClassID!=CT_PROGRESSBAR&& pItemEventInfo[i].ClassID!=CT_TREEVIEW&& pItemEventInfo[i].ClassID!=CT_TRACKBAR&& pItemEventInfo[i].ClassID!=CT_UPDOWN ){ //WM_COMMAND sprintf(Command+i2,"%sCase %s\r\n",spaces,pItemEventInfo[i].IdName); i2+=lstrlen(Command+i2); if(pItemEventInfo[i].ClassID==CT_MENU){ sprintf(Command+i2,"%s\t%s_%s_MenuClick()\r\n",spaces,pWindowInfo->name,pItemEventInfo[i].IdName); i2+=lstrlen(Command+i2); for(i3=0;i3name,pItemEventInfo[i].IdName,pItemEventInfo[i].pEventNames[i3]); i2+=lstrlen(Command+i2); HeapDefaultFree(pItemEventInfo[i].pEventNames[i3]); } sprintf(Command+i2,"%s\tEnd Select\r\n",spaces); i2+=lstrlen(Command+i2); } HeapDefaultFree(pItemEventInfo[i].IdName); HeapDefaultFree(pItemEventInfo[i].pEventNames); } else{ //WM_NOTIFY情報のメモリ解放 for(i3=0;i3name,MessageName); } else if(lstrcmp(MessageName,"Create")==0){ if(pWindowInfo->type==WNDTYPE_MODALDLG||pWindowInfo->type==WNDTYPE_MODELESSDLG) sprintf(Command,"%sCase WM_INITDIALOG\r\n",spaces); else sprintf(Command,"%sCase WM_CREATE\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s=hWnd\r\n",spaces,pWindowInfo->HandleName); i+=lstrlen(Command+i); if(pWindowInfo->MenuID){ //メニュー作成 for(i2=0;i2MenuID)==0) break; } if(i2!=ProjectInfo.NumberOfMenu){ sprintf(Command+i,"%s\tSetMenu(hWnd,hMenu_%s)\r\n",spaces,ProjectInfo.pMenuInfo[i2].IdName); i+=lstrlen(Command+i); } } //子ウィンドウ作成 for(i2=0,sw=0;i2NumberOfChildWindows;i2++){ if(pWindowInfo->pChildInfo[i2].Control==CT_UPDOWN){ sprintf(Command+i,"%s\tCreateUpDownControl(%d,%d,%d,%d,%d,hWnd,%s,GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,0,0,100,0)\r\n", spaces, pWindowInfo->pChildInfo[i2].style, pWindowInfo->pChildInfo[i2].pos.x,pWindowInfo->pChildInfo[i2].pos.y, pWindowInfo->pChildInfo[i2].size.cx,pWindowInfo->pChildInfo[i2].size.cy, pWindowInfo->pChildInfo[i2].IdName); i+=lstrlen(Command+i); } else{ GetItemClassName(temporary,pWindowInfo->pChildInfo[i2].Control); temp2=FormatCaption(pWindowInfo->pChildInfo[i2].caption); sprintf(Command+i,"%s\tCreateWindowEx(&H%08x,\"%s\",\"%s\",&H%08x,%d,%d,%d,%d,hWnd,%s As HMENU,GetModuleHandle(0),0)\r\n", spaces, pWindowInfo->pChildInfo[i2].ExStyle, temporary, temp2, pWindowInfo->pChildInfo[i2].style, pWindowInfo->pChildInfo[i2].pos.x, pWindowInfo->pChildInfo[i2].pos.y, pWindowInfo->pChildInfo[i2].size.cx, pWindowInfo->pChildInfo[i2].size.cy, pWindowInfo->pChildInfo[i2].IdName); i+=lstrlen(Command+i); HeapDefaultFree(temp2); sprintf(Command+i,"%s\tSendMessage(GetDlgItem(hWnd,%s),WM_SETFONT,hFont_%s As WPARAM,0)\r\n", spaces, pWindowInfo->pChildInfo[i2].IdName, pWindowInfo->name); i+=lstrlen(Command+i); if(pWindowInfo->pChildInfo[i2].Control==CT_IMAGEBOX){ //イメージ ボックスの場合 if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_ICON){ if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_FILE){ if(strstr(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,":")|| strstr(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,"\\\\")){ sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,\"%s\",IMAGE_ICON,0,0,LR_DEFAULTSIZE or LR_LOADFROMFILE)\r\n", spaces, pWindowInfo->name, pWindowInfo->pChildInfo[i2].IdName, pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path); } else{ if(sw==0){ sw=1; lstrcpy(Command+i,"\r\n"); i+=2; sprintf(Command+i,"%s\tDim ImageFilePath[MAX_PATH] As Byte\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tDim ModulePath[MAX_PATH] As Byte, i As Long\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tGetModuleFileName(GetModuleHandle(0),ModulePath,MAX_PATH)\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tFor i=lstrlen(ModulePath)-1 To 0 Step -1\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\t\tIf ModulePath[i]=&H5C Then Exit For\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tNext\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tModulePath[i+1]=0\r\n",spaces); i+=lstrlen(Command+i); lstrcpy(Command+i,"\r\n"); i+=2; } sprintf(Command+i,"%s\twsprintf(ImageFilePath,\"%%s%s\",ModulePath)\r\n",spaces,pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path); i+=lstrlen(Command+i); sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,ImageFilePath,IMAGE_ICON,0,0,LR_DEFAULTSIZE or LR_LOADFROMFILE)\r\n", spaces, pWindowInfo->name, pWindowInfo->pChildInfo[i2].IdName); } i+=lstrlen(Command+i); } else if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_RES){ sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,%s As *Byte,IMAGE_ICON,0,0,LR_DEFAULTSIZE)\r\n", spaces, pWindowInfo->name, pWindowInfo->pChildInfo[i2].IdName, pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path); i+=lstrlen(Command+i); } sprintf(Command+i,"%s\tSendMessage(GetDlgItem(hWnd,%s),STM_SETICON,hImage_%s_%s As WPARAM,0)\r\n", spaces, pWindowInfo->pChildInfo[i2].IdName, pWindowInfo->name, pWindowInfo->pChildInfo[i2].IdName); i+=lstrlen(Command+i); } else if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_BITMAP){ if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_FILE){ if(strstr(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,":")|| strstr(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,"\\\\")){ sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,\"%s\",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE or LR_LOADFROMFILE)\r\n", spaces, pWindowInfo->name, pWindowInfo->pChildInfo[i2].IdName, pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path); } else{ if(sw==0){ sw=1; lstrcpy(Command+i,"\r\n"); i+=2; sprintf(Command+i,"%s\tDim ImageFilePath[MAX_PATH] As Byte\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tDim ModulePath[MAX_PATH] As Byte, i As Long\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tGetModuleFileName(GetModuleHandle(0),ModulePath,MAX_PATH)\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tFor i=lstrlen(ModulePath)-1 To 0 Step -1\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\t\tIf ModulePath[i]=&H5C Then Exit For\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tNext\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tModulePath[i+1]=0\r\n",spaces); i+=lstrlen(Command+i); lstrcpy(Command+i,"\r\n"); i+=2; } sprintf(Command+i,"%s\twsprintf(ImageFilePath,\"%%s%s\",ModulePath)\r\n",spaces,pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path); i+=lstrlen(Command+i); sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,ImageFilePath,IMAGE_BITMAP,0,0,LR_LOADFROMFILE)\r\n", spaces, pWindowInfo->name, pWindowInfo->pChildInfo[i2].IdName); } i+=lstrlen(Command+i); } else if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_RES){ sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,%s As *Byte,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE)\r\n", spaces, pWindowInfo->name, pWindowInfo->pChildInfo[i2].IdName, pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path); i+=lstrlen(Command+i); } sprintf(Command+i,"%s\tSendMessage(GetDlgItem(hWnd,%s),STM_SETIMAGE,IMAGE_BITMAP,hImage_%s_%s As LPARAM)\r\n", spaces, pWindowInfo->pChildInfo[i2].IdName, pWindowInfo->name, pWindowInfo->pChildInfo[i2].IdName); i+=lstrlen(Command+i); } } } } if(bProcedureCall) sprintf(Command+i,"%s\t%s_%s(ByVal (lParam As VoidPtr))\r\n",spaces,pWindowInfo->name,MessageName); return WM_CREATE; } else if(lstrcmp(MessageName,"Destroy")==0){ sprintf(Command,"%sCase WM_DESTROY\r\n",spaces); i=lstrlen(Command); if(bProcedureCall){ sprintf(Command+i,"%s\t%s_%s()\r\n",spaces,pWindowInfo->name,MessageName); i+=lstrlen(Command+i); } if(pWindowInfo->MenuID){ //メニューを解放 for(i2=0;i2MenuID)==0) break; } if(i2!=ProjectInfo.NumberOfMenu){ sprintf(Command+i,"%s\tSetMenu(hWnd,NULL)\r\n",spaces); i+=lstrlen(Command+i); } } //イメージ ボックス用の変数を解放 for(i2=0;i2NumberOfChildWindows;i2++){ if(pWindowInfo->pChildInfo[i2].Control==CT_IMAGEBOX){ if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_ICON) sprintf(Command+i,"%s\tDestroyIcon(hImage_%s_%s)\r\n",spaces,pWindowInfo->name,pWindowInfo->pChildInfo[i2].IdName); else if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_BITMAP) sprintf(Command+i,"%s\tDeleteObject(hImage_%s_%s)\r\n",spaces,pWindowInfo->name,pWindowInfo->pChildInfo[i2].IdName); i+=lstrlen(Command+i); } } return WM_DESTROY; } else if(lstrcmp(MessageName,"DropFiles")==0){ sprintf(Command,"%sCase WM_DROPFILES\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As HDROP)\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"HScroll")==0){ sprintf(Command,"%sCase WM_HSCROLL\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(LOWORD(wParam),HIWORD(wParam),lParam As HWND)\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"KeyDown")==0){ sprintf(Command,"%sCase WM_KEYDOWN\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,lParam As Long)\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"KeyPress")==0){ sprintf(Command,"%sCase WM_CHAR\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,lParam As Long)\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"KeyUp")==0){ sprintf(Command,"%sCase WM_KEYUP\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,lParam As Long)\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"LButtonDown")==0){ sprintf(Command,"%sCase WM_LBUTTONDOWN\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"LButtonDblClick")==0){ sprintf(Command,"%sCase WM_LBUTTONDBLCLK\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"LButtonUp")==0){ sprintf(Command,"%sCase WM_LBUTTONUP\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"MButtonDown")==0){ sprintf(Command,"%sCase WM_MBUTTONDOWN\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"MButtonDblClick")==0){ sprintf(Command,"%sCase WM_MBUTTONDBLCLK\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"MButtonUp")==0){ sprintf(Command,"%sCase WM_MBUTTONUP\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"MouseMove")==0){ sprintf(Command,"%sCase WM_MOUSEMOVE\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"Move")==0){ sprintf(Command,"%sCase WM_MOVE\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"Notify")==0){ //コモンコントロールメッセージと共に挿入 return WM_NOTIFY; } else if(lstrcmp(MessageName,"Paint")==0){ sprintf(Command,"%sCase WM_PAINT\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\tDim ps As PAINTSTRUCT\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tDim hDC As HDC\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\thDC=BeginPaint(hWnd,ps)\r\n",spaces); i+=lstrlen(Command+i); sprintf(Command+i,"%s\t%s_%s(hDC)\r\n",spaces,pWindowInfo->name,MessageName); i+=lstrlen(Command+i); sprintf(Command+i,"%s\tEndPaint(hWnd,ps)\r\n",spaces); return WM_PAINT; } else if(lstrcmp(MessageName,"QueryClose")==0){ sprintf(Command,"%sCase WM_CLOSE\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\tDim cancel=0 As Integer\r\n",spaces); i+=lstrlen(Command+i); if(bProcedureCall){ sprintf(Command+i,"%s\t%s_%s(cancel)\r\n",spaces,pWindowInfo->name,MessageName); i+=lstrlen(Command+i); } if(pWindowInfo->type==WNDTYPE_MODALDLG) sprintf(Command+i,"%s\tIf cancel=0 Then EndDialog(hWnd,0)\r\n",spaces); else sprintf(Command+i,"%s\tIf cancel=0 Then DestroyWindow(hWnd)\r\n",spaces); return WM_CLOSE; } else if(lstrcmp(MessageName,"RButtonDblClick")==0){ sprintf(Command,"%sCase WM_RBUTTONDBLCLK\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"RButtonDown")==0){ sprintf(Command,"%sCase WM_RBUTTONDOWN\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"RButtonUp")==0){ sprintf(Command,"%sCase WM_RBUTTONUP\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"Resize")==0){ sprintf(Command,"%sCase WM_SIZE\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"SetFocus")==0){ sprintf(Command,"%sCase WM_SETFOCUS\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s()\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"Timer")==0){ sprintf(Command,"%sCase WM_TIMER\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam As DWord)\r\n",spaces,pWindowInfo->name,MessageName); } else if(lstrcmp(MessageName,"VScroll")==0){ sprintf(Command,"%sCase WM_VSCROLL\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(LOWORD(wParam),HIWORD(wParam),lParam As HWND)\r\n",spaces,pWindowInfo->name,MessageName); } /////////////////// // MMSYS コマンド else if(lstrcmp(MessageName,"MciNotify")==0){ sprintf(Command,"%sCase MM_MCINOTIFY\r\n",spaces); i=lstrlen(Command); sprintf(Command+i,"%s\t%s_%s(wParam,lParam)\r\n",spaces,pWindowInfo->name,MessageName); } return 0; } char **GetMenuItemConstData(MENU_INFO *pMenuInfo,int NumberOfMenu,int *ConstNumber,char **ppNames,int *NamesNum,char *buffer,int *base){ extern HANDLE hHeap; int i,i2,sw1; for(i=0;i=0;i2--){ if(pMenuInfo[i2].pMenuInfo){ sprintf(temporary,"%s_%d",MenuHandle,i2); i+=GetMakeMenuCommand(pMenuInfo[i2].pMenuInfo,pMenuInfo[i2].NumberOfMenu,temporary,Command+i,0); sprintf(Command+i,"InsMenu %s,0,MF_BYPOSITION,Ex\"%s\",0,%s,%d\r\n", MenuHandle, pMenuInfo[i2].caption, temporary, pMenuInfo[i2].state); i+=lstrlen(Command+i); } else{ if(pMenuInfo[i2].type==MFT_STRING){ sprintf(Command+i,"InsMenu %s,0,MF_BYPOSITION,Ex\"%s\",%s,0,%d\r\n", MenuHandle, pMenuInfo[i2].caption, pMenuInfo[i2].IdName, pMenuInfo[i2].state); i+=lstrlen(Command+i); } else if(pMenuInfo[i2].type==MFT_SEPARATOR){ sprintf(Command+i,"InsMenu %s,0,MF_BYPOSITION,\"\"\r\n", MenuHandle); i+=lstrlen(Command+i); } } } return i; } int GetDestroyMenuCommand(MENU_INFO *pMenuInfo,int NumberOfMenu,char *MenuHandle,char *Command){ int i,i2; char temporary[MAX_PATH]; i=0; sprintf(Command+i,"\tDestroyMenu(%s)\r\n",MenuHandle); i+=lstrlen(Command+i); for(i2=NumberOfMenu-1;i2>=0;i2--){ if(pMenuInfo[i2].pMenuInfo){ sprintf(temporary,"%s_%d",MenuHandle,i2); i+=GetDestroyMenuCommand(pMenuInfo[i2].pMenuInfo,pMenuInfo[i2].NumberOfMenu,temporary,Command+i); } } return i; } void SaveWindowProgram(){ extern HANDLE hHeap; extern PROJECTINFO ProjectInfo; int i,i2,i3,i4,i5,i6,sw1,sw2,sw3,sw4,size; char *buffer,**ppNames,temporary[MAX_PATH]; size=2; buffer=(char *)HeapAlloc(hHeap,0,65535*size); lstrcpy(buffer,"'このファイルはウィンドウ定義ファイル(*.wnd)をもとに生成されています\r\n\r\n"); i2=lstrlen(buffer); if(ProjectInfo.dwOption&PJ_OP_COMMCTRL){ //コマンコントロールを初期化 lstrcpy(buffer+i2,"Dim _RadSys_InitCtrls As INITCOMMONCONTROLSEX\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_InitCtrls.dwSize=Len(_RadSys_InitCtrls)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_InitCtrls.dwICC=ICC_WIN95_CLASSES\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"InitCommonControlsEx(_RadSys_InitCtrls)\r\n\r\n"); i2+=lstrlen(buffer+i2); } //////////// //IDを定義 ppNames=(char **)HeapAlloc(hHeap,0,1); for(i=0,i4=1000,i5=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } } //メニューのIDを定義 ppNames=GetMenuItemConstData(ProjectInfo.pMenuInfo,ProjectInfo.NumberOfMenu,&i4,ppNames,&i5,buffer,&i2); HeapDefaultFree(ppNames); lstrcpy(buffer+i2,"\r\n"); i2+=lstrlen(buffer+i2); //ハンドル変数を定義 for(i=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } //背景に使用するブラシを定義 lstrcpy(buffer+i2,"Dim h3DFaceBrush As HBRUSH\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"h3DFaceBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE))\r\n"); i2+=lstrlen(buffer+i2); for(i=0;i=0x1000){ sprintf(buffer+i2,"Dim _RadSys_hBackBrush%d As HBRUSH\r\n",i); i2+=lstrlen(buffer+i2); sprintf(buffer+i2,"_RadSys_hBackBrush%d=CreatePatternBrush(LoadImage(GetModuleHandle(0),%s,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE or LR_SHARED))\r\n", i, ProjectInfo.res.pBitmapResInfo[ProjectInfo.windowInfos[i].bgColor-0x1000].IdName); i2+=lstrlen(buffer+i2); } } lstrcpy(buffer+i2,"\r\n"); i2+=lstrlen(buffer+i2); //イメージ ボックス用の変数を定義 for(i=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } } } } lstrcpy(buffer+i2,"\r\n"); i2+=lstrlen(buffer+i2); //メニュー作成 for(i=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } ////////////////////////// //オブジェクトの解放処理 sprintf(buffer+i2,"Sub %s_DestroyObjects()\r\n",ProjectInfo.name); i2+=lstrlen(buffer+i2); //メニュー解放 for(i=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } for(i=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } //背景ブラシを解放 lstrcpy(buffer+i2,"\tDeleteObject(h3DFaceBrush)\r\n"); i2+=lstrlen(buffer+i2); for(i=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } ////////////////////////// //ダイアログボックス関連 //クラス登録 lstrcpy(buffer+i2,"\r\nFunction DefaultCallProc(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tDefaultCallProc=DefWindowProc(hWnd,message,wParam,lParam)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"End Function\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\r\nDim _RadSys_dlgwcl As WNDCLASSEX\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"FillMemory(VarPtr(_RadSys_dlgwcl),Len(_RadSys_dlgwcl),0)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.cbSize=Len(_RadSys_dlgwcl)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.hInstance=GetModuleHandle(0)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.style=CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI_APPLICATION))\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.hIconSm=LoadIcon(NULL,MAKEINTRESOURCE(IDI_WINLOGO))\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.hCursor=LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW))\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.lpszClassName=\"NORMALDLG\"\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.hbrBackground=h3DFaceBrush\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_dlgwcl.lpfnWndProc=AddressOf(DefaultCallProc)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"RegisterClassEx(_RadSys_dlgwcl)\r\n"); i2+=lstrlen(buffer+i2); //DialogBox関数 lstrcpy(buffer+i2,"\r\nFunction DialogBox(hOwnerWnd As HWND, TemplateName As LPSTR) As LONG_PTR\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tDim hDlg As HWND\r\n"); i2+=lstrlen(buffer+i2); for(i=0,sw1=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } if(sw1){ lstrcpy(buffer+i2,"\tElse\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\t\tExit Function\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tEnd If\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tEnableWindow(hOwnerWnd,0)\r\n\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tDim msg As MSG, iResult As Long\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tDo\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\t\tiResult=GetMessage(msg,0,0,0)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\t\tIf iResult=0 or iResult=-1 Then Exit Do\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\t\tIf IsDialogMessage(hDlg,msg) Then Continue\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\t\tTranslateMessage(msg)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\t\tDispatchMessage(msg)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tLoop\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tDialogBox=msg.wParam\r\n"); i2+=lstrlen(buffer+i2); } lstrcpy(buffer+i2,"End Function\r\n"); i2+=lstrlen(buffer+i2); //EndDialog関数 lstrcpy(buffer+i2,"Sub EndDialog(hWnd As HWND, lResult As Long)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tEnableWindow(GetWindow(hWnd,GW_OWNER),1)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tDestroyWindow(hWnd)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"\tPostMessage(0,WM_QUIT,lResult,0)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"End Sub\r\n"); i2+=lstrlen(buffer+i2); //CreateDialog関数 lstrcpy(buffer+i2,"\r\nFunction CreateDialog(hOwnerWnd As HWND, TemplateName As LPSTR) As HWND\r\n"); i2+=lstrlen(buffer+i2); for(i=0;i65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } lstrcpy(buffer+i2,"End Function\r\n"); i2+=lstrlen(buffer+i2); /////////////////////// // 保存(Callback.wbp) sprintf(temporary,"%sCallback.wbp",ProjectInfo.dir); WriteBuffer(temporary,buffer,i2); lstrcpy(buffer,"'このファイルはウィンドウ定義ファイル(*.wnd)をもとに生成されています\r\n\r\n"); i2=lstrlen(buffer); lstrcpy(buffer+i2,"Dim _RadSys_wcl As WNDCLASSEX\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"FillMemory(VarPtr(_RadSys_wcl),Len(_RadSys_wcl),0)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_wcl.cbSize=Len(_RadSys_wcl)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_wcl.hInstance=GetModuleHandle(0)\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_wcl.style=CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS\r\n"); i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"_RadSys_wcl.hCursor=LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW))\r\n"); i2+=lstrlen(buffer+i2); for(i=0;i=0x1000){ //色指定またはビットマップ sprintf(buffer+i2,"_RadSys_wcl.hbrBackground=_RadSys_hBackBrush%d\r\n",i); } i2+=lstrlen(buffer+i2); lstrcpy(buffer+i2,"RegisterClassEx(_RadSys_wcl)\r\n"); i2+=lstrlen(buffer+i2); sprintf(buffer+i2,"CreateWindowEx(&H%08x,\"%s%d\",\"%s\",&H%08x,%d,%d,%d,%d,0,0,GetModuleHandle(0),0)\r\n", ProjectInfo.windowInfos[i].ExStyle, ProjectInfo.windowInfos[i].ClassName,i, ProjectInfo.windowInfos[i].caption, ProjectInfo.windowInfos[i].style, ProjectInfo.windowInfos[i].pos.x, ProjectInfo.windowInfos[i].pos.y, ProjectInfo.windowInfos[i].size.cx, ProjectInfo.windowInfos[i].size.cy); i2+=lstrlen(buffer+i2); } while(i2>65535*(size-1)){ size++; buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size); } } ///////////////////////// // 保存(MakeWindow.wbp) sprintf(temporary,"%sMakeWindow.wbp",ProjectInfo.dir); WriteBuffer(temporary,buffer,i2); HeapDefaultFree(buffer); } int GetSaveMenuData(char *buffer,int SpaceNum,MENU_INFO *pMenuInfo,int ItemNum){ int i,i2; char spaces[MAX_PATH]; memset(spaces,' ',SpaceNum*4); spaces[SpaceNum*4]=0; for(i=0,i2=0;i &windowInfos ) { extern HANDLE hHeap; extern MDIINFO MdiInfo[MAX_WNDNUM]; extern PROJECTINFO ProjectInfo; int i,i2,i3,size; char *buffer,*temporary; size=2; buffer=(char *)HeapAlloc(hHeap,0,GENERAL_SIZE*size); for(i=0,i2=0;iIdName=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1); lstrcpy(pChildInfo->IdName,temp3); //位置 i5=GetOneParameter(temp2,i5,temp3); pChildInfo->pos.x=GetValue(temp3); i5=GetOneParameter(temp2,i5,temp3); pChildInfo->pos.y=GetValue(temp3); i5=GetOneParameter(temp2,i5,temp3); pChildInfo->size.cx=GetValue(temp3); i5=GetOneParameter(temp2,i5,temp3); pChildInfo->size.cy=GetValue(temp3); //テキスト i5=GetOneParameter(temp2,i5,temp3); RemoveStringQuotes(temp3); RestoreCaptionSequence(temp3); pChildInfo->caption=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1); lstrcpy(pChildInfo->caption,temp3); //スタイル i5=GetOneParameter(temp2,i5,temp3); pChildInfo->style=GetValue(temp3); //拡張スタイル i5=GetOneParameter(temp2,i5,temp3); pChildInfo->ExStyle=GetValue(temp3); //クラス i5=GetOneParameter(temp2,i5,temp3); pChildInfo->Control=GetValue(temp3); if(pChildInfo->Control==CT_IMAGEBOX){ //イメージ ボックスの場合 i5=GetOneParameter(temp2,i5,temp3); pChildInfo->ImageCtrlInfo.type=GetValue(temp3); i5=GetOneParameter(temp2,i5,temp3); RemoveStringQuotes(temp3); pChildInfo->ImageCtrlInfo.path=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1); lstrcpy(pChildInfo->ImageCtrlInfo.path,temp3); } ProjectInfo.windowInfos.back().NumberOfChildWindows++; } //////////// //メニュー else if(lstrcmpi(temporary,"MENU")==0&&i3==0){ ProjectInfo.NumberOfMenu++; ProjectInfo.pMenuInfo=(MENU_INFO *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,ProjectInfo.pMenuInfo,ProjectInfo.NumberOfMenu*sizeof(MENU_INFO)); i4=ProjectInfo.NumberOfMenu-1; //ID名 ProjectInfo.pMenuInfo[i4].IdName=(char *)HeapAlloc(hHeap,0,lstrlen(temp2)+1); lstrcpy(ProjectInfo.pMenuInfo[i4].IdName,temp2); ProjectInfo.pMenuInfo[i4].pMenuInfo=GetMenuData(buffer,&i,&ProjectInfo.pMenuInfo[i4].NumberOfMenu); if(!ProjectInfo.pMenuInfo[i4].pMenuInfo){ //"ウィンドウ定義ファイルが壊れています。\n\n%s" sprintf(temporary,STRING_ERROR_BROKEN_WNDFILE,path); MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION); HeapDefaultFree(temp2); HeapDefaultFree(buffer); return 0; } } else if(lstrcmpi(temporary,"END")==0&&i3) i3=0; else{ //"ウィンドウ定義ファイルが壊れています。\n\n%s" sprintf(temporary,STRING_ERROR_BROKEN_WNDFILE,path); MessageBox(hOwner,temporary,APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION); HeapDefaultFree(temp2); HeapDefaultFree(buffer); return 0; } i--; } } HeapDefaultFree(temp2); HeapDefaultFree(buffer); return 1; } struct NEW_WINDOW{ char name[MAX_PATH]; char HandleName[MAX_PATH]; char CallBackName[MAX_PATH]; BOOL type; }; NEW_WINDOW NewWindow; BOOL CALLBACK DlgProject_NewWindow(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){ char temporary[MAX_PATH],temp2[MAX_PATH]; switch(message){ case WM_INITDIALOG: SetPosCenter(hwnd); SendDlgItemMessage(hwnd,IDC_AUTOSET,BM_SETCHECK,BST_CHECKED,0); SendMessage(hwnd,WM_COMMAND,IDC_AUTOSET,0); SendDlgItemMessage(hwnd,IDC_MODALDLG,BM_SETCHECK,BST_CHECKED,0); break; case WM_COMMAND: switch(LOWORD(wParam)){ case IDOK: GetDlgItemText(hwnd,IDC_WINDOWNAME,NewWindow.name,MAX_PATH); GetDlgItemText(hwnd,IDC_WINDOWHANDLE,NewWindow.HandleName,MAX_PATH); GetDlgItemText(hwnd,IDC_WINDOWPROC,NewWindow.CallBackName,MAX_PATH); if(SendDlgItemMessage(hwnd,IDC_DEFWINDOW,BM_GETCHECK,0,0)) NewWindow.type=WNDTYPE_DEFAULT; else if(SendDlgItemMessage(hwnd,IDC_MODALDLG,BM_GETCHECK,0,0)) NewWindow.type=WNDTYPE_MODALDLG; else if(SendDlgItemMessage(hwnd,IDC_MODELESSDLG,BM_GETCHECK,0,0)) NewWindow.type=WNDTYPE_MODELESSDLG; EndDialog(hwnd,1); return 1; case IDCANCEL: EndDialog(hwnd,0); return 1; case IDC_WINDOWNAME: if(HIWORD(wParam)==EN_CHANGE) SendMessage(hwnd,WM_COMMAND,IDC_AUTOSET,0); return 1; case IDC_AUTOSET: if(SendDlgItemMessage(hwnd,IDC_AUTOSET,BM_GETCHECK,0,0)){ SendDlgItemMessage(hwnd,IDC_WINDOWHANDLE,EM_SETREADONLY,1,0); SendDlgItemMessage(hwnd,IDC_WINDOWPROC,EM_SETREADONLY,1,0); GetDlgItemText(hwnd,IDC_WINDOWNAME,temporary,MAX_PATH); if(temporary[0]){ sprintf(temp2,"h%s",temporary); SetDlgItemText(hwnd,IDC_WINDOWHANDLE,temp2); sprintf(temp2,"%sProc",temporary); SetDlgItemText(hwnd,IDC_WINDOWPROC,temp2); } else{ SetDlgItemText(hwnd,IDC_WINDOWHANDLE,""); SetDlgItemText(hwnd,IDC_WINDOWPROC,""); } } else{ SendDlgItemMessage(hwnd,IDC_WINDOWHANDLE,EM_SETREADONLY,0,0); SendDlgItemMessage(hwnd,IDC_WINDOWPROC,EM_SETREADONLY,0,0); } return 1; } break; } return 0; } void GetDefaultWindowFont(LOGFONT *LogFont){ LogFont->lfHeight=-12; LogFont->lfWidth=0; LogFont->lfEscapement=0; LogFont->lfOrientation=0; LogFont->lfWeight=FW_REGULAR; LogFont->lfItalic=0; LogFont->lfUnderline=0; LogFont->lfStrikeOut=0; LogFont->lfCharSet=SHIFTJIS_CHARSET; LogFont->lfOutPrecision=OUT_STROKE_PRECIS; LogFont->lfClipPrecision=CLIP_STROKE_PRECIS; LogFont->lfQuality=DRAFT_QUALITY; LogFont->lfPitchAndFamily=FF_SWISS; lstrcpy(LogFont->lfFaceName,"MS Pゴシック"); } void Project_Window_Insert(void){ extern HANDLE hHeap; extern PROJECTINFO ProjectInfo; int i; char temporary[MAX_PATH],temp2[1024],*pTemp; if(!DialogBox(hResInst,MAKEINTRESOURCE(IDD_PROJECT_NEWWINDOW),hOwner,(DLGPROC)DlgProject_NewWindow)) return; //重複チェック sprintf(temporary,"%s.sbp",NewWindow.name); if(ProjectInfo.pobj_DBFileInfo->dupli_check(temporary)){ sprintf(temp2,"\"%s\" ファイルは既にプロジェクト内に存在します。",temporary); MessageBox(hOwner,temp2,APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION); return; } for(i=0;iname,MdiInfo[i].path)==0){ SendMessage(MdiInfo[i].hwnd,WM_CLOSE,0,0); break; } } //ウィンドウ情報のメモリを解放 HeapDefaultFree(pWindowInfo->name); HeapDefaultFree(pWindowInfo->filepath); HeapDefaultFree(pWindowInfo->HandleName); HeapDefaultFree(pWindowInfo->caption); HeapDefaultFree(pWindowInfo->ClassName); HeapDefaultFree(pWindowInfo->CallBackName); //子ウィンドウのメモリを解放 for(i=0;iNumberOfChildWindows;i++){ HeapDefaultFree(pWindowInfo->pChildInfo[i].IdName); HeapDefaultFree(pWindowInfo->pChildInfo[i].caption); } HeapDefaultFree(pWindowInfo->pChildInfo); //ツリービューから削除 extern HWND hMaterialTreeView; TreeView_DeleteItem(hMaterialTreeView,pWindowInfo->hTreeItem); //ProjectInfo.windowInfos構造体から削除 std::vector::iterator it = ProjectInfo.windowInfos.begin(); for( int i=0; i!=WndInfoNum ;i++, it++ ) { } ProjectInfo.windowInfos.erase( it ); ProjectInfo.ModifyOfMaterial=1; }