Solved

Lost Focus on showDialog (Windows Application)

Posted on 2004-09-15
7
2,694 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
Comment Utility
try...
step1Form.hide();
step2Form.showDialog(this);
0
 
LVL 8

Expert Comment

by:AaronReams
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Accepted Solution

by:
sideb earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility


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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

16 Experts available now in Live!

Get 1:1 Help Now