OnPaint() works differently between 2K and XP?

  • Thread starter Thread starter weixiang
  • Start date Start date
W

weixiang

Hi,

I wrote a progam, which pop up a form that with OnPaint() overrided. It
works great in XP but bad in 2K. In 2K, most of the form content will not
be displayed until I drag the form a little. And I set a breakpoint to the
OnPaint... The breakpoint was hit when the form popuped... But if I shrink
the VS.NET to make it can't overlap with the popup form, the form content is
still not displayed after the OnPaint() returned. If I move the form a
little, the content will be displayed all right even without the former
breakpoint reached.

I tried that in both .NET framework 1.1 and 1.0.

Is that a bug of .NET framework in Windows 2K? How can I avoid this
problem?

Thank you very much,
Wei Xiang
 
Wei,

Can you show the code in the OnPaint method? It is possible that there
could be a bug, but XP is just an extension of the W2K codebase, so I don't
see any reason why you should have this kind of problem.

Hope this helps.
 
My code is quite simple:

protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
int i, j;
for (i=0; i<rowCount; i++)
{
for (j=0; j<colCount; j++)
{
int id = j*rowCount + i;
if (id < imageListSmallPic.Images.Count)
g.DrawImageUnscaled(imageListSmallPic.Images[id], i*iconWidth,
j*iconHeight);
}
}
}

I don't know whether it can be different in 2K. Firstly the imageList is
24bit. And I tried to set it to 8 bit, but solve nothing.

I have the SP4 installed in 2K, also the newest patches.

Thank you very much
Wei Xiang


Nicholas Paldino said:
Wei,

Can you show the code in the OnPaint method? It is possible that there
could be a bug, but XP is just an extension of the W2K codebase, so I don't
see any reason why you should have this kind of problem.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

weixiang said:
Hi,

I wrote a progam, which pop up a form that with OnPaint() overrided. It
works great in XP but bad in 2K. In 2K, most of the form content will not
be displayed until I drag the form a little. And I set a breakpoint to the
OnPaint... The breakpoint was hit when the form popuped... But if I shrink
the VS.NET to make it can't overlap with the popup form, the form
content
is
still not displayed after the OnPaint() returned. If I move the form a
little, the content will be displayed all right even without the former
breakpoint reached.

I tried that in both .NET framework 1.1 and 1.0.

Is that a bug of .NET framework in Windows 2K? How can I avoid this
problem?

Thank you very much,
Wei Xiang
 
Wei,

The bit level of the images sounds like it could be part of the problem.
How are you converting the 24 bit images to 8 bit? I don't think 2000
supports 24 bit images (for example, when I try and render the icons from XP
in 2000, it fails).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


weixiang said:
My code is quite simple:

protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
int i, j;
for (i=0; i<rowCount; i++)
{
for (j=0; j<colCount; j++)
{
int id = j*rowCount + i;
if (id < imageListSmallPic.Images.Count)
g.DrawImageUnscaled(imageListSmallPic.Images[id], i*iconWidth,
j*iconHeight);
}
}
}

I don't know whether it can be different in 2K. Firstly the imageList is
24bit. And I tried to set it to 8 bit, but solve nothing.

I have the SP4 installed in 2K, also the newest patches.

Thank you very much
Wei Xiang


message news:[email protected]...
Wei,

Can you show the code in the OnPaint method? It is possible that there
could be a bug, but XP is just an extension of the W2K codebase, so I don't
see any reason why you should have this kind of problem.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

weixiang said:
Hi,

I wrote a progam, which pop up a form that with OnPaint() overrided. It
works great in XP but bad in 2K. In 2K, most of the form content will not
be displayed until I drag the form a little. And I set a breakpoint
to
the
OnPaint... The breakpoint was hit when the form popuped... But if I shrink
the VS.NET to make it can't overlap with the popup form, the form
content
is
still not displayed after the OnPaint() returned. If I move the form a
little, the content will be displayed all right even without the former
breakpoint reached.

I tried that in both .NET framework 1.1 and 1.0.

Is that a bug of .NET framework in Windows 2K? How can I avoid this
problem?

Thank you very much,
Wei Xiang
 
I set the color depth to 8 bit by call imageList.ColorDepth =
ColorDepth.Depth8Bit before add icons to it.

And, as I said, the form will be shown correctly when I move that a little,
without the OnPaint() called...

Nicholas Paldino said:
Wei,

The bit level of the images sounds like it could be part of the problem.
How are you converting the 24 bit images to 8 bit? I don't think 2000
supports 24 bit images (for example, when I try and render the icons from XP
in 2000, it fails).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


weixiang said:
My code is quite simple:

protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
int i, j;
for (i=0; i<rowCount; i++)
{
for (j=0; j<colCount; j++)
{
int id = j*rowCount + i;
if (id < imageListSmallPic.Images.Count)
g.DrawImageUnscaled(imageListSmallPic.Images[id], i*iconWidth,
j*iconHeight);
}
}
}

I don't know whether it can be different in 2K. Firstly the imageList is
24bit. And I tried to set it to 8 bit, but solve nothing.

I have the SP4 installed in 2K, also the newest patches.

Thank you very much
Wei Xiang


message news:[email protected]...
Wei,

Can you show the code in the OnPaint method? It is possible that there
could be a bug, but XP is just an extension of the W2K codebase, so I don't
see any reason why you should have this kind of problem.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

I wrote a progam, which pop up a form that with OnPaint() overrided. It
works great in XP but bad in 2K. In 2K, most of the form content
will
not
be displayed until I drag the form a little. And I set a breakpoint to
the
OnPaint... The breakpoint was hit when the form popuped... But if I
shrink
the VS.NET to make it can't overlap with the popup form, the form content
is
still not displayed after the OnPaint() returned. If I move the
form
 
I wrote a tiny test program, which can be downloaded from
http://weixiang.nease.net/data/TestOnPaint.rar

It seems the ImageList draw has problem. If I call graphics.FillRectangle
in OnPaint() method, it can display correctly. But the
graphics.DrawImageUnscaled(imageList,...) could not work well in Win 2K.

weixiang said:
I set the color depth to 8 bit by call imageList.ColorDepth =
ColorDepth.Depth8Bit before add icons to it.

And, as I said, the form will be shown correctly when I move that a little,
without the OnPaint() called...

message news:[email protected]...
Wei,

The bit level of the images sounds like it could be part of the problem.
How are you converting the 24 bit images to 8 bit? I don't think 2000
supports 24 bit images (for example, when I try and render the icons
from
XP
in 2000, it fails).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


weixiang said:
My code is quite simple:

protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
int i, j;
for (i=0; i<rowCount; i++)
{
for (j=0; j<colCount; j++)
{
int id = j*rowCount + i;
if (id < imageListSmallPic.Images.Count)
g.DrawImageUnscaled(imageListSmallPic.Images[id], i*iconWidth,
j*iconHeight);
}
}
}

I don't know whether it can be different in 2K. Firstly the imageList is
24bit. And I tried to set it to 8 bit, but solve nothing.

I have the SP4 installed in 2K, also the newest patches.

Thank you very much
Wei Xiang


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote
in
message Wei,

Can you show the code in the OnPaint method? It is possible that
there
could be a bug, but XP is just an extension of the W2K codebase, so I
don't
see any reason why you should have this kind of problem.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

I wrote a progam, which pop up a form that with OnPaint()
overrided.
It
works great in XP but bad in 2K. In 2K, most of the form content will
not
be displayed until I drag the form a little. And I set a
breakpoint
to
the
OnPaint... The breakpoint was hit when the form popuped... But
if
 
Back
Top