Selecting a drawn line with the mouse VB.net - vb.net

If I have a form with a line drawn on it how can I select that line by clicking on it with a mouse button, so that I can then do things with it like delete or modyfy?

You need to do some maths to see if the clicked mouse point lies on the line in question:
http://forums.codeguru.com/showthread.php?419763-Check-a-Point-lies-in-a-Line-segment
However you may need to add some tolerance because the user may click one pixel away but still expect the line to be selected. Also you may need to think about what happens when two lines intersect or are drawn over one another?

Related

How can you keep the current line centered vertically in the editor

I've searched all the settings and Google but can find nothing. It seems such an obvious feature. If I use the arrow keys to scroll vertically through the code, I quickly end up with the cursor at the top or bottom of the screen whereas I really want to be doing my editing near the centre of the screen, which means I have to do two operations: scroll the code to where I want it and then move the cursor.
What I want is to hit a shortcut (e.g. the Scroll Lock key) and then when I press up- or down-arrow the cursor stays where it is (relative to the screen) and the code scrolls past it.
I've read that some tools allow you to set the number of "always visible" lines above and below the cursor which would do the job, but I can't find that in Rider either.
Am I missing something obvious, or is there an add-in or something I can customize to get what I want?
Found it! There are Move Up and Scroll and Move Down and Scroll actions in the keymap settings. Assign hotkeys to them (weren't assigned in my config) and it will work like you described it.

VB Form Not Holding Format

In the design window, I have my controls formatted one way, but when I run my program, the formatting changes. The window looks larger and the digit button is no longer aligned. I have no clue how to fix this. I am taking an intro level course, so I can't fix this with code. When I wrote my first couple of programs, I didn't have an issue with resizing, but for the last two or three, they never hold their size.
My Program
the above issue please check the anchor tag of each control it should be Top left.
To hold the control position
1 Add panel control to form then dock it to form
2 Add the other
control it will hold the control position as well

PowerPoint animation issue: one name, picture appears, disappears, second name appears in the same place

I have been playing with animations in PowerPoint, but this relatively simple thing seems to be beyond my range. I want on the first (title) slide, one name with his details to appear below, then disappear on clicking (or pressing "n") and then another name should appear in the same place (where the first name was) with his details. If this can be managed with animations, fine, otherwise I am open to use VBA macros also.
If this is too easy, I would like to add a symbol/picture (.bmp) for the first person to appear in the middle of the slide, which would disappear with that name, and then with the second name appearing, the second picture/symbol (.jpg) should appear in the middle of the slide. I will be glad if someone can show me how to do this. Thank you very much.
I don't think you'll need to use macros. I can't picture exactly what you want the presentation to look like, but this sounds quite easy. I'll give you an instruction list, as clear as I can make it.
Place the item(s) (the placeholders containing the name and details, as well as the pictures) you want to animate into your presentation, in the positions you want.
Select the item(s) you want to appear first, and choose a suitable entrance effect from the Add animation menu.
Bring up the animations pane from the animations ribbon, if you haven't already done so. If you wanted multiple items to appear at once, then set any extra items to with previous.
Do the same with an exit effect (on the same item(s)). They should be after the entrance animations on the animation pane. The first (from the exit animations) should be on click; the rest should be with previous.
Select the next item(s) you want to appear, and choose an entrance effect. Instead of on click, choose after previous.
Test to see if everything works the way you want it to.
I've done my best to make this as clear as possible, but if there was an inaccuracy, or something unclear anywhere, then please let me know.

Draw border around controls on VBA Userform without using a Frame?

I am designing a VBA UserForm (in Excel, if it is relevant) and I would like some controls to be visually grouped together.. but when I put them in a frame, I am getting some undesired results (part of it has to do with the RefEdit control which seems to be particularly unhappy inside a frame).
Is there a way to draw a border around a group of controls on a form without putting them inside a Frame?
Use a label with the caption deleted and the border style set to fmBorderStyleSingle. It may appear on top of your other controls, so right click on it and select "send backwards" until it's behind your other controls.
The best way to do this would be to create the shape over where you need it to be. Drag highlight everything that you want on top of it, then right click and brink it all forwards. Then when you drag your shape back over the top it will in fact be underneath everthing else.
Hope that helps.
This worked for me and I was at first having the same issue where I had to choose to "Send Backward" up to 30 times per label in some cases. I found that hitting the Ctrl-K sends it to the back of all controls with one time hitting these keys.

Rectangles & Parsing in vb.net

This is kinda....a two part question. The first one is much more important than the second one, both of these are in the same project, and in vb.net.
How can I constrain the bounds of a rectangle object, which is controlled by a mouse, so it cannot be drawn outside a PictureBox? It is kindof a standard lasso control, the user can click and drag and it will draw a box from the initial click point to the mouse's current location. The starting point is at (rectX,rectY), and the box is drawn to the bottom right using rectDimX and rectDimY (to set the width and height) to see how much of a change has occurred with the mouse. Basically, its what you get with a click and drag on a Windows desktop. The issue here is that the rectangle is able to be drawn outside the PictureBox it is being drawn on, and the next part of the code attempts to reference this location, and then fails with an OutOfMemory exception. This leads me to my second question:
How can I make the rectangle draw in more than the fourth quadrant, which is only positive numbers? If it goes anywhere else, it does not show the rectangle, though it does still have the correct values. I know i could code this four times based on starting location and mouse location, but that would be a huge hassle and a rewrite of the whole rectangle code.
Is there an easy solution for either of these? The first one is a much bigger hassle, as it will be very time consuming if there is no easy way.
Thanks for the help!
For the first part of your question, even if the user drags the mouse beyond the edge of your picture box, you don't have to use those coordinates for your drawing routine. Simply do something like
If (DrawingPoint.X > PictureBox.Right)
DrawingPoint.X = PictureBox.Right // Right-hand limit of picture box
End If
And similar for the Y direction.
As for the negative numbers while drawing, you want to translate screen coordinates to client area coordinates. Have a look at ScreenToClient and ClientToScreen.