retaining the relative position of objects while resizing in windows form - vb.net

I am using Visual Basic in Visual Studio 10 .I have a windows form and I have to display a world map(a jpeg displayed in picturebox ) with radio buttons over each of the country . The problem is while resizing the window the radio buttons get dislocated. One way to fix this is calculating the ratio of
Scree.width/(initial x-coordinate of radio box)
and similarly
Screen.height/(initial y-coordinate of radio box)
and using this to generate the new x and y coordinates after resizing but as the number of countries are too large this is very tedious and for smaller countries the difference in the initial coordinates is not much and due to precision loss in higher resolution the radio box are overlapping. Is there a workaround for this. Also the method described isn't working after adding zoom as the portion of image displayed on screen changes and as a followup I would like to ask how can I add sliding functionality to image ( like after clicking the mousedown and moving the pointer should move the image keeping the radio boxes over the respective countries, Is using scroll bars better for this purpose? )

Replace your PictureBox with a Panel.
With the PANEL and your IMAGE set:
PANEL.BackgroundImage = IMAGE
PANEL.BackgroundImageLayout = ImageLayout.None
PANEL.AutoScroll = True
PANEL.AutoScrollMinSize = IMAGE.Size
At last, add all RadioButtons to the PANEL.

Related

how to clip a dynamically created dialog controls

I have a dialog window (MFC, CDialogEx) on which I am displaying some kind of information - mostly text, with some hints about the context (hints made with background color, presence of frames and formatting). Text and everything is written in OnPaint(), using standard CPaintDC dc(this);. Text is long, so everything is scrollable and clipped (with dc.SetClipRgn) to the client area of the dialog (minus some margins). So far, so good, everything works as expected.
On top of that I wanted to add radio buttons that will allow showing cross links between parts of the text (this is kind of a story telling system). No problems with adding them either:
CButton* pCB = new CButton;
pCB->Create(_T(""), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | WS_GROUP, cr, this, iButtonNo);
pCB->ShowWindow(SW_SHOW);
(cr is a CReg with button coordinates, iButtonNo is a control ID). Now, when I scroll the dialog I just call SetWindowPos for every radio button to move it together with the text - and it works OK too.
The only thing that I have no idea how to deal with is the radio button clipping. At the moment they are drawn on the whole dialog window. Is there a way to clip the buttons to the same region my text is clipped? I tried to pass the clipping region to the CButton DC (plus some other tricks I could think of) but to no avail.

Make a responsive form in design view (not programmatically)

I am doing a WinForms program which should have a fully responsive design in a full screen.
I get an approach which works more or less well. It consists into calculate a ratio between display screen and original form size.
Then I apply this ratio to the width, left, height, top properties of each control inside the form.
My doubt is about to use a native way for doing this, since, using anchors, the controls keep their same distances with parent control borders, but I doesn't do proportionally, for instance:
Form with 100x100
Button 20x20 located in (10,10)
If I resized the form to 200x200 (multiply by 2), the best approach I can do in design view is keeping the four anchors to the button, so button size will be 120x120 at the same position (10,10), while what I need is a button with size 40x40, at position (20,20), since form size was multiply by 2.
Is it possible with winforms native operations in design view? (Avoiding to make calculations)
Yes it is possible.
Using the Property Dock = Fill you can ask for a component to take all the room in its container.
Now using a TableLayoutPanel, you can define cells to put your components in. And giving cell a percentage size, you can make sure the sizes will change when the form is resized...
Here are more information on these things :
Dock Property
TableLayoutPanel Class
TableLayoutPanel Tutorial

x and y coordinates of mouse location in Photoshop

