FillRectangle drew 12 squares, can also be understood as 12 pixels, how to use the mouse to drag any box and then select one or more squares, moved to any position and drag by effect, the great god come and teach,
CodePudding user response:
Don't use gdi +? Selection problem itself is a container of the item the mouse, use gdi drawing, a lot of logic have to realize, too much trouble.CodePudding user response:
This plainly is the calculation of coordinates1, the size and location of the storage 12 squares
2, the MouseDown, judgment, in which box to record the location of the mouse MouseDown
3, when the mouse MouseMove, according to the offset, to assign a value to grid coordinates, redrawn again can
CodePudding user response:
You just realized drawing here, which doesn't have anything to do with drag and drop something, drag and drop API is to use the system to respond to mouse events, according to the type of event to handle the corresponding contents, according to your demand, is actually in the mouse press, continue processing MouseMove event, according to the location of the mouse to draw, you need to define a type to describe the various states of these graphics, such as position, color, etc, and then create a global object, change the state of these objects in the mouse events, redrawn notice again, refresh interface, so basically can achieve the effect you want.CodePudding user response:
Need regular development of custom controls,The so-called "GDI + drawing" usually refers to the canvas line draw some points on the surface, such as the lowest operation, then also don't understand this sort of thing at all controls the development level of knowledge, how to apply controls general idea? You'll develop controls, developed dozens of hundreds of controls, to the initial structure,
Use controls and some people will say: "too slow, not directly on the canvas with GDI + drawing fast", this is really a paradox! Pick up, drag, and so on operation is "control design techniques", if some people say that all the controls are not suitable for drawing, that is to say all round is square, there is no any word,
CodePudding user response:
For example "redraw", then what redraw? Have a think about?It is impossible for a random draw on the canvas, to tens of thousands, hundreds of thousands of other visible coordinated control, such as you draw casually, so when you "drag" how to make other controls (don't know when you write a program, in the future to develop and add tens of thousands of control instance) graphics are not affected and can redraw, drag the mouse when how can "through" behind the various controls and drag objects without losing track of pick up? And so on, these are the basic knowledge of control, without control knowledge like primary school grade 5 students learning college physics, calculus is too early,
CodePudding user response:
https://pan.baidu.com/s/1pib7dSQpp_BekucuLxgbNAThe extracted code: exw5