WindowState and override OnPaintBackground ??

J

juvi

Hello,

my application is a fullscreen app and has a mainform and another form (both
are set to WindowState.Maximized through the designer)

I override the OnPaintBackground() in the other form to do
nothing....unfortunately when calling this form then the taskbar is displayed
(so its in window mode again).....how to prevent this??? thx juvi
 
P

Paul G. Tobey [eMVP]

You have not given us the full information on what you're doing. The *only*
thing special about each form is the setting of Maximized? I doubt that.

Paul T.
 
P

Paul G. Tobey [eMVP]

"drawn always on the dimmed background" This doesn't tell me anything.
You're saying that the task bar is not behind your window and, because of
that, does not get the faded effect that other windows, which are behind
your form, get? What do you mean by "taskbar", also? The two menu buttons
at the bottom as shown in Alex's sample on Windows Mobile? The Windows CE
taskbar in a non-Windows Mobile device? The bar along the top of the
Windows Mobile sceen showing the window title, signal strength, etc.?

You didn't say what operating system or version you're using, either. You
might want to read this:

http://guruce.com/blogpost/howtoaskquestionsonnewsgroups

Paul T.
 
J

juvi

I will try to ask once again ;-) (maybe it is qualified enough this time).

I am writing an application for Windows Mobile 6 with c# .net cf 2.0 in
Visual Studio 2008.

This is my goal: I want to create a new form which should add some kind of
dimmed background effect (dimming the previous form) while showing a
CustomMessageBox panel.

This is what I have so far to get my dimmed background effect:

protected override void OnPaint(PaintEventArgs e)
{
Bitmap dimBackGround = new Bitmap(this.Width, this.Height);
Graphics gxTemp = Graphics.FromImage(dimBackGround);
gxTemp.Clear(Color.Black);
//P/Invoking the alphablend API in PlatformAPIs class
PlatformAPIs.DrawAlpha(e.Graphics, dimBackGround, 100, 0, 0);
gxTemp.Dispose();
dimBackGround.Dispose();
}

protected override void OnPaintBackground(PaintEventArgs e)
{
//base.OnPaintBackground(e);
}

This works and I get my dimmed background effect. Both forms (mainForm,
CustomMessageBoxForm) have WindowState.Maximized definied but unfortunately
the dimmed background still shows the titlebar of the form....hope we can
find a solution for that.

thx
juvi
 
P

Paul G. Tobey [eMVP]

I still don't get it. You're saying everything works perfectly, then you
say that, oh, no it doesn't, but the failure mode is not clear to me. What's
is dimmed or not dimmed that is wrong? Is the problem one of having
something dimmed or does this have nothing whatsoever to do with dimming the
background? Take a screen capture of the problem and draw some arrows and
labels on the picture that tell us what the problem is. Words aren't doing
it...

Paul T.
 
P

Paul G. Tobey [eMVP]

That looks *exactly* like what I'd expect. What's wrong with it? The
application you are running, Background Form, has its title on the title
bar, just as you'd expect. It has popped up a "message box", which would
not normally change the title bar, but, since it's dimming the background,
the title bar of the application is dimmed. I guess that, if you don't want
to do that, you could find the size of the title bar and exclude that area
from the dimmed area in the "message box" form.

Paul T.
 
C

Christopher Fairbairn [MVP]

Hi Juvi,

What you are seeing is a side effect of the code. The dialog is actually
properly being shown fullscreen without a titlebar, but since it doesn't
redraw (the OnEraseBackground method has been overriden to do nothing) it is
still showing the old contents when the OnPaint event handler draws an alpha
blended black rectangle over top of it.

You'll also see this issue if you rotate the device while the message box is
up (or even drag the message box around). Screen artifacts will start to
build up as the window is ignoring paint requests by the OS and hence
doesn't repaint over the old position of the message box.

If you change the BackgroundForm's WindowState property to Normal you should
see that you get the effect you desire (i..e the navbar not being greyed
out). This is because the OS will then be responsible for painting the
navbar portion of the screen, and the black alpha blended rectangle is only
covering the area underneath it. This won't fix the screen rotation issue
however, which is a harder problem to resolve.

Hope this helps,
Christopher Fairbairn
 

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