Modeless Dialogs
-
Has anyone succeeded in spawning a modeless dialog that stays on top of the main form, but that does not just stay on top of every window in the shell? That is, behaviour identical to Find/Replace dialogs in VS and Office. In C++ this is routine, but in .Net I have failed when: 1) Setting dialog's TopLevel to false, and making dialog a child of main form. This only allows rendering the dialog within the client area of the main form, of course, since it is treated as a non-form child control. 2) Using Win32 API SetParent() and SetWindowPos() directly. The dialog freezes and paints garbage. CLR does not recognise Windows' way of setting parent-child relationships, I suspect, and proper message handling requires the dialog to be in the parent's collection. I am investigating some wild hacks, but would appreciate it if anyone has insights on this. TIA
-
Has anyone succeeded in spawning a modeless dialog that stays on top of the main form, but that does not just stay on top of every window in the shell? That is, behaviour identical to Find/Replace dialogs in VS and Office. In C++ this is routine, but in .Net I have failed when: 1) Setting dialog's TopLevel to false, and making dialog a child of main form. This only allows rendering the dialog within the client area of the main form, of course, since it is treated as a non-form child control. 2) Using Win32 API SetParent() and SetWindowPos() directly. The dialog freezes and paints garbage. CLR does not recognise Windows' way of setting parent-child relationships, I suspect, and proper message handling requires the dialog to be in the parent's collection. I am investigating some wild hacks, but would appreciate it if anyone has insights on this. TIA
Not sure if it's the right way, but the following works for me: Set the dialog's ShowInTaskBar property false, and after creating the dialog (in some method of the main form) call MainForm.AddOwnedForm(DialogForm). Chris Jobson
-
Not sure if it's the right way, but the following works for me: Set the dialog's ShowInTaskBar property false, and after creating the dialog (in some method of the main form) call MainForm.AddOwnedForm(DialogForm). Chris Jobson
Chris Jobson wrote: Not sure if it's the right way Going from memory, the docs for
AddOwnedForm
say that is what it does so I would say that is The Right Way™ :) James "It is self repeating, of unknown pattern" Data - Star Trek: The Next Generation -
Not sure if it's the right way, but the following works for me: Set the dialog's ShowInTaskBar property false, and after creating the dialog (in some method of the main form) call MainForm.AddOwnedForm(DialogForm). Chris Jobson
Thank you Chris, that's exactly what the doctor ordered :) It's a pleasure to have contributors such as yourself on CP. Incredible that I overlooked that in the docs; probably scanned the protected methods too quickly, and got lost in keyword searches! Cheers
-
Chris Jobson wrote: Not sure if it's the right way Going from memory, the docs for
AddOwnedForm
say that is what it does so I would say that is The Right Way™ :) James "It is self repeating, of unknown pattern" Data - Star Trek: The Next Generation