|
-
Sep 5th, 2003, 06:26 PM
#1
User Drawn Controls (RESOLVED)
How come when you user draw your controls the background doesn't draw properly? I mean if I move the control around it paints whatever was/is behind it in the background like where the control used to be.
Last edited by Edneeis; Sep 10th, 2003 at 01:05 PM.
-
Sep 5th, 2003, 08:30 PM
#2
I wonder how many charact
Edneesis, you obviously are expanding your reach... its shocking enough to see you ask a question.
You seem to be having a very specific problem, perhaps specific to your installation.
Could you clarify what you mean by "move"? Do you mean like setting the control to new coordinates, or dragging it somewhere?
-
Sep 10th, 2003, 09:48 AM
#3
Yes that is what I mean by move or resizing it even. So if I am using my control at designtime and position it on the form then drag it over a bit and if it overlaps where it was before then you can still see some left overs of the previous one.
I tried BinaryAnge's idea posted here but that just freaked out my machine. I've been gone for a few days but will now resume trying to solve this.
-
Sep 10th, 2003, 10:04 AM
#4
-
Sep 10th, 2003, 10:06 AM
#5
I wonder how many charact
I don't have that problem with my usercontrols, and I haven't done anything to change events such as the OnPaint event. I'm guessing you have changed this event to get these result?
Perhaps you could upload the source if not protected..
anyway, here's a few tips from a website that might help...
http://www.syncfusion.com/FAQ/WinFor...73c.asp#q1023q
Also look into the SetStyle function parameters...
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
Last edited by nemaroller; Sep 10th, 2003 at 10:16 AM.
-
Sep 10th, 2003, 10:27 AM
#6
I don't have any trouble with normal usercontrols just when I want to draw my own. Sure I can post the project all though there isn't much to it. If you use the OnPaint method to draw anything on a usercontrol then you should experience this problem.
I tried searching for 'code project' but those two words must be pretty common because I got a ton of results. So I thumbed through some with related titles or by you MrPolite but the closest thing I found was your cool Apply a Texture code.
-
Sep 10th, 2003, 10:28 AM
#7
I wonder how many charact
Found this which kinda describes a behavior you may be having:
ControlStyle - > AllPaintingInWmPaint
If true, the control ignores the window message WM_ERASEBKGND to reduce flicker. This style should only be applied if the UserPaint bit is set to true.
If the AllPaintingInWmPaint bit is set to true, the window message WM_ERASEBKGND is ignored, and both OnPaintBackground and OnPaint methods are called directly from the window message WM_PAINT
-
Sep 10th, 2003, 10:39 AM
#8
I wonder how many charact
Q: I have been working on a custom control that can be resized and moved around at runtime And I am wondering is there any easy way to get the paint result of lets say a combo box after giving the size. I would like to be able to retrieve the comboboxes paint and use it to paint over my control that way I save time having to do all the code to process and make them look the same. Note this is for designing at runtime so the controls do not need to be interactive beyond moveable and resizable which I have already taken care of.
A: Joe, I think what you are looking for is a combination of the InvokePaint method on the Control class (raises the paint event for a control you specify) and overriding the Paint event itself. You can find out more about the InvokePaint method at http://msdn.microsoft.com/library/de...aintTopic.asp, and more about Overriding the Paint event at http://msdn.microsoft.com/library/de...aintevent.asp.
-
Sep 10th, 2003, 10:55 AM
#9
The first thing I thought of was the styles too but I played with them and it didn't seem to have any effect.
I'll look into the InvokePaint thanks for the help.
-
Sep 10th, 2003, 11:24 AM
#10
Here is a picture of what I mean:
-
Sep 10th, 2003, 11:26 AM
#11
-
Sep 10th, 2003, 12:02 PM
#12
just a question
you had this somewhere in your code
For Each ctrl As Control In pnl.Controls
I'm at school right now and I'm using vs2002 and not 2003. vs2002 gives an error for that line. Heh it's kinda like the C++ way of writing code. I'm just wondering, is that valid in vs2003?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 10th, 2003, 12:06 PM
#13
Yes it was something new they added to VS 2003. I believe you could always do that in C# too. It makes For each loops more convenient.
-
Sep 10th, 2003, 12:10 PM
#14
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 10th, 2003, 01:02 PM
#15
Hey where did Lethal's post go? That helped me figure it out (sort of).
Well it seems the problem is in using ControlPaint's DrawBorder method. If I draw using normal paint methods or even other methods from ControlPaint then it works fine. So I'll just draw the border's myself. Thanks.
ControlPaint is an object that makes painting control parts easier.
CORRECTION: Its not even the method its using the ClipRectangle as the rectangle. If you use x0,y0,me.Width,Me.Height then it all works fine.
Last edited by Edneeis; Sep 10th, 2003 at 01:05 PM.
-
Sep 10th, 2003, 02:16 PM
#16
PowerPoster
Yeah, I noticed my post disappeared. Not sure what happened...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|