Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Focus issues when using DLL assemblies

Posted on 2004-08-20
5
Medium Priority
?
206 Views
Last Modified: 2010-04-15
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

myComObj.IsValid(....)

Under certain circumstances this function will launch the dialog described above, using the following code :

if (blah blah blah)
{
 GetUserData gud = new GetUserData();
 gud.ShowDialog();
}
else
{
 ...
}

Simple enough, well I thought so until this focus issue appaeared
0
Comment
Question by:MrEyes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 4

Expert Comment

by:somnatic
ID: 11850629
you might want to try to send a single tab when the form is loaded.

SendKeys.Send("{TAB}");

funnily, the dottet line will then be there (even if you switch controls around).

Don't know why .. but appearently it works ..
0
 

Author Comment

by:MrEyes
ID: 12097953
Firstly apologies for not replying earlier

The solution suggested by Somnatic is not feasible as in code review this would be considered a hack rather than a real solution.

I am either looking for a real solution or a presentable reason as to why this "feature" exisits.
0
 
LVL 4

Expert Comment

by:somnatic
ID: 12099493
of course it is ...

i checked petzold and co. but couldn't find an explanation for that dotted line ... since nobody else in the company could answer that question it was said to be ok (even if no beautiful).

anyway .. should you ever find out - please let me know :)
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 12142508
Submitted to PAQ with points refunded (500)

DarthMod
Community Support Moderator
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question