How to programmatically resize a view in MFC? - mfc

To my surprise, I can't easily find a solution. I want to set initial size of a view in MFC. How can I do that?

You don't size a view, but you can size the view's parent frame window:
GetParentFrame()->MoveWindow(x, y, width, height);

Related

Translate coords to re-position dialog box?

I am hooking CreateDialogIndirectParam. I want to do some manipulations over the dialog box, but but the width, height, and x and y positions are in dialog box units. Can someone explain how to convert them to screen coordinates?
Thanks in advance.
Try the MapDialogRect() function. I think it does what you think.
Remember that the mapping depends on the font used by the dialog, so the HWND must be that particular dialog.
Also from GetDialogBaseUnits():
pixelX = MulDiv(templateunitX, baseunitX, 4);
pixelY = MulDiv(templateunitY, baseunitY, 8);
Being baseunitX the value tmAveCharWidth and baseUnitY the value tmHeight returned by function GetTextMetrics(). You just need a HDC with the dialog font selected.

Can I lock the width or height of an MFC dialog during resizing?

Is there a way to lock a dialog box's size in one direction (restrict only width or only height) in MFC?
You need to override OnGetMinMaxInfo. In OnInitDialog you can capture the current height, and then use it for both minimum and maximum height. Call __super::OnGetMinMaxInfo first and then only change the height members. Note that the window may not exist the first couple times OnGetMinMaxInfo are called.
Here's a detailed article on GetMinMaxInfo.

How to resize a CTabCtrl to fit its contents

I have a CTabCtrl in my program and 3 "child" *CFormView*s that I show/hide whenever the user changes the active tab.
Instead of using a fixed size, I'd like to resize the enclosing CTabCtrl to match the size of the largest CFormView.
You can use this:
GetDlgItem(IDC_YOURCONTROL)->MoveWindow(xPosInScreen, yPosInScreen, Width, Height);
Hope it helps.

how to resize dialog which are added to property sheet?

i am trying to rezize dailog which are added to property sheet using move window function but nothing is affecting. it taking same size as in resource file.
how to resize it in code ?
this->MoveWindow(xPosInScreen, yPosInScreen, Width, Height);
You can use it on initialisation function.

How to get the inside dimensions of a decorated window in XWindows?

If I create a full screen window where m_winw and m_winh is the full screen size, it seems to create a window for me where the outside dimension is the full screen and the inside is smaller based on the "decoration" (window border) size. Is there a way to query the window to get it's inside width and height?
m_win=XCreateWindow(m_display, m_rootwin, m_winx, m_winy, m_winw, m_winh, 0,
CopyFromParent,CopyFromParent,m_visual,CWColormap|CWEventMask,&attributes);
This is on linux.
See XGetWindowAttributes, XGetGeometry. According to the man page:
The width and height members are set tothe inside size of the window, not including the border.