static int UppOneSimplify(VarItem &varItem, int step) { // setup item type varItem.kind = VarItem::COMPLEX; // if we're just doing first scan phase, signal that we need further evaluation later #ifdef EVALDEEP if(!step) // next step is 1 return 1; #else varItem.value = placeHolder; return 0; #endif // de-reference and forward simplify MIValue val = varItem.EvaluateExpression(varItem.evaluableExpression + "." + "ptr"); if(val.IsError() || !val.IsString()) { varItem.value = "Upp::One<> = <can't evaluate contents>"; return 0; } String ptr = val.ToString(); if(ptr == "0x0") { varItem.value = "Upp::One<> = <EMPTY>"; return 0; } // replace variable with de-referenced one VarItem vItem(&varItem.Debugger(), "*" + varItem.evaluableExpression + "." + "ptr"); varItem = vItem; return varItem.GetSimplifyStep(); }
VOID CMyAddin::InitMenu(LPEXCHEXTCALLBACK lpeecb) { try { HBITMAP hBmp; //_bstr_t bstrNewMenuText(OLESTR(APP_NAME)); //CComPtr < Office::CommandBarControls> spCmdCtrls; //CComPtr < Office::CommandBarControls> spCmdBarCtrls; //CComPtr < Office::CommandBarPopup> spCmdPopup; CComPtr <Office::CommandBarControl> spCmdCtrl; CComPtr < Office::CommandBar> spCmdBar; Outlook::_ExplorerPtr spExplorer = m_OLAppPtr->ActiveExplorer(); Office::_CommandBarsPtr spCmdBars = spExplorer->CommandBars; enum Outlook::OlItemType itemType = spExplorer->CurrentFolder->GetDefaultItemType(); if ((itemType!=Outlook::olContactItem) && (itemType!=Outlook::olMailItem)) { return; } // get the outlok Context Menu. for this enumerate all the command bars for "Context Menu" command bar CComPtr<Office::CommandBar> pTempBar; BOOL bFound =false; for(long i = 0; i < spCmdBars->Count ; i++) { CComVariant vItem(i+1); //zero based index pTempBar=NULL; spCmdBars->get_Item(vItem,&pTempBar); if((pTempBar) && (!wcscmp(L"Context Menu",pTempBar->Name))) { spCmdBar = pTempBar; bFound = true; break; } } if (!bFound) return; spCmdCtrl = spCmdBar->FindControl(Office::msoControlButton, vtMissing, APP_NAME); if (spCmdCtrl!=NULL) { /*Office::MsoBarProtection oldProtectionLevel = spCmdBar->Protection; spCmdBar->Protection = Office::msoBarNoProtection;*/ spCmdCtrl->Priority = 1; /*spCmdCtrl->PutVisible(VARIANT_TRUE); spCmdCtrl->PutTag(APP_NAME); spCmdCtrl->OnAction = "MyButtonsAction";*/ //spCmdBar->Protection = oldProtectionLevel; //spCmdBar->Reset(); return; } CComPtr < Office::CommandBarControl> spNewMenu; // change the commandbar protection to zero Office::MsoBarProtection oldProtectionLevel = spCmdBar->Protection; spCmdBar->Protection = Office::msoBarNoProtection; //set the new item type to ControlButton; CComVariant vtType(Office::msoControlButton); //add a new item to command bar spNewMenu = spCmdBar->Controls->Add(vtType); //set a unique Tag that u can be used to find your control in commandbar spNewMenu->Tag = APP_NAME; //a caption spNewMenu->Caption = APP_NAME; // priority (makes sure outlook includes this item in everytime) spNewMenu->Priority =1 ; // store the new button ID into a variable //m_vtId = m_pSortButton ->Id; // visible the item spNewMenu->Visible = true; //set the new item type to ControlButton; /*CComVariant vtType(Office::msoControlButton); CComVariant vMenuType(1); // type of control - menu CComVariant vMenuPos(6); CComVariant vMenuEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR); CComVariant vMenuShow(VARIANT_TRUE); // menu should be visible CComVariant vMenuTemp(VARIANT_TRUE); // menu is temporary // now create the actual menu item and add it spNewMenu = spCmdBar->Controls->Add(vMenuType, vMenuEmpty, vMenuEmpty, vMenuEmpty, vMenuTemp); ATLASSERT(spNewMenu); spNewMenu->PutCaption(bstrNewMenuText); spNewMenu->PutEnabled(VARIANT_TRUE); spNewMenu->PutVisible(VARIANT_TRUE); spNewMenu->PutTag(APP_NAME); spNewMenu->OnAction = "MyButtonsAction";*/ //we'd like our new menu item to look cool and display // an icon. Get menu item as a CommandBarButton CComQIPtr <Office::_CommandBarButton> spCmdMenuButton(spNewMenu); ATLASSERT(spCmdMenuButton); //spCmdMenuButton->PutStyle(Office::msoButtonIconAndCaption); hBmp = NULL; /*(HBITMAP)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP_PHONE), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);*/ if (hBmp) { // put bitmap into Clipboard ::OpenClipboard(NULL); ::EmptyClipboard(); ::SetClipboardData(CF_BITMAP, (HANDLE)hBmp); ::CloseClipboard(); ::DeleteObject(hBmp); // set style before setting bitmap spCmdMenuButton->PutStyle(Office::msoButtonIconAndCaption); if (FAILED(spCmdMenuButton->PasteFace())) { //MessageBox(NULL, "Error", "Error", MB_OK); } ::OpenClipboard(NULL); ::EmptyClipboard(); ::CloseClipboard(); } spCmdBar->Protection = oldProtectionLevel; if (m_pMyContextMenuItem==NULL) { m_pMyContextMenuItem = new COutlookButton(spNewMenu); m_pMyContextMenuItem->m_OLAppPtr = m_OLAppPtr; } // show the menu spNewMenu->PutVisible(VARIANT_TRUE); } catch(...) { //MessageBox(NULL, "Error", "Error", MB_OK); } }
HRESULT CMyAddin::InstallInterface(IExchExtCallback *lpExchangeCallback) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); try { CString csTitle = APP_NAME; // This will be the display-name of the toolbar HBITMAP hBmp; // First we need to get the active Explorer, you could see this as the active window (it's more to it but let's keep it at that for now) Outlook::_ExplorerPtr spExplorer = m_OLAppPtr->ActiveExplorer(); if (spExplorer == NULL) { return S_FALSE; } // Then we need to have a pointer to the commandbars, that is the toolbars in the UI Office::_CommandBarsPtr spCmdBars = spExplorer->CommandBars; if (spCmdBars == NULL) { return S_FALSE; } try { CComVariant vName(csTitle); // This is the caption of the toolbar CComVariant vTemp(TRUE); CComPtr <Office::CommandBar> spToolbar; CComVariant vPos(1); //CComVariant vTemp(VARIANT_TRUE); CComVariant vEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR); /*spToolbar = spCmdBars->Add(vName, // Caption vtMissing, // <ignore this for now> vtMissing, // <ignore this for now> vTemp); // The toolbar should be temporary, // that way we have to add it every time we*/ //spToolbar = spCmdBars->Add(vName, // Caption // vPos, // <ignore this for now> // vEmpty, // <ignore this for now> // vTemp); // The toolbar should be temporary, // that way we have to add it every time we CComPtr <Office::CommandBarControl> pButton = NULL; CComPtr <Office::CommandBarControls> pBarControls = NULL; //pBarControls = spToolbar->GetControls(); /*m_pToolBar = (Office::CommandBarControlPtr)(pBarControls->Add((long)Office::msoBarFloating, //msoControlButton, vtMissing, vtMissing, vtMissing, vTemp));*/ // get the outlok Context Menu. for this enumerate all the command bars for "Context Menu" command bar CComPtr<Office::CommandBar> pTempBar; for(long i = 0; i < spCmdBars->Count ; i++) { CComVariant vItem(i+1); //zero based index pTempBar=NULL; spCmdBars->get_Item(vItem,&pTempBar); if((pTempBar) && (!wcscmp(CString(APP_NAME).AllocSysString(),pTempBar->Name))) { return S_FALSE; } } m_pToolBar = (Office::CommandBarPtr)(spCmdBars->Add(APP_NAME, vPos, /*Office::msoBarFloating,*/ vtMissing, vTemp)); pButton = (Office::CommandBarControlPtr)m_pToolBar->Controls->Add(Office::msoControlButton, vtMissing, vtMissing, vtMissing, vTemp); pButton->Caption = APP_NAME; pButton->OnAction = "MyButtonsAction"; BOOL bSetImage = TRUE; // I've set this to FALSE, but if you want an image to appear on the button, // you will need to have an image in the resources. // The only drawback of this is that there is only one way of // putting an image on the button, and that is by going through the // clipboard. And by doing so, the contents of the clipboard will be // lost, unless you implement some logic to store the clipboard-data // before doing this and then restoring the data once the image is on // the button. if (bSetImage) { UINT uiBitmapId = 0; CComQIPtr <Office::_CommandBarButton> spCmdButton(pButton); // to set a bitmap to a button, load a 32x32 bitmap // and copy it to clipboard. Call CommandBarButton's PasteFace() // to copy the bitmap to the button face. to use // Outlook's set of predefined bitmap, set button's FaceId to // the button whose bitmap you want to use hBmp =(HBITMAP)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP_PHONE), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT); if (hBmp) { // put bitmap into Clipboard ::OpenClipboard(NULL); ::EmptyClipboard(); ::SetClipboardData(CF_BITMAP, (HANDLE)hBmp); ::CloseClipboard(); ::DeleteObject(hBmp); // set style before setting bitmap spCmdButton->PutStyle(Office::msoButtonIconAndCaption); if (FAILED(spCmdButton->PasteFace())) { TRACE("Failed to paste face to button\n"); } }/* else { char serr[50]; DWORD err = GetLastError(); ltoa(err, serr, 10); MessageBox(NULL, serr, "error", MB_OK); }*/ } // With the button physically added to the toolbar, we just need to // create an object of COutlookButton to sink it's events. m_pMyButton = new COutlookButton(pButton); m_pMyButton->m_OLAppPtr = m_OLAppPtr; // The only thing left to do is to make the toolbar visible. //spToolbar->PutVisible(VARIANT_TRUE); LoadToolbarSettings(); } catch(...) { } // Add menu item _bstr_t bstrNewMenuText(CString(APP_NAME).AllocSysString()); CComPtr < Office::CommandBarControls> spCmdCtrls; CComPtr < Office::CommandBarControls> spCmdBarCtrls; CComPtr < Office::CommandBarPopup> spCmdPopup; CComPtr < Office::CommandBarControl> spCmdCtrl; CComPtr < Office::CommandBar> spCmdBar; // get CommandBar that is Outlook's main menu HRESULT hr = spCmdBars->get_ActiveMenuBar(&spCmdBar); if (FAILED(hr)) return S_FALSE; //hr; // get menu as CommandBarControls spCmdCtrls = spCmdBar->GetControls(); ATLASSERT(spCmdCtrls); // we want to add a menu entry to Outlook's 6th(Tools) menu //item CComVariant vItem(5); spCmdCtrl= spCmdCtrls->GetItem(vItem); ATLASSERT(spCmdCtrl); IDispatchPtr spDisp; spDisp = spCmdCtrl->GetControl(); // a CommandBarPopup interface is the actual menu item CComQIPtr < Office::CommandBarPopup> ppCmdPopup(spDisp); ATLASSERT(ppCmdPopup); spCmdBarCtrls = ppCmdPopup->GetControls(); ATLASSERT(spCmdBarCtrls); CComVariant vMenuType(1); // type of control - menu CComVariant vMenuPos(6); CComVariant vMenuEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR); CComVariant vMenuShow(VARIANT_TRUE); // menu should be visible CComVariant vMenuTemp(VARIANT_TRUE); // menu is temporary CComPtr < Office::CommandBarControl> spNewMenu; // now create the actual menu item and add it spNewMenu = spCmdBarCtrls->Add(vMenuType, vMenuEmpty, vMenuEmpty, vMenuEmpty, vMenuTemp); ATLASSERT(spNewMenu); spNewMenu->PutCaption(bstrNewMenuText); spNewMenu->PutEnabled(VARIANT_TRUE); spNewMenu->PutVisible(VARIANT_TRUE); spNewMenu->OnAction = "MyButtonsAction"; //we'd like our new menu item to look cool and display // an icon. Get menu item as a CommandBarButton CComQIPtr < Office::_CommandBarButton> spCmdMenuButton(spNewMenu); ATLASSERT(spCmdMenuButton); spCmdMenuButton->PutStyle(Office::msoButtonIconAndCaption); // we want to use the same toolbar bitmap for menuitem too. // we grab the CommandBarButton interface so we can add // a bitmap to it through PasteFace(). spCmdMenuButton->PasteFace(); // Empty whatever we put in the clipboard ::OpenClipboard(NULL); ::EmptyClipboard(); ::CloseClipboard(); // With the button physically added to the toolbar, we just need to // create an object of COutlookButton to sink it's events. m_pMyMenuItem = new COutlookButton(spNewMenu); m_pMyMenuItem->m_OLAppPtr = m_OLAppPtr; // show the menu spNewMenu->PutVisible(VARIANT_TRUE); } catch(...) { } return S_FALSE; }
BOOL GetFileInfo(CLOUD_MEIDA_METADATA_STRUCT* instruct,const CString filepath,bool* bIsAudio,bool* bIsPhoto,bool* bIsVideo) { CString fileDir ,fileName; fileDir.Append(filepath); PathRemoveFileSpec((LPWSTR)(LPCTSTR)fileDir);//Get dir Name fileName.Append(PathFindFileName(filepath));//Get file name IShellDispatch* pShellDisp = NULL; Folder *pFolder; FolderItem *pFolderItem; CComBSTR stitle,str; HRESULT hr = S_OK; CoInitialize(NULL); hr = ::CoCreateInstance( CLSID_Shell, NULL,CLSCTX_SERVER, IID_IShellDispatch, (LPVOID*)&pShellDisp ); if( hr == S_OK ) { hr = pShellDisp->NameSpace(CComVariant(fileDir),&pFolder); hr = pFolder->ParseName(CComBSTR(fileName),&pFolderItem); CComVariant vItem(pFolderItem); //CComVariant vEmpty; //int i = 0; // for (int i = 0 ;i < 100;i++) // { // hr = pFolder->GetDetailsOf(vEmpty,i,&stitle); // hr = pFolder->GetDetailsOf(vItem,i,&str); //COLE2T lpszTitle(stitle); //COLE2T lpszInfo(str); //TCHAR buf[300]; //afxDump <<i <<": "<< lpszTitle.m_psz<<" "<<lpszInfo.m_psz<<"\n"; // int a = 1; // } CString csPerceivedType; csPerceivedType = GetDetailsOf(pFolder,vItem,COLUMN_SORTING_TYPE_PerceivedType); *bIsAudio = PathMatchSpec(csPerceivedType,_T("audio")); *bIsPhoto = PathMatchSpec(csPerceivedType,_T("image")); *bIsVideo = PathMatchSpec(csPerceivedType,_T("video")); instruct->Duration = GetDurection(GetDetailsOf(pFolder,vItem,COLUMN_SORTING_TYPE_Duration)); if(!*bIsAudio && !*bIsPhoto && !*bIsVideo) return FALSE; if(*bIsAudio) { instruct->Album = GetDetailsOf(pFolder,vItem,COLUMN_SORTING_TYPE_Album); } else { instruct->Album = fileDir; instruct->Date = GetTime(GetDetailsOf(pFolder,vItem,COLUMN_SORTING_TYPE_CreatedDate)); } instruct->Size = GetDetailsOf(pFolder,vItem,COLUMN_SORTING_TYPE_Size); instruct->Title = GetDetailsOf(pFolder,vItem,COLUMN_SORTING_TYPE_Title); if(instruct->Title.IsEmpty()) { CString csFileNameWithOutExtension; csFileNameWithOutExtension.Append(fileName); PathRemoveExtension((LPWSTR)(LPCTSTR)csFileNameWithOutExtension); instruct->Title = csFileNameWithOutExtension; } instruct->Genre = GetDetailsOf(pFolder,vItem,COLUMN_SORTING_TYPE_Genre); hr = pShellDisp->Release(); pShellDisp = NULL; } CoUninitialize(); return TRUE; }
static int UppVectorSimplify(VarItem &varItem, int step) { // setup item type varItem.kind = VarItem::ARRAY; // if we're just doing first scan phase, signal that we need further evaluation later #ifdef EVALDEEP if(!step) // next step is 1 return 1; #else varItem.value = placeHolder; return 0; #endif // just getting items count... if(step == 1) { // initialize default value varItem.value = "<can't evaluate>"; // get items count MIValue val = varItem.EvaluateExpression(varItem.evaluableExpression + ".items"); if(val.IsError() || !val.IsString()) return 0; varItem.items = atoi(val.ToString()); // update value varItem.value = Format("Upp::Vector with %d elements", varItem.items, ""); // if no elements, just quit if(!varItem.items) return 0; return 2; } int count = min(EVALDEEP_VECTOR, varItem.items); // start from item 0 step -= 2; // fetch elements, check on first if they're SIMPLE, so displayable VarItem vItem(&varItem.Debugger(), varItem.evaluableExpression + Format(".vector[%d]", step)); if(!vItem) { varItem.value << " <can't evaluate contents>"; return 0; } if(vItem.kind != VarItem::SIMPLE) { varItem.value << " = [...]"; return 0; } vItem.Simplify(); if(!step) varItem.value << " = [ ]"; const char *sep = step ? " , " : ""; varItem.value = varItem.value.Left(varItem.value.GetCount() - 2) + sep + vItem.value + " ]"; if(++step >= count) return 0; else return step + 2; }
static int UppValueSimplify(VarItem &varItem, int step) { enum { SMALL = 0, MEDIUM = 31 }; // SMALL has to be 0 because of GetSpecial and because is it ending zero enum { KIND = 14, SLEN = 15, LLEN = 2, SPECIAL = 13 }; enum { STRING = 0, REF = 255, VOIDV = 3 }; // get the embedded 'data' string 'chr' member // it contains info about value type union { char chr[16]; char *ptr; dword *wptr; qword *qptr; word v[8]; dword w[4]; qword q[2]; int iData; int64 i64Data; double dData; bool bData; struct { byte day; byte month; int16 year; byte hour; byte minute; byte second; }; } u; // see Upp::String code for how it works.... MIValue val = varItem.EvaluateExpression("(" + varItem.evaluableExpression + ").data.chr"); if(!val.IsString()) return 0; String chrs = val.ToString(); memcpy(u.chr, ~chrs, 16); // get value type, among the fixed ones // we could try later to decode registered types.... dword type; bool isSpecial = !u.v[7] && u.v[6]; if(!isSpecial) type = STRING_V; else { byte st = u.chr[SPECIAL]; if(st == REF) { // ptr()->GetType() // by now, just mark as ref... type = REF; } else if(st == VOIDV) type = VOID_V; else type = st; } // by now, treat all types beyond VALUEMAP_V as unknown if(type > VALUEMAP_V) type = UNKNOWN_V; // now, based on type, we can decode it varItem.kind = VarItem::SIMPLE; switch(type) { case VOID_V: { varItem.value = "<VOID>"; return 0; } case INT_V: { varItem.value = FormatInt(u.iData); return 0; } case DOUBLE_V: { varItem.value = FormatDouble(u.dData); return 0; } case STRING_V: { // we simply replace the VarItem with the string VarItem vItem(&varItem.Debugger(), "(" + varItem.evaluableExpression + ").data"); vItem.evaluableExpression = varItem.evaluableExpression; vItem.shortExpression = varItem.shortExpression; varItem = vItem; return 0; } case DATE_V: { varItem.value = Format("Upp::Date = %02d/%02d/%04d", u.day, u.month, u.year); return 0; } case TIME_V: { varItem.value = Format("Upp::Time = %02d/%02d/%04d - %02d:%02d:%02d", u.day, u.month, u.year, u.hour, u.minute, u.second); return 0; } break; case ERROR_V: { varItem.value = "<ERROR_V>"; return 0; } case VALUE_V: { varItem.value = "<VALUE_V>"; return 0; } case WSTRING_V: { varItem.value = "<WSTRING_V>"; return 0; } case VALUEARRAY_V: { varItem.value = "<VALUEARRAY_V>"; return 0; } case INT64_V: { varItem.value = FormatInt64(u.i64Data); return 0; } case BOOL_V: { varItem.value = (u.bData ? "TRUE" : "FALSE"); return 0; } case VALUEMAP_V: { varItem.value = "<VALUEMAP_V>"; return 0; } case UNKNOWN_V: default: { varItem.value = "<UNKNOWN_V>"; return 0; } } }