473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

A problem with UserControls and MessageBoxes

Hi

I am currently investigating a very annoying problem with one of our
applications.

We have a UserControl that runs in IE.

As the control fires up the constructor does some status checking and if the
database is in
one of several states we want to notify the user.

Unfortunately there are a couple of issues with this.

Seems like when we used the native MessageBox.Show the control stops
receiving windows messages and never fully initializes. So we came up with a
class that wraps the Windows native MessageBox function in user32.dll.

This version allows the usercontrol to complete and generally behaves
correctly, everywhere but in the constructor.

If we present a message box during the constructor it does not appear to be
modal with respect to the UserControl,
so the user can continue to interact with the U.C. even though we don't want
them to.

This causes all sorts of problems.

I've got to think that maybe the U.C. handle isn't valid, and that's why the
parentage isn't being respected.

Do any of you have an possible solutions for me to try.

In old style SDK programming I'd probably just post a message back to the
U.C. and display the warning a little later,
but I don't want to have to declare a WndProc unless I absolutely have to.

Thanks
Mar 15 '06 #1
3 1344
On Wed, 15 Mar 2006 08:10:32 -0500, "Tim Osborne"
<Ti*********@xcellenet.com> wrote:

And multithreading?
Mar 15 '06 #2
A modal dialog box requires some form of handle to be passed to it.

Internally if you dont pass a handle the handle is usually exgtracted from
the current owner screen where the code is executed.

During the Constructor even i am pretty sure there is no handle available,
thus the modal dialog box dosn't know which screen to stay in front of, thus
its not modal in your application.

Regards

"Tim Osborne" <Ti*********@xcellenet.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi

I am currently investigating a very annoying problem with one of our
applications.

We have a UserControl that runs in IE.

As the control fires up the constructor does some status checking and if
the database is in
one of several states we want to notify the user.

Unfortunately there are a couple of issues with this.

Seems like when we used the native MessageBox.Show the control stops
receiving windows messages and never fully initializes. So we came up with
a class that wraps the Windows native MessageBox function in user32.dll.

This version allows the usercontrol to complete and generally behaves
correctly, everywhere but in the constructor.

If we present a message box during the constructor it does not appear to
be modal with respect to the UserControl,
so the user can continue to interact with the U.C. even though we don't
want them to.

This causes all sorts of problems.

I've got to think that maybe the U.C. handle isn't valid, and that's why
the parentage isn't being respected.

Do any of you have an possible solutions for me to try.

In old style SDK programming I'd probably just post a message back to the
U.C. and display the warning a little later,
but I don't want to have to declare a WndProc unless I absolutely have to.

Thanks

Mar 15 '06 #3
Oh I quite understand there is no valid handle, and that's why its not
modal.

I was wondering if anyone had a solution, other than my 'PostMessage'
approach.

Which BTW I've just finished coding, and it seems to work.

It just seems like a bit of a kludge and my project lead might not like it
when I explain it to him, so I'm looking for
alternatives.

Thanks
"scott blood" <sc*********@hotmail.com> wrote in message
news:eJ*************@TK2MSFTNGP12.phx.gbl...
A modal dialog box requires some form of handle to be passed to it.

Internally if you dont pass a handle the handle is usually exgtracted from
the current owner screen where the code is executed.

During the Constructor even i am pretty sure there is no handle available,
thus the modal dialog box dosn't know which screen to stay in front of,
thus its not modal in your application.

Regards

"Tim Osborne" <Ti*********@xcellenet.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi

I am currently investigating a very annoying problem with one of our
applications.

We have a UserControl that runs in IE.

As the control fires up the constructor does some status checking and if
the database is in
one of several states we want to notify the user.

Unfortunately there are a couple of issues with this.

Seems like when we used the native MessageBox.Show the control stops
receiving windows messages and never fully initializes. So we came up
with a class that wraps the Windows native MessageBox function in
user32.dll.

This version allows the usercontrol to complete and generally behaves
correctly, everywhere but in the constructor.

If we present a message box during the constructor it does not appear to
be modal with respect to the UserControl,
so the user can continue to interact with the U.C. even though we don't
want them to.

This causes all sorts of problems.

I've got to think that maybe the U.C. handle isn't valid, and that's why
the parentage isn't being respected.

Do any of you have an possible solutions for me to try.

In old style SDK programming I'd probably just post a message back to the
U.C. and display the warning a little later,
but I don't want to have to declare a WndProc unless I absolutely have
to.

Thanks


Mar 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kate | last post by:
Hi: I have a picturebox control, and at runtime various usercontrols are added to it to make a diagram. As dynamically added usercontrols, they are of type VBExtender. Is there a way to save...
2
by: Claire | last post by:
I need my communication status window to be topmost when it's open/active. Ive set the TopMost property of the form to true and it does work ok. After performing tasks this window generates an...
4
by: Carlos | last post by:
Hi all, I am new to asp in general, and I would like to know if it is good practice just to display a messagebox after a form validation is performed and the user must be warned about missing...
5
by: Kiyomi | last post by:
I have created a UserControl which takes two input parameters to run. I now would like to use this UserControl in aspx page in which the user can supply two parameters. How can I pass these...
3
by: YYZ | last post by:
I swear I've done my research, and now I was just hoping someone could explain this to me. I've got a base class (usercontrol) that I am using just as an interface. Meaning, I've defined...
0
by: seigo | last post by:
Hello, I faced with the following problem. I have a PlaceHolder on a page and a few UserControls which have custom events, for instance: public delegate void SelectHandler(object sender,...
3
by: Nathan Sokalski | last post by:
I have my UserControls in a subdirectory called usercontrols. In the code for one of my UserControls I have the following: Public Property adimage() As String Get Return...
4
by: Nathan Sokalski | last post by:
In several of my UserControls I add properties. If I access these properties in the CodeBehind of the pages that use the controls, I recieve an error when compiling. The reason for this is because...
1
by: zimdanen | last post by:
I am trying to use NUnit for testing, at the insistence of a coworker. In order to test the code, I are using an MDI (also at the insistence of that coworker) so that I can get to the forms that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.