I'm trying to drag one or more files from my application to an outlook mail-message.
If I drag to my desktop the files are copied to the desktop as expected, but when dragging into a new outlook 2013 mail message, nothing happens... Only when I drag explicitly to the 'attachments textbox' do they appear, this is not helpful because the attachment-textbox isn't shown by default.
I don't understand why when I drag file(s) from my desktop to the mail I can just drop them and the attachment-text automatically appears showing the files but when I drag from my app it's not working..., here's my code :
'
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
var _files = new string[] { #"E:\Temp\OR_rtftemplates.xml", #"E:\Temp\Tail.Web_Trace.cmd" };
var fileDragData = new DataObject(DataFormats.FileDrop, _files);
(sender as Form).DoDragDrop(fileDragData, DragDropEffects.All);
Console.WriteLine("{0} - button1_MouseDown", DateTime.Now.TimeOfDay);
}
'
I've also added the files to the DataObject by using the 'SetFileDropList' method but that makes no difference.
The must be some magic property I have to set to get this working right with an outlook-message.
I hope someone can shed some light on this.
thanks,
Jurjen.
I just tested some other stuff on a machine running .NET 4.0 (app was compiled in .NET 4.5), after changing .NET target to 4.0 and recompiling it does work, dragging files into a new outlook message, very strange, might be a problem when migrating to .NET 4.5 later... but for now it works...
Related
We have a C# WinForms application and one control is using the DragDrop to collect files that is dropped onto it.
Recently, for infrastructural reasons, it was decided to move the application into Citrix and run it as a Citrix Application.
As far as we can see, everything works as expected part from the drop functionality.
The DragDrop has worked without any problem when running the desktop application outside Citrix. It also works if it is started from a Citrix Desktop. But when hosting it as a Citrix Application, No event is fired; not the DragDrop and not the DragEnter. The mouse marker just have the "denied" glyph, as if the AllowDrop would be false.
We have seen that some applications works as a Citrix Application (e.g. a standard Windows Explorer or Outlook), some behaved strange (as Adobe) and some did not work at all (as foxit reader).
Edit: This is a distillation of the code used when testing the problem.
public Form1()
{
InitializeComponent();
AllowDrop = true;
DragEnter += Form1_DragEnter;
DragDrop += Form1_DragDrop;
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
var formats = e?.Data?.GetFormats() ?? new[] { "<Null>" };
var text = $"Formats: {string.Join(", ", formats)}";
MessageBox.Show(text);
}
Edit2: The Citrix guys in our company have now tweaked the Citrix environment so we actually get the events but unfortunately not the FileDrop format that I used to work with. We are now only getting the FileContents format (with a null result when getting from that format) and FileGroupDescriptorW (with only the file name present, and not the path).
We are still working with Citrix on the matter, and I will post a result in the end.
I added a listview in my winform application using .NET 4.8 Framework.
I added a ColumnWidthChanging event to disable the user from adjusting column widths and it works as expected in Windows 10.
But when I tried to run my application in Windows Server 2016, the event does not trigger. I added logging to determine if the event was called and no logs were written.
MainForm.cs
private void listView_Counters_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
e.NewWidth = this.listView_Counters.Columns[e.ColumnIndex].Width;
logger.Info("Column Width: " + e.NewWidth.ToString());
e.Cancel = true;
}
MainForm.Designer.cs
//
// listView_Counters
//
this.listView_Counters.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
resources.ApplyResources(this.listView_Counters, "listView_Counters");
this.listView_Counters.HideSelection = false;
this.listView_Counters.Name = "listView_Counters";
this.listView_Counters.UseCompatibleStateImageBehavior = false;
this.listView_Counters.View = System.Windows.Forms.View.Details;
this.listView_Counters.ColumnWidthChanging += new System.Windows.Forms.ColumnWidthChangingEventHandler(this.listView_Counters_ColumnWidthChanging);
Is this a limitation in Windows Server OS? Or is there another way to do ColumnWidthChanging event?
I appreciate all the help and ideas. Thank you.
Server windows usually have many access restrictions that other regular windows do not have.
You can usually solve the problem of writing and accessing users and software by setting access levels in the folder of the running project and setting access to the files to be written to.
I've got a Drop Down Menu that is dynamically filled every time it opens, here is the logic that does it:
private void joysticksToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
_joysticks = _joystickWrapper.FindDevices(DeviceType.Joystick);
joysticksToolStripMenuItem.DropDownItems.Clear();
foreach (var di in _joysticks)
{
var item = new ToolStripMenuItem(di.ProductName);
item.Checked = di.InstanceGuid == _joystickWrapper.CurrentDeviceInfo.InstanceGuid;
joysticksToolStripMenuItem.DropDownItems.Add(item);
}
}
When I run the application this is what I see:
The check is in the wrong location and the blue area is too wide.
Any ideas on where to look to fix this? The entire menu is all System.Windows.Forms, no custom visual code in the entire application.
I tried on my current machine (Windows 10 Build 9926) and on my dev server (Server 2012R2) with the same results. I've also compiled this to the NET Framework 4.5 and 4.5.1
EDIT
For those interested, here is the git repo for this project:
https://github.com/adam8797/RovControl
I came across this exact same issue and was finally able to resolve it by setting the ImageScalingSize property of the MenuStrip to 16,16 (it had somehow been set to 32,32, possibly due to my editing of the form on a high DPI machine)
I see you adding items in Menu while its opening. Seems like the selected area and its width is already defined and its not reacting to the new data you inserted. What about trying to manually define width of Menu Item and see if that helps.
Hi I am having a very strange problem. I have a form with multiple tooltips that appear when the mouse is over a specific control. So far I was developing the form on a Windows 7 machine and everything were going fine. Tonight I tested my executable on my other Windows 7 machine (same version and service pack) but none of the tooltips are working.
Does anybody have an idea what might be the problem? Bellow I am giving the code for one such Tooltip
ToolTip UrlNameInputBallonTip = new ToolTip();
private void CheckForUrl()
{
UrlNameInputBallonTip.IsBalloon = true;
if (IsValidHttpUri(UrlNameInput.Text) == false && IsValidHttpsUri(UrlNameInput.Text) == false)
{
UrlNameInputBallonTip.SetToolTip(UrlNameInput, "This is not a valid url!\r\nex. \"http://domain\"");
UrlNameInputBallonTip.Show("This is not a valid url!\r\nex. \"http://domain\"", UrlNameInput, UrlNameInput.Width / 2, UrlNameInput.Height, 5000);
}
else
{
UrlNameInputBallonTip.Hide(this);
}
}
Hi I was able to find the cause of the problem and I am reporting this for future reference. On the suspected machine the option to display balloon tips (arrow pointing to the control) was disabled. I am not sure why, perhaps some other app disable it at some point, but after enabling it through registry ti works fine now. Thanks for the help!
I am creating a small Visual Studio 2010 extension in C# which uses the IWpfTextViewCreationListener and TextViewCreated to capture when a new TextView is opened in the VS environment. The problem I am having is that this method only fires when a new window is opened via the VS Solution Explorer window, and not fired when VS already contains opened windows when started, and switching window tabs. I have tried looking for something like TextViewChanged, but could not find such method. Is there anyway to capture the new TextView when another tabbed window is selected?
Any help would be greatly appreciated.
This question has also been posted on the MSDN VS Extensibility forum:
VSX 2010 - Alternative to TextViewCreated such as (TextViewChanged)?
Thanks
John
There is no TextViewCreated, but if you register to IWpfTextView.GotAggregateFocus as it is created, you get a hook to every switch between files:
public void TextViewCreated(IWpfTextView textView)
{
textView.GotAggregateFocus += TextViewCameToFocus;
// Do stuff when a new IWpfTextView is created...
}
void TextViewCameToFocus(object sender, EventArgs e)
{
var focusedTextView = (IWpfTextView)sender;
// Do stuff when a specific IWpfTextView comes to focus...
}
You may also want to keep track of the IWpfTextView objects, if you want to be able to link between the fired events to your logic of each textview.