Home > Net >  Questions about Picturebox drawing
Questions about Picturebox drawing

Time:03-12

Idea is set a Picturebox1 to another Picturebox2 parent window, 1 loaded background here, WMF files, 2 in the drawing,
Why can the drawing, but it is not a flash,
What a great god can solve, thank!

Private Sub Button1_Click (ByVal sender As Systemobject, ByVal e the As System. EventArgs) Handles for. Click
DrawALine (PageToShow, Color Red, 50, 50, 5, 100)
End Sub

"Establish a mapping of the following functions
Public Sub DrawALine (ByVal WhereToDraw as Picturebox, ByVal Draw_Color as Color,
ByVal StartPoint_X As an Integer, ByVal the StartPoint Y As an Integer, ByVal Line_Width As an Integer, ByVal Line_Height As Integer)
Dim Pic As New PictureBox
With Pic
.name="Pic"
Size=New Size (Line_Width + 6, Line_Height + 6) SizeMode=PictureBoxSizeMode. StretchImage
The Parent=WhereToDraw
Location=New Point (StartPoint_X - 3 StartPoint_Y - 3)
End With
Dim g As Graphics=Pic. CreateGraphics () defines the canvas Dim DrawPen As New Pen (Draw_color Line_Width)
G.D rawLine (Draw_Pen, 3, 3, 3 + Line_Width, 3 + Line_Height)

Ernd Suib

CodePudding user response:

There may be knocked at the wrong in the sentence, the code is modified based on photo scanning, you forgive me

CodePudding user response:

You know how the control display?
Painting background control first, and then apply colours to a drawing control, and then perform user mapping,
Your event to the button on the control mapping, when control obscured or refresh, can make the control system is invalid, trigger the WM_PAINT, redraw the control, before you paint is not
You can put the code on the control of Paint, but will be flashing, you could look at the double buffer drawing can solve your problem.

CodePudding user response:

reference rabbit party at large on the second floor response:
you know how to control is displayed?
Painting background control first, and then apply colours to a drawing control, and then perform user mapping,
Your event to the button on the control mapping, when control obscured or refresh, can make the control system is invalid, trigger the WM_PAINT, redraw the control, before you paint is not
You can put the code on the control of Paint, but will be flashing, you could look at the double buffer drawing can solve your problem,

Thank you bosses answer, I was programming enthusiasts, the foundation is not solid,
Just I put this function in WhereToDraw Paint, can complete shows,
But my purpose is to want to do a by calling a function to draw many parameters of different shapes, and each graphics can drag small programs alone,
This don't know whether you glad, thank you very not,

CodePudding user response:

In the parent window Paint event functions. Add PageToDraw invalidate () to the
New problem appeared again, don't refresh is brought about by the window after the change, painted Picturebox control turned black

CodePudding user response:

1. The PAINT event put on drawing code
2. Your so-called elsewhere, then modify the rendering code used elsewhere parameters, and then perform a control invalidate method can,
  • Related