473,408 Members | 2,839 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,408 software developers and data experts.

Wierd problem

I have a peculiar problem,

I have a tabpage with a label control on it. When i set a background
image to the tabpage and drag the label around it has paint issues in
that it is slow, granted the image i am using is 5mb!!! HOWEVER...

I have inherited the tabpage created an Image reference in it, and
overrriden the onPaint method to draw the image

now if i press a button that sets the background image of the control
and drag it works really slow, however if i then set the backimage to
null and set my own image reference IT works FINE!!! No issues even a
5MB image. If i just set my own internal image first it isnt smooth
however setting it after the backimage ON/OFF does cause it to work.
However i cant set and unset the background image in code as that
does not make it work properly it has to happen in that order and via
a button etc. Could it be something todo with focus????

Could someone explain to me why this is happening? As i am unable to
understand what is happening, and a solution to my problem?
Thanks!!!!!!!!
Below is the code to my tabpage
public class TabWork : TabPage
{

public Image imagex;

public TabWork()
{

}

protected override void OnPaint(PaintEventArgs e)
{
if(imagex!=null)
{
e.Graphics.DrawImageUnscaled(imagex, 0, 0, imagex.Width,
imagex.Height);
}
base.OnPaint (e);
}

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

}
Nov 15 '05 #1
2 3531
Hi,

I (probably we) do not understand the 'dragging' part of your problem.
Could you explain it a little deeper, with a steps list or so like,

1. create a new form
2. add a tabcontrol, DockStyle.Fill
3. add a tabpage
4. set a background image of about 5 MB
and so on

I tried to reproduce your problem, but I don't experience any slowdowns.
Not at design-time, not at run-time.

Greetings,

Bram.
"CMEDIA_SOUND" <ze*******@yahoo.co.uk> wrote in message
news:80**************************@posting.google.c om...
I have a peculiar problem,

I have a tabpage with a label control on it. When i set a background
image to the tabpage and drag the label around it has paint issues in
that it is slow, granted the image i am using is 5mb!!! HOWEVER...

I have inherited the tabpage created an Image reference in it, and
overrriden the onPaint method to draw the image

now if i press a button that sets the background image of the control
and drag it works really slow, however if i then set the backimage to
null and set my own image reference IT works FINE!!! No issues even a
5MB image. If i just set my own internal image first it isnt smooth
however setting it after the backimage ON/OFF does cause it to work.
However i cant set and unset the background image in code as that
does not make it work properly it has to happen in that order and via
a button etc. Could it be something todo with focus????

Could someone explain to me why this is happening? As i am unable to
understand what is happening, and a solution to my problem?
Thanks!!!!!!!!
Below is the code to my tabpage
public class TabWork : TabPage
{

public Image imagex;

public TabWork()
{

}

protected override void OnPaint(PaintEventArgs e)
{
if(imagex!=null)
{
e.Graphics.DrawImageUnscaled(imagex, 0, 0, imagex.Width,
imagex.Height);
}
base.OnPaint (e);
}

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

}

Nov 15 '05 #2
Sorry if i wasnt to clear here is a step by step account of how to
reproduce my problem and other detailed info about it
1) add a tabcontrol and then a tabpage to a form

2) add a custom contorl to the tabpage (a normal control eg label will
work as well but i

am using a custom control)

3) add functionality that allows you to drag the control/label (i just
use the controls

mousedown to start DoDragDrop, and then use the drag_enter/move events
of the tabpage to

make it drag)

4) now set a background image, some big image say 1mb and 1024x768 and
drag the

contorl/label, you should see that it is slow to paint the control
when dragging
HOW CAN I MAKE THE PAINTING SMOOTH?
I have tried double buffer overriding onpaintbackground etc.. but that
is not the solution

as if i add my control to a panel and then set the panels
backgroundimage to a large image

the painting is smooth!!!! So the panel does something to make
painting smooth that the

tabpage does not. The solution i have come across is detailed below
however it has a weird

problem which i will list below. For now use the following steps to
produce my problem

Start a new project

1) inherit from tabpage and produce a custom tabpage class with the
code below
public class MyTab : TabPage
{

public Image imagex;

public MyTab()
{

}

protected override void OnPaint(PaintEventArgs e)
{
if(imagex!=null)
{
e.Graphics.DrawImageUnscaled(imagex, 0, 0, imagex.Width,
imagex.Height);
}
base.OnPaint (e);
}

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

}
2) add tabcontrol to form and add the inherited tabpage to it

