Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Well am emigrating from VB6 to c#...

 

- "I have good acknowledged in VB6, so I think I will create my project with little prob " I thought to my self... But I was wrong, I had (still have) big problems, problems that did not exist in VB6 like (something simple) working with transparent labels.

 

In .NET labels r just xtreme slow! They realy s*** its redraw is so slow that I can count the redraw turn while it's removing the labels backcolor to transparent for each label (refresh)!

 

So, some ACES said to me to use System.Drawing.Graphics text, after I learn how to used this I got stuck, because drawing text this way will deny my acess to events, simply, because their will be none! I want to use mouse_click, mouse_over on text (like we do on labels) but, throught system.drawing.graphics. I think its impossible.

 

1 - Is it realy impossible?

 

2 - Why is transparecy on .NET so slow?

 

3 - Is there a way to walk around this, by skiping the use of DirectX, GDI, etc...?

 

4 - Even if there is no other way, is it to dificult?

 

5 - Can I read coordenates from mouse pointer (pixel position x,y)? I think this way i could solve things up...

 

Tks for ur attention, and I hope I can hear from u soon!

- EFileTahi-A -

Posted

I haven't noticed labels being very slow. What OS are you running on what processor/how much RAM?

 

On win98se I have noticed all the graphics stuff being very slow.

BS - Beer Specialist
Posted (edited)

I have a 3.0 cpu and 512 400mhz mem, win XP, .NET 2003, u know, all the good stuff... what do u mean u have not noticed? try this:

 

- put a, lets say, a 800x600 picture in the mains form background

- put about 20 transparent labels on a form.

- Now run the program... u will see .NET (of course it only takes a second) redrawing the labels everytime u bring the window to front...

 

this is not a hardware issue, as many ppl have complained about this...

Yet its exactly the same thing that happens on my wifes 1.GHZ cpu...

 

U can yet see the diference that makes (in the .NET editing mode of course), by moving a label with a solid color background with the CRTL + Arrows and doing the same thing with a label with a transparent background, u will notice that the transparent one will move MUCH slower...

 

Anyway tks for posting m8 since nobyelse post... i just hope this is not an hard topic...

 

PS: In VB6 i had no prob with transparent labels...

Edited by EFileTahi-A
  • *Gurus*
Posted

In VB6, labels were windowless, allowing it to paint them on top of whatever was behind them. Windows Forms does not support windowless controls, but has a far better framework for doing your own drawing.

 

I suggest you write a simple library that you can plug in to your form that will draw text when it needs to, and raises any mouse events that you need. As long as you're storing rectangles for where to paint your text, you can do hit testing in your container's MouseMove etc events.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted
As long as you're storing rectangles for where to paint your text' date=' you can do hit testing in your container's MouseMove etc events.[/quote']

 

what do u mean by that? Am planing to use mouse coords for mouse trigger... it works but it is a pain in the *** to code....

Posted

it is quit simple

if you store a rectangle for the location and size of you label

then you can easely see if a point is inside that rectangle.

 

in your mousedown event do

 

dim yourect as new Rectangle(loc,size)

if yourect.Contains(e.X,e.Y) then

'now you can fire a onlabel clickevent or do watever you like

end if

 

maybe your trying do code to mutch yourself

or am i hearing you wrong?

 

hope it helps

Posted
it is quit simple

if you store a rectangle for the location and size of you label

then you can easely see if a point is inside that rectangle.

 

in your mousedown event do

 

dim yourect as new Rectangle(loc,size)

if yourect.Contains(e.X,e.Y) then

'now you can fire a onlabel clickevent or do watever you like

end if

 

maybe your trying do code to mutch yourself

or am i hearing you wrong?

 

hope it helps

 

Well tks for posting m8...

 

What kind of rectangule r u tralking about?

 

this.DrawRectanglesRectangle(new System.Windows.Forms.PaintEventArgs);
System.Drawing.Graphics graphics = this.CreateGraphics();
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(this.Pos_Top.Left -20,this.Pos_Top.Top,240,280);
graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle);
graphics.DrawRectangle(System.Drawing.Pens.CornflowerBlue, rectangle);

 

will this kind of rectangle do that?

 

Remember that I have to use transparent things only... But am skiping the use of objects because the: .backcolor = transparency is too slow and makes odd refreshes...

 

Am really sry, but i have only 2 weeks of C#... Am very confused with all this, if u could post a fully working example code that would be wonderfull!

 

tks in advance!

Posted
here 's a basic idea on how to do it...

 

Well that example just kick ***, but not i have a prob... i wish only to change the name of the transLabel rather then create a new one.

 

How can I turn: "transLabel lbl = new transLabel(this);" into pulblic? So that i can just call the "lbl.text" and change the its text whenever i want it?

 

I tryed to put the "transLabel lbl = new transLabel(this);" into to the public declare zone or somthing but the "...(this)" fails me because in ur exampe there is a part of code inside the "transLabel class" that require a "control parent" or something like...

 

- EFileTahi-A -

Posted
Well that example just kick ***, but not i have a prob... i wish only to change the name of the transLabel rather then create a new one.

 

How can I turn: "transLabel lbl = new transLabel(this);" into pulblic? So that i can just call the "lbl.text" and change the its text whenever i want it?

 

I tryed to put the "transLabel lbl = new transLabel(this);" into to the public declare zone or somthing but the "...(this)" fails me because in ur exampe there is a part of code inside the "transLabel class" that require a "control parent" or something like...

 

- EFileTahi-A -

 

first declare your class and then in the initialisation of you app create an instance in it

 

like this

 

transLabel lbl;

 

 

and then in the init or at form load

 

me.lbl = new transLabel(me)

 

or c#

 

this.lbl = new transLabel(this);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...