Firstly let me apologise for the rather vague title, the problem I am encountering is a little difficult to briefly describe.
I have just encountered an interesting focus problem, which after doing some testing & searching I am at a loss to explain (which is why I have allocated 500 points for a working solution)
I have a C# COM object that under certain circumstances will show a form. This is a simple form with 2 buttons (ok, cancel) and a listview. By default the OK button has focus (through code by setting .Focus(), and through design by setting its tab order to 0).
When the form is displayed the button has focus because if I press return the code behind the button is executed (I am not using the AcceptButton property on the form) - the curious problem is how the button is rendered.
Normally if a button has focus a dotted line is drawn just inside the buttons bounds and the button shadow is enhanced. On the COM launched form the shadow is drawn but the inner line is not, but if I tab around to the button again it does have the dotted line.
If I create a .NET assembly and call the function through the framework the button is also rendered incorrectly.
If I add a Main() function to the form and launch it directly then the button is rendered correctly (with the shadow and the dotted line)
Does anybody have any ideas of what direction I should go to find a solution to this problem?
More Info :
The assembly has a entry point function called (this function is marked as public so it can also be called in .NET via referencing):
IsValid(ref int errorcode, ref string errordesc, bool valid)
When using the assembly as COM (in Delphi), I instantiate the DLL (constructor does not perform any code) and then call
Under certain circumstances this function will launch the dialog described above, using the following code :
if (blah blah blah)
GetUserData gud = new GetUserData();
Simple enough, well I thought so until this focus issue appaeared