0

I am using this code:

IntPtr hwndf = this.Handle;
IntPtr hwndParent = FindWindow("ProgMan.exe", null);
SetParent(hwndf, hwndParent);

However I get an error. The error says :

The call is ambiguous between the following methods or properties: 'HyperBox.Form1.FindWindow(string, string)' and 'HyperBox.Form1.FindWindow(string, string)'

How can I fix this? Thanks.

Richard Schneider
  • 34,944
  • 9
  • 57
  • 73
Layne Wapp
  • 43
  • 11

1 Answers1

-1

Cast null to string so that the program knows which of the overridden methods to use:

IntPtr hwndf = this.Handle;
IntPtr hwndParent = FindWindow("ProgMan.exe", (string)null);
SetParent(hwndf, hwndParent);
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
  • Both methods accept two string parameters. Casting null to a string will still be ambiguous. – Leon Newswanger Nov 10 '12 at 03:13
  • Ahh ok - if you have two methods with the same signature (i.e. same name & parameter types) that's the issue; the compiler has no way of differentiating so will reject it. A simple (hack) fix would be to change one of the parameters on one of the inputs to accept a character array or object instead of a string, then cast back to a string when you come to use it in the code. – JohnLBevan Nov 11 '12 at 16:09