HDDEDATA FAR PASCAL _export PowDdeServerProc (UINT type,UINT fmt,HCONV hconv,HSZ hsz1,HSZ hsz2,HDDEDATA hdata,DWORD dwData1,DWORD dwData2) { LPSTR exec; HWND hWnd; DWORD size; HDDEDATA hDat; switch (type) { case XTYP_CONNECT: return (HDDEDATA)IsTopic(hsz1); case XTYP_EXECUTE: { char buf[1000]; if (IsTopic(hsz1)) { DdeGetData(hdata,buf,sizeof(buf),0); exec=GetExecData(buf); if (IsCommand(buf,"openfile")) { if (*exec && (hWnd=AlreadyOpen(exec))) BringWindowToTop(hWnd); else { #ifndef _WIN32 DownStr(exec); #endif AddFile(exec); } return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"newfile")) { hWnd=AddFile(0); if (hWnd && *exec) { HWND old; if (old=AlreadyOpen(exec)) SendMessage (hwndMDIClient,WM_MDIDESTROY,(WPARAM)old,0L); #ifndef _WIN32 DownStr(exec); #endif SetWindowText(hWnd,exec); SetWindowWord(hWnd,GWW_UNTITLED,0); } return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"savefile")) { if (GetActiveEditWindow(hwndMDIClient)) { if (*exec) { #ifndef _WIN32 AnsiLower(exec); #endif SetWindowText(GetActiveEditWindow(hwndMDIClient),exec); SetWindowWord(GetActiveEditWindow(hwndMDIClient),GWW_UNTITLED,0); } SendMessage(hwndFrame,WM_COMMAND,IDM_FILESAVE,0); } return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"activate")) { if (*exec && (hWnd=AlreadyOpen(exec))) BringWindowToTop(hWnd); return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"appendtext") || IsCommand(buf,"addtext")) { if (*exec && GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient))) EditAddText(GetActiveEditWindow(hwndMDIClient),exec); return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"inserttext")) { if (*exec && GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient))) EditInsertText(GetActiveEditWindow(hwndMDIClient),exec); return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"appendfile") || IsCommand(buf,"addtext")) { if (*exec && GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient))) { EditGotoPos(GetActiveEditWindow(hwndMDIClient),-1,-1); InsertFile(exec); } return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"insertfile")) { if (*exec && GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient))) InsertFile(exec); return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"showposition")) { /* go to line/col of a given file (open if necessary) */ if (*exec) { char *file,*sline,*scol; int line=-1,col=-1; file=strtok(exec," "); if (file) { /* read position */ sline=strtok(NULL," "); if (sline) { line=atoi(sline); scol=strtok(NULL," "); if (scol) col=atoi(scol); } /* display the file */ if (hWnd=AlreadyOpen(file)) BringWindowToTop(hWnd); else { #ifndef _WIN32 DownStr(file); #endif AddFile(file); } /* set caret to given position */ EditGotoPos(GetActiveEditWindow(hwndMDIClient),line,col); } } return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"addtool")) { /* create a new tool */ if (*exec) { LPSTR lp; char *name,*cmd,*dir,*options; BOOL menu,askArg,toTop; int buttonId; name=cmd=dir=options=NULL; menu=askArg=toTop=FALSE; buttonId=0; /* read tool name */ name=strtok(exec,","); if (name) { cmd=strtok(NULL,","); if (cmd) { dir=strtok(NULL,","); if (dir) { options=strtok(NULL,","); if (options) { lp=strtok(NULL,","); if (lp) { menu=(BOOL)atoi(lp); lp=strtok(NULL,","); if (lp) { buttonId=atoi(lp); lp=strtok(NULL,","); if (lp) { toTop=(BOOL)atoi(lp); lp=strtok(NULL,","); if (lp) { askArg=(BOOL)atoi(lp); } } } } } } } } if (strcmp(dir," ")==0) dir=""; if (strcmp(options," ")==0) options=""; if (name && cmd && *name && *cmd && (menu || buttonId)) ToolAdd(name,cmd,dir,options,menu,buttonId,toTop,askArg); } return (HDDEDATA)DDE_FACK; } else if (IsCommand(buf,"deletetool")) { /* remove an external tool */ if (*exec) ToolDelete(exec); return (HDDEDATA)DDE_FACK; } } return (HDDEDATA)DDE_FNOTPROCESSED; } case XTYP_POKE: { if (IsTopic(hsz1)) { if (IsEqualString(hsz2,"editbuffer")) { if (GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient))) { LPSTR lBuf; if (lBuf=DdeAccessData(hdata,(LPDWORD)&size)) { EditResetContent(GetActiveEditWindow(hwndMDIClient)); EditAddText(GetActiveEditWindow(hwndMDIClient),lBuf); DdeUnaccessData(hdata); } } return (HDDEDATA)DDE_FACK; } } return (HDDEDATA)DDE_FNOTPROCESSED; } case XTYP_REQUEST: { if (IsTopic(hsz1)) { if (IsEqualString(hsz2,"activefile")) { if (GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient))) { long len; char name[100]; HSZ hitem; hitem=DdeCreateStringHandle(ddeInstId,(LPSTR)"activefile",CP_WINANSI); len=GetWindowText(GetActiveEditWindow(hwndMDIClient),(LPSTR)name,sizeof(name)); return DdeCreateDataHandle(ddeInstId,(LPSTR)name,len+1,0,hitem,CF_TEXT,0); } } else if (IsEqualString(hsz2,"editbuffer")) { if (GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient))) { LPSTR lp; HGLOBAL h; if (h=EditGetText(GetActiveEditWindow(hwndMDIClient))) { HSZ hitem; hitem=DdeCreateStringHandle(ddeInstId,(LPSTR)"editbuffer",CP_WINANSI); lp=GlobalLock(h); hDat=DdeCreateDataHandle(ddeInstId,lp,GlobalSize(h),0,hitem,CF_TEXT,0); GlobalUnlock(h); GlobalFree(h); } else hDat=0; return hDat; } } else if (IsEqualString(hsz2,"compiler")) { /* return name of active compiler interface dll */ char name[100]; HSZ hitem; hitem=DdeCreateStringHandle(ddeInstId,(LPSTR)"compiler",CP_WINANSI); strcpy(name,actConfig.compiler); return DdeCreateDataHandle(ddeInstId,(LPSTR)name,strlen(name)+1,0,hitem,CF_TEXT,0); } else if (IsEqualString(hsz2,"executable")) { /* return name of target executale */ BOOL isExecutable; //FARPROC lpfn; char name[500]; HSZ hitem; if (IsCompilerInterfaceLoaded()) { if (!*actPrj) { RemoveMessageWindow(); if (GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient)) && !GetWindowWord(GetActiveEditWindow(hwndMDIClient),GWW_UNTITLED)) { SetDefaultProjectName(); isExecutable=(*compGetTarget)(hCompData,(LPSTR)name); if (*name && *RunArgs) { /* append run arguments (as string included in "") */ strcat(name," \""); strcat(name,RunArgs); strcat(name,"\""); } } else *name=0; } else isExecutable=(*compGetTarget)(hCompData,(LPSTR)name); } else *name=0; hitem=DdeCreateStringHandle(ddeInstId,(LPSTR)"executable",CP_WINANSI); return DdeCreateDataHandle(ddeInstId,(LPSTR)name,strlen(name)+1,0,hitem,CF_TEXT,0); } } return (HDDEDATA) NULL; } } if (type&XCLASS_FLAGS) return (HDDEDATA)DDE_FNOTPROCESSED; else return (HDDEDATA)NULL; }
LRESULT CALLBACK ProjectProc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { int i; RECT rs; NM_TREEVIEW *nm; DWINFO info; LPNMTVKEYDOWN key; PROJECTITEM *data; TVHITTESTINFO hittest; HWND win; HTREEITEM oldSel; static HCURSOR origCurs; static BOOL dragging; static BOOL inView; static HTREEITEM srcItem, dstItem; switch (iMessage) { LOGFONT lf; case WM_SYSCOMMAND: if (wParam == SC_CLOSE) SendMessage(hwnd, WM_CLOSE, 0, 0); break; // case WM_SETTEXT: // return SendMessage(hwndTab, iMessage, wParam, lParam); case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: SetFocus(hwnd); break; case WM_NOTIFY: nm = (NM_TREEVIEW*)lParam; switch (nm->hdr.code) { case NM_CUSTOMDRAW: return CustomDraw(hwnd, (LPNMTVCUSTOMDRAW)nm); case N_EDITDONE: DoneRenaming(); break; case TVN_BEGINDRAG: GetCursorPos(&hittest.pt); ScreenToClient(prjTreeWindow, &hittest.pt); srcItem = TreeView_HitTest(prjTreeWindow, &hittest); data = GetItemInfo(srcItem); if (data && (data->type == PJ_FILE || data->type == PJ_FOLDER)) { dragging = TRUE; SetCapture(hwnd); origCurs = SetCursor(dragCur); inView = TRUE; } break; case TVN_KEYDOWN: key = (LPNMTVKEYDOWN)lParam; switch (key->wVKey) { case VK_INSERT: if (GetKeyState(VK_CONTROL) &0x80000000) { data = GetItemInfo(prjSelectedItem); if (data) { int msg = -1; switch (data->type) { case PJ_WS: msg = IDM_EXISTINGPROJECT; break; case PJ_PROJ: msg = IDM_NEWFOLDER; break; case PJ_FOLDER: msg = IDM_EXISTINGFILE; break; } if (msg != -1) PostMessage(hwnd, WM_COMMAND, msg, 0); } } else if (GetKeyState(VK_SHIFT) &0x80000000) { data = GetItemInfo(prjSelectedItem); if (data) { int msg = -1; switch (data->type) { case PJ_WS: msg = IDM_NEWPROJECT; break; case PJ_PROJ: msg = IDM_NEWFOLDER; break; case PJ_FOLDER: msg = IDM_NEWFILE_P; break; } if (msg != -1) PostMessage(hwnd, WM_COMMAND, msg, 0); } } else { data = GetItemInfo(prjSelectedItem); if (data && (data->type != PJ_WS)) PostMessage(hwnd, WM_COMMAND, IDM_RENAME, 0); } break; case VK_DELETE: if (!(GetKeyState(VK_CONTROL) &0x80000000) && !(GetKeyState(VK_SHIFT) &0x8000000)) { data = GetItemInfo(prjSelectedItem); if (data && (data->type == PJ_FOLDER || data->type == PJ_FILE)) PostMessage(hwnd, WM_COMMAND, IDM_REMOVE, 0); } break; case VK_RETURN: SendMessage(hwnd, WM_COMMAND, IDM_OPENFILES, 0); break; } break; case NM_DBLCLK: oldSel = prjSelectedItem; GetCursorPos(&hittest.pt); ScreenToClient(prjTreeWindow, &hittest.pt); prjSelectedItem = TreeView_HitTest(prjTreeWindow, &hittest); if (prjSelectedItem) PostMessage(hwnd, WM_COMMAND, IDM_OPENFILES, 0); prjSelectedItem = oldSel; return 0; case NM_RCLICK: GetCursorPos(&hittest.pt); ScreenToClient(prjTreeWindow, &hittest.pt); prjSelectedItem = TreeView_HitTest(prjTreeWindow, &hittest); if (prjSelectedItem) { TreeView_SelectItem(prjTreeWindow, prjSelectedItem); } CreateProjectMenu(); break; case TVN_SELCHANGED: nm = (NM_TREEVIEW*)lParam; prjSelectedItem = nm->itemNew.hItem; if (prjSelectedItem == 0) prjSelectedItem = workArea->hTreeItem; break; case TVN_ITEMEXPANDED: nm = (NM_TREEVIEW *)lParam; data = GetItemInfo(nm->itemNew.hItem); if (data) { if (data->type == PJ_FOLDER) { TV_ITEM setitem; memset(&setitem, 0, sizeof(setitem)); setitem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE; setitem.iImage = setitem.iSelectedImage = nm->action == TVE_EXPAND ? ilfolderOpen : ilfolderClose; setitem.hItem = nm->itemNew.hItem; TreeView_SetItem(prjTreeWindow, &setitem); } if (nm->action == TVE_EXPAND) { data->expanded = TRUE; } else data->expanded = FALSE; return 0; } break; case TVN_DELETEITEM: nm = (NM_TREEVIEW *)lParam; if (nm->itemOld.hItem == prjSelectedItem) prjSelectedItem = TreeView_GetSelection(prjTreeWindow); break; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_TBPROFILE: if (HIWORD(wParam) == CBN_SELENDOK) { int i = SendMessage(hwndTbProfile, CB_GETCURSEL, 0 , 0); if (i != CB_ERR) { if (i == 0) { strcpy(currentProfileName, sysProfileName); } else { PROFILENAMELIST *pf = profileNames; while (pf && --i) pf = pf->next; if (pf) { strcpy(currentProfileName, pf->name); } } MarkChanged(workArea, TRUE); } } break; case ID_TBBUILDTYPE: if (HIWORD(wParam) == CBN_SELENDOK) { int i = SendMessage(hwndTbBuildType, CB_GETCURSEL, 0 , 0); if (i != CB_ERR) { profileDebugMode = i == 0 ? 1 : 0; MarkChanged(workArea, TRUE); } } break; case IDM_RESETPROFILECOMBOS: { HWND htemp; PROFILENAMELIST *pf; int selected,n; int count; POINT pt; pf = profileNames; selected = 0; count = 0; SendMessage(hwndTbProfile, CB_RESETCONTENT, 0, 0); SendMessage(hwndTbProfile, CB_ADDSTRING, 0, (LPARAM)sysProfileName); while (pf) { count++; if (!strcmp(pf->name,currentProfileName)) selected = count; SendMessage(hwndTbProfile, CB_ADDSTRING, 0, (LPARAM)pf->name); pf = pf->next; } SendMessage(hwndTbProfile, CB_SETCURSEL, selected, 0); SendMessage(hwndTbBuildType, CB_RESETCONTENT, 0, 0); SendMessage(hwndTbBuildType, CB_ADDSTRING, 0, (LPARAM)"Debug"); SendMessage(hwndTbBuildType, CB_ADDSTRING, 0, (LPARAM)"Release"); SendMessage(hwndTbBuildType, CB_SETCURSEL, profileDebugMode ? 0 : 1, 0); pt.x = 5; pt.y = 5; htemp = ChildWindowFromPoint(hwndTbProfile, pt); SendMessage(htemp, EM_SETREADONLY, 1, 0); htemp = ChildWindowFromPoint(hwndTbBuildType, pt); SendMessage(htemp, EM_SETREADONLY, 1, 0); EnableWindow(hwndTbProfile, TRUE); EnableWindow(hwndTbBuildType, TRUE); break; } case IDM_IMPORT_CWS: ImportProject(FALSE); break; case IDM_IMPORT_CTG: ImportProject(TRUE); break; case IDM_DOSWINDOW: { DosWindow(activeProject ? activeProject->realName : NULL, NULL, NULL, NULL, NULL); } break; case IDM_MAKEWINDOW: { char exec[MAX_PATH]; sprintf(exec, "%s\\bin\\imake.exe", szInstallPath); DosWindow(activeProject ? activeProject->realName : NULL, exec, "", "Custom Make", "Make Is Complete."); } break; case IDM_RUN: SaveWorkArea(workArea); dbgRebuildMain(wParam); break; case IDM_SETACTIVEPROJECT: ProjectSetActive(); break; case IDM_NEWFILE_P: ProjectNewFile(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_EXISTINGFILE: ProjectExistingFile(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_NEWPROJECT: ProjectNewProject(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_EXISTINGPROJECT: ProjectExistingProject(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break ; case IDM_REMOVE: ProjectRemove(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_RENAME: ProjectRename(); break; case IDM_NEWFOLDER: ProjectNewFolder(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_NEWWS: if (uState != notDebugging) { if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, "This action requires the debugger to be stopped.") != IDOK) { break; } abortDebug(); } SelectWindow(DID_PROJWND); ProjectNewWorkArea(); break; case IDM_OPENWS: if (uState != notDebugging) { if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, "This action requires the debugger to be stopped.") != IDOK) { break; } abortDebug(); } SelectWindow(DID_PROJWND); ProjectExistingWorkArea(); break; case IDM_CLOSEWS: if (making) break; if (uState != notDebugging) { if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, "This action requires the debugger to be stopped.") != IDOK) { break; } abortDebug(); } CloseWorkArea(); break; case IDM_SAVEWS: SaveAllProjects(workArea, TRUE); break; case IDM_COMPILEFILEFROMTREE: { PROJECTITEM *data = GetItemInfo(prjSelectedItem); if (data && data->type == PJ_FILE) { unlink(data->outputName); Maker(data, TRUE); } } break; case IDM_COMPILEFILE: win = (HWND)SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0); if (IsWindow(win) && IsEditWindow(win)) { HTREEITEM item = FindItemByWind(win); PROJECTITEM *data = GetItemInfo(item); if (data) { unlink(data->outputName); Maker(data, TRUE); } } break; case IDM_GENMAKE: if (workArea && workArea->children) { genMakeFile(workArea); } else { ExtendedMessageBox("Makefile Generation", MB_SETFOREGROUND | MB_SYSTEMMODAL, "You need at least one project to generate a make file"); } break; case IDM_MAKE: if (HIWORD(wParam)) if (GetKeyState(VK_CONTROL) &0x80000000) SendMessage(hwnd, WM_COMMAND, IDM_COMPILEFILE, 0); else if (GetKeyState(VK_SHIFT) &0x80000000) Maker(activeProject, FALSE); else Maker(workArea, FALSE); else Maker(workArea, FALSE); break; case IDM_MAKE_RIGHTCLICK: if (HIWORD(wParam)) if (GetKeyState(VK_CONTROL) &0x80000000) SendMessage(hwnd, WM_COMMAND, IDM_COMPILEFILE, 0); else if (GetKeyState(VK_SHIFT) &0x80000000) Maker(activeProject, FALSE); else Maker(workArea, FALSE); else { if (prjSelectedItem) { PROJECTITEM *data = GetItemInfo(prjSelectedItem); if (data) { Maker(data, FALSE); break; } } Maker(workArea, FALSE); } break; case IDM_BUILDALL: Maker(workArea, TRUE); break; case IDM_BUILDALL_RIGHTCLICK: if (prjSelectedItem) { PROJECTITEM *data = GetItemInfo(prjSelectedItem); if (data) { Maker(data, TRUE); break; } } Maker(workArea, TRUE); break; case IDM_BUILDSELECTED: Maker(activeProject, FALSE); break; case IDM_STOPBUILD: StopBuild(); break; case IDM_CALCULATEDEPENDS: CalculateProjectDepends(GetItemInfo(prjSelectedItem)); break; case IDM_RUNNODEBUG: { SaveWorkArea(workArea); RunProgram(activeProject); break; } case IDM_SELECTPROFILE: SelectProfileDialog(); break; case IDM_ACTIVEPROJECTPROPERTIES: if (activeProject) prjSelectedItem = activeProject->hTreeItem; // fall through case IDM_PROJECTPROPERTIES: data = GetItemInfo(prjSelectedItem); ShowBuildProperties(data); break; case IDM_PROJECTDEPENDS: data = GetItemInfo(prjSelectedItem); EditProjectDependencies(data); break; case IDM_OPENFILES: data = GetItemInfo(prjSelectedItem); if (data) if (data->type == PJ_FILE) { if (strlen(data->realName) >= 3 && !stricmp(data->realName + strlen(data->realName) -3, ".rc")) { NavigateToResource(data); } else { strcpy(info.dwName, data->realName); strcpy(info.dwTitle, data->displayName); info.dwLineNo = - 1; info.logMRU = FALSE; info.newFile = FALSE; CreateDrawWindow(&info, TRUE); } } break; case IDM_CLOSE: SendMessage(hwnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hwnd, iMessage, wParam, lParam); } break; case WM_LBUTTONUP: if (dragging) { SetCursor(origCurs); ReleaseCapture(); dragging = FALSE; TreeView_SelectDropTarget(prjTreeWindow, NULL); if (inView && dstItem != srcItem && srcItem && dstItem) { DragTo(dstItem, srcItem); } } break; case WM_MOUSEMOVE: if (dragging) { hittest.pt.x = (long)(short)LOWORD(lParam); hittest.pt.y = (long)(short)HIWORD(lParam); dstItem = TreeView_HitTest(prjTreeWindow, &hittest); if (dstItem && dstItem != srcItem) { PROJECTITEM *srcData = GetItemInfo(srcItem); data = GetItemInfo(dstItem); if (srcData && data) { PROJECTITEM *p = data->parent; while (p) if (p == srcData) break; else p = p->parent; if (p) { if (inView) { inView = FALSE; SetCursor(noCur); TreeView_SelectDropTarget(prjTreeWindow, NULL); } break; } } if (data && (data->type == PJ_PROJ || data->type == PJ_FOLDER)) { if (!inView) { inView = TRUE; SetCursor(dragCur); } TreeView_SelectDropTarget(prjTreeWindow, dstItem); } else { if (inView) { inView = FALSE; SetCursor(noCur); TreeView_SelectDropTarget(prjTreeWindow, NULL); } } } else { if (inView) { inView = FALSE; SetCursor(noCur); TreeView_SelectDropTarget(prjTreeWindow, NULL); } } } break; case WM_SETFOCUS: PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); SetFocus(prjTreeWindow); break; case WM_CREATE: hwndProject = hwnd; GetClientRect(hwnd, &rs); treeViewSelected = 0; dragCur = LoadCursor(hInstance, "ID_DRAGCUR"); noCur = LoadCursor(hInstance, "ID_NODRAGCUR"); folderClose = LoadBitmap(hInstance, "ID_FOLDERCLOSE"); folderOpen = LoadBitmap(hInstance, "ID_FOLDEROPEN"); treeIml = ImageList_Create(16, 16, ILC_COLOR24, IL_IMAGECOUNT+2, 0); mainIml = LoadBitmap(hInstance, "ID_FILES"); ChangeBitmapColor(mainIml, 0xffffff, RetrieveSysColor(COLOR_WINDOW)); ImageList_Add(treeIml, mainIml, NULL); ilfolderClose = ImageList_Add(treeIml, folderClose, 0); ilfolderOpen = ImageList_Add(treeIml, folderOpen, 0); DeleteObject(folderClose); DeleteObject(folderOpen); DeleteObject(mainIml); prjTreeWindow = CreateWindowEx(0, sztreeDoubleBufferName, "", WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_TRACKSELECT, 0, 0, rs.right, rs.bottom, hwnd, (HMENU)ID_TREEVIEW, hInstance, NULL); TreeView_SetImageList(prjTreeWindow, treeIml, TVSIL_NORMAL); lf = systemDialogFont; projFont = CreateFontIndirect(&lf); lf.lfItalic = TRUE; italicProjFont = CreateFontIndirect(&lf); lf.lfItalic = FALSE; lf.lfWeight = FW_BOLD; boldProjFont = CreateFontIndirect(&lf); SendMessage(prjTreeWindow, WM_SETFONT, (WPARAM)boldProjFont, 0); return 0; case WM_CLOSE: SaveAllProjects(workArea, FALSE); break; case WM_DESTROY: FreeSubTree(workArea, FALSE); DestroyWindow(prjTreeWindow); DeleteObject(projFont); DeleteObject(boldProjFont); DeleteObject(italicProjFont); DestroyCursor(dragCur); DestroyCursor(noCur); hwndProject = 0; break; case WM_SIZE: MoveWindow(prjTreeWindow, 0, 0, LOWORD(lParam), HIWORD(lParam), 0); break; default: break; } return DefWindowProc(hwnd, iMessage, wParam, lParam); }
void InitMenuPopup(HMENU menu) { HWND win; BOOL mf_state; BOOL x_state; int selstart, selend; SetWindowMenu(); SetMenuCheckedState(menu, DID_PROJWND, IDM_VIEWPROJECT); SetMenuCheckedState(menu, DID_PROPSWND, IDM_VIEWPROPS); SetMenuCheckedState(menu, DID_INFOWND, IDM_VIEWINFO); SetMenuCheckedState(menu, DID_ERRWND, IDM_VIEWERR); SetMenuCheckedState(menu, DID_BROWSEWND, IDM_VIEWBROWSE); SetMenuCheckedState(menu, DID_STACKWND, IDM_VIEWSTACK); SetMenuCheckedState(menu, DID_THREADWND, IDM_VIEWTHREAD); { MENUITEMINFO info; info.cbSize = sizeof(MENUITEMINFO); info.fMask = MIIM_STATE; GetMenuItemInfo(menu, IDM_VIEWASM, MF_BYCOMMAND, &info); info.fState = (info.fState &~MFS_CHECKED) | (hwndASM ? MFS_CHECKED : 0); SetMenuItemInfo(menu, IDM_VIEWASM, MF_BYCOMMAND, &info); } SetMenuCheckedState(menu, DID_MEMWND, IDM_VIEWMEM); SetMenuCheckedState(menu, DID_MEMWND+1, IDM_VIEWMEM2); SetMenuCheckedState(menu, DID_MEMWND+2, IDM_VIEWMEM3); SetMenuCheckedState(menu, DID_MEMWND+3, IDM_VIEWMEM4); SetMenuCheckedState(menu, DID_REGWND, IDM_VIEWREGISTER); SetMenuCheckedState(menu, DID_WATCHWND, IDM_VIEWWATCH); SetMenuCheckedState(menu, DID_WATCHWND+1, IDM_VIEWWATCH2); SetMenuCheckedState(menu, DID_WATCHWND+2, IDM_VIEWWATCH3); SetMenuCheckedState(menu, DID_WATCHWND+3, IDM_VIEWWATCH4); SetMenuCheckedState(menu, DID_LOCALSWND, IDM_VIEWLOCALS); SetMenuCheckedState(menu, DID_BREAKWND, IDM_VIEWBP); win = (HWND)SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0); mf_state = MF_GRAYED; if (editWindows && IsWindow(win) && (IsEditWindow(win) || IsResourceWindow(win))) { mf_state = MF_ENABLED; } EnableMenuItem(menu, IDM_SAVEAS, mf_state); EnableMenuItem(menu, IDM_SAVE, mf_state); EnableMenuItem(menu, IDM_CUT, mf_state); EnableMenuItem(menu, IDM_COPY, mf_state); EnableMenuItem(menu, IDM_PASTE, mf_state); EnableMenuItem(menu, IDM_CLOSEWINDOW, mf_state); EnableMenuItem(menu, IDM_CLOSE, mf_state); mf_state = MF_GRAYED; if (editWindows && IsWindow(win) && IsEditWindow(win)) { mf_state = MF_ENABLED; SendMessage(GetDlgItem(win, ID_EDITCHILD), EM_GETSEL, (WPARAM) &selstart, (LPARAM) &selend); } EnableMenuItem(menu, IDM_COPYWINDOW, mf_state); EnableMenuItem(menu, IDM_PRINT, mf_state); EnableMenuItem(menu, IDM_TOUPPER, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_TOLOWER, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_INDENT, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_UNINDENT, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_COMMENT, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_UNCOMMENT, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_SELECTALL, mf_state); EnableMenuItem(menu, IDM_FIND, mf_state); x_state = mf_state; if (!AnyBookmarks()) x_state = MF_GRAYED; EnableMenuItem(menu,IDM_NEXTBOOKMARK,x_state) ; EnableMenuItem(menu,IDM_PREVBOOKMARK,x_state) ; EnableMenuItem(menu,IDM_NEXTBOOKMARKFILE,x_state) ; EnableMenuItem(menu,IDM_PREVBOOKMARKFILE,x_state) ; EnableMenuItem(menu,IDM_BOOKMARKWINDOW,x_state) ; EnableMenuItem(menu,IDM_REMOVEBOOKMARKS,x_state) ; EnableMenuItem(menu, IDM_FIND, mf_state); // EnableMenuItem(menu,IDM_FINDINFILES,mf_state) ; EnableMenuItem(menu, IDM_FINDNEXT, mf_state); EnableMenuItem(menu, IDM_REPLACE, mf_state); x_state = mf_state; if (win == hwndASM) x_state = MF_ENABLED; EnableMenuItem(menu, IDM_GOTO, x_state); if (defaultWorkArea || !PropGetBool(NULL, "BROWSE_INFORMATION")) mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_BROWSETODECLARATION, mf_state); EnableMenuItem(menu, IDM_BROWSETODEFINITION, mf_state); if (defaultWorkArea || !PropGetBool(NULL, "BROWSE_INFORMATION")) mf_state = MF_GRAYED; else mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_VIEWBROWSE, mf_state); EnableMenuItem(menu,IDM_BROWSETO,mf_state) ; EnableMenuItem(menu,IDM_BROWSEBACK,mf_state) ; EnableMenuItem(menu, IDM_BOOKMARK, mf_state); if (!making && IsEditWindow(win)) { if (!FindItemByWind(win)) mf_state = MF_GRAYED; else mf_state = MF_ENABLED; } else mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_COMPILEFILE, mf_state); mf_state = MF_GRAYED; if (SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0)) mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_CLOSEALLWINDOWS, mf_state); EnableMenuItem(menu, IDM_CASCADE, mf_state); EnableMenuItem(menu, IDM_TILEHORIZ, mf_state); EnableMenuItem(menu, IDM_TILEVERT, mf_state); EnableMenuItem(menu, IDM_ARRANGE, mf_state); EnableMenuItem(menu, IDM_SAVEALL, mf_state); EnableMenuItem(menu, IDM_SAVEALL2, mf_state); EnableMenuItem(menu, IDM_NEWPROJECT, MF_ENABLED); EnableMenuItem(menu, IDM_VIEWPROJECT, MF_ENABLED); if (making || hwndGeneralProps) mf_state = MF_GRAYED; else mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_CLOSEWS, mf_state); EnableMenuItem(menu, IDM_GENMAKE, mf_state); EnableMenuItem(menu, IDM_MAKE, mf_state); EnableMenuItem(menu, IDM_BUILDALL, mf_state); EnableMenuItem(menu, IDM_BUILDSELECTED, mf_state); mf_state = MF_GRAYED; if (!making && !hwndGeneralProps) mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_GENERALPROPERTIES, mf_state); EnableMenuItem(menu, IDM_SELECTPROFILE, mf_state); EnableMenuItem(menu, IDM_BUILDRULES, mf_state); if (!activeProject) mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_ACTIVEPROJECTPROPERTIES, mf_state); EnableMenuItem(menu, IDM_PROJECTPROPERTIES, mf_state); EnableMenuItem(menu, IDM_PROJECTDEPENDS, mf_state); EnableMenuItem(menu, IDM_RUNNODEBUG, mf_state); if (making) mf_state = MF_ENABLED; else mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_STOPBUILD, mf_state); if (IsWindow(win)) { EnableMenuItem(menu, IDM_UNDO, SendMessage(win, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_REDO, SendMessage(win, EM_CANREDO, 0, 0) ? MF_ENABLED : MF_GRAYED); } if (uState == notDebugging) mf_state = MF_ENABLED; else mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_OPENWS, mf_state); EnableMenuItem(menu, IDM_CLOSEWS, mf_state); EnableMenuItem(menu, IDM_NEWWS, mf_state); EnableMenuItem(menu, IDM_REOPENWS, mf_state); EnableMenuItem(menu, IDM_IMPORTWS, mf_state); mf_state = ((uState == notDebugging || uState == atException || uState == atBreakpoint) && !making && activeProject) ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_RUN, mf_state); mf_state = (uState != notDebugging && (uState == atException || uState == atBreakpoint) && !making && activeProject) ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_STOPDEBUGGING, mf_state); EnableMenuItem(menu, IDM_RUNTO, mf_state); EnableMenuItem(menu, IDM_SCROLLTOBP, mf_state); // EnableMenuItem(menu, IDM_VIEWBP, mf_state); EnableMenuItem(menu, IDM_VIEWASM, mf_state); EnableMenuItem(menu, IDM_VIEWMEM, mf_state); EnableMenuItem(menu, IDM_VIEWMEM2, mf_state); EnableMenuItem(menu, IDM_VIEWMEM3, mf_state); EnableMenuItem(menu, IDM_VIEWMEM4, mf_state); EnableMenuItem(menu, IDM_VIEWREGISTER, mf_state); EnableMenuItem(menu, IDM_VIEWSTACK, mf_state); EnableMenuItem(menu, IDM_VIEWWATCH, mf_state); EnableMenuItem(menu, IDM_VIEWWATCH2, mf_state); EnableMenuItem(menu, IDM_VIEWWATCH3, mf_state); EnableMenuItem(menu, IDM_VIEWWATCH4, mf_state); EnableMenuItem(menu, IDM_VIEWLOCALS, mf_state); EnableMenuItem(menu, IDM_VIEWTHREAD, mf_state); EnableMenuItem(menu, IDM_HBREAK, mf_state); EnableMenuItem(menu, IDM_DATABREAKPOINT, mf_state); EnableMenuItem(menu, IDM_FUNCTIONBREAKPOINT, mf_state); mf_state = uState == Running ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_STOP, mf_state); { BOOL state = TagAnyDisabledBreakpoints() || hbpAnyDisabledBreakpoints() || databpAnyDisabledBreakpoints(); ModifyMenu(menu, IDM_DISABLEALLBREAKPOINTS, MF_BYCOMMAND | MF_STRING, IDM_DISABLEALLBREAKPOINTS, state ? "E&nable All Breakpoints" : "D&isable All Breakpoints"); } mf_state = (TagAnyBreakpoints() || hbpAnyBreakpoints() || databpAnyBreakpoints()) ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_REMOVEALLBREAKPOINTS, mf_state); EnableMenuItem(menu, IDM_DISABLEALLBREAKPOINTS, mf_state); mf_state = MF_GRAYED; if (activeProject && GetResData(activeProject)) mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_NEWRESOURCE, mf_state); mf_state = MF_GRAYED; if (IsWindow(win) && IsResourceWindow(win)) { struct resRes *res = (struct resRes *)GetWindowLong(win, 0); if (res->resource->itype == RESTYPE_DIALOG) mf_state = MF_ENABLED; } EnableMenuItem(menu, IDM_CREATIONORDER, mf_state); EnableMenuItem(menu, IDM_SETTABSTOPS, mf_state); EnableMenuItem(menu, IDM_SETGROUPFLAGS, mf_state); EnableMenuItem(menu, IDM_GRIDMENU, mf_state); EnableMenuItem(menu, IDM_SHOWGRID, mf_state); EnableMenuItem(menu, IDM_SNAPTOGRID, mf_state); if (mf_state == MF_ENABLED) { if (snapToGrid) { CheckMenuItem( menu, IDM_SNAPTOGRID, MF_BYCOMMAND | MF_CHECKED); } else { CheckMenuItem( menu, IDM_SNAPTOGRID, MF_BYCOMMAND); } if (showGrid) { CheckMenuItem( menu, IDM_SHOWGRID, MF_BYCOMMAND | MF_CHECKED); } else { CheckMenuItem( menu, IDM_SHOWGRID, MF_BYCOMMAND); } } mf_state = MF_GRAYED; if (IsWindow(win) && IsResourceWindow(win)) { struct resRes *res = (struct resRes *)GetWindowLong(win, 0); if (res->resource->itype == RESTYPE_BITMAP || res->resource->itype == RESTYPE_CURSOR || res->resource->itype == RESTYPE_ICON) mf_state = MF_ENABLED; } EnableMenuItem(menu, IDM_FLIPMENU, mf_state); EnableMenuItem(menu, IDM_ROTATEMENU, mf_state); EnableMenuItem(menu, IDM_CLEAR, mf_state); EnableMenuItem(menu, IDM_CLEARSELECTION, mf_state); // mf_state = uState == atBreakpoint || uState == atException ? MF_ENABLED : MF_GRAYED ; // EnableMenuItem(menu,IDM_HBREAK, mf_state ) ; mf_state = PropGetInt(NULL, "MSDN_HELP_MODE") == 0 ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu,IDM_CONFIGWEBHELP, mf_state ) ; }