Scale all control to window size - visual-studio-2010

I have a dialog based application which contain controls such treectrl,listsctrl and group box contain all the buttons control. I am working in Visual Studio 2010 Professional Edition.All controls are placed in the Dialog at design time and no control is created at run time.
Using
int desktopW = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int desktopH = GetSystemMetrics(SM_CYVIRTUALSCREEN);
got the width and height of window, then found the relative position of the controls.
Using SetWindowPos try to change the width and height of various control, if new width and height is less than old control width and height.
But that involves a lot of calculation.
Is there exist any easy way to change the control position/scaling based on window size?

Use Dynamic Layout for the controls.
See the Properties of each control. Then by using the Moving Type and Sizing Type properties you can specify how the control must move and/or resize as the dialog frame resizes.

Related

Win32 Dialog box: how to keep all objects in windows centered when resizing

I am building and maintaining a Win32 app using Visual Studio.
I have recently edited the .rc file adding WS_THICKFRAME to my dialog STYLE line for all dialog windows to allow them to be resizable.
My current problem is, when I resize a window, its content remains fixed to the left. How can I make the window's content remain centered when resizing using the border?
Pointing to any relevant documentation on this would also be helpful, as I have not had lucky finding that.
If you only want to reposition (rather than resize) the individual controls, an easy way would be to create a non-modal container dialog to hold the controls, make that dialog a child of the resizable dialog, and then when you handle WM_SIZE for the outer dialog, you only have to reposition that one non-modal dialog.
Your new position is ((newWidth- controlDlgWidth) / 2, (newHeight-controlDlgHeight)/2), where controlDlgWidth, controlDlgHeight are the width and height of the child dialog.
I say to use a non-modal dialog for this, so that you can continue using a resource script, rather than needing to add a whole bunch of explicit CreateWindow() calls.

Resizing UWP Window on User Drag

I am trying to change the size of the UI Elements within a UWP Window on the change of the size of the window itself, such as clicking the edge of the window and dragging right. However, on increase of size, there seems to be Bounds set on the creation of the Window for the maximum size of the content, is there anyway to bypass this Bounds?
Try setting the UI Element's HorizontalAlignment and/or VerticalAlignment to "Stretch". Alternatively, if you want to scale it too, you may put the whole thing in a ViewBox. There are really quite a few options to achieve what you want.

How to change the apparent height of a Combobox control with the dropdownlist but not ownerdraw style?

Background: In a certain dialog there are several controls in a row. I would like all of them to have the same apparent height. However for a combobox with the CBS_DROPDOWNLIST style and no CBS_OWNERDRAW* I am having trouble changing the apparent height.
Question: How can I change the apparent height of such a DROPDOWNLIST combobox?
I am aware that the combobox does not allow changing the height with SetWindowPos. I was however under the impression that sending a CB_SETITEMHEIGHT message with wParam= -1 should modify the height. This method does work for comboboxes with the CBS_OWNERDRAWFIXED style set (I wanted to avoid setting this style though to preserve the "button-like" look).
Environment: My Win32 application uses Common-Controls 6.0 and I am concerned about the appearance in an environment where visual styles are enabled (Windows 7, Aero).
I don't think this is possible.
As you mention, neither SetWindowPos nor MoveWindow work like you expect. That's because the height of a ComboBox includes the height of the drop-down. The control automatically resizes itself according to the size of the font it uses. So to change the size, change the size of the control's font by sending it a WM_SETFONT message.
But I don't understand why this is a problem. You say that you want a series of controls to have the same height, but unless you're changing the height of the other controls, they should already match. Since all controls on a dialog generally use the same font, combo boxes and text boxes should all have the same height already. When you use v6 of the common controls and Visual Styles are enabled, they'll be applied to all of these controls and they should have a uniform appearance. You shouldn't have to mess with the heights manually.

MFC grid is absolute layout and gets clipped during window resize

Using visual studio C++ 2010.
Currently in a window in MFC code I have a grid. I want the grid to "become smaller" if I resize the window (drag the corners manually), but as I resize the window the grid actually is completely static, so e.g. resizing the window to a very small size will cause the edges of the grid to become outside of the window's visibility.
I noticed that the other "objects" within this window (notably, the MFC buttons I have such as "cancel") do scale with the window and don't go out of sight when I resize the window to a smaller size. They follow the window's edges as if they were given smart relative coordinates instead of absolute coordinates that my grid follows.
Currently I am using the grid here http://www.codeproject.com/Articles/8/MFC-Grid-control-2-27 although I highly suspect it is not the source of the problem (there is an example code that uses it, and the resize behaves as expected; I cannot compile it but I ran the exe example). I recently switched from MSFlexGrid (because it doesn't support 64 bit) but in the previous version when I used to use MSFlexGrid, it didn't have this problem either.
I thought it might be some sort of window property or object property in the .rc file but I compared the files and found no leads.
There is no such a thing like a window property that tells window to adjust the size to the size of the parent.
If buttons change size and position, you are probably using some kind of class that takes care of resizing of the child controls.
Follow the same for your grid, or notify grid about the parent size change and adjuxt grid size accordingly.

How do you change the height of a SketchFlow ComboBox?

SketchFlow allows for the changing of the Height property for the TextBox and ListBox controls. However, I seem to be unable to change the Height property for a ComboBox. The Height property can be changed in the Properties window but it has no effect (at design or run time).
You shuold open sketchstyles.xaml in notepad or visual studio. Then find the style for combobox-sketch. You will find 2 places(once in outermost grid definition and another in the end) of min-height in the style, set them both to what you want.
Are you sure you have the combobox item selected in the Objects and Timeline panel? I tried this and it works fine for me. Are you able to resize it using the mouse and adorners?

Resources