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
Solved

Lost Focus on showDialog (Windows Application)

Posted on 2004-09-15
7
2,799 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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!
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

791 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