DWORD CPEExport::GetFunc(int nIndex) { if (nIndex<GetFuncCount()) { DWORD dwFirstFunc=GetFirstFunc(); return dwFirstFunc+nIndex*4; } return 0; }
static BOOL GetFragments(CCFUNCDATA *funcs, int funcpos, int curarg, char **fragments) { char buf[2048], *last= funcs->fullname,*p; int n = GetFuncCount(funcs); int i, nesting = 0; for (i=0; i < funcpos && funcs; i++) funcs = funcs->next; if (!funcs) return FALSE; p = funcs->fullname; while (*p) { switch(*p) { case '@': if (!nesting) last = p; break; case '#': nesting++; break; case '~': if (nesting) nesting--; break; } p++; } if (last != p) { while (*last && *last != '$') last ++; * last = 0; } sprintf(buf, "%d of %d", funcpos+1, n); fragments[0] = strdup(buf); unmangle(buf, funcs->fullname); if (last != p) *last = '$'; strcat(buf, "("); for (i=0; i < curarg && i < funcs->args->argCount; i++) { GetArgData(buf + strlen(buf), &funcs->args->data[i]); if (i < funcs->args->argCount-1) strcat(buf, ", "); } fragments[1] = strdup(buf); fragments[2] = NULL; if (i < funcs->args->argCount) { GetArgData(buf, &funcs->args->data[i]); if (i < funcs->args->argCount-1) strcat(buf, ", "); i++; fragments[2] = strdup(buf); } fragments[3] = NULL; buf[0] = 0; for (;i < funcs->args->argCount; i++) { GetArgData(buf + strlen(buf), &funcs->args->data[i]); if (i < funcs->args->argCount-1) strcat(buf, ", "); } strcat(buf, ")"); fragments[3] = strdup(buf); return TRUE; }
LRESULT CALLBACK funcProc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { static EDITDATA *ptr; static CCFUNCDATA **funcs[100]; static int funcpos[100]; static int nesting[100]; static int curarg[100]; static int index; static HFONT normal, bold, oldfont; static POINT origin[100]; static HBITMAP leftarrow, rightarrow; int offset; int oldbk, oldfg; LOGFONT lf; PAINTSTRUCT ps; HPEN pen; HBRUSH brush; HDC dc; SIZE size1, size2; RECT r; char * fragments[4]; switch(iMessage) { case WM_CREATE: leftarrow = LoadBitmap(hInstance, "ID_CCLEFTARR"); rightarrow = LoadBitmap(hInstance, "ID_CCRIGHTARR"); lf = systemDialogFont; normal = (HFONT)CreateFontIndirect(&lf); lf.lfWeight = FW_BOLD; bold = CreateFontIndirect(&lf); SetLayeredWindowAttributes(hwnd, TRANSPARENT_COLOR, 0xff, LWA_COLORKEY); break; case WM_USER: funcs[index] = (CCFUNCDATA *)lParam; funcpos[index] = 0; nesting[index] = 0; curarg[index] = 0; index++; if (IsWindowVisible(hwnd)) SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); break; case WM_USER + 1: { POINTL pt; ptr = (EDITDATA *)lParam; posfromchar((HWND)wParam, ptr, &pt,ptr->selendcharpos); origin[index-1].x = pt.x; origin[index-1].y = pt.y; MapWindowPoints((HWND)wParam, hwndFrame, &origin[index-1], 1); origin[index-1].y += ptr->cd->txtFontHeight; } break; case WM_USER + 2: curarg[index-1] = wParam; SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); break; case WM_SHOWWINDOW: { if (wParam) { SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); } else { ccFreeFunctionList(funcs[--index]); if (index) ShowWindow(hwnd, SW_SHOW); } } case WM_USER + 3: if (IsWindowVisible(hwnd)) { switch(wParam) { case VK_DOWN: if (GetFuncCount(funcs[index-1]) > 1) { funcpos[index-1] ++; if (funcpos[index-1] >= GetFuncCount(funcs[index-1])) funcpos[index-1] = 0; SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); return 0; } case VK_UP: if (GetFuncCount(funcs[index-1]) > 1) { funcpos[index-1] --; if (funcpos[index-1] < 0) funcpos[index-1] = GetFuncCount(funcs[index-1]); SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); return 0; } case VK_HOME: case VK_END: case VK_PRIOR: case VK_NEXT: if (index == 1) ShowWindow(hwnd, SW_HIDE); else { ccFreeFunctionList(funcs[--index]); SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); } return 1; case VK_BACK: if (ptr->selendcharpos) switch(ptr->cd->text[ptr->selendcharpos - 1].ch) { case ',': --curarg[index-1]; SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); return 1; case '(': if (--nesting[index-1] < 0) { if (index == 1) ShowWindow(hwnd, SW_HIDE); else { ccFreeFunctionList(funcs[--index]); SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); } } break; case ')': ++nesting[index-1]; break; } return 1; break; default: { int key = KeyboardToAscii(wParam, lParam, TRUE); switch(key) { case ',': ++curarg[index-1]; SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); break; case '(': ++nesting[index-1]; break; case ')': if (--nesting[index-1] < 0) { if (index == 1) ShowWindow(hwnd, SW_HIDE); else { ccFreeFunctionList(funcs[--index]); SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); } } break; } return 1; break; } } } break; case WM_PAINT: dc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &r); brush = CreateSolidBrush(TRANSPARENT_COLOR); FillRect(dc, &r, brush); DeleteObject(brush); brush = CreateSolidBrush(RetrieveSysColor(COLOR_INFOBK)); brush = SelectObject(dc, brush); pen = CreatePen(PS_SOLID, 0, 0); pen = SelectObject(dc, pen); RoundRect(dc, r.left, r.top, r.right, r.bottom, 5, 5); brush = SelectObject(dc, brush); DeleteObject(brush); pen = SelectObject(dc, pen); DeleteObject(pen); if (GetFragments(funcs[index-1], funcpos[index-1], curarg[index-1], fragments)) { SIZE sz; HDC *memDC = CreateCompatibleDC(dc); int offset = 3 + GetSystemMetrics(SM_CXBORDER); normal = SelectObject(dc, normal); oldbk = SetBkColor(dc, RetrieveSysColor(COLOR_INFOBK)); oldfg = SetTextColor(dc, RetrieveSysColor(COLOR_INFOTEXT)); GetTextExtentPoint32(dc, fragments[0], strlen(fragments[0]), &sz); TextOut(dc, offset+12, 2, fragments[0], strlen(fragments[0])); leftarrow = SelectObject(memDC, leftarrow); TransparentBlt(dc, offset+2, ((sz.cy+3)-10)/2, 10, 10, memDC, 0, 0, 10, 10, 0xc0c0c0); offset += 12 + sz.cx; leftarrow = SelectObject(memDC, leftarrow); rightarrow = SelectObject(memDC, rightarrow); TransparentBlt(dc, offset+2, ((sz.cy+3)-10)/2, 10, 10, memDC, 0, 0, 10, 10, 0xc0c0c0); rightarrow = SelectObject(memDC, rightarrow); offset += 12 + 4; GetTextExtentPoint32(dc, fragments[1], strlen(fragments[1]), &sz); TextOut(dc, offset, 2, fragments[1], strlen(fragments[1])); offset += sz.cx; if (fragments[2]) { normal = SelectObject(dc, normal); bold = SelectObject(dc, bold); GetTextExtentPoint32(dc, fragments[2], strlen(fragments[2]), &sz); TextOut(dc, offset, 2, fragments[2], strlen(fragments[2])); offset += sz.cx; bold = SelectObject(dc, bold); normal = SelectObject(dc, normal); } GetTextExtentPoint32(dc, fragments[3], strlen(fragments[3]), &sz); TextOut(dc, offset, 2, fragments[3], strlen(fragments[3])); offset += sz.cx; DeleteDC(memDC); normal = SelectObject(dc, normal); oldbk = SetBkColor(dc, oldbk); oldfg = SetTextColor(dc, oldfg); FreeFragments(fragments); } EndPaint(hwnd, &ps); return 0; } return DefWindowProc(hwnd, iMessage, wParam, lParam); }