Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have made a user control that has a graphic for a backdrop. Its a JPG and I use the DrawImage function to apply it to the form. The image has regions, well more like a lame type of button, so when I move the mouse over them, a rectangle is drawn over them to give it a higlight effect. These regions are stored in an array of rectangles (about 20 of them). So when the mouse moves and the position is inside one of the rectangles, a rectangle is drawn over the button.

 

The problem I am having is the CPU usage. When the form is being display (doesn't have to be in focus), the CPU usage for the app runs at 50%. This will happen when the mouse is still.

 

Is there a way to get around this problem, so when the mouse isn't moving, it wont use as much CPU.

 

I have the AllPaintingInWmPaint and DoubleBuffer set to true. I was messing around with the Mouse Hover event to try to set a variable so when the Paint event ran, I could jump out of the event before any drawing started, and when the mouse moved again, set that variable back. I couldn't get this to work, the event seemed to only fire when nothing had been drawn onto the control.

 

Hope this makes a bit of sense to someone

 

Thanks

Posted

Feel free to delete or ignore or whatever you like...Found my problem. Stupidly, I was calling invalidate inside the paint event...a never ending loop!

 

Don't you feel stupid when you find an error like 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...