Oh no Clive.. that sounds a hack.. may not work. So yours is a test bed app
that says oops you missed a icon for the Form?.. ahh...
Did u google and see if you get anything?
- keep the handle as last resort! (sometimes hack is a good practice,
although I hate it)
VJ
Actually I'm looking to check whether a form which *shouldn't* have an icon
displayed (it has FormBorderStyle = FixedDialog and the icon is not set,
which means no icon is displayed, not even the default one) has *not*
accidentally acquired one. We have localised forms, which means that the
visual designer will always modify the InitializeComponent to set the Icon
to something from the .resx. Hence every time somebody modifies one of these
localised forms, the visual designer adds back in code (thanks, Microsoft!)
to explicitly set the icon to a copy of the default icon, and thus it now
appears in the dialog. I want to write some NUnit tests to check when this
has happened and someone has forgotten to correct it, 'cos I'm getting fed
up.
I Googled and couldn't find anything useful. I tried my nasty hack comparing
the handle against a dummy form, and it appears to work, i.e. the handles
are the same if I do not set the icon, but if I do, they are different. Yes,
it is *very* yucky...
> Oh no Clive.. that sounds a hack.. may not work. So yours is a test bed
> app that says oops you missed a icon for the Form?.. ahh...
[quoted text clipped - 21 lines]
>>>> a form or not? I have been trying using PInvoke with Win32 APIs with no
>>>> success.
Matt Brunell - 15 Mar 2007 20:00 GMT
You could try name-hiding the "Icon" property.
like this:
class YourForm : Form
{
new public Icon Icon
{
get { return null; }
set { }
}
}
Name hiding is NOT polymorphic.
If you have a Form reference, your code will not be executed.
The InitializeCompoenent function calls
this.Icon = (get something form resources);
However, if you do this, the default icon still appears on the form.
I think you may just be better off using the Form.ShowIcon property.
--Matt
> Actually I'm looking to check whether a form which *shouldn't* have an icon
> displayed (it has FormBorderStyle = FixedDialog and the icon is not set,
[quoted text clipped - 40 lines]
>
> - Show quoted text -
Clive Dixon - 16 Mar 2007 12:01 GMT
ShowIcon: That's in 2.0 - we are still stuck with 1.1 unfortunately. Besides
which, the docs say
"This property has no effect if FormBorderStyle is set to FixedDialog.",
which is the case in my situation.
> You could try name-hiding the "Icon" property.
>
[quoted text clipped - 79 lines]
>>
>> - Show quoted text -