Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, I have problem with DragDrop. I trying to move reactangle along with te cursor.

Private Graphic as Graphics= Panel1.CreateGraphics

Private Sub Panel1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles frm.DragOver
Dim NewP = New Point(e.x,e.y)
Dim rec As New Drawing.Rectangle(NewP, SelCtl.Size)
Graphic.Clear(frm.BackColor)
Graphic.DrawRectangle(Penk, rec)
end sub

 

How can i simulate Flip method from DDraw to avoid flickering?

  • *Gurus*
Posted

You'll have to take advantage of the build-in double buffering, which on the face of it is quite easy but you'll have to do a bit of work in this instance to get it working.

 

Firstly, you'll have to inherit from Panel and use your own control instead, because you need to use the protected function SetStyle to enable Double Buffering and other associated styles. Then you'll have to give that control some kind of property for setting where the rectangle should be drawn.

 

Finally, in the DragOver event, instead of drawing you set the rectangle property and call .Invalidate on the control, forcing it to draw itself. Double buffering in Windows Forms only works when the control draws itself in the Paint event.

MVP, Visual Developer - .NET

 

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

 

My free .NET Windows Forms Controls and Articles

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...