3) add user control to tabpage then add functionality to drag the
control

4) make an Image object in the and set it to a large image in the form
class name it

LARGE_IMAGE

e.g. Image LARGE_IMAGE = Image.FromFile(@"C:\image.jpg");

5) add 4 buttons to the form which the following in their click events
Button 1
========

tabpage.imagex = LARGE_IMAGE;

Button 2
========

tabpage.imagex = null;

Button 3
========

tabpage.BackGroundImage = LARGE_IMAGE;

Button 4
========

tabpage.BackGroundImage = null;
6) OK now that everythings ready we can begin the test! If you press
Button 1 you will see

that when you drag the control the image appears underneath it however
the painting isnt

very smooth but is smoother than in the first example above where you
set the

backgroundimage. Now if you press Button 2 so the tabpage.imagex is
set to null. painting

should be smooth again as no background is set. (Forget about the
backimage getting erased

and painting when u move the control i understand why that is
happening that is not the

Problem).

Now press Button 3 to set the tabpage's backgroundimage and drag the
control around it is

slow to paint now press button 4 to set the backgroundimage to null.
OK THIS IS THE WEIRD

PART, Press Button 1 and tabpage.imagex should paint SMOOTH!!!!! IT is
fine now.
I cant understand why this happens? It only paints smooth after
setting and unsetting the

tabpage's backgroundimage. I have tried doing the following

tabpage.BackGroundImage = LARGE_IMAGE;
tabpage.BackGroundImage = null;
tabpage.imagex = LARGE_IMAGE;

in the constructor of the inherited tabpage but that does not make it
smooth, i have added

the 3 lines of code to a seperate button again to no change. It seems
i have to add the

code to different buttons only then will it work!!! WIERD.
Please please can anyone shed any light on this situation? I want
smooth painting on the

tabpage with out pressing mulitples buttons LOL





"Bram" <bv*****@nospam.skynet.be> wrote in message news:<40***********************@news.skynet.be>...
Hi,

I (probably we) do not understand the 'dragging' part of your problem.
Could you explain it a little deeper, with a steps list or so like,

1. create a new form
2. add a tabcontrol, DockStyle.Fill
3. add a tabpage
4. set a background image of about 5 MB
and so on

I tried to reproduce your problem, but I don't experience any slowdowns.
Not at design-time, not at run-time.

Greetings,

Bram.

Nov 15 '05 #3

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

Similar topics

3
by: vool | last post by:
Hi all, I've got a really wierd problem here. When I access a web page that adds information to a database on a PC running XP Pro it works as it should. When I access the same page from a...
3
by: Markus Fischer | last post by:
Hi, I'm experiencing a wierd problem with IE 6 in Windows with two _slightly_ different Version. Give the following HTMl-Code, ideally the output of offsetTop should be "105"; a few pixel...
6
by: Qun Cao | last post by:
Hello, I am just starting to play threading in python, here is a really interesting problem I am very curious about: " import thread def main(): thread.start_new(test.()) def test():
1
by: cody | last post by:
I have a OOP problem with the well known pattern where objects containing an object which represents a list of subobjects. Now my problem is that the ctor of a subobject indirectly calls the...
1
by: Dean | last post by:
PageOne.aspx has an image control. The imageURL of the image control points to ImagePump.aspx. ImagePump.aspx gets a bitmap out of a SQLServer database, puts in into a bitmap object and does a:...
1
by: Flores Eken | last post by:
Hi group, I've made my own implementation of the Time Tracker ASP.NET starterkit, added several features and extra's, works like a charm. Now i've uploaded it to my hosting account, to be able...
0
by: Michael | last post by:
Hi, I found a wierd problem in DataGrid. If I set DataGrid's DataSource to empDataSet1 at designtime, then I can never change its DataSource at runtime, e.g., in the Button1_Click event...
5
by: Johs32 | last post by:
I have the follwing code: #include <stdio.h> #include <stdlib.h> struct data { int *ip; };
5
by: desktop | last post by:
I am confused about the use of the template parameter "E" in the below class. Since when is it allowed to use these parameters like "E(1)" and what does it mean (where can I read more about this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.