How do I turn on the X and Y coordinates for the location of the mouse on screen?
I have Photoshop CC. I'm creating interfaces and would like to be able to know the location of my mouse.
Although I can't currently check as i don't have photoshop CC on this computer, from past experience if you go
Window -> Information
A palette should appear with the coordinates of the cursor in it.
Press F8 to open info palette. That will show your mouse position in x and y coordinates.
You can also press Ctrl + R to view the ruler. Then take the mouse to the top left corner and by dragging from there you can change 0,0 coordinates of x,y position to anywhere on canvas.
when you draw something like rectangle and draw with pressing space bar. It will show lively width height and x y coordinates as well in Photoshop CC
Position with guides and the grid
Guides and the grid help you position images or elements precisely. Guides appear as nonprinting lines that float over the image. You can move and remove guides. You can also lock them so that you don’t move them by accident.
Smart Guides help you align shapes, slices, and selections. They appear automatically when you draw a shape or create a selection or slide. You can hide Smart Guides if you need to.
The grid is useful for laying out elements symmetrically. The grid appears by default as nonprinting lines but can also be displayed as dots.
Guides and grids behave in similar ways:
Selections, selection borders, and tools snap to a guide or the grid when dragged within 8 screen (not image) pixels. Guides also snap to the grid when moved. You can turn this feature on and off.
Guide spacing, along with guide and grid visibility and snapping, is specific to an image.
Grid spacing, along with guide and grid color and style, is the same for all images.
Show or hide a grid, guides, or smart guides
Do one of the following:
Choose View > Show > Grid.
Choose View > Show > Guides.
Choose View > Show > Smart Guides.
Choose View > Extras. This command also shows or hides layer edges, selection edges, target paths, and slices.
Place a guide
If the rulers are not visible, choose View > Rulers.
Note:
For the most accurate readings, view the image at 100% magnification or use the Info panel.
Do one of the following to create a guide:
Choose View > New Guide. In the dialog box, select Horizontal or Vertical orientation, enter a position, and click OK.
Drag from the horizontal ruler to create a horizontal guide.
Drag to create a horizontal guide
Dragging to create a horizontal guide
Hold down Alt (Windows) or Option (Mac OS), and drag from the vertical ruler to create a horizontal guide.
Drag from the vertical ruler to create a vertical guide.
Hold down Alt (Windows) or Option (Mac OS), and drag from the horizontal ruler to create a vertical guide.
Hold down Shift and drag from the horizontal or vertical ruler to create a guide that snaps to the ruler ticks. The pointer changes to a double-headed arrow when you drag a guide.
(Optional) If you want to lock all guides, choose View > Lock Guides.
Move a guide
Select the Move tool , or hold down Ctrl (Windows) or Command (Mac OS) to activate the Move tool.
Position the pointer over the guide (the pointer turns into a double-headed arrow).
Move the guide in any of the following ways:
Drag the guide to move it.
Change the guide from horizontal to vertical, or vice versa, by holding down Alt (Windows) or Option (Mac OS) as you click or drag the guide.
Align the guide with the ruler ticks by holding down Shift as you drag the guide. The guide snaps to the grid if the grid is visible and View > Snap To > Grid is selected.
Remove guides from the image
Do one of the following:
To remove a single guide, drag the guide outside the image window.
To remove all guides, choose View > Clear Guides.
Set guide and grid preferences
Do one of the following:
(Windows) Choose Edit > Preferences > Guides, Grid, & Slices.
(Mac OS) Choose Photoshop > Preferences > Guides, Grid, & Slices.
For Color, choose a color for the guides, the grid, or both. If you choose Custom, click the color box, choose a color, and click OK.
For Style, choose a display option for guides or the grid, or both.
For Gridline Every, enter a value for the grid spacing. For Subdivisions, enter a value by which to subdivide the grid.
If desired, change the units for this option. The Percent option creates a grid that divides the image into even sections. For example, choosing 25 for the Percent option creates an evenly divided 4‑by‑4 grid.
Click OK.
To the top
Work efficiently with Smart Guides
Smart Guides come in handy in several scenarios, such as the following:
Option (Mac)/Alt (Win) + Drag a Layer: When you drag a layer while keeping the Option (Mac) or Alt (Windows) key pressed, Photoshop displays reference measurement guides showing the distance between the original layer and the duplicate layer. This feature works with both the Move and Path Selection tools.
Distance between the layers: original and duplicate
Distance between the layers: original and duplicate
Path measurements: Photoshop displays measurement guides while you're working with paths. Measurement guides are also displayed when you select the Path Selection tool and then drag a path within the same layer.
Path measurements
Path measurements
Matched Spacing: When you duplicate or move an object, Photoshop displays measurement guides to visually indicate spacing between other objects that match the spacing between the selected object and its immediate neighbors.
Cmd (Mac)/Ctrl (Win) + Hover Over a Layer: You can view measurement guides while working with layers. With one layer selected, hover over another layer with the Cmd (Mac) or Ctrl (Windows) key pressed. You can use arrow keys in conjunction with this feature to nudge the selected layer.
Measurement guides while working with layers
Measurement guides while working with layers
Distances from the canvas: When you hold down the Cmd (Mac) or Ctrl (Windows) key while hovering outside a shape, Photoshop displays distances from the canvas.
Distances of a shape from the canvas
Distances of a shape from the canvas
Spacing between matched objects

Vb.Net Label always centered

I'm using vb.net to make a screen saver.
I want my label where the text shows to always be centered no matter what screen size it is.
is there a way to get the screen resolution of the current monitor?
if i can get that then i can calculate the middle and set my label there.
Stretch the label to the whole width of the form and dock/anchor to left and right side within the label parameters. This will center your label whatever the size of the form.

Controls change place and form size changes

I have designed a form in VB.NET. At design time I have placed two buttons on it.
When I run it, the form size looks smaller and the buttons I have placed at the bottom are not visible. Also the alignment of the text and picture box is also different from what I set at design time.
Computer at which I am running the form is using a different resolution.
change the properties (F4) of the buttons: in ANCHOR put Bottom, Right
your buttons will be tied to the bottom and the right of the screen, instead of to the top, left, which is the default.
Grab the screen size at runtime with
Dim screen as System.Windows.Forms.Screen = System.Windows.Forms.Screen.PrimaryScreen
and using a scale factor depending on the current size (in design), scale the window to match. Check the coordinates of the buttons by hand to make sure they are not outside of the visible portion of the window.
You may not have to leave this feature in if you can debug it to the point that you know the exact resolution that you need.