If I double click top border of a window it will resize vertically from top to the bottom of the desktop, but retain its width.
How do I do it in code?
Probably by just this code:
with Screen.MonitorFromWindow(Handle).WorkareaRect do
SetBounds(Self.Left, Top, Self.Width, Height);
And the following alternative adds an animation:
Hide;
with Screen.MonitorFromWindow(Handle).WorkareaRect do
SetBounds(Self.Left, Top, Self.Width, Height);
AnimateWindow(Handle, 200, AW_ACTIVATE or AW_VER_POSITIVE);
To be able to restore to the previous size, I thought SetWindowPlacement could be used, but I cannot make it work though.
Related
First, if this isn't a great way to do this, PLEASE suggest better. I can't seem to find an exact solution to what must be a common desire (see post title).
My approach was to trap the WM_PAINT message and check whether the window position is maximized. If it is, then run this code:
SetWindowLong(hCDGWnd, GWL_STYLE, 0); // remove all styling
SetWindowPos(hCDGWnd, HWND_TOP, 0, 0, 1280, 720, SWP_SHOWWINDOW); // full screen is 1280 x 720
StretchDIBits(hdc, 0, 0, 1280, 720, CDG_XOFFSET, CDG_YOFFSET, CDG_RENDER_WIDTH, CDG_RENDER_HEIGHT,
bmBits, (LPBITMAPINFO)&bmInfo, DIB_RGB_COLORS, SRCCOPY);
What I want to see is my BITMAP stretched to fill the entire client area, which should just fill the entire screen. Actually it is a section taken out of a larger bitmap. It seems like the window is in fact full screen, but the bitmap is its normal size and not stretched. Curiously, when I was fiddling with the window positioning stuff I had all kinds of attempts leaving the styling but trying to position the title bar and frame offscreen (see below) - the bitmap was appearing stretched just fine during those close but failed attempts. Now I've got the window right, suddenly the bitmap no longer stretches. Is there something about removing the styling that would screw up the StretchDIBits function?
Also, when I attempt leaving the style in place, and use AdjustWindowRect() to have my client size be fullscreen, it returns {-3, -26, 1283, 723 } which makes sense - 3 pixel border plus 23 more for title bar on top. But, just to explore things, when I don't even test for maximized state, and just make the window have x = -3, y = -26, cx = 1286, cy = 749, then almost everything is fine except the bottom of the window is shy of fullscreen by about 4 pixels. When I make the window height much bigger - say 760 - IT STAYS THE SAME HEIGHT!? I so confused. If try this maneuver only when maximized, it seems like windows ignores my attempts to have the title bar off the top of the screen.
I have a scrollrect object on a UI canvas that has a viewport object child, and the viewport object has a content object child that stores all of the items to be scrolled.
I have selected the viewport for reference. I want to resize the viewport rect relative to LevelScroller (see hierarchy) in order for there to be a margin around the scrollview, so that the scrolling items do not touch the edge of the gray LevelScroller rect. But the viewport rect is not resizeable. Right now the result is this:
See how the button at the top (1S-Levitation) is cut off by the grey panel. I want there to be a margin between the point where it is cut off and the gray box.
I have tried adding a horizontal layout group to LevelScroller to forcibly add a margin, but this did not work. Why is the viewport not resizeable?
Any help is appreciated
I believe that the viewport is not resizable because it is supposed to manage how your scroll will behave during the user interaction. As an example, you have only one cell in your content container and the user drag it down, once it is released it is supposed to move back to the top of your viewport, and if you put a margin in there it will not be capable of move entirely back to the top.
But hopefully you can do the following trick to have your margin:
Create an empty game object called Scroller and set it as the father of your LevelScroller. Then, set your LevelScroller RectTransform to stretch in both directions, and set the desired margin on the RectTransform Top, Bottom, Right and Left fields. You should have something like this:
LevelScroller as a child with 10 pixels of top and bottom margin
Then create another empty object child of your parent Scroller, and put it behind the LevelScroller. Lets call it BgImage. Now, set the RectTransform of BgImage to stretch in both directions and add an image to it. Ta daaa, you should have now your background with your margins on your viewport.
BgImage working as the background of the LevelScroller
I'm targeting android but I don't know how to layout the UI so it works for all devices. How do I do this?
I have a TextField with a Button for searching and the search results are displayed below in a TableView below. So I have a table view but the bottom is cut off.
this.searchResults = Ti.UI.createTableView({
top:'70px',
height:'450dp'
});
As you can see from the code above I clearly dont know how to do this. How do you lay things out for android?
You can set top/bottom/left/right values. If you want the table to stop at the bottom edge of the screen, you could set bottom: 0. It's the same for iOS.
If I'm working on Android stuff, and I want it to resize proportionate to the size of the screen I often use percentages. So
this.searchResults = Ti.UI.createTableView({
top:'10%',
height:'90%'
});
Alternatively, If you want pin point accurate calculations, you can ask appcelerator for the platform width and height, and resize things proportionately yourself. Like so:
var height = Ti.Platform.DisplayCaps.platformHeight; //Screen height in pixels
this.searchResults = Ti.UI.createTableView({
top:'75dp',
height: (height - (75 * Ti.Platform.DisplayCaps.logicalDensityFactor)) //height - 75dp converted to pixels
});
I have an NSScrollview that takes up an entire window. The scrollview has a vertical scrollbar but no horizontal scrollbar. The window color is gray. The window is resizable.
Cocoa automatically draws a white square with a light gray border around the window's resize handle (right below the bottom of the vertical scroller). I would like to remove that little white square so that the gray window color and resize grooves show through. How do I do that?
Share photos on twitter with Twitpic http://twitpic.com/show/thumb/27dcp1.png
Just a guess, but try setting the scroll view's background color to [NSColor clearColor].
Send the window a setShowsResizeIndicator:NO and draw your own indicator as you like...
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.