Screenshot of form whose dimensions are greater than screen dimensions - windows

I have a TForm object whose height is greater than the required vertical resolution of my screen.
For some reason, Windows doesn't allow the visible (client?) area of the form to exceed the screen resolution, so vertical scrollbars appear on my form.
How would I get a TBitmap image or screenshot of the entire form (no scrollbars, all form components visible) so that all content of the form is visible?

At first you have to make sure the form has no scrollbars. For that you can write an event handler for FormConstrainedResize and adjust MaxWidth and MaxHeight to your needs. If the form size is restricted during design, set the required Width and Height in the FormCreate event to the desired values.
Now you can use GetFormImage to get the screenshot.

Related

SwiftUI Button height on watchOS

On iOS by default if you add the button in SwiftUI its size is equal to the size of the text. Setting the padding to some value expands the size to be bigger than the text by that value.
On watchOS by default the button has the text and background with applied padding. I don't see any way to reduce that padding (to make the button height closer to the height of the text). I have tried with setting padding and frame but it doesn't appear to be helpful - it appears even counter intuitive as increasing the padding reduces the height of the visible button but it keeps the overall size of the button in the layout which still isn't helpful.
Just to note that with storyboards this reduction of height is possible so I would assume that there should be a way in SwiftUI.
Set the button’s buttonStyle(:) to PlainButtonStyle() and you’ll have full control over the padding and frame. The downside is that you no longer get the default button background, so you’ll need to recreate it if you need it.

Scrollview in Interface Builder with Autolayout with content size dynamically set to screen size?

I want to set the content view of a scrollview to whatever the current screen size is, but AutoLayout is doing some funky stuff. This is trivial in code... just create a scrollview with a frame that is the superview's bounds. Then create a content view with the scrollview bounds and populate it and set the alwaysBounces... properties to YES. In interface builder though, this is some kind of sinful thing it seems.
I know Autolayout handles scrollviews totally differently because it wants to infer the content size based on constraints. My approach that failed is setting the scrollview to have 0 distance to its superview (all sides attached). Then, the same with the content view (the single scrollView subview)- attached to all superview edges. Then the precompiler thing complains about not knowing the content size, so I set a width and height constraint at placeholder to be removed at build time. But the result is a (CGRect){0,0,0,0} contentView. The 0 space to trailing edge and bottom of superview are totally ignored.
So how can I make a scrollview with a dynamic content size based on the screen size?
Bonus points if you can explain how you would do the same, but for a content size of 2x screen width.
You can try setting a constraint for the content view's width to equal the scroll view's width (for your bonus question: with a multiplier of 2). Same for height.
Not sure what the point of having a scroll view whose content is always the size of the scroll view is. By definition it wouldn't scroll, right?

JavaFx image resizing

I have a borderPane with a menu top,a grid left and an image in the center.I want the image to have the same size as the center of the border because now the image goes over my grid.
I tried this:
imageView.fitWidthProperty().bind(box.widthProperty());
where imageView is the name for my image and box is the BorderPane object.Thank you.
See JavaFX Feature Request RT-21337 Add ImageViewPane and MediaViewPane controls which contains a code attachment for a sample ImageViewPane implementation which which will resize the ImageView it contains to the area available to the region. To get the behaviour required you might also need to implement computeMinWidth and computeMinHeight on the ImageViewPane so that they return zero rather than the minimum size of the Image.
now the image goes over my grid
This is because the minimum size of your image is currently larger than the available space of the center of your BorderPane:
BorderPane does not clip its content by default, so it is possible that childrens' bounds may extend outside its own bounds if a child's min size prevents it from being fit within it space.
Some potential alternatives to prevent the center content overflowing the border:
Manually set a clip on the center node to prevent it overflowing the borders.
Dynamically resize the ImageView as in the ImageViewPane sample linked above.
Place the ImageView in a ScrollPane.
Use the css -fx-background-image attributes to display and dynamcially resize your image rather than using an ImageView.
Set the center of the borderpane first before setting the border content, that way it will be rendered underneath the border content.
Use a different construct from a borderpane (e.g. a HBoxes, VBoxes, etc.) which don't overlap their nodes when the nodes are larger than the available display area.
I tried this: imageView.fitWidthProperty().bind(box.widthProperty());
My guess from the code provided is that this didn't work because the enclosing box of the image is a dynamically resizable pane of some sort, so the minimum width of the box is being determined by the width of the image and not vice versa.

gwt - trigger recalculation of 100% width

I have a ScrollPanel in which
I have a FlexTable with two columns and a dynamic number of rows.
The first column only contains Labels, the second various widgets.
Some of those widgets in the second column are manually layed out triggered by a ResizeEvent.
When one of those manually resizing widget is present, and the browserwindow gets resized to a smaller size, then vertical scrollbars will apear and allow to scroll the area in the size that was previously present. When I resize a second time then the width of the first resize-step will be the new minimum size that the ScrollPanel will represent.
This problem only exists for firefox and chrome, IE does work as expected.
I tried to manually call my resize procedure twice with the same ResizeEvent but that doesn't help. I also tried to fire the ResizeEvent on the ScrollPanel after my widgets have completed their manual resize procedure, also had no effect on this problem.
I cannot disable the vertical scrollbar completly. Some of the widgets have a minimal width, and if the browser gets smaller then the biggest minimal width + the width of the label column than the scrollbar is necessary.

Zooming an image inside a picture box

I'm have a picture box control and 2 Command Buttons. I have an image displayed inside the picture box.
Is it possible to zoom the image when the Zoom-in and Zoom out buttons are clicked?
Or I can even put a scroll bar. Is it possible to zoom the image according to the scroll bar movements?
I'm using VB 6.
I assume here that you are using BMP or JPG files here.
The simple scratch method is to place an Image control in the PictureBox, initially with the property Stretch = False. Initially, it would be in the top left hand corner. After setting the Picture property to your picture object, the Image control will be resized to fit the image. Save the original width and height of the control in variables. Now set Stretch = True. You can zoom in by resizing the image using
img.Move 0, 0, sngWidth * sngMagFactor, sngHeight * sngMagFactor
Where sngMaxFactor = 4! or however much you want to zoom by.
Restore back to original size by:
img.Move 0, 0, sngWidth, sngHeight
You can also pan the zoomed image by altering the Left and Top arguments in the Move() method.
It might be easiest to use two pic boxes, one inside the other. The 'outer' box can be thought of as a viewport into the 'inner' box, which you resize and position as needed. The effect will be the same but the coding is much simpler.

Resources