ShowDialog issue

L

Lloyd Dupont

I have custom dialogs (Form with owner drawn title and no border) and I show
them with ShowDialog() , the problem is, most of the time when I show them,
my main window is miniaturized and I didn't manage to make it appear again.

I had to find the running task and click activate.

I try BringToFront(), Show() and win32 function ShowWindow(),
SetForeground(), BringWindowToTop(), all unsuccessfully.

any tip ?
 
M

Manni

For me the same - I have a Mainform - calling differnt other form (one by
one) via ShowDialog.
To remove the Entry from the taskbar I call frmMain.Visible=false befroe I
open the dialog,
and frmMain.Visible=true after closing the dialog.

On PPC everthing works fine, but with CE.NET I get just the minimzed version
of my MainForm,
so the user has to click on the taskbar!!

Also tried "SetFocus" or things like this - nothing helps!!

By the way, when opening the dialog (very simple, just a cancel button), the
titlebar
flickers many times (showing the MaiForm / TheDialog caption).

So pleas, does somebody know
A.) how to bring back the MainForm (on CE.NET)
B.) how to avoid this flickering (on PPC as well as on CE:NET)

Thanx

Manfred
 
I

Isaque Briglia Gonçalves

Hi,

I'm too frustated with this. I believe this s bug of CF.
Showdialog function don't work 100%. For me, the
main dialog freeze.

My solution is create a class with iherits the system.windows.forms.form
and replace the iherits of the form to the class, and call the new
Showdialog
method (ShowDialogEx). See below:

public class frmModalDialog: System.Windows.Forms.Form
{
public frmModalDialog()
{
//
// TODO: Add constructor logic here
//
}

private bool bClosing = false;

protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
base.OnClosing (e);

this.bClosing = (!e.Cancel);
}

public void ShowDialogEx()
{
this.Show();

while (!this.bClosing)
System.Windows.Forms.Application.DoEvents();
}
}
 
L

Lloyd Dupont

ghu...
what do you mean ?

I just run VS.NET 2003 and it deploy for me the Compact framework on the
PocketPC
(with MS PPC v3.0.11171).

BTW I show the GetLastError() value after some of this win32 calls.
once I get XX: not implemented
and twice I get XX: bad windows number. although I took great pain to get my
windows number, I think I had tested both, GetForegroundWindow() and
GetFocus()
 
G

Ginny Caughey [MVP]

Lloyd,

I asked about the version of the compact framework, because SP1 fixes some bugs.
From your description though it sounds like your PInvokes may not be quite
right.
 
M

Manni

Hi Ginny!

I do no PInvokes!
The only thing I use is Form.Visible= / Form.Activate / Form.SetFocus

But I get exact the same effect!

Since I replaced my CAB Files in the VS.NET folder I'm pretty sure to have
SP1 installed on the emulator;
(VS made a deploy).

By the way - is there a way to determine (on the device / emulator) the
version of the CF or if SP1 is installed??

Thanks

Manfred
 
G

Ginny Caughey [MVP]

Manni,

You should get different versions returned by
System.Environment.OSVersion.Version -
Versions: V1 RTM==1.0.2268.0, V1 SP1==1.0.3111.0
 
P

Paul

Hi there

I have the same problem on PPC2003 and I'm running SP1. It is possible
to hide or make a main application form, but when it some to making the
form visible again, nothing works. I am purely useing hide, visible,
show and bring to front.
Do you have any other ideas?

Paul
 
G

Ginny Caughey [MVP]

Paul,

I don't know what exactly is going on in your app, so all I can suggest is to
just try some dumb stuff like calling Show twice or not calling BringToFront
just to see if the form is visible under other ones, etc. I don't know if this
is something that sp2 will address, and I'm sorry I don't have a better answer
for you.
 
P

Paul

I'll not keep on for info, but for clarification:

frmMain is projects startup object
Sub form is loaded with following code:

'// Hide form to keep task switching neat
frmMain.Visible = False

'// Show subform modally
frmSubForm.ShowDialog()

'// processing returned to main form so make
'// main form visible again
frmMain.Visible = True

Everything works OK up until making the form visible again. Will give
the multiple calls idea a go. Bugged admittedly, but for the duration I
was using SP2, it had no effect on the form behaviour.

Many thanks for your input.
 
G

Ginny Caughey [MVP]

Paul,

I'd suggest just removing frmMain.Visible = false and frmMain.Visible = true.
Since frmSubForm is modal, it should display and stay on top until you close it
anyway.
 
P

Paul

That is what you'd think - but if the app loses focus to another
program, when the focus is returned (say, through the task switcher)
focus defaults to the main form, irrespective of modal forms (which ,I
think, is something one of the other people in this thread mentioned).
 
G

Ginny Caughey [MVP]

Paul,

Ok I understand what you're saying. If you try to actually do anything on the
main form, it shouldn't "work" though, right? Is this PocketPC or CE? On my CE
4.1 device, when a modal dialog loses focus, either the main form or the modal
dialog form can be selected from the task switcher, but I don't have a PocketPC
device to test this on at the moment to see if the behavior is the same.
 
P

Paul

Ginny

Firstly, thanks for your extended efforts with this.

I'm using a PPC2003 device (Dell Axim). Just did a test for the Main
form being unusable. You're right - the main form is indeed un-usable.
For the time being, I've got a flag that gets set on a button on the
Modal form to show that the user wants the form closed, otherwise when
the app loses focus the modal form gets shutdown automatically.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top