HICON CSIM_ext::createIcon(const char *name) { ICON_MAP::iterator it = m_icons.find(name); if (it != m_icons.end()) return (*it).second; string cmd = "ICON "; cmd += name; CComBSTR in(cmd.c_str()); CComBSTR out; if (!ProcessStr || !ProcessStr(in, &out)) return NULL; size_t size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), 0, 0, NULL, NULL); char *res = new char[size + 1]; size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), res, size, NULL, NULL); res[size] = 0; if (res[0] != '>') return NULL; string r = res + 1; ICONINFO info; info.fIcon = TRUE; info.xHotspot = 8; info.yHotspot = 8; info.hbmMask = createBitmap(r); info.hbmColor = createBitmap(r); HICON hIcon = CreateIconIndirect(&info); m_icons.insert(ICON_MAP::value_type(name, hIcon)); DeleteObject(info.hbmMask); DeleteObject(info.hbmColor); return hIcon; }
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR cmdLine, int) { CComBSTR in("FILE "); in.Append(cmdLine); CComBSTR out; ProcessStr(in, &out); return 0; }
HRESULT CSIM_ext::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { if (lpData == NULL) return 0; if (((uFlags & 0x0000000F) == CMF_NORMAL) || (uFlags & CMF_EXPLORE)){ CComBSTR in("CONTACTS 3"); CComBSTR out; unsigned n = 0; if (ProcessStr && ProcessStr(in, &out)){ HMENU hsub = NULL; size_t size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), 0, 0, NULL, NULL); char *res = new char[size + 1]; size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), res, size, NULL, NULL); res[size] = 0; if (res[0] == '>'){ char *name = res + 1; unsigned id = 0; for (char *p = name; *p; p++){ if ((*p == ' ') && (id == 0)){ id = atol(name); name = p + 1; } if (*p == '\n'){ *p = 0; if (strlen(name)){ if (hsub == NULL) hsub = CreatePopupMenu(); AppendMenu(hsub, MF_STRING, idCmdFirst + id, name); if (id > n) n = id; id = 0; } name = p + 1; } } } delete[] res; if (hsub != NULL){ AppendMenu(hmenu, MF_POPUP | MF_STRING, (unsigned)hsub, "Send to SIM contact"); } } return n; } return 0; }
/* * Routine: ProcessInclude * Purpose: Allow nested files * Algorithm: * Data Structures: * * Parindent: Standard input:235: Error:Unexpected end of file ams: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: * 20020515: should allow for escaped quotation marks */ int ProcessInclude (char *stmt, token_t * tokens) { char *cp; int nRetCode; char *szHoldName; int nHoldLine; cp = ProcessStr (stmt, tokens); szHoldName = strdup(CurrentFileName); nHoldLine = nLineNumber; nRetCode = ParseFile (cp); free(CurrentFileName); CurrentFileName = szHoldName; nLineNumber = nHoldLine; return (nRetCode); }
HRESULT CSIM_ext::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) { if (lpData == NULL) return S_OK; STGMEDIUM stgmedium = { TYMED_HGLOBAL, NULL }; FORMATETC formatetc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; HRESULT hr = lpData->GetData(&formatetc, &stgmedium); if (SUCCEEDED(hr)){ char *drop_files = (char*)GlobalLock(stgmedium.hGlobal); DROPFILES *files = (DROPFILES*)drop_files; drop_files += files->pFiles; CComBSTR in("SENDFILE \""); if (files->fWide){ in += (unsigned short*)drop_files; }else{ in += drop_files; } in += "\" "; ItemInfo info = getItemInfo(LOWORD(lpici->lpVerb) + CmdBase); char b[12]; sprintf(b, "%u", info.id); in += b; GlobalUnlock(stgmedium.hGlobal); CComBSTR out; if (ProcessStr) ProcessStr(in, &out); } GlobalFree(stgmedium.hGlobal); if (lpData){ lpData->Release(); lpData = NULL; } return S_OK; }
HRESULT CSIM_ext::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { if ((lpData == NULL) || (uFlags & CMF_DEFAULTONLY)) return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); CmdBase = idCmdFirst; if (((uFlags & 0x0000000F) == CMF_NORMAL) || (uFlags & CMF_EXPLORE)){ STGMEDIUM stgmedium = { TYMED_HGLOBAL, NULL }; FORMATETC formatetc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; HRESULT hr = lpData->GetData(&formatetc, &stgmedium); if (!SUCCEEDED(hr)) return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); char *drop_files = (char*)GlobalLock(stgmedium.hGlobal); DROPFILES *files = (DROPFILES*)drop_files; GlobalUnlock(stgmedium.hGlobal); CComBSTR in("CONTACTS 3"); CComBSTR out; unsigned cmd_id = idCmdFirst; if (ProcessStr && ProcessStr(in, &out)){ HMENU hMain = NULL; HMENU hSub = NULL; size_t size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), 0, 0, NULL, NULL); char *res = new char[size + 1]; size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), res, size, NULL, NULL); res[size] = 0; if (res[0] == '>'){ string r = res + 1; string line = getToken(r, '\n'); unsigned nContacts = atol(getToken(line, ' ').c_str()); unsigned nGroups = atol(line.c_str()); bool bSubMenu = false; if ((nContacts > 20) && (nGroups > 1)){ hMain = CreatePopupMenu(); bSubMenu = true; } unsigned old_grp = (unsigned)(-1); while (!r.empty()){ line = getToken(r, '\n'); if (line.empty()) continue; unsigned id = atol(getToken(line, ' ').c_str()); unsigned grp = atol(getToken(line, ' ').c_str()); string icon = getToken(line, ' '); if (!line.empty()){ if (hMain){ if (grp != old_grp){ old_grp = grp; if (bSubMenu){ char *res = NULL; hSub = CreatePopupMenu(); char *grp = "Group"; char cmd[64]; sprintf(cmd, "GROUP %u", old_grp); CComBSTR in(cmd); CComBSTR out; if (ProcessStr && ProcessStr(in, &out)){ size_t size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), 0, 0, NULL, NULL); char *res = new char[size + 1]; size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), res, size, NULL, NULL); res[size] = 0; if (res[0] == '>') grp = res + 1; } AppendMenu(hMain, MF_POPUP | MF_STRING, (unsigned)hSub, grp); if (res) delete[] res; }else{ AppendMenu(hSub, MF_SEPARATOR, 0, NULL); } } }else{ hMain = CreatePopupMenu(); hSub = hMain; } ItemInfo info; info.text = line.c_str(); info.icon = createIcon(icon.c_str()); info.id = id; m_items.insert(ITEM_MAP::value_type(cmd_id, info)); AppendMenu(hSub, MF_STRING | MF_OWNERDRAW, cmd_id, line.c_str()); cmd_id++; } } } delete[] res; if (hMain != NULL) InsertMenu(hmenu, indexMenu++, MF_POPUP|MF_BYPOSITION, (UINT)hMain, "Send to SIM contact"); } return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, cmd_id - idCmdFirst); } return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); }