How can I get an IVsDropdownBar out of an EnvDTE.Window? - visual-studio-2010

I get notified whenever a new window is opened by this method:
private void OnWindowActivated(EnvDTE.Window GotFocus, EnvDTE.Window LostFocus)
What I want to do now is to get the selected method in the object IVsDropdownBar, whenever this is changed.
So how can I get a reference to this object?

I haven´t tried that, so this answer is just an idea...
In accordance to MSDN you can obtain an IVsDropdownBar instance through the IVsDropdownBarManager service; the GetDropdownBar method returns the drop-down bar associated with the code window (might be the case that there isn´t a drop-down bar, since this addornment is language service specific and can be turned of via the options).
The documentation states that the IVsDropdownBarManager can be obtained from an IVsCodeWindow; I guess you can get such an instance from the active document window, somehow...
Once you have the IVsDropdownBar object, the GetClient and GetCurrentSelection methods might be of your interest; GetCurrentSelection allows you to query the selection for a certain drop-down; for instance...
IVsDropdownBar bar;
int hr = manager.GetDropdownBar(out bar);
if (hr == VSConstants.S_OK && bar != null)
{
IVsDropdownBarClient barClient;
hr = bar.GetClient(out barClient);
if (hr == VSConstants.S_OK && barClient != null)
{
// const int TypesDropdown = 0;
const int MembersDropdown = 1;
int curSelection;
hr = bar.GetCurrentSelection(MembersDropdown, out curSelection);
if (hr == VSConstants.S_OK && curSelection >= 0)
{
hr = barClient.GetEntryText(MembersDropdown, curSelection, out text);
if (hr == VSConstants.S_OK)
{
...
}
}
}
}
Not sure, if the obtained information is useful...
The documentation states, it can be
[...] plain or fancy text [...] and the drop-down code makes no assumption about their semantics.

Related

Is there any way to call send method on email opened in inline reply based on custom send button click

I have found a similar post by another user.
https://stackoverflow.com/questions/61183940/is-there-any-way-to-call-send-method-on-composed-mail-opened-in-inline-reply-bas
which is answered, But the page which has answer is no longer active
https://stackoverflow.com/questions/61142613/using-activeinlineresponse-in-vsto-add-in-send-mailitem-after-modifying-header/61144021#comment108226887_61144021
Tried noting as such
Edit : I did call the Item.Send in the Inspector Activate event.. and new inspector event where i call the activate method.
But the window does not disappear unless I click on the window icon in the task bar [to bring it to focus.].
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
Base objBase = new Base();
dynamic mailItem = objBase.GetItemObject(Inspector.CurrentItem);
var inspector = Inspector as Outlook.InspectorEvents_10_Event;
if (inspector != null)
{
inspector.Close += Inspectors_CloseInspector;
}
if (mailItem != null)
{
//if (mailItem.EntryID == null)
//{
if (mailItem is Outlook.MailItem)
{
if (IsInlineItem)
{
_MailItem = mailItem;
((Outlook.InspectorEvents_Event)Inspector).Activate += new Outlook.InspectorEvents_ActivateEventHandler(InspectorActivate);
((Outlook.InspectorEvents_Event)Inspector).Deactivate += new Outlook.InspectorEvents_DeactivateEventHandler(InspectorDeactivate);
((Outlook.InspectorEvents_Event)Inspector).Close += new Outlook.InspectorEvents_CloseEventHandler(Inspectors_CloseInspector);
Inspector.Activate();
}
else if (mailItem.Sent == false)
{ _MailItem = mailItem; }
else
{
Marshal.ReleaseComObject(mailItem);
}
}
else
{
_MailItem = mailItem;
Marshal.ReleaseComObject(mailItem);
}
//}
}
objBase.WriteError("new Inspector");
}
private void InspectorActivate()
{
Base objBase = new Base();
Outlook.Inspector ActiveInspector = Application.ActiveInspector();
if (ActiveInspector is null)
{
}
else
{
//Base objBase = new Base();
dynamic selectedItem = objBase.GetItemObject(ActiveInspector.CurrentItem);
if (selectedItem != null && _MailItem.Subject == selectedItem.Subject && selectedItem.Sent == false)
{
try
{
selectedItem.Send();
}
catch (Exception e)
{
}
finally
{
Marshal.ReleaseComObject(selectedItem);
Marshal.ReleaseComObject(ActiveInspector);
}
}
}
That question got deleted. I will repost the answer:
Yes, OOM blocks some methods for the inline response. The best you can do is simulate a click on the Send button using the accessibility API.
If using Redemption is an option (I am its author), it exposes SafeExplorer.ActiveInlineResponseSend method:
SafeExplorer sExplorer = new Redemption.SafeExplorer();
sExplorer.Item = Application.ActiveExplorer;
sExplorer.ActiveInlineResponseSend();
The Explorer.ActiveInlineResponse property returns an item object representing the active inline response item in the explorer reading pane. You ca use the same properties and methods of the MailItem object on this item, except for the following:
MailItem.Actions property
MailItem.Close method
MailItem.Copy method
MailItem.Delete method
MailItem.Forward method
MailItem.Move method
MailItem.Reply method
MailItem.ReplyAll method
MailItem.Send method
As you can see the Send method is not supported on the inline response items in Outlook.
As a possible workaround you may call the Display method which can open the item in a new inspector window where you could get the instance and call the Send method. The NewInspector event is fired whenever a new inspector window is opened, either as a result of user action or through program code. But I'd suggest getting the Inspector.Activate event fired to get the MailItem instance and call the Send method.

Unable to find TrackSelectionView .getDialog class in exoplayer2 on AndroidX

Unable to find TrackSelectionView .getDialog class on AndroidX.
But v7Support Libraries normal working.
error: cannot find symbol method getDialog(Activity,CharSequence,DefaultTrackSelector,int)
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo != null)
{
CharSequence title = string;
int rendererIndex = index;
int rendererType = mappedTrackInfo.getRendererType(rendererIndex);
boolean allowAdaptiveSelections =
rendererType == C.TRACK_TYPE_VIDEO || (rendererType == C.TRACK_TYPE_AUDIO &&
mappedTrackInfo.getTypeSupport(C.TRACK_TYPE_VIDEO) == MappingTrackSelector.MappedTrackInfo.RENDERER_SUPPORT_NO_TRACKS);
Pair<AlertDialog, TrackSelectionView> dialogPair = TrackSelectionView.getDialog((Activity) context, title, trackSelector, rendererIndex);
dialogPair.second.setShowDisableOption(non);
//dialogPair.second.setAllowAdaptiveSelections(allowAdaptiveSelections);
//Set the dialog to not focusable (makes navigation ignore us adding the window)
dialogPair.first.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
dialogPair.first.show();
dialogPair.first.getWindow().getDecorView().setSystemUiVisibility(((Activity) context).getWindow().getDecorView().getSystemUiVisibility());
//Clear the not focusable flag from the window
dialogPair.first.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}
Find exoplayer dialog track in the TrackSelectionView .getDialog

