Пример #1
0
void CreateStringTableDrawWindow(struct resRes *info)
{
    char name[512];
    int maximized;
    HWND hwnd;
    sprintf(name, "%s - %s", szUntitled, info->name);
    SendMessage(hwndClient, WM_MDIGETACTIVE, 0, (LPARAM) &maximized);
    hwnd = CreateMDIWindow(szStringTableDrawClassName, name, WS_VISIBLE |
           WS_CHILD | WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | MDIS_ALLCHILDSTYLES | 
        WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
        WS_SIZEBOX | (PropGetInt(NULL, "TABBED_WINDOWS") ? WS_MAXIMIZE : WS_SYSMENU),
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndClient, hInstance, 
        (LPARAM)info); 
    if (hwnd)
    {
        SendMessage(hwndSrcTab, TABM_ADD, (WPARAM)name, (LPARAM)hwnd);
        if (info->resource->changed)
            ResRewriteTitle(info, TRUE);
    }
}
Пример #2
0
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 ) ;


}
Пример #3
0
int Print(HWND win)
{
    BOOL rv = TRUE;
    int start, end;
    PRINTDLG pd;
    HWND hDlgCancel = 0;
    memset(&pd, 0, sizeof(pd));
    pd.lStructSize = sizeof(pd);
    pd.hwndOwner = hwndFrame;
    pd.Flags = PD_NOPAGENUMS | PD_RETURNDC | PD_COLLATE ;
    pd.hInstance = hInstance;
    SendDlgItemMessage(win, ID_EDITCHILD, EM_GETSEL, (WPARAM) &start, (LPARAM)
        &end);
    tabSetting = PropGetInt(NULL, "TAB_INDENT");
    leftmargin = PropGetInt(NULL, "PRINTER_LEFT");
    rightmargin = PropGetInt(NULL, "PRINTER_RIGHT");
    topmargin = PropGetInt(NULL, "PRINTER_TOP");
    bottommargin = PropGetInt(NULL, "PRINTER_BOTTOM");
    PropGetString(NULL, "PRINTER_HEADER", printHeader, sizeof(printHeader));
    PropGetString(NULL, "PRINTER_FOOTER", printFooter, sizeof(printFooter));
    if (tabSetting <= 0)
        tabSetting = 4;
    if (end != start)
        pd.Flags |= PD_SELECTION;
    if (PrintDlg(&pd))
    {
        DOCINFO di;
        HWND child;
        char *buf,  *pos,  *savepos1;
        if (pd.Flags &PD_SELECTION)
        {
            if (end <= start)
                return TRUE ;
        }
        child = GetDlgItem(win, ID_EDITCHILD);
        buf = GetEditData(child);
        if (!buf)
            return TRUE ;
        if (pd.Flags &PD_SELECTION)
        {
            savepos1 = pos = buf + start;
            buf[end] = 0;
        }
        else
            savepos1 = pos = buf;
        printing = TRUE;
        memset(&di, 0, sizeof(di));
        di.cbSize = sizeof(di);
        di.lpszDocName = (char*)SendMessage(win, WM_FILETITLE, 0, 0);
        if (pd.Flags &PD_PRINTTOFILE)
            di.lpszOutput = "FILE:";
        SetAbortProc(pd.hDC, &AbortProc);

        if (StartDoc(pd.hDC, &di) > 0)
        {
            int pelsx, pelsy;
            int width, height, rows, cols;
            int done = FALSE;
            char headerLeft[256],headerRight[256],headerCenter[256];
            char FooterLeft[256],FooterRight[256],FooterCenter[256];
            SIZE strsize ;
            HFONT hFont, oldhFont;

            pelsx = GetDeviceCaps(pd.hDC, LOGPIXELSX);
            pelsy = GetDeviceCaps(pd.hDC, LOGPIXELSY);

            fontdata.lfHeight =  - MulDiv(11, pelsx, 72);
            hFont = CreateFontIndirect(&fontdata);
            oldhFont = SelectObject(pd.hDC, hFont);
            GetTextExtentPoint32(pd.hDC, "A", 1, &strsize);

            width = GetDeviceCaps(pd.hDC, HORZRES);
            height = GetDeviceCaps(pd.hDC, VERTRES);
//            buf = GetEditData(win);

            rows = (height - (topmargin + bottommargin) *pelsy * 10 / 254) /
                strsize.cy ;
            cols = (width - (leftmargin + rightmargin) *pelsx * 10 / 254) /
                strsize.cx;

            if (rows <= 0 || cols <= 0)
            {
                AbortDoc(pd.hDC);
                free(buf);
                DeleteObject(hFont);
                if (pd.hDC != NULL)
                    DeleteDC(pd.hDC);
                if (pd.hDevMode != NULL)
                    GlobalFree(pd.hDevMode);
                if (pd.hDevNames != NULL)
                    GlobalFree(pd.hDevNames);
                return FALSE;
            }
            SelectObject(pd.hDC, oldhFont);
            if (printHeader[0])
                rows -= 2;
            if (printFooter[0])
                rows -= 2;
            total_pages = countPages(savepos1, rows, cols);
            setTimeFormats();
            split(printHeader, headerLeft, headerRight, headerCenter);
            split(printFooter, FooterLeft, FooterRight, FooterCenter);
            hDlgCancel = CreateDialog(hInstance, "PRINTABORTDLG", 0, (DLGPROC)
                CancelProc);
            EnableWindow(hwndFrame, FALSE);
            do
            {
                int colcount = pd.nCopies;
                int pagenum = 1;
                pos = savepos1;
                while (printing &&  *pos && StartPage(pd.hDC) > 0)
                {
                    int i, j, k;
                    int hdrlines = 0;
                    char line[512];
                    char *savepos2 = pos;
                    oldhFont = SelectObject(pd.hDC, hFont);
                    if (printHeader[0])
                    {
                        char buf[256];
                        int cx ;
                        int cy = topmargin * pelsy * 10/ 254;
                        cx = subs(pd.hDC, buf, headerLeft, di.lpszDocName, pagenum);
                        cx = leftmargin * pelsx * 10 / 254;
                        TextOut(pd.hDC, cx, cy, buf, strlen(buf));
                        cx = subs(pd.hDC, buf, headerCenter, di.lpszDocName, pagenum);
                        cx = (width - cx)/2 ;
                        TextOut(pd.hDC, cx, cy, buf, strlen(buf));
                        cx = subs(pd.hDC, buf, headerRight, di.lpszDocName, pagenum);
                        cx = width - cx - rightmargin * pelsx * 10 / 254;
                        TextOut(pd.hDC, cx, cy, buf, strlen(buf));
                        hdrlines = 2;
                    }
                    for (i = 0; i < rows; i++)
                    {
                        int count = 0;
                        if (*pos == '\n')
                        {
                            pos++;
                        }
                        else if (*pos == '\f')
                        {
                            pos += 2;
                            break;
                        }
                        else
                        {
                            for (j = 0; j < cols; j++)
                            {
                                if (*pos == '\t')
                                {
                                    int n = tabSetting - j % tabSetting;
                                    pos++;
                                    for (k = 0; k < n; k++)
                                        line[count++] = ' ';
                                    j += n - 1;
                                } 
                                else
                                {
                                    if (*pos < 32 ||  *pos > 126)
                                    {
                                        if (*pos == '\n')
                                            pos++;
                                        break;
                                    }
                                    line[count++] =  *pos++;
                                }
                            }
                            TextOut(pd.hDC, leftmargin *pelsx * 10 / 254, (i + hdrlines)
                                *strsize.cy + topmargin * pelsy * 10 / 254, line, count);
                        }
                        if (! *pos)
                            break;
                    }
                    if (printFooter[0])
                    {
                        char buf[256];
                        int cx ;
                        int cy = height - strsize.cy - bottommargin * pelsy * 10 / 254;
                        cx = subs(pd.hDC, buf, FooterLeft, di.lpszDocName, pagenum);
                        cx = leftmargin * pelsx * 10 / 254;
                        TextOut(pd.hDC, cx, cy, buf, strlen(buf));
                        cx = subs(pd.hDC, buf, FooterCenter, di.lpszDocName, pagenum);
                        cx = (width - cx) / 2;
                        TextOut(pd.hDC, cx, cy, buf, strlen(buf));
                        cx = subs(pd.hDC, buf, FooterRight, di.lpszDocName, pagenum);
                        cx = width - cx - rightmargin * pelsx * 10 / 254;
                        TextOut(pd.hDC, cx, cy, buf, strlen(buf));
                    }
                    SelectObject(pd.hDC, oldhFont);
                    if (printing)
                        if (EndPage(pd.hDC) <= 0)
                            goto doneprinting;
                    if (!(pd.Flags &PD_COLLATE))
                    {
                        if (--colcount)
                        {
                            pos = savepos2;
                        }
                        else
                        {
                            colcount = pd.nCopies;
                            pagenum++;
                        }
                    }
                    else
                    {
                        pagenum++;
                    }
                        
                }
            }
            while (printing && (pd.Flags &PD_COLLATE) && --pd.nCopies)
                ;
            if (!printing)
                AbortDoc(pd.hDC);
            doneprinting: if (printing)
                EndDoc(pd.hDC);
            EnableWindow(hwndFrame, TRUE);
            if (hDlgCancel)
                DestroyWindow(hDlgCancel);
            DeleteObject(hFont);
        }
        FreeEditData(buf);

    }
    if (pd.hDC != NULL)
        DeleteDC(pd.hDC);
    if (pd.hDevMode != NULL)
        GlobalFree(pd.hDevMode);
    if (pd.hDevNames != NULL)
        GlobalFree(pd.hDevNames);
    return rv;
}
Пример #4
0
 void showFunction(HWND hwnd, EDITDATA *p, int ch)
 {
     sqlite3_int64 id, baseid;
     CCFUNCDATA *functionData = NULL;
     char name[2046], *q = name;
     int end = p->selstartcharpos;
     int pos = p->selstartcharpos - 1;
     POINT cpos;
     SIZE size;
     int curArg = 0;
     if (instring(p->cd->text, &p->cd->text[p->selstartcharpos]))
         return;
     p->cd->selecting = FALSE;
     
     if (pos <= 0 || PropGetInt(NULL, "CODE_COMPLETION") == 0)
         return ;
     if (ch == '(' || ch == ',' && !IsWindowVisible(hwndShowFunc))
     {
         char name[512], *p1;
         int pos;
         int i;
         int commaCount = 0;
         DWINFO *info = (DWINFO *)GetWindowLong(GetParent(hwnd), 0);
         int lineno = SendMessage(hwnd, EM_EXLINEFROMCHAR, 0, p->selstartcharpos)+1;
         CCFUNCDATA * functionData = NULL;
         BOOL parsed = FALSE;
         CHARRANGE range;
         if (ch == ',')
         {
             int nesting  =1 ;
             pos = p->selendcharpos-1;
             while (nesting > 0 && pos> 0 && p->cd->text[pos].ch != '{' && p->cd->text[pos].ch != '}')
             {
                 if (p->cd->text[pos].ch == ')')
                     nesting++;
                 else if (p->cd->text[pos].ch == '(')
                     nesting --;
                 else if (p->cd->text[pos].ch == ',' && nesting == 1)
                     commaCount++;
                 pos--;
             }
             if (nesting)
                 return;
             if (!pos || !isalnum(p->cd->text[pos-1].ch) && p->cd->text[pos-1].ch != '_')
                 return;
             range.cpMin = pos;
             range.cpMax = pos;
         }
         else
         {
             range.cpMin = p->selendcharpos-1;
             range.cpMax = p->selendcharpos-1;
         }
         GetWordSpan(p, &range);
         if (range.cpMin == range.cpMax)
             return;
         pos = range.cpMin;
         while (pos && isspace(p->cd->text[pos-1].ch))
         {
             pos--;
         }
         if (pos && p->cd->text[pos-1].ch == ':')
         {
             pos = CPPScanBackward(p, range.cpMax, TRUE);
         }
         else
         {
             pos = range.cpMin;
         }
         for (i=pos; i < range.cpMax; i++)
             name[i-pos] = p->cd->text[i].ch;
         name[i-pos] = 0;
         p1 = name;
         GetQualifiedName(name + i-pos + 1, &p1, FALSE, FALSE);
         strcpy(name, name +i-pos + 1);
         while (pos && isspace(p->cd->text[pos-1].ch))
         {
             pos--;
         }
         if (pos && (p->cd->text[pos-1].ch == '.' || p->cd->text[pos-1].ch == '>'))
         {
             int start = 0;
             start = CPPScanBackward(p, p->selendcharpos, TRUE);
             if (start != pos)
             {
                 char qual[2048];
                 for (i=start; i < pos; i++)
                     qual[i-start] = p->cd->text[i].ch;
                 qual[i-start] = 0;
                 parsed = TRUE;
                 sprintf(qual + strlen(qual), "@%s", name);
                 functionData = ccLookupFunctionList(lineno, info->dwName, qual);
             }
         }
         if (!parsed)
         {
             CCFUNCDATA **scan;
             char funcbase[2048], nsbase[512], abase[512];
             abase[0] = 0;
             GetContainerData(lineno, info->dwName, nsbase, funcbase);
             if (strrchr(name, '@') != name)
             {
                 char *p = strrchr(name, '@');
                 strncpy(abase, name, p - name);
                 abase[p-name] = 0;
                 strcpy(name, p);
                 *p = 0;
             }
             functionData = ccLookupFunctionList(lineno, info->dwName, name);
             if (!functionData)
             {
                 name[0] = '_';
                 functionData = ccLookupFunctionList(lineno, info->dwName, name);
                 name[0] = '@';
             }
             scan = &functionData;
             while (*scan)
             {
                 char nsbase2[2048];
                 if ((*scan)->args->member)
                 {
                     if  (!funcbase[0] || strncmp(funcbase, (*scan)->fullname, strlen(funcbase)))
                     {
                         CCFUNCDATA *remove = *scan;
                         *scan = (*scan)->next;
                         remove->next = NULL;
                         ccFreeFunctionList(remove);
                     }
                     else
                     {
                         scan = &(*scan)->next;
                     }
                 }
                 else
                 {
                     char *last, *p ;
                     int nesting = 0;
                     p = last = (*scan)->fullname;
                     while (*p)
                     {
                         switch(*p)
                         {
                             case '@':
                                 if (!nesting)
                                     last = p;
                                 break;
                             case '#':
                                 nesting++;
                                 break;
                             case '~':
                                 if (nesting)
                                     nesting--;
                                 break;
                         }
                         p++;
                     }
                     if (last != (*scan)->fullname
                         && (strncmp((*scan)->fullname, funcbase, last - (*scan)->fullname)
                           || funcbase[last - (*scan)->fullname] != '@' && funcbase[last - (*scan)->fullname] != 0))
                     {    
                         BOOL found = FALSE;                        
                         char *p = nsbase;
                         while (*p)
                         {
                             char *q = nsbase2;
                             while (*p && *p != ';')
                                 *q++ = *p++;
                             if (*p)
                                 p++;
                             *q = 0;
                              if  (!strncmp((*scan)->fullname, nsbase2, last - (*scan)->fullname)
                                                           &&( nsbase2[last - (*scan)->fullname] == '@' || nsbase2[last - (*scan)->fullname] == 0))
                              {
                                  found = TRUE;
                                  break;
                              }
                         }
                         if (!found)
                         {
                             strcpy(nsbase2, abase);                                
                              if  (!strncmp((*scan)->fullname, nsbase2, last - (*scan)->fullname)
                                                           && nsbase2[last - (*scan)->fullname] == 0)
                              {
                                  found = TRUE;
                              }
                         }
                         if (!found)
                         {
                             CCFUNCDATA *remove = *scan;
                             *scan = (*scan)->next;
                             remove->next = NULL;
                             ccFreeFunctionList(remove);
                         }
                         else
                             scan = &(*scan)->next;
                     }
                     else {
                         BOOL found = abase[0] == '\0';
                                                 
                         strcpy(nsbase2, abase);                                
                          if  (!strncmp((*scan)->fullname, nsbase2, last - (*scan)->fullname)
                                                       && nsbase2[last - (*scan)->fullname] == 0)
                          {
                              found = TRUE;
                          }
                         if (!found)
                         {
                             CCFUNCDATA *remove = *scan;
                             *scan = (*scan)->next;
                             remove->next = NULL;
                             ccFreeFunctionList(remove);
                         }
                         else
                         {
                             scan = &(*scan)->next;
                         }
                     }
                 }
             }
             
         }
         if (functionData)
         {
             if (!hwndShowFunc)
             {
                 hwndShowFunc = CreateWindowEx(0 | /*WS_EX_TOPMOST | WS_EX_LAYERED |*/ WS_EX_NOACTIVATE, "xccfuncclass", "",
                                             (WS_CHILD),
                                             CW_USEDEFAULT, CW_USEDEFAULT,
                                             CW_USEDEFAULT, CW_USEDEFAULT,
                                             hwndFrame, 0, GetModuleHandle(0), 0);
                 // done this way to associate the popup with the application rather than the desktop
                 SetWindowLong(hwndShowFunc, GWL_STYLE, (GetWindowLong(hwndShowFunc, GWL_STYLE) & ~WS_CHILD ) | WS_POPUP);
             }
             SendMessage(hwndShowFunc, WM_USER, 0, (LPARAM)functionData);
             SendMessage(hwndShowFunc, WM_USER+1, (WPARAM)hwnd, (LPARAM)p);
             SendMessage(hwndShowFunc, WM_USER+2, commaCount, 0);
             ShowWindow(hwndShowFunc, SW_SHOW);
             SetFocus(hwnd);
         }
     }
 }