|
It's the IID (interface GUID) that's the problem, but the COM object GUID (that's what a CLSID is - a GUID for a class). You must have defined an interop class for the shell object that implements IDragSourceHelper .
See, you don't actually create an interface; an interface is abstract and can't be instantiated. What happens behind the scenes (in the CLR) is that the COM object is created and AddRef'd. The CLR QI's (QueryInterface) for the interface when you perform a cast and returns the interface you want (to which you're casting).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Perhaps I wasn't clear enough in my question...
I already have all the interop classes created. (That's was my point in saying I have everything working for the IDropTargetHelper interface). I wasn't suggesting I was trying to create an interface - I was sparing a paragraph spelling out what my already working code does. My question was why I can get the IDropTargetHelper working but not the IDragSourceHelper using the same overall logic.
Now - according to shlguid.h the IID for the drop helper (IID_IDropTargetHelper) is 4657278B-411B-11d2-839A-00C04FD918D0. That works - no problem there at all.
It would stand to reason, then, that the guid for IID_IDragSourceHelper would work for using the IDragSourceHelper interface. IID_IDragSourceHelper is DE5BF786-477A-11d2-839D-00C04FD918D0. That's the part that doesn't work - when I create the object derived from the IDragSourceHelper interface I get the message specified in my first post.
Oddly, the value 4657278B-411B-11d2-839A-00C04FD918D0 is in my registry in several places, while DE5BF786-477A-11d2-839D-00C04FD918D0 is not in my registry.
|
|
|
|
|
Look man, I don't know you. I don't know most of the people that show up in this forum looking for help. The only person I truly know here is Nick and I'm familiar with a few others that frequent this forum like Dave and Christian.
When people come to this forum, I assume nothing. I don't know if you know what you're doing. Since you're peering into header files and based on other information, it appears you do know what you're doing; but how could've I known that? As I said, I don't know you. So please don't get testy.
Sorry, it's just that I've been getting a lot of this crap lately because forums present faceless people sitting on a keyboard potentially on the other side of the world.
As for your questions and comments...
IIDs don't have to be registered, so the fact that IID_IDragSourceHelper isn't found in your registry isn't not surprising. Of course the CLSID must be registered, which I'm sure you know.
The documentation for both the IDropTargetHelper and IDragSourceHelper interfaces state that the COM object with CLSID_DragDropHelper implements both. When I import shell32.dll, however, this coclass isn't imported, so I'm curious where you got it (or did you declare the class yourself, which is entirely possible).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I three together the follow. The ComImportAttribute changes the metadata such that an instance is marked as imported and created from the attributed GUID. By casting, I am effectively QI'ing for the two interfaces.
In both cases, "False" is printed to the console, showing that the object does implement both interfaces. Sorry I don't have time to throw together a better sample (and keep in mind that when using interfaces not every method has to be defined (so long as they're in the correct VTBL order):
using System;
using System.Runtime.InteropServices;
[
GuidAttribute("4657278A-411B-11d2-839A-00C04FD918D0"),
ClassInterface(ClassInterfaceType.None),
ComImport
]
public class DragDropHelper : IDropTargetHelper, IDragSourceHelper
{
}
[
GuidAttribute("4657278B-411B-11d2-839A-00C04FD918D0"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
ComImport
]
public interface IDropTargetHelper
{
}
[
GuidAttribute("DE5BF786-477A-11d2-839D-00C04FD918D0"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
ComImport
]
public interface IDragSourceHelper
{
}
class Test
{
static void Main()
{
DragDropHelper helper = new DragDropHelper();
IDropTargetHelper dropHelper = (IDropTargetHelper)helper;
IDragSourceHelper dragHelper = (IDragSourceHelper)helper;
Console.WriteLine(dropHelper == null);
Console.WriteLine(dragHelper == null);
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, guys, I have a form(window1) and I want click a button and then display another form(window2). If I use window2.ShowDialog(), window2 is displayed correctly. But I would like to use window2.Show(), the label control on the form can n't display correctly. Why/
Who can help me?
Thank you very much.
vigorous
|
|
|
|
|
If you include code, we can better help you. Does you you button handler look like this?
private void button_Click(object sender, EventArgs e)
{
OtherWindow other = new OtherWindow();
other.Show();
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Yes ,you are right. The code is very similar.
Do you know the reason of display incorrectly?
Thank you
vigorous
|
|
|
|
|
What exactly do you mean it "display[s] incorrectly?" Please be specific or we can't help you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am importing data from file into arraylists. Then I use the arraylists to fill a DataTable that I use as a DataSource for a DataGrid. But when I refill the Grid with new data from files, selection by pressing rowheader gets slower and slower. I get a delay before the entire row is highlighted. If I select a cell first, then the rowheader for the row containing that cell, the delay is not there. It only happens after refilling the table/grid a couple of times. It alså happens if I add columns to the table at run time (after adding about 5 columns it gets a noticable delay). What is up with that?
-Atle
|
|
|
|
|
I want to check a string entered in a TextBox & check wether it has valid C# stements.. or a part of C# statements (maybe MessageBox es )
How can I do that?
_____________________________________________________
Yea! I could be wrong...
|
|
|
|
|
yes.....it is:
if(string == "something"){ }
|
|
|
|
|
SJ_Phoenix wrote:
if(string == "something"){ }
This is not the best method for checking a string. Instead, do something below:
string s = "Nick";
if(string.Compare(s, "Nick") == 0)
{
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
To add, you can use String.Compare to perform case-insensitive searched by adding a bool as the third parameter. By default, this performs a comparison using the invariant culture, but you can specify a specific culture to perform a comparison using the text rules for that culture as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I think you're all missing the point.
He wants to evaluate a string to see if its contents are a valid C# code snippet, not a specific piece of text.
Not that I know the answer, mind you, but I thought I'd at least try to get the guy some help.
If it were me, I'd be looking at on-the-fly code compilation and let the compiler to the parsing.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
|
YES YES YES! Thank you.
I exactly want to do what Mr. Grim says. I am using a textbox where users have to enter a string, I need to validate if it is a valid C# statement. And is it possible to display the . (dot) operator menu..
Help PLZ
_____________________________________________________
Yea! I could be wrong...
|
|
|
|
|
You will have to place the text into the context, and then compile it (via CodeDomSnippet or something). where are you planning on using the code?
top secret xacc-ide 0.0.1
|
|
|
|
|
Ok but how do you compile the code with .. CodeDomSnippet..?? & I'm trying to use the validation for a textbox. Users have to enter statements & they should be validated to true if they are valid C# statements.
HELP
PLZ
_____________________________________________________
Yea! I could be wrong...
|
|
|
|
|
What you wanna do is way more complex than you can handle right now, I suggest you learn a bit more beforetrying to attempt something like this. A good understanding of parser and lexer technologies is essential.
top secret xacc-ide 0.0.1
|
|
|
|
|
Thanx for clearing that up..
Recources please!
_____________________________________________________
Yea! I could be wrong...
|
|
|
|
|
Hi folks
I've got a new Problem using the UIPAB v2.0
I tried to implement a Wizard, but i didn't found any method for navigation nonlinear. The navigation graph wich is presented by the examples are only linear, but i have the problem that the following form depends on data wich is given in the wizard-page. So there are maybey two or more pages wich can follow another page.
Are there any possibilties to controll the navigation dependending on the data?
****************************
phoenixcp
Free Win2k and support Linux
****************************
|
|
|
|
|
If you have a problem with a specific product, you need to consult support for that product (or if it's from an article here on CodeProject, ask in the article's message board at the bottom of the article).
If you have a problem specific to C# (like how to marshal data, if necessary, using UIPAB), this is the place to ask.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear all:
My Org. use a Encryption for its passwords & I have to obey it too in my App to be the same as all other App. in Org.
In this Encryption we use entered values's Ascii & ...
I can get the ASCII value of Chars as:
(int)'A' = 65 & vise versa (char)65 = 'A'
but since I use Farsi(Arabic) Chars it gives me Unicode of that char like:
(int)'ش' = 1588
Is there any way to use its ASCII & not unicode?!
Of course, I can use change Farsi entered Chars to English to get its ASCII but some of Encrypted Chars are not English letters & I have to use them!
I realy need ur help bc all App. is waiting for that Login part
Thanks in Advance & Hope to hear from u ASAP!
Always ,
Hovik Melkomian.
|
|
|
|
|
First you need to understand that all characters (and hence, all strings) are treated as Unicode in .NET (strings are even stored as Unicode in the assembly).
You can, however, use the Encoding class with the proper codepage.
See, ASCII is actually 7bit characters. Anything over 127 requires a codepage in order to resolve the symbols correctly.
To get the codepage for Farsi, you can either refer to it by the codepage, or if you don't know it do something like this:
CultureInfo ci = new CultureInfo("ar");
int codepage = ci.TextInfo.ANSICodePage; If you read the class documentation for the CultureInfo class in the .NET Framework SDK, you can find the LCIDs and culture name abbreviations (like "en-US" for "English (United States)"). For a non-regional Arabic language, you can use the LCID 0x01 (1).
So, to get an Encoding for that codepage, do this:
Encoding enc = Encoding.GetEncoding(0x04e8);
byte[] buffer = enc.GetBytes(yourFarsiString);
foreach (byte b in buffer)
Console.Write(b.ToString("x2"));
Console.WriteLine();
Here's an example of decoding a Unicode string I assume says "Hello" (in Farsi) into ANSI characters using the Farsi codepage:
using System;
using System.Globalization;
using System.Text;
class Test
{
static void Main()
{
CultureInfo ci = new CultureInfo("ar");
int codepage = ci.TextInfo.ANSICodePage;
Console.WriteLine("Using codepage 0x{0:x4}", codepage);
string str = "\ufeed\ufee0\ufe8e\ufeeb";
Console.WriteLine("Decoding " + str);
Encoding enc = Encoding.GetEncoding(codepage);
byte[] buffer = enc.GetBytes(str);
foreach (byte b in buffer)
Console.Write("0x{0:x2} ", b);
Console.WriteLine();
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear Heath Stewart:
Thanks for ur fast response & sorry for my delay! Actually I was working to fix my problem & I did as:
byte[] ubuf = Encoding.Unicode.GetBytes(c.ToString());<br />
Encoding enc = Encoding.GetEncoding(1256);<br />
byte[] abuff = Encoding.Convert(Encoding.Unicode, enc, ubuf); (But Tnx for ur code)
But now I need the opposite of that!
I mean I have ASCII now & this time I wanna have its character.
As u know values r not same since I have to make it as same as other softwares in my Office.
Example:
(char)211 = 'Ó' witch is wrong & should be 'س' Unicode 1587
Please help me about this, witch is highly appreciated!
Again tnx for code & Hello Sample;) & Sope to hear from u ASAP.
Always ,
Hovik Melkomian.
|
|
|
|