예제 #1
0
void FileBrowseLeft()
{
    if (!fileBrowseCursor)
        return;
    else
    {
        fileBrowseCursor = fileBrowseCursor->prev;
        if (!fileBrowseCursor)
        {
            HWND current = (HWND)SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0);
            if (active == current)
            {
                SetFocus(current);
            }
            else
            {
                PostMessage(hwndClient, WM_MDIACTIVATE, (WPARAM)active, 0);
            }
        }
    }
    if (fileBrowseCursor)
    {
        DWINFO info;
        strcpy(info.dwName, fileBrowseCursor->info->dwName);
        info.dwLineNo = fileBrowseCursor->lineno;
        info.logMRU = FALSE;
        info.newFile = FALSE;
        CreateDrawWindow(&info, TRUE);
    }
    SendMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
}
예제 #2
0
파일: browse.c 프로젝트: doniexun/OrangeC
void BrowseBack(void)
{
    if (!browseCount)
        return ;
    browsebacklist[--browseCount]->logMRU = FALSE;
    CreateDrawWindow(browsebacklist[browseCount], TRUE);
    free(browsebacklist[browseCount]);
}
예제 #3
0
void FileBrowseTrigger(int i)
{
    if (ordered[i])
    {
        DWINFO info;
        strcpy(info.dwName, ordered[i]->info->dwName);
        info.dwLineNo = ordered[i]->lineno;
        info.logMRU = FALSE;
        info.newFile = FALSE;
        CreateDrawWindow(&info, TRUE);
    }
}
예제 #4
0
void FileBrowseRight()
{
    if (!fileBrowseCursor)
    {
        active = (HWND)SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0);
        fileBrowseCursor = fileBrowseInfo;
    }
    else if (fileBrowseCursor->next)
        fileBrowseCursor = fileBrowseCursor->next;
    else
        return;
    if (fileBrowseCursor)
    {
        DWINFO info;
        strcpy(info.dwName, fileBrowseCursor->info->dwName);
        info.dwLineNo = fileBrowseCursor->lineno;
        info.logMRU = FALSE;
        info.newFile = FALSE;
        CreateDrawWindow(&info, TRUE);
    }
    SendMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
}
예제 #5
0
파일: prjwnd.c 프로젝트: bencz/OrangeC
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);
}
예제 #6
0
파일: dbgstack.c 프로젝트: doniexun/OrangeC
LRESULT CALLBACK StackProc(HWND hwnd, UINT iMessage, WPARAM wParam,
    LPARAM lParam)
{
    LV_ITEM item;
    LV_COLUMN lvC;    
    RECT r;
    LPNMHDR nmh;
    char module[256];
    SCOPE *sl;
    int i, lines;
    switch (iMessage)
    {
        case WM_CTLCOLORSTATIC:
            return (HBRUSH)(COLOR_WINDOW + 1);
        case WM_TIMER:
            KillTimer(hwnd, 100);
            ListView_SetItemState(hwndLV, curSel, 0, LVIS_SELECTED);
            break;
        case WM_NOTIFY:
            nmh = (LPNMHDR)lParam;
            if (nmh->code == NM_SETFOCUS)
            {
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0);
            }
            else if (nmh->code == LVN_GETDISPINFO)
            {
                LV_DISPINFO *p = (LV_DISPINFO *)lParam;
                SCOPE *x = (SCOPE *)p->item.lParam;
                char addr[256];
                p->item.mask |= LVIF_TEXT | LVIF_DI_SETITEM;
                p->item.mask &= ~LVIF_STATE;
                if (p->item.iSubItem == 2)
                {
                    p->item.pszText = x->name;
                }
                else
                {
                    sprintf(addr,"%8X", x->address);
                    p->item.pszText = addr;
                }
            }
            else if (nmh->code == LVN_ITEMCHANGED)
            {
                LPNMLISTVIEW p = (LPNMHDR)lParam;
                if (p->uChanged & LVIF_STATE)
                {
                    if (p->uNewState & LVIS_SELECTED)
                    {
                        i = 0;
                        PostMessage(hwnd, WM_USER, p->iItem, 0);
                        SetTimer(hwnd, 100, 400, 0);
                    }
                }
            }
            else if (nmh->code == LVN_KEYDOWN)
            {
                switch (((LPNMLVKEYDOWN)lParam)->wVKey)
                {
                    case 'C':
                        if (GetKeyState(VK_CONTROL) &0x80000000)
                        {
                            CopyText(hwnd);
                        }
                        break;
                    case VK_UP:
                        if (curSel > 0)
                            SendMessage(hwnd, WM_USER, curSel-1, 0);
                        break;
                    case VK_DOWN:
                        if (curSel < ListView_GetItemCount(hwndLV) - 1)
                            SendMessage(hwnd, WM_USER, curSel + 1, 0);
                        break;
                }
            }
            break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_TBPROCEDURE:
                    if (HIWORD(wParam) == CBN_SELENDOK)
                    {
                        int i = SendMessage(hwndTbProcedure, CB_GETCURSEL, 0 , 0);
                        if (i != CB_ERR)
                        {
                            SendMessage(hwnd, WM_USER, i, 0);
                        }
                    }
                    break;
            }
            break;
        case WM_USER:
        {
            memset(&item, 0, sizeof(item));
            if (curSel != 0)
            {
                item.iItem = curSel;
                item.iSubItem = 0;
                item.mask = LVIF_IMAGE;
                item.iImage = IML_BLANK;
                ListView_SetItem(hwndLV, &item);
            }

            curSel = wParam;
            if (curSel != 0)
            {
                item.iItem = curSel;
                item.mask = LVIF_IMAGE;
                item.iImage = IML_CONTINUATION;
                ListView_SetItem(hwndLV, &item);
            }
            sl = StackList;
            lines = curSel;
            while (sl && lines)
            {
                sl = sl->next;
                lines--;
            }
            if (sl)
            {
                if (GetBreakpointLine(sl->address, module, &lines, curSel != 0))
                {
                    char *p;
                    static DWINFO x;
                    strcpy(x.dwName, sl->fileName);
                    p = strrchr(module, '\\');
                    if (p)
                        strcpy(x.dwTitle, p + 1);
                    else
                        strcpy(x.dwTitle, module);
                    x.dwLineNo = sl->lineno;
                    x.logMRU = FALSE;
                    x.newFile = FALSE;
                    SetScope(sl);
                    CreateDrawWindow(&x, TRUE);
                }
            }
        }
            break;
        case WM_CREATE:
            hwndStack = hwnd;
            GetClientRect(hwnd, &r);
            hwndLV = CreateWindowEx(0, WC_LISTVIEW, "", 
                           LVS_REPORT | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE | WS_BORDER,
                           0,0,r.right-r.left, r.bottom - r.top, hwnd, 0, hInstance, 0);
            ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
            StackFont = CreateFontIndirect(&fontdata);
            SendMessage(hwndLV, WM_SETFONT, (WPARAM)StackFont, 0);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM ;
            lvC.cx = 20;
            lvC.iSubItem = 0;
            ListView_InsertColumn(hwndLV, 0, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 80;
            lvC.iSubItem = 1;
            lvC.pszText = "Address";
            ListView_InsertColumn(hwndLV, 1, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 200;
            lvC.iSubItem = 2;
            lvC.pszText = "Location";
            ListView_InsertColumn(hwndLV, 2, &lvC);
            ListView_SetImageList(hwndLV, tagImageList, LVSIL_SMALL);
            break;
        case WM_SIZE:
            r.left = r.top = 0;
            r.right = LOWORD(lParam);
            r.bottom = HIWORD(lParam);
            MoveWindow(hwndLV, r.left, r.top, r.right - r.left,
                r.bottom - r.top, 1);
            break;
            // fall through
        case WM_RESTACK:
            SetScope(NULL);
            ClearStackArea(hwnd);
            EnableWindow(hwndLV, uState != notDebugging && wParam);
            EnableWindow(hwndTbProcedure, uState != notDebugging && wParam);
            if (uState != notDebugging && wParam)
            {
                int i = 0;
                char buf[256];
                SCOPE *list;
                SetStackArea(hwnd);
                
                list = StackList;
                ListView_DeleteAllItems(hwndLV);
                memset(&item, 0, sizeof(item));
                SendMessage(hwndTbProcedure, CB_RESETCONTENT, 0, 0);
                while (list)
                {

                    item.iItem = i;
                    item.iSubItem = 0;
                    item.mask = LVIF_IMAGE | LVIF_PARAM;
                    if (i == 0)
                    {
                        if (activeThread == stoppedThread)
                            item.iImage = IML_STOPBP;
                        else
                            item.iImage = IML_STOP;
                        if (i == curSel)
                            SetScope(list);
                            
                    }
                    else if (i == curSel)
                    {
                        item.iImage = IML_CONTINUATION;
                        SetScope(list);
                    }
                    else
                    {
                        item.iImage = IML_BLANK;
                    }
                    item.lParam = (LPARAM)list;
                    ListView_InsertItem(hwndLV, &item);
                    
                    item.iSubItem = 1;
                    item.mask = LVIF_PARAM | LVIF_TEXT;
                    item.lParam = (LPARAM)list;
                    item.pszText = "";
                    ListView_InsertItem(hwndLV, &item);
                    i++;
                    sprintf(buf, "%08x %s", list->address, list->name);
                    SendMessage(hwndTbProcedure, CB_ADDSTRING, 0, (LPARAM)buf);
                    list = list->next;
                }
                SendMessage(hwndTbProcedure, CB_SETCURSEL, curSel, 0);
            }
            break;
        case WM_DESTROY:
            ClearStackArea(hwnd);
            hwndStack = 0;
            DeleteObject(StackFont);
            break;
        case WM_SETFOCUS:
            SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0);
            break;
        case WM_KILLFOCUS:
            break;
    }
    return DefWindowProc(hwnd, iMessage, wParam, lParam);
}
예제 #7
0
void InfoPad::handleEvent(TEvent& event)
{
    if (event.what == evCommand && event.message.command == cmQuit)
    {
        while (editWindows)
            editWindows->WinMessage(WM_COMMAND, IDM_CLOSE, 0);
    }
    TApplication::handleEvent(event);
    if (event.what == evCommand)
    {
        switch (event.message.command)
        {
            case ID_OPTIONS:
                optionsBox();
                break;
            case ID_MOREWINDOWS:
                if (WindowMRU.Get(0))
                    WindowMenuBox();
                else
                    messageBox("No windows available", mfInformation);
                break;
            case ID_UNDO:
                if (current)
                {
                    current->child->WinMessage(WM_UNDO, 0, 0);
                }
                break;
            case IDM_REDO:
                if (current)
                {
                    current->child->WinMessage(WM_REDO, 0, 0);
                }
                break;
            case ID_CUT:
                if (current)
                {
                    current->child->WinMessage(WM_CUT, 0, 0);
                }
                break;
            case ID_COPY:
                if (current)
                {
                    current->child->WinMessage(WM_COPY, 0, 0);
                }
                break;
            case ID_PASTE:
                if (current)
                {
                    current->child->WinMessage(WM_PASTE, 0, 0);
                }
                break;
            case ID_NEW:
                openfile((DWINFO *)-1, True, True);
                break;
            case ID_OPEN:
                CreateDrawWindow((DWINFO *)0, True);
                break;
            case ID_SAVE:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_SAVE, 0);
                }
                break;
            case ID_SAVEAS:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_SAVEAS, 0);
                }
                break;
            case ID_CLOSE:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_CLOSE, 0);
                    current->close();
                    current = NULL;
                }
                break;
            case ID_SEARCH:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_FIND, 0);
                }
                break;
            case ID_REPLACE:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_REPLACE, 0);
                }
                break;
            case ID_SEARCHNEXT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_FINDNEXT, 0);
                }
                break;
            case ID_GOTO:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_GOTO, 0);
                }
                break;
            case ID_TOUPPER:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_TOUPPER, 0);
                }
                break;
            case ID_TOLOWER:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_TOLOWER, 0);
                }
                break;
            case ID_INDENT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_INDENT, 0);
                }
                break;
            case ID_OUTDENT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_UNINDENT, 0);
                }
                break;
            case ID_COMMENT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_COMMENT, 0);
                }
                break;
            case ID_UNCOMMENT:
                if (current)
                {
                    current->WinMessage(WM_COMMAND, IDM_UNCOMMENT, 0);
                }
                break;
            case ID_CLOSEALL:
                CloseAll();
                break;
            case ID_ABOUT:
                AboutBox();
                break;
            default:
                if (event.message.command >= FILE_MRU_BASE && event.message.command < FILE_MRU_BASE + MRU::MAX_MRU)
                {
                    static DWINFO temp;
                    MRUItem *p = cfg.FileMRU().Get(event.message.command - FILE_MRU_BASE);
                    if (p)
                    {
                        newInfo = &temp;
                        newInfo->dwLineNo =  - 1;
                        newInfo->logMRU = TRUE;
                        strcpy(newInfo->dwTitle, p->title);
                        strcpy(newInfo->dwName, p->name);
                        openfile(newInfo, FALSE, TRUE);
                    }
                }
                else if (event.message.command >= WINDOW_MRU_BASE && event.message.command < WINDOW_MRU_BASE + MRU::MAX_WINDOW_MRU)
                {
                    static DWINFO temp;
                    MRUItem *p = WindowMRU.Get(event.message.command - WINDOW_MRU_BASE);
                    if (p)
                    {
                        newInfo = &temp;
                        newInfo->dwLineNo =  - 1;
                        newInfo->logMRU = TRUE;
                        strcpy(newInfo->dwTitle, p->title);
                        strcpy(newInfo->dwName, p->name);
                        openfile(newInfo, FALSE, TRUE);
                    }
                }
                break;
        }
    }

}
예제 #8
0
파일: brswnd.c 프로젝트: bencz/OrangeC
LRESULT CALLBACK BrowseProc(HWND hwnd, UINT iMessage, WPARAM
    wParam, LPARAM lParam)
{
    static HFONT font;
    LV_ITEM item;
    POINT pt;
    LV_COLUMN lvC;
    RECT r;
    int i;
    LPNMHDR nmh;
    static LVITEM pressed;
    switch (iMessage)
    {
        case WM_USER+1:
        {
            DWINFO info;
            char *q;
            memset(&info,0, sizeof(info));
            strcpy(info.dwName, browselist[pressed.lParam]->file);
            q = strrchr(info.dwName, '\\');
            if (q)
                strcpy(info.dwTitle, q + 1);
            else
                strcpy(info.dwTitle, info.dwName);
            info.dwLineNo = TagNewLine(browselist[pressed.lParam]->file, browselist[pressed.lParam]->line);
            info.logMRU = FALSE;
            info.newFile = FALSE;
            CreateDrawWindow(&info, TRUE);
            break;
        }
        case WM_CTLCOLORSTATIC:
        {
            return (LRESULT)(HBRUSH)(COLOR_INACTIVECAPTION + 1);
        }
        case WM_CTLCOLORBTN:
        {
            return (LRESULT)GetStockObject(NULL_BRUSH);
        }

        case WM_NOTIFY:
            nmh = (LPNMHDR)lParam;
            if (nmh->code == NM_SETFOCUS)
            {
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0);
            }
            else if (nmh->code == LVN_GETDISPINFO)
            {
                LV_DISPINFO *p = (LV_DISPINFO *)lParam;
                char name[512] = "", *q;
                switch (p->item.iSubItem)
                {
                    case 1: /* id*/
                        sprintf(name,"%d", p->item.lParam +1);
                        break;
                    case 2: /*name*/
                        strcpy(name, browselist[p->item.lParam]->name);
                        break;
                    case 3: /* browse */
                        sprintf(name, "%d", browselist[p->item.lParam]->line);
                        break;
                    case 4: /*file*/
                        q = strrchr(browselist[p->item.lParam]->file, '\\');
                        if (!q)
                            q = browselist[p->item.lParam]->file;
                        else
                            q++;
                        strcpy(name, q);
                        break;
                }
                if (name[0])
                {
                    p->item.mask |= LVIF_TEXT | LVIF_DI_SETITEM;
                    p->item.mask &= ~LVIF_STATE;
                    p->item.pszText = name;
                }
            }
            else if (((LPNMHDR)lParam)->code == NM_DBLCLK)
            {
                LVHITTESTINFO hittest;
                GetCursorPos(&hittest.pt);
                ScreenToClient(hwndLV, &hittest.pt);
                if (ListView_SubItemHitTest(hwndLV, &hittest) >= 0)
                {
                    LVITEM lvitem;
                    lvitem.iItem = hittest.iItem;
                    lvitem.iSubItem = 0;
                    lvitem.mask = LVIF_PARAM;
                    ListView_GetItem(hwndLV, &lvitem);
                    memcpy(&pressed, &lvitem, sizeof(pressed));
                    SendMessage(hwnd, WM_USER + 1, 0, 0);
                }
            }
            else if (nmh->code == LVN_KEYDOWN)
            {
                switch (((LPNMLVKEYDOWN)lParam)->wVKey)
                {
                    case 'C':
                        if (GetKeyState(VK_CONTROL) &0x80000000)
                        {
                            CopyText(hwnd);
                        }
                        break;
                    case VK_UP:
                        if (curSel > 0)
                            SendMessage(hwnd, WM_USER, curSel-1, 0);
                        break;
                    case VK_DOWN:
                        if (curSel < ListView_GetItemCount(hwndLV) - 1)
                            SendMessage(hwnd, WM_USER, curSel + 1, 0);
                        break;
                }
            }
            break;
        case WM_COMMAND:
            switch(wParam)
            {
                case IDC_RETURN:
                    GetWindowText(hwndEdit, brsName, sizeof(brsName));
                    SendMessage(hwndCombo, WM_SAVEHISTORY, 0, 0);
                    CreateUsageList();
                    return 0;
                case IDC_ESCAPE:
                    SendMessage(hwndEdit, WM_SETTEXT, 0, (LPARAM)brsName);
                    return 0;
                default:
                    if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == 300)
                    {
                        displayFull = !displayFull;
                        PostMessage(hwnd, WM_USER, 0, 0);
                    }
                    if (HIWORD(wParam) == CBN_SELENDOK && LOWORD(wParam) == 500)
                    {
                        PostMessage(hwnd, WM_COMMAND, IDC_RETURN, 0);
                    }
                    break;
            }
            break;
            
        case WM_USER:
        {
            int k = 0;
            char buf[40];
            sprintf(buf, "%d Usages", browsecount);
            SetWindowText(hwndButton, buf);
            
            ListView_DeleteAllItems(hwndLV);
            memset(&item, 0, sizeof(item));
            for (i=0; i < browsecount; i++)
            {
                if (displayFull || browselist[i]->definition || browselist[i]->declaration)
                {
                    item.iItem = k++;
                    item.iSubItem = 0;
                    item.mask = LVIF_IMAGE | LVIF_PARAM;
                    item.lParam = i;
                    item.iImage = browselist[i]->definition ? 0 : browselist[i]->declaration ? 1 : 2;
                    ListView_InsertItem(hwndLV, &item);
                }            
            }
        }
            break;
        case WM_DRAWITEM:
        {
            LPDRAWITEMSTRUCT pDis = (LPDRAWITEMSTRUCT)lParam;
            HDC memdc;
            char staticText[256];
            BOOL state = !! displayFull;
            int len = SendMessage(pDis->hwndItem, WM_GETTEXT, 
                sizeof(staticText), (LPARAM)staticText);
            SIZE sz;
            RECT r;
            POINT textpos, iconpos;
            GetClientRect(pDis->hwndItem, &r);
            GetTextExtentPoint32(pDis->hDC, staticText, len, &sz);
            SetBkMode(pDis->hDC, TRANSPARENT);   
            iconpos.x = 4;
            iconpos.y = (r.bottom - r.top - 16)/2;
            textpos.x = r.right - 4 - sz.cx;
            textpos.y = (r.bottom - r.top - sz.cy)/2;
            DrawFrameControl(pDis->hDC, &pDis->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH | (state ? DFCS_PUSHED : 0));
            TextOut(pDis->hDC, pDis->rcItem.left+ textpos.x, pDis->rcItem.top+textpos.y, staticText, len);
            memdc = CreateCompatibleDC(pDis->hDC);
            SelectObject(memdc, buttonbmp);
            TransparentBlt(pDis->hDC, pDis->rcItem.left+ iconpos.x, pDis->rcItem.top+iconpos.y, 16, 16, memdc, 0, 0, 16, 16, 0xc0c0c0);
            DeleteDC(memdc);
        }
        return 0;
        case WM_CREATE:
            hwndBrowse = hwnd;
            GetClientRect(hwnd, &r);
            hwndBackground = CreateWindow("static", "", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
                                                0,0, r.right - r.bottom, BUTTONHEIGHT + 4, hwnd, 0, hInstance, 0);
            hwndButton = CreateWindow("button", "0 Usages",  WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                         2,2,BUTTONWIDTH,BUTTONHEIGHT, hwnd, (HMENU)300, hInstance, 0);
            ApplyDialogFont(hwndButton);
            hwndCombo = CreateWindow("COMBOBOX", "", WS_CHILD + WS_CLIPSIBLINGS +
                WS_BORDER + WS_VISIBLE + CBS_DROPDOWN + CBS_AUTOHSCROLL, 
                                BUTTONWIDTH + 10, 4, 200, 100, hwnd, (HMENU)500, hInstance, 0);
            ApplyDialogFont(hwndCombo);
            SubClassHistoryCombo(hwndCombo);
            SendMessage(hwndCombo, WM_SETHISTORY, 0, (LPARAM)varinfohist);
            pt.x = pt.y = 5;
            hwndEdit = ChildWindowFromPoint(hwndCombo, pt);
            oldproc = (WNDPROC)SetWindowLong(hwndEdit, GWL_WNDPROC, (int)EditHook);
            BringWindowToTop(hwndButton);
            BringWindowToTop(hwndCombo);
            font = CreateFontIndirect(&systemDialogFont);
            SendMessage(hwndErrButton, WM_SETFONT, (WPARAM)font, 0);
            SendMessage(hwndWarnButton, WM_SETFONT, (WPARAM)font, 0);
            hwndLV = CreateWindowEx(0, WC_LISTVIEW, "", 
                           LVS_REPORT | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE | WS_BORDER,
                           0,BUTTONHEIGHT + 4,r.right-r.left, r.bottom - r.top-BUTTONHEIGHT-4, hwnd, 0, hInstance, 0);
            ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_DOUBLEBUFFER);
            ApplyDialogFont(hwndLV);
            GetWindowRect(hwndLV, &r);
            lvC.mask = LVCF_WIDTH;
            lvC.cx = 50;
            lvC.iSubItem = 0;
            ListView_InsertColumn(hwndLV, 0, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 50;            lvC.iSubItem = 1;
            lvC.pszText = "Id";
            ListView_InsertColumn(hwndLV, 1, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 250;
            lvC.iSubItem = 2;
            lvC.pszText = "Name";
            ListView_InsertColumn(hwndLV, 2, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 50;
            lvC.iSubItem = 3;
            lvC.pszText = "Line";
            ListView_InsertColumn(hwndLV, 3, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = r.right - r.left - 375;
            lvC.iSubItem = 4;
            lvC.pszText = "File";
            ListView_InsertColumn(hwndLV, 4, &lvC);
            ListView_SetImageList(hwndLV, tagImageList, LVSIL_SMALL);
            break;
        case WM_RESETHISTORY:
            SendMessage(hwndCombo, WM_SETHISTORY, 0, (LPARAM)varinfohist);
            break;
        case WM_SIZE:
            r.left = r.top = 0;
            r.right = LOWORD(lParam);
            r.bottom = HIWORD(lParam);
            MoveWindow(hwndLV, r.left, r.top+BUTTONHEIGHT + 4, r.right - r.left,
                r.bottom - r.top-BUTTONHEIGHT - 4, 1);
            MoveWindow(hwndBackground, r.left, r.top, r.right - r.left, BUTTONHEIGHT + 4, 1);
            lvC.mask = LVCF_WIDTH;
            lvC.cx = r.right - r.left - 375;
            ListView_SetColumn(hwndLV, 4, &lvC);
            break;
        case WM_DESTROY:
            hwndBrowse = 0;
            break;
        case WM_SETFOCUS:
            break;
        case WM_KILLFOCUS:
            break;
    }
    return DefWindowProc(hwnd, iMessage, wParam, lParam);
}
예제 #9
0
파일: browse.c 프로젝트: doniexun/OrangeC
void BrowseTo(HWND hwnd, char *msg)
{
    static char name[256];
    int ofs;
    if (defaultWorkArea)
        return ;
    if (!browsing)
    {
        if (msg)
        {
            strcpy(name, msg);
            browsing = TRUE;
        }
        else
            browsing = SendMessage(hwnd, WM_WORDUNDERCURSOR, 0, (LPARAM)name);
        if (!PropGetBool(NULL, "BROWSE_INFORMATION") && browsing)
        {
            ExtendedMessageBox("Browse Info Alert", MB_OK, 
                "Browse information not enabled");
            browsing = FALSE;
            return ;
        }
    }
    else
    {
        SendMessage(hwnd, WM_WORDUNDERCURSOR, 0, (LPARAM)name);
    }
    if (browsing)
    {
        sqlite3 *db = NULL;
        DWINFO info;
        CHARRANGE charrange;
        int curline;
        char *filname;
        PROJECTITEM *pj;
        if (msg)
        {
            curline =  - 2;
            filname = "";
        }
        else
        {
            SendDlgItemMessage(hwnd, ID_EDITCHILD, EM_EXGETSEL, (WPARAM)0, 
                (LPARAM) &charrange);
            curline = SendDlgItemMessage(hwnd, ID_EDITCHILD, EM_EXLINEFROMCHAR,
                0, (LPARAM)charrange.cpMin) + 1;
            filname = (char*)SendMessage(hwnd, WM_FILENAME, 0, 0);
        }
        memset(&info, 0, sizeof(info));
        db = BrowseOpenDBByHWND(hwnd, &pj);
        if (!db)
        {
            return ;
        }
        if (FindLine(db, filname, curline, name, info.dwName, &info.dwLineNo))
        {
            char *p = strrchr(info.dwName, '\\');
            if (p)
                strcpy(info.dwTitle, p + 1);
            info.logMRU = FALSE;
            info.newFile = FALSE;
            InsertBrowse(name, curline);
            CreateDrawWindow(&info, TRUE);
        }
        DBClose(db);
    }
    browsing = FALSE;
}