473,563 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(PaintEv entArgs e)
{
if(imagex!=null )
{
e.Graphics.Draw ImageUnscaled(i magex, 0, 0, imagex.Width,
imagex.Height);
}
base.OnPaint (e);
}

protected override void OnPaintBackgrou nd(PaintEventAr gs pevent)
{
base.OnPaintBac kground (pevent);
}

}
Nov 15 '05 #1
2 3547
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_SOU ND" <ze*******@yaho o.co.uk> wrote in message
news:80******** *************** ***@posting.goo gle.com...
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(PaintEv entArgs e)
{
if(imagex!=null )
{
e.Graphics.Draw ImageUnscaled(i magex, 0, 0, imagex.Width,
imagex.Height);
}
base.OnPaint (e);
}

protected override void OnPaintBackgrou nd(PaintEventAr gs pevent)
{
base.OnPaintBac kground (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 onpaintbackgrou nd 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(PaintEv entArgs e)
{
if(imagex!=null )
{
e.Graphics.Draw ImageUnscaled(i magex, 0, 0, imagex.Width,
imagex.Height);
}
base.OnPaint (e);
}

protected override void OnPaintBackgrou nd(PaintEventAr gs pevent)
{
base.OnPaintBac kground (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.BackGro undImage = LARGE_IMAGE;

Button 4
========

tabpage.BackGro undImage = 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.BackGro undImage = LARGE_IMAGE;
tabpage.BackGro undImage = 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.b e>...
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
1990
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 PC running XP Home I get a ' Internal server error - page cannot be dispalyed' message.
3
2860
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 plus minus would still be ok, whyever. I've tested this successfully on 6.0.2800.1106 on a german W2KPro machine, also with 6.0.2800.1106 on a german...
6
1706
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
1227
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 property in Foo which returns the BarList, since to this time the ctor of BarList did not returned yet, the reference "list" is still null and so the next...
1
1340
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: myImage.save(response.outputstream, ImageFormat.jpeg). This code works however, on this page I refer to a sessionvariable that is accessable...
1
1069
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 to share it with my co-workers, so far no problem... still works like a charm. Until I tried to access the application over HTTPS (SSL).. logon works...
0
1100
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 procedure: DataGrid1.DataSource = dataView1; DataGrid1.DataBind(); But if I clear DataGrid's DataSource property at designtime,
5
1664
by: Johs32 | last post by:
I have the follwing code: #include <stdio.h> #include <stdlib.h> struct data { int *ip; };
5
1710
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 kind of use)? template <typename E> class Mytest { public: Mytest(int n) { s = E(0);
0
7659
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7580
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7945
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5481
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2079
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.