I have a view which derives directly from the CFormView and then I
display a child dialog on it at runtime.
Visual Studio creates automatically resource entry for my view class.
The dialog can be resied dynamically by the user by pressing the
button and I would like the view to always fit the size of the dialog.
At the moment when I press a button and the dialog dimensions change I
cannot resize the view and a scrollbar is created, which looks really
ugly.
Could someone help me with this problem? How can I automatically
resize the view so that it always fits the dialog window?
Everything is happening in the MDI world.
Thanks for help,
Pshemek
AliR.
<przemysl...@gazeta.pl> wrote in message
news:1190303985.1...@g4g2000hsf.googlegroups.com...
CRect Rect;
GetWindowRect(&Rect);
SetWindowPos(NULL,0,0,Rect.Width()+50,Rect.Height()+50,SWP_NOMOVE|SWP_NOZORDER);
GetParentFrame()->GetWindowRect(&Rect);
GetParentFrame()->SetWindowPos(NULL,0,0,Rect.Width()+50,Rect.Height()+50,SWP_NOMOVE|SWP_NOZORDER);
AliR.
"AliR (VC++ MVP)" <Al...@online.nospam> wrote in message
news:l3xIi.8167$JD....@newssvr21.news.prodigy.net...
Should I include this in OnInitialUpdate() or perhaps in OnInitDialog
in the child dialog??
Cheers
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
AliR.
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:4u46f3tvanltfjqkt...@4ax.com...
Well,
This does not work, the frame is much bigger than the dialog itself.
Any other ideas?
Thanks for help
((CMainFrame*)AfxGetMainWnd())->RecalcLayout();
((CFormView*)GetActiveView())->ResizeParentToFit(FALSE);
>> On Thursday, September 20, 2007 12:18 PM AliR \(VC++ MVP\) wrote:
>> Call ResizeParentToFit from within the View.
>>
>> AliR.
>>> On Thursday, September 20, 2007 12:22 PM AliR \(VC++ MVP\) wrote:
>>> Scratch that:
>>> Do this instead:
>>>
>>> CRect Rect;
>>>
>>> GetWindowRect(&Rect);
>>>
>>> SetWindowPos(NULL,0,0,Rect.Width()+50,Rect.Height()+50,SWP_NOMOVE|SWP_NOZORDER);
>>>
>>> GetParentFrame()->GetWindowRect(&Rect);
>>>
>>> GetParentFrame()->SetWindowPos(NULL,0,0,Rect.Width()+50,Rect.Height()+50,SWP_NOMOVE|SWP_NOZORDER);
>>>
>>>
>>> AliR.
>>>
>>> "AliR (VC++ MVP)" <Al...@online.nospam> wrote in message
>>> news:l3xIi.8167$JD....@newssvr21.news.prodigy.net...
>>>> On Thursday, September 20, 2007 4:20 PM przemyslaw.sliw wrote:
>>>> OR=ADDER);
>>>> SW=ADP_NOMOVE|SWP_NOZORDER);
>>>> .104@newssvr21.news.prodigy.net...
>>>>
>>>> Should I include this in OnInitialUpdate() or perhaps in OnInitDialog
>>>> in the child dialog??
>>>>
>>>> Cheers
>>>>> On Thursday, September 20, 2007 8:44 PM Joseph M. Newcomer wrote:
>>>>> How did you get the "+50" derived?
>>>>> joe
>>>>>
>>>>>
>>>>> Joseph M. Newcomer [MVP]
>>>>> email: newc...@flounder.com
>>>>> Web: http://www.flounder.com
>>>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>>>>>> On Thursday, September 20, 2007 8:59 PM AliR \(VC++ MVP\) wrote:
>>>>>> Pulled it out my you know what.
>>>>>>
>>>>>> AliR.
>>>>>>> On Friday, September 21, 2007 3:39 AM przemyslaw.sliw wrote:
>>>>>>> On Sep 21, 1:59 am, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
>>>>>>> vanltfjqktrqk...@4ax.com...
>>>>>>> am>
>>>>>>> OZ=ADORDER);
>>>>>>> 0,=ADSWP_NOMOVE|SWP_NOZORDER);
>>>>>>> g=2E
>>>>>>> I
>>>>>>>
>>>>>>> Well,
>>>>>>>
>>>>>>> This does not work, the frame is much bigger than the dialog itself.
>>>>>>> Any other ideas?
>>>>>>>
>>>>>>> Thanks for help
>>>>>>>> On Friday, September 21, 2007 9:52 AM Joseph M. Newcomer wrote:
>>>>>>>> See below...
>>>>>>>> On Fri, 21 Sep 2007 00:39:52 -0700, przemysl...@gazeta.pl wrote:
>>>>>>>>
>>>>>>>> ****
>>>>>>>> Try this:
>>>>>>>> CRect r;
>>>>>>>> GetWindowRect(&r);
>>>>>>>> CRect parent;
>>>>>>>> GetParentFrame()->ScreenToClient(&r);
>>>>>>>> GetParentFrame()->CalcWindowRect(&r);
>>>>>>>> GetParentFrame()->SetWindowPos(NULL, 0, 0, r.Width(), r.Height(), SWP_NOMOVE |
>>>>>>>> SWP_NOZORDER);
>>>>>>>>
>>>>>>>> this should get something tighter. Normally, I just call ResizeParentToFit().
>>>>>>>> joe
>>>>>>>> ****
>>>>>>>> Joseph M. Newcomer [MVP]
>>>>>>>> email: newc...@flounder.com
>>>>>>>> Web: http://www.flounder.com
>>>>>>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>>>>>>>> Submitted via EggHeadCafe
>>>>>>>> Using DataList to List Category/Subcategory with expand - collapse facility via javascript
>>>>>>>> http://www.eggheadcafe.com/tutorials/aspnet/6b6d6022-60f6-4d05-beaf-7737a1f26987/using-datalist-to-list-categorysubcategory-with-expand--collapse-facility-via-javascript.aspx
>
>((CFormView*)GetActiveView())->SetScaleToFitSize(((CFormView*)GetActiveView())->GetTotalSize());
****
There's something incredibly suspect about any computation that has this many casts. I've
done resized CFormViews without ever writing anything this convoluted.
It also has long-term risks in that it assumes that the active view is a CFormView (and
when the client says, "By the way, we want a graphical view as well", your code had better
keep working, and the above code will fail horribly).
In some cases, I want the view to resize and I want the controls to dynamically resize to
match; in other cases, I really want the scrollbars. But in neither case did I end up
writing something that involved either GetActiveView() or a cast. I consider the
combination of GetActiveView and explicit casting to be extremely hazardous. I rarely
even consider GetActiveView to be even meaningful.
You can check out a number of examples on my MVP Tips site that have dynamically resized
CFormViews.
joe
****