NPAPI plugin develop on mac10.8

I have some problems,i use xcode write a npapi plugin on mac10.8,I want to draw a picture on the plugin but when i get the pNPWindow->window pointer through NPP_SetWindow(NPP instance, NPWindow* pNPWindow); I find that nNPWindow->window is NULL ,i spend must to find the problem,but i can not,somebody can help me。 sorry,my english so poor。
code is like that,
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin *plugin = new CPlugin(instance);
if(plugin == NULL)
return NPERR_OUT_OF_MEMORY_ERROR;
instance->pdata = (void *)plugin;
NPBool supportsCG = false;
NPError err;
err = browser->getvalue(instance, NPNVsupportsCoreGraphicsBool,&supportsCG);
if (err == NPERR_NO_ERROR && supportsCG)
browser->setvalue(instance,NPPVpluginDrawingModel,(void*)NPDrawingModelCoreGraphics);
return NPERR_NO_ERROR;
}
NPError NPP_SetWindow(NPP instance, NPWindow* pNPWindow)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
if(pNPWindow == NULL)
return NPERR_GENERIC_ERROR;
if(pNPWindow->window)
writelog("window != NULL");
if(pNPWindow->window == NULL) //this is he problem pNPWindow->window always NULL
writelog("window == NULL");
return NPERR_NO_ERROR;
}
Anything you're going to use on Mac 10.8 won't support the carbon event model, so window will always be NULL. Assuming that you're trying to use the CoreGraphics drawing model you will get the CGContextRef when the event is fired to draw.
See https://wiki.mozilla.org/NPAPI:CocoaEventModel for more information on the Cocoa event model. The other option you have is the CoreAnimation model (with the InvalidatingCoreAnimation model on firefox and chrome)
You might want to take a look at FireBreath, which works on 10.8 and abstracts all of the complication of this stuff for you.
NPP_SetWindow (NPP npp, NPWindow* pNPWindow)
For many, this will be where the real fun starts — this function is called to tell the plugin which window they are in. From the Gecko SDK (npapi.h):
typedef struct _NPWindow
{
void* window; /* Platform specific window handle */
/* OS/2: x - Position of bottom left corner */
/* OS/2: y - relative to visible netscape window */
int32 x; /* Position of top left corner relative */
int32 y; /* to a netscape page. */
uint32 width; /* Maximum window size */
uint32 height;
NPRect clipRect; /* Clipping rectangle in port coordinates */
/* Used by MAC only. */
void * ws_info; /* Platform-dependent additonal data, linux specific */
NPWindowType type; /* Is this a window or a drawable? */
} NPWindow;
A pointer to this structure is passed in with each call. On windows, the “void* window” will dereference to an HWND. On other platforms, it will likewise be dereferenced as an appropriate type.
Notice that again NPP npp is the first parameter. This will be the case on all NPP functions except NPP_New, where the mimetype is also passed in. Since we created a PluginInstance object and assigned it to npp->pdata in NPP_New, we need to create a small stub function to forward our NPP_New to a method on that object, like so:
// Called by browser whenever the window is changed, including to set up or destroy
NPErrorNPP_SetWindow (NPP npp, NPWindow* pNPWindow)
{
if (npp == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
else if (npp->pdata == NULL)
return NPERR_GENERIC_ERROR;
PluginInstance *inst = (PluginInstance *)npp->pdata;
return inst->NpapiSetWindow(pNPWindow);
}
On windows, when SetWindow is called we need to save the HWND and subclass the window so that we can get our own window event proc.
NPError PluginInstance::NpapiSetWindow (NPWindow* pNPWindow)
{
NPError rv = NPERR_NO_ERROR;
if(pNPWindow == NULL)
return NPERR_GENERIC_ERROR;
// window just created; in initWindow, set initialized to true
if(!this->initialized) {
if(!this->initWindow(pNPWindow)) {
return NPERR_MODULE_LOAD_FAILED_ERROR;
}
}
// Window was already created; just pass on the updates
this->updateWindow(pNPWindow);
return rv;
}
With these functions, we get notified in one function when the window is first set, and another is called each time an update is made.

Wrong PIDL got from CIDA when dragging a Control Panel item

I'm working on a drag and drop problem now and trying to get the PIDLs of the items being dragged from windows shell to my application.
The code below can get correct PIDLs if the dragged item is 'My Computer' or 'Control Panel' itself, but it doesn't work when the dragged item is an item in the 'Control Panel'.
What's wrong with my code?
#define GetPIDLFolder(pida) (LPCITEMIDLIST)(((LPBYTE)pida)+(pida)->aoffset[0])
#define GetPIDLItem(pida, i) (LPCITEMIDLIST)(((LPBYTE)pida)+(pida)->aoffset[i+1])
STGMEDIUM medium;
UINT fmt = RegisterClipboardFormat(CFSTR_SHELLIDLIST);
FORMATETC fe= {fmt, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
HRESULT GETDATA_RESULT = pDataObject->GetData(&fe, &medium);
if (SUCCEEDED(GETDATA_RESULT))
{
LPIDA pida = (LPIDA)GlobalLock(medium.hGlobal);
LPCITEMIDLIST pidlFolder = GetPIDLFolder(pida);
int n = pida->cidl; // the n is always correct
if( n > 0 )
{
LPCITEMIDLIST pidlItem = GetPIDLItem(pida, 0);
// the pidlItem is wrong when the dragged object is an item in 'Control Panel'
}
GlobalUnlock(medium.hGlobal);
}
ReleaseStgMedium(&medium);
Any idea? Thanks
Zach#Shine
If I D&D Mouse, Network Connections and Fonts I get the following output in my test app:
0 Mouse | sfgao=4 hr=0
1 ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{7007ACC7-3202-11D1-AAD2-00805FC1270E} | sfgao=20000004 hr=0
2 C:\WINDOWS\Fonts | sfgao=60000004 hr=0
The Network Connections and Fonts pidls can be converted to fully qualified shell paths while Mouse only returns a relative path/displayname.
This makes sense if you check the documentation for IShellFolder::GetDisplayNameOf:
...They do not guarantee that
IShellFolder will return the requested
form of the name. If that form is not
available, a different one might be
returned. In particular, there is no
guarantee that the name returned by
the SHGDN_FORPARSING flag will be
successfully parsed by
IShellFolder::ParseDisplayName. There
are also some combinations of flags
that might cause the
GetDisplayNameOf/ParseDisplayName
round trip to not return the original
identifier list. This occurrence is
exceptional, but you should check to
be sure.
It is clear that when dealing with controlpanel items, you need to keep the pidl around and only use GetDisplayNameOf for display strings in your UI.
(IShellLink::SetIDList on the Mouse pidl will create a working shortcut so the pidl is valid)
void OnDrop(IDataObject*pDO)
{
STGMEDIUM medium;
UINT fmt = RegisterClipboardFormat(CFSTR_SHELLIDLIST);
FORMATETC fe= {fmt, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
HRESULT hr = pDO->GetData(&fe, &medium);
if (SUCCEEDED(hr))
{
LPIDA pida = (LPIDA)GlobalLock(medium.hGlobal);
if (pida)
{
LPCITEMIDLIST pidlFolder = GetPIDLFolder(pida);
for (UINT i=0; i<pida->cidl; ++i)
{
LPCITEMIDLIST pidlItem = GetPIDLItem(pida,i);
LPITEMIDLIST pidlAbsolute = ILCombine(pidlFolder,pidlItem);
if (pidlAbsolute)
{
IShellFolder*pParentSF;
hr= SHBindToParent(pidlAbsolute,IID_IShellFolder,(void**)&pParentSF,&pidlItem);
if (SUCCEEDED(hr))
{
STRRET str;
hr= pParentSF->GetDisplayNameOf(pidlItem, SHGDN_FORPARSING, &str);
if (SUCCEEDED(hr))
{
TCHAR szName[MAX_PATH];
hr= StrRetToBuf(&str,pidlItem,szName,MAX_PATH);
if (SUCCEEDED(hr))
{
SFGAOF sfgao = SFGAO_FOLDER|SFGAO_FILESYSTEM|SFGAO_HASSUBFOLDER|SFGAO_CANLINK;
hr= pParentSF->GetAttributesOf(1,&pidlItem,&sfgao);
TRACE(_T("%u %s | sfgao=%X hr=%X\n"),i,szName,sfgao,hr);
CreateTestShortcut(pidlAbsolute);
}
}
pParentSF->Release();
}
ILFree(pidlAbsolute);
}
}
GlobalUnlock(medium.hGlobal);
}
ReleaseStgMedium(&medium);
}
}

Hiding the keyboard when a control loses focus?

now I have this:
public void focusChanged(Field field, int eventType) {
if ( field == txtAmount && eventType == 1)
{
getVirtualKeyboard().setVisibility(VirtualKeyboard.HIDE);
}
}
Now my problem is that the keyboard isn't hiding. I think the error is in the eventType parameter. What number identifies a LostFocus event? I hard coded in '1' for tests but it doesnt seem to work.
FocusChangeListener focusListener;
//In the constructor:
txtAmount = new EditField(Field.FIELD_RIGHT);
txtAmount.setFocusListener(focusListener);
public void focusChanged(Field field, int eventType) {
if ( field == txtAmount && eventType == 1)
{
Dialog.alert("iasdi");
getVirtualKeyboard().setVisibility(VirtualKeyboard.HIDE);
}
}
why isn't this working? is there an enum or something that i can use to choose what eventType I should react to?
Also, if I remove the event type (so that the code executed regardless of the action just when focus changes right? nothing happens the dialog I put in for show, doesn't display meaniing the event is never entered. Any suggestions?
thanks
eventType can be one of next constants, declared in FocusChangeListener class:
public static final int FOCUS_GAINED = 1;
public static final int FOCUS_CHANGED = 2;
public static final int FOCUS_LOST = 3;
!!! Use FOCUS_LOST = 3 instead of FOCUS_GAINED = 1 to handle focus lost event.
Also, check for null getVirtualKeyboard() method returning value, because it returns null on touch devices without virtual keyboard (like Bold 9700).
public static void hideVirtualKeyboard() {
if (net.rim.device.api.ui.VirtualKeyboard.isSupported()) {
Screen screen = UiApplication.getUiApplication().getActiveScreen();
if (null != screen) {
net.rim.device.api.ui.VirtualKeyboard vk = screen
.getVirtualKeyboard();
if (vk != null) {
vk.setVisibility(net.rim.device.api.ui.VirtualKeyboard.HIDE);
}
}
}
}
For matching the eventType, try using the constants defined in FocusChangeListener instead of hard coding "1". In this case, you probably want to use FocusChangeListener.FOCUS_LOST.
As for the case of the code not running, are you actually setting the value of the "focusListener" variable? From the code you posted, you aren't and it will just be passing as "null" into setFocusListener().

Resources