Drawing A Resizable Rectangle (by Edge/corner Dragging)?
Jul 19, 2003
I am trying to make a rectangle that can be resized by the userby clicking and dragging the edges/corners of the rectangleTypically, if the mouse enters the rectangle region, then smalladjustment boxes should appear at the corners of the rectangleand also at the middle of the rectangle's edges (to allow the userto drag and resize the rectangle). When the mouse leaves therectangle region, then the adjustment boxes should disappear.I have the code to draw the rectangle and to produce the smalladjustment boxes, but I'm not sure how to accomplish thedrag and resizing steps (or if it's even possible with the way mycode is written).
Code:Imports SystemImports System.DrawingImports System.Windows.Forms
Private bBlocking, bValidBox As Boolean Private pt1, pt3 As Point Private rectBox As Rectangle Private cornerRect1 As Rectangle Private cornerRect2 As
I want to write a vb program to allow user to draw rectangle. User can click on a point as starting position and drag on the screen. A rectangle is drawn with the current mouse position and the starting position. The user then release the mouse as end position. When the rectangle is drawn, user can resize the rectangle by drag the border of the rectangle.
I'M creating a kind of photo viewer, and I cannot figure out how to orient the scroll buttons with the photos I want to draw because they all are different sizes.This is really hard to explain so please ask questions if you don't understand.I'M thinking if i could draw every photo on a single rectangle and then the scroll bars will position that rectangle up or down. but is there a way to make a rectangle inside another one so it only shows inside that rectangle?
I have used this code to draw an rectangle around the panel
vb
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.PaintWith Panel1 e.Graphics.DrawRectangle(Pens.Gray, .Left - 1, .Top - 1, .Width + 1, .Height + 1) End WithEnd Sub
but when the form is resized the rectangle isnt drawn properly.The panel has Left,R,T,B anchor.
Okay, I've got a rectangle shape named Header and in the form class I Dim a new rectangle named DrawingRect. Here is the code that I used to set the location coordinates and size.
Dim DrawingRect As New Rectangle(Header.Size.Width - 18, Header.Size.Height - 17, 14, 14)
Whenever I run the program, however, it stops me and says "InvalidOperationException was unhandled". How do I get this to work?
I have made a program that lets you select an area of a picture and then crop it, I am having problems while drawing the rectangle that shows which area will be cropped, following is my code.
[CODE].............
This is declaration of all the variables that I am using.
[CODE].............
Over here I send the graphics handle of the "canvas" control (which is just a picturebox) to a higher level, so I can use it later.
[CODE].............
Over here I get the starting position for my rectangle
[CODE].............
This part is supposed to draw the rectangle, as I am moving the mouse over the Canvas control, but I get an error where the rectangle is being drawn, I originally thought that the problem might have been with the fact that as soon as I begin moving the mouse, the CropWidth and CropHeight variables are at zero, and that is causing the invalid input error. So I made it that it would not draw the rectangle until it reached a minimum size of 4 x 4 pixels but it still does not fix the error, I debugged to see if there was a problem with the values of the variables, but they all seemed fine, I even tries doing this CanvasGraphics.DrawRectangle(Pens.Red, 20, 20, 20, 20) so as to eliminate the factor of the wrong values, but still the same error.
I'm just getting started, and it's as simple as that: I need guidance to draw a rectangle or place a dot or a point on Form1, in VB 2008 Express. I knew how in VB6 -- let's build on that.
Clicking on the picture will cause the picture to move in the following manner: * If the picture is in the top left corner, it will move to the center, then to the top right corner * If the picture is in the top right corner, it will move to the center, then to the lower right corner * If the picture is in the bottom right corner, it will move to the center, then to the bottom left corner * If the picture is in the bottom left corner, it will move to the center, then to the top left corner
I'm drawing a rectangle snapped to a grid by getting the start point(Mouse down e.location) and the end point(mouseup(e.location). The coding I'm having trouble with is having the program determine which way to draw the rectangle(where the location should be, and the height and width.) Now, this would be extremely simple if the user started their rectangle from the top left corner and ended it in the bottom right every time. But you need to be able to drag from all angles. So does anyone have some code lying around that I could look at so I could actually get my rectangles drawn right?
How can i draw text(demo demo) on exist image from top right corner to bottom left corner of exit image (on photo) in windows based applicaiton using vb.net.
I'm making a custom class that mocks the System.Drawing.Rectangle class because the Rectangle class doesn't have a name property. I need a name property because I am adding all of my rectangles to a collection and I need a little more info stored than just their locale and size. So I changed the _onPaint event but nothing is working out when I run the program?
Public Class Rectanglar : Inherits UserControl Public BackgroundColor As Color = Color.Blue Public Sub New(ByVal name As String, ByVal XY As Point, ByVal Widthy As Integer, ByVal Heighty As Integer)
Given a rectangle of width w and height h. and a coordinate x,y in that rectangle I would like to identify which triangle I am within.
i.e. the function should take parameters(x,y) and return a,b,c,d or a zero based number representing that triangle index i.e. (0=A,1=B,2=C,3=D) if they are in that order.
I think this would be something like >= the formula of the red line and >= the formula of the green line?
I just made a basic browser using VB... So now I am wondering how to make it resizable so that when it is resized the browser and buttons remain in same layout but the text box and browser space resize to the new screen size and the buttons do not change layout or get covered (it has buttons for back, forward, refresh, home, and stop then a text box for the url and then a go button, I want them to remain in same order but the text box to enlarge and the go button to keep to the right side of the box - and I want the browser spot to grow too).
I have to implement an application that allow the user to design his own card, the user will be able to drag and drop controls from toolbox and move them in the form and re-size them.
I can't make the control to be resizable,and i want to make the control just like the one in visual studio designer with the container that allow user to change the size ..
I am running a program that needs to allow the user to be able to change the size of a text box at run time. I know I need to use the MouseDown, mouseMove, and mouseUp events. I just need some help with the coding to send the information.
I do want my windows to be resizable i.e. the MDI Child ws should not be resizable. owever, I could not find any property which I can set for the same.
Recently I was working on a project that included several DataGridView objects. With one, I dynamically create columns based on the types of data being displayed. I established a baseline size (so each column would initially display the same width), and a minimum size. AutoSizeMode was set to None. I knew that I wanted the new column to be resizable by the user, so I put in code to that effect: Resizable = True
When I tested the code, the columns were not resizable. I traced the code, looking for anything that would reset the property Resizable to False. Nothing. I commented out the line with the Resizable = True command; The columns were resizable after this. At this point, I remembered that Resizable is defaulted to true. But I still did not understand why the columns were not resizable after setting the property to True.
I did some experiments. If you create a new DatagridViewTextBoxColumn, add it to the DatagridView, and then set the Resizable property to True, the result (via Watch) is False {2}. If you do the same, but set the Resizable property to False, the result is True {1}.
This is disturbing (and confusing) on at least two levels. The fact that the exact opposite boolean value is passed in. The fact that {2} is False. It was always my understanding that VB treated {0} as False, and Any other value as True.
I have two DataGridView controls, with three buttons in between them vertically, in a VB 2005 form that need to be resized and moved around on a form resize.
The code below works, and does what I want. It takes the difference between the new size and the default size, splits the height difference between the two DataGridViews, and moves things around correctly.
What bugs me about it is that I've hard-coded the defaults into the ResizeEnd handler. How would I go about passing the default size so that I don't repeat myself?
Even better, is there a way to do it with anchoring, docking, and other stuff, so that I don't even need to write code?
Private Sub dlgShowAssets_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd Dim defaultWindowSize As New System.Drawing.Size(759, 619)
I am trying to create TextBoxes and RichTextBoxes that can be moved and resized durig runtime as part of a program that makes/edits media-slides for online learning. The textboxes can currently be moved and resized by filling out the values for Top, Left, Height and Width on "property sheets", a method I would like to change into something a little bit more user-friendly
I created a user control with besides the TextBox or RichTextBox 3 objects to control the moving.I have currently added 3 panels to try to use for this purpose.I have written all the code to resize the TextBox when my new control is resized and when theMoveAndResizeHandles are set to be visible.The resize panels are currently 10 points x 10 points (easy to change because the 10 points are defined in a constant) and located top left above and bottom right under the textbox. The panel to resize is located next to top-left panel and has the width of the textbox - 10 pixels
My question at this point is: were Panels an appropriate choice or is there a more fitting way to do this? -and-
Which events should I use to check for movement and resizing of the control? I would start looking into "dragging and dropping" as event, but I have as yet no idea wether this will work and what the gotcha's will be in my approach.