|
So overwrite the DoDragDrop method, replace the structures with managed COM structures etc, and just let .NET interact with it in the way it was designed.
The only problem I can see is, will .NET recognise the new method and handle the mouse pointer shape automaticaly? Or is that windows that manges that and determines whether it is a dropable location?
I'm going to assume it's windows and get on with it at some point when I feel better.
God I hate Colds. They ruin thought processes
Cat
|
|
|
|
|
No, don't override DoDragDrop . For one, it's not virtual (meaning you have to declare it with the new ) keyword. Second, the data parameter expects an IDataObject (or temporary, unformatted Object ) from .NET - not COM (type Types, while named the same, are still different Types).
You need to P/Invoke the native DoDragDrop functions. I only meant that you could initiate drag-n-drop using the same event handlers but using the P/Invoked code. Your drop targets can use the managed drag-n-drop events because the data object will by seen by .NET the same way. If you want to support the same formats as the DataFormats class fields, just use the same format IDs as they have (which you can find by using the same strings (check the fields' values) or the IDs, which you can get from the Win32 headers).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Gotcha.
I shall crack on with it.
I'll let you know how I go, and when I got it working, I suppose the lease I could do is stick the code up on CP.
Thanks again for helping me get my head around that one.
I just had the biggest "AAAAAHHHHH!!!" moment when the penny dropped.
Cata
|
|
|
|
|
I have a Rich Text Box Control. In which i want that only text along with its formatting(bold, color etc) be pasted. But it should discard IF clipboard item contains Image.
I tried using
if(!(Clipboard.GetDataObject().GetDataPresent(DataFormats.Bitmap)))
{
Clipboard.GetDataObject().GetFormats();
this.Paste();
}
but does not allow Image to be pasted but if data to be pasted contains Image and Text both it fails to restrict.
I also tried with DataFormats.Text but then only text is pasted and formatting is lost. Can anybody help me.
|
|
|
|
|
There are different types of image data formats you should check, not just DataFormats.Bitmap . That only specifies a Windows Bitmap and while some programs may put both, for example, JPG and its uncompressed BMP format in the data object, some might not. So make sure you check that there are no images. This would be an exclusive approach.
You could also use an inclusive approach. If you only want formatted or plain text inserted, that check for the existence of those and only those by using DataObject.GetFormats and making sure that all the string array elements are what you want (which reminds me, your call Clipboard.GetDataObject.GetFormats() is useless since you aren't using it's return value - is just a waste of instructions). This would be an inclusive approach and can better limit what you accept in your RichTextBox . Just check for DataFormats.Rtf , DataFormats.Text , DataFormats.UnicodeText , and/or DataFormats.OemText .
The latter method is probably better because the clipboard formats (which are also used in drag-n-drop routines) are not limited to what's in the DataFormats class. Those are just some common ones that are pre-registered by Windows and understandable in .NET. Applications can easily make up their own formats and there are other common formats that the RichTextBox might understand.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
I have an FTP server by some users. Each user has a folder and can add or delete a file in his specified folder.
Now I want that I'm notifed by email when a user makes any change in his folder.
Can I use C# to do this situation?
Does FTP server provide me this situation or I have to develop a program?
regards,
Mehdi
|
|
|
|
|
Doing this via FTP would be difficult - if even possible. About the only way is to poll the folders and check for recent changes. A better way would be to write a program that uses the FileSystemWatcher component to watch the directories on the server (i.e., not via FTP but on the file system itself) and alerts you of changes.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi.
I've got a button with no text (only and icon) and I need a shortcut key (accelerator key) to the button.
Normally i would do something like "Cl&ose" to use the "o" as a shortcut, but my button has no text, so how do i accimplish this?
|
|
|
|
|
Set KeyPreview to true on your Form that contains the button and handle the KeyDown or KeyUp event, which will give you the active modifier keys (Alt, Ctrl, and/or Shift) and the key that was pressed in a KeyEventArgs passed to the event handler.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I extended my menuitem with an additional property. it works well with the property editor.
now I need write some code to detect and change the extended properties. I tried using the folowing code but it is not "detecting" the extended properties.
<br />
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(menuItem1);<br />
foreach (PropertyDescriptor myProperty in properties)<br />
textBox1.Text += myProperty.Description.ToString() + '\n';<br />
how can I detect and edit extended properties?
thank you...
Peter Kaiser
|
|
|
|
|
"detect and edit" is rather ambiguous and perhaps you could clarify.
If you are talking about getting and setting values, see the PropertyDescriptor.GetValue and PropertyDescriptor.SetValue , which both use the PropertyDescriptor for your Type, and you pass your actual object (menuItem1 ) so that you get the value for that property on that object. See the SDK documentation for those two methods for more information and examples.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank you, I will try to explain:
I used
[ProvideProperty("ImageIndex", typeof(MenuItem))]
to "add" the Property "ImageIndex" to MenuItem.
Now I want to move through all MenuItems by code and set the values of "ImageIndex".
(More abstract I would prefer to move through all components, check if they have the extended property "ImageIndex" and set the value)
Peter Kaiser
|
|
|
|
|
You should really read about providers. You're doing it completely wrong. You can just add a property like that - you can extend the MenuItem and add properties and methods, or you can create a type designer or editor that can simulate a property at design-time and that writes out code to make use of that "virtual" property. Essentially, this is what IExtenderProviders are, and you must implement that interface and provide the Type as the second parameter to the ProvidePropertyAttribute . Be sure to read about those two things in the .NET SDK documentation.
This amounts to another component that actually stores the values on behalf of the attributes class (or rather, and instance of that class). So, the MenuItem doesn't actually have that property, but another components would. If you name the property ImageIndex , then your extender provider would have a SetImageIndex and GetImageIndex method, as well as some optional specially-named methods to help with serialization.
There is a great couple articles about extender providers, including an example of what you're trying to do (adding an image easily to a menu) here at CP:It's always a good idea to try searching first before posting a question. Chances are that is has been asked / solved before and you'll get answers quicker than waiting for a reply.
Be sure to read the documentation for IExtenderProvider and ProvidePropertyAttribute as well.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thank you...
I know, that MenuItem doesn't actually have that property!
I know whta you wrote me about the extender provider and his set and get-methods!
I also know about the metioned articles, because I used Menu Images!
I just wanted to know, if there is a chance to find out if there is a extender provider for a component, and how to get and set the values of its properties at runtime..
Peter Kaiser
|
|
|
|
|
If you know what you are doing, then why did you have MenuItem as the Type of the provider?! This won't work.
If you need to figure out if your extender provider has a value for the control, then you need to add a property to your extender provider that contains a list of the controls for which it handles. Also, extender providers usually work in such a way that any instance of that type has a provided property, and if it doesn't you should make sure of it. James's article presents a good way to do this (the Ensure* methods) so that you never get null when you don't expect it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi all
i am working on small project , i need help.......
how can i implement start button (like in windows)for my application ?
thanks alote
|
|
|
|
|
What do you mean? A button which pops up a menu when you click it? Or a button which looks just like the start button?
If the first: Use the ContextMenu control.
If the latter: Under Windows XP you can use UXTheme.dll (and some C# wrapper) to skin your button.
[EDIT]Oops. Didn't read you message's subject line. But please clarify anyway.[/EDIT]
- Daniël Pelsmaeker
|
|
|
|
|
hey,
i know it's kind a silly to ask but does anyone know of a way to conver a C# program into an dos-executable? I do not need the win-32 graphics, just the core routines. Can anyone give he a clou how to do this (without rewriting the whole bunch)
Thanx a lot
Jeroen
|
|
|
|
|
When you create your project, select "Console Application"
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
It is impossible to create a -real- DOS application using .NET, but, as said, you can let an application run in a console (some kind of DOS-box). This is just fake Windows without UI.
- Daniël Pelsmaeker
|
|
|
|
|
In the end it has to run on a genuine DOS pc, an old 286 laptop, but since working on that laptop is hard to do (tiny B/W screen) so therefor I'm trying to write C# on my pc an then move the .exe to teh laptop. But I'm unfamiliar to consoles, what should I thick of? something like cmd under win xp? And further on does dos accepst dll's?
regards
Jeroen
|
|
|
|
|
The .NET Framework is only supported for Windows 98 and onwards. And very soon Microsoft will be dropping support for Windows 98 anyway.
Consider writing your DOS application in a system that was designed for that platform such as C/C++
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
Hey
Is is possible to make a custom formborderstyle in .NET.
I want to put an image or "skin" at the head of a winform.
|
|
|
|
|
You can set FormBorderStyle = FormBorderStyle.None on the form. No border (or titlebar) will then be shown. Now you can override OnPaint and draw it yourself.
- Daniël Pelsmaeker
|
|
|
|
|
Does anyone know a free toolbox for download which is like "Ultimate Toolbox 9.0"?
|
|
|
|