atl和VB比起来的优势在哪里?
大侠,给我点信心吧。
VB Code:
If objInspector.CurrentItem.Class = olMail Then
My ATL code:
CComQIPtr<Outlook::_Inspector> spInspector(Ctrl);
//we only handle the first selected email
IDispatch *ppItem;
//get the mail item
spInspector->get_CurrentItem(&ppItem);
//the mailitem we want!
//-------------below line have some problem---------
//because I do not know what is ppItem's item, may be mailitem or
//note item or contact item, I have to get_Class() and know it type.
//Now the key problem is IDispatch* do not have get_Class Method and
// I do not find <Outlook::Item> type in the type library
//what should I do?
CComQIPtr<Outlook::_MailItem> spItem(ppItem);
//temporary variable is not useful
enum OlObjectClass type;
spItem->get_Class(&type);
ppItem->Release();
if(type!=olMail){
return;
}
//CComQIPtr<Outlook::MailItem> spMailItem(Ctrl);
}