How to set owner when showing form?

  • Thread starter Thread starter Voi Coi
  • Start date Start date
V

Voi Coi

Hi,

How to set owner when showing a modal (or modaless) form with
Show/ShowDialog?

Thanks,
 
This is absolutly FALSE ! The "Parent" property is used to set the "holder"
of a control (or a form). If you do "frm.Parent = this;" you will have your
dialog window "embedded" into the main form, underneath all the controls...

Since the "Owner" property will only be available in .Net CF 2.0, how can I
do it using APIs ?

The problem is quite simple to reproduce:
1. Create a new project with a main form.
2. Add a button.
3. Create a new window (with BorderStyle = FixedDialog) called "dialog"
4. In the button code, create a new "dialog" object and call the ShowDialog
method.

Run...

With the keyboard, do the Alt-Tab (task manager) key sequence, or with the
emulator, right-click the Taskbar to launch the task manager. Now, you see
both windows, the main AND the dialog. Switch to the Main and you're stuck!
(Atl-Tab, switch to the dialog and you're not stuck anymore.)

It's as if the "FixedDialog" style has no effect on the window style. The
border is always 1 pixel wide (not 3D), there's always an icon, etc. In fact,
there's no difference between the standard window and the dialog window.
 
This is absolutly FALSE ! The "Parent" property is used to set the
"holder"
of a control (or a form). If you do "frm.Parent = this;" you will have
your
dialog window "embedded" into the main form, underneath all the
controls...

Everything is a Window. The dialog will be "below" the controls if the
z-order places it there, but that's not a requirement.
Since the "Owner" property will only be available in .Net CF 2.0, how can
I
do it using APIs ?

P/Invoke SetParent
With the keyboard, do the Alt-Tab (task manager) key sequence, or with the
emulator, right-click the Taskbar to launch the task manager. Now, you see
both windows, the main AND the dialog. Switch to the Main and you're
stuck!
(Atl-Tab, switch to the dialog and you're not stuck anymore.)

This is an expected side effect of the fact all CF Forms are top-level
Windows. Another way to reproduce this is probably to run another app then
come back to yours.
It's as if the "FixedDialog" style has no effect on the window style. The
border is always 1 pixel wide (not 3D), there's always an icon, etc. In
fact,
there's no difference between the standard window and the dialog window.

Windows styles in PPC are overridden by the shell. A classic example is the
"caption bar" area. Looking at it, you'd be inclined to think it's the
caption area of your form, but it's not. It a whole different process
running that small window handling icons and text changes.

-Chris
 
All CF forms are "top-level" ??? Why?
Can I change this? (I mean, can I set a form, using a P/invoke API, to be
"not top-level"?)

If the shell overrides the window style, then why do the C++ forms are still
looking 3D (try Microsoft Word Viewer, then open the About box. A nice 3D
window that doesn't appear in the Task Manager list... The same is true with
Wordpad and the Paragraph dialog.)

By the way, I'm running my apps under Windows CE 5.0, not a Pocket PC.
(Sorry, I forgot to mention...)
 
All CF forms are "top-level" ??? Why?

No idea. I didn't make that decision. I agree that it's less than ideal.
Can I change this? (I mean, can I set a form, using a P/invoke API, to be
"not top-level"?)

Yep, as I said, P/Invoke SetParent
If the shell overrides the window style, then why do the C++ forms are
still
looking 3D (try Microsoft Word Viewer, then open the About box. A nice 3D
window that doesn't appear in the Task Manager list... The same is true
with
Wordpad and the Paragraph dialog.)

Because these aren't in the PPC. That makes a huge difference. You should
be able to get correct Window style behavior with the CF. If you can't
P/Invoke and alter the style bits manually.

-Chris
 
Well, I'll try the SetParent command. I just don't really know how to get
both the parent AND the dialog window's handles (GetCapture needs a visible
window, right? So, when I create the window, then it is not visible until I
call the ShowDialog() method...)

To answer your question, no, the BorderStyle has no effect under WinCE 5
(not PPC). I'll have to use the OpenNetCF's Win32Window.SetWindowStyle
command... but where can I find a definition of the style bits?

Thank you very much for your help!
 
Back
Top