Solved

Lost Focus on showDialog (Windows Application)

Posted on 2004-09-15
7
2,726 Views
Last Modified: 2009-06-08
I'm developing a windows aplication that starts in a main form and when user selects FILE/NEW PROJECT, a wizard is displayed (in modal way). This wizard is a sequence of forms displayed with showDialog. Each step of the wizard has a NEXT button and a BACK button. The code is like these:

When FILE/NEW PROJECT menu of main form is selected:
step1Form.showDialog();

When NEXT button of step 1 is pressed:
step1Form.hide();
step2Form.showDialog();

When NEXT is pressed, the main form lost focus for any windows aplication running (word, excel, explorer, IE, etc...) and the step2Form appears in front of it. Now, we have my main form hidden by a windows application and the step2 form in front of the windows application. There's a file sample in:

This is the original error!
http://www.tecgraf.puc-rio.br/~nazareth/code/TesteBugShowModalErro.zip

This is a try to solve it (not good yet)!
http://www.tecgraf.puc-rio.br/~nazareth/code/TesteBugShowModalMelhor.zip

Anybody knows how can fix it?
Thanks!

ps. sorry about my english, i'm brazilian ;)



0
Comment
Question by:Gonella
7 Comments
 
LVL 5

Expert Comment

by:tomasX2
ID: 12070018
try...
step1Form.hide();
step2Form.showDialog(this);
0
 
LVL 8

Expert Comment

by:AaronReams
ID: 12070456
You might consider saving yourself a lot of time by using an existing wizard in your code...

http://www.codeproject.com/cs/miscctrl/tswizard.asp

http://www.codeproject.com/cs/miscctrl/ak_wizard.asp

http://www.codeproject.com/cs/miscctrl/DesignTimeWizard.asp

There's many more out there also... good luck.

Cheers,
Aaron

0
 

Author Comment

by:Gonella
ID: 12071693
AaronReams, thanks for the tip but I won't use a 3rd party wizard in this project because I need total control on this forms and all of its design and code is already done.

TomasX2, the problem occurs when the hide() is called, so, I think that nothing after hide() will make some difference, but I tryed your solution and didn't work.


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Accepted Solution

by:
sideb earned 500 total points
ID: 12074176
Como voce é brasileiro, ai vai....

Uma sugestão, voce poderia usar paineis ao invés de usar vários forms.

Em cada painel teria a sua "tela" e voce iria ocultando e exibindo a cada etapa.

Espero ter ajudado.

0
 

Author Comment

by:Gonella
ID: 12075170
SideB, your idea of using panels to do the steps is a nice one, but I think there's a way to show a sequence of dialog forms without lose the focus. I'm probably missing something...

Using panels make de interface management more dificult...

Thank you anyway, I will try it later.
0
 
LVL 5

Expert Comment

by:tomasX2
ID: 12075648


I think the showDialog with the IWindow32 parameter tells the form who the parent is...
when you created the step1 form from the main form did you create it with a step1Form.showDialog(this) overload or just the regular...

I tried this at home yesterday and I did it like this and it worked out better than without the overload.

// main form
step1Form = new Form2();
step1Form.showDialog(this);

// step one form on next click...
this.Hide()
step2Form = new Form3()
step2Form.showDialog(this);

// step two on back
this.Hide()
step1Form = new Form2();
step1Form.showDialog(this);
0
 

Author Comment

by:Gonella
ID: 12076622
tomasX2, the results of your code is almost good, in fact, much better than without overload, but it still with a strange behavior, like a flick when the hide() is called. I got something like this in the example I posted at:

http://www.tecgraf.puc-rio.br/~nazareth/code/TesteBugShowModalMelhor.zip

I need smooth transition between forms, any idea?

Thank you for the help.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now