|
|
Comments and Discussions
|
|
 |

|
I've looked through the documentation and downloaded and ran the sample. For some reason when I use this code in my project all the controls just disappear as soon as I try to resize the dialog. The sample/demo works fine. I'm using VS 2005.
I'd post some code, but it looks very similar to the sample code. There are a couple differences between my project and the demo, but I'm not sure any of them really matter:
- I include "easysize.h" in my class header instead of StdAfx.h
- My Dialog is a member of another class (CView), and I'm using a multi-doc configuration with MFC
- I'm using a few controls from Ultimate Toolbox (also on this site)
My only guesses are that it's somehow hiding all the controls on resize, or it's is using the a parent frame as it's reference point. I'm not the biggest C++ guru, so I'm not sure how I would determine what is going wrong.
Any ideas? Thanks in advance!
|
|
|
|

|
Hi !!
In my application dialog there is one list control having only one colume. The column width is width of list control. I want this case should be as it is whenever the dialog is resized.
Waiting eagerly for suggestion / reply.
Thanks and Regards,
John Pinto.
|
|
|
|

|
I just ran across this article. Found it to be excellent and really easy to use. Agree with the poster below "I wish I can vote 6"
|
|
|
|

|
Can any body told me how to resize the child dialog in tab control when my tab control is resized?
Many Thanks
sumit
|
|
|
|

|
All other corners will resize, but the upper left corner gives the resize icon but ignores any resize attempts. Any ideas anybody?
|
|
|
|

|
I have followed your article.But I cannot do it well.
I use VS2008.
|
|
|
|

|
Hi!
I can't use EASYSIZE_MINSIZE in OnSizing event handler.
Here my piece of code goes:
BEGIN_MESSAGE_MAP(MyView, CFormView)
ON_WM_ERASEBKGND()
ON_WM_SIZE()
ON_WM_SIZING()
ON_WM_CREATE()
END_MESSAGE_MAP()
... and ...
void MyView::OnSizing(UINT fwSide, LPRECT pRect)
{
CFormView::OnSizing(fwSide, pRect);
EASYSIZE_MINSIZE(100, 100, fwSide, pRect);
}
Is there somthing wrong with that?
[]'s
modified on Tuesday, September 30, 2008 9:03 AM
|
|
|
|

|
Thanks for sharing with us!
|
|
|
|

|
this code is very useful to resize controls.
I would like to align 4 icons in center. i tried but i cannot align icons in center. Is it possible with this code?
EASYSIZE(IDC_MYICON1,ES_KEEPSIZE,ES_BORDER,ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_MYICON2,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_MYICON3,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_MYICON4,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
|
|
|
|

|
thanks a lot for sharing this excellent job!
but i found 2 bugs when using the macro:
1?if u project is based on dialog and u put a RichEdit control in it.it could be compiled well but even couldn't be executed!
2?if u project is a multiple document application, u design a dialog in it
and put a RichEdit control in the dialog. add the macro in the dialog class, use the dialog somewhere.
it could be comiled and executed. but when resizing the dialog, the controls in it do not resize with it until u swith to another window and return!
i think there is something special about richedit but what is it?
Is anybody here could help me, thanks in advance
|
|
|
|

|
I appreciate your hard work on this. I found it extremely handy when used to resize my application. It does take a bit of learning, but once you pick it up it's easy to follow. I've given all credit due to the original programmer. One additional note. I discovered that the order in which you reference your objects is important. For instance I had a set of 3 buttons across the top of my form. Unless I centered the middle button first, and then set the others relative, it wouldn't space properly(evenly).
Danke
J.W.
|
|
|
|

|
I use it in a cfromview,but it doesn't work normally,the Group box doesn't shrink when the Resolution is 800*600.The dialog contains the List box,the Group box and so on.
|
|
|
|

|
thanks
|
|
|
|

|
Marvelous piece of work.
Thanks
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language; please excuse any grammatical or spelling mistakes"
|
|
|
|

|
Hi, first of all: thank you for this - very easy to use and implement.
In the text of the article, you state that it works on CPropertyPages too, but I can't get that to work.
OnSize() of the sheet is called only on creation of the Page, and so resizing the PropertySheet does not send the WM_SIZE to the PropertyPage.
Adding a call to the PropertyPage::OnSize() in the PropertySheet::OnSize() function gives no effect. (PropertySheet does not have EasySize). It seems to be redrawing as there is some flicker, but the controls don't size or move at all.
Am I doing something wrong? (Of course I am but what is it?) How can I get EasySize to work in a PropertyPage?
Thanks for any help you can give me.
Wouter
|
|
|
|

|
Suppose i have given a button id in the left or in the right. Now the control resizes till the buttons edge. There should be some gap between those two controls. How can i provide the gap (offset) in between those controls? Please help...
|
|
|
|
|

|
I have been using this macro now in many projects and it does a really good job. Can you detail a little what got updated? (I would run diffs myself but I have modified your original slightly years ago to better suite my application.)
|
|
|
|

|
now u said that to specify a minimum size for ur dialog u must impement the OnSizing Function
what is exaclty the Message that fire this function
since WM_SIZE fire the OnSize() fucntion
wat msg will fire the OnSizing() function ?
thnx alot for ur time and concen.
|
|
|
|

|
I noticed something... well actually took my a long time testing to figur it out:
When your Dialog class is derived from another dialog, you need to include INIT_EASYSIZE before calling the OnInitDialog of the base class else you will get unpredicable results. I have tested this on Windows CE, don't know if the same problem occurs on a 'normal' Windows environment.
BOOL CMyDlg::OnInitDialog()
{
INIT_EASYSIZE;
CMyBaseDlg::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Many thanks for this really useful code!
|
|
|
|

|
In the first place, good job! it's nice and simple.
A nice thing to do would be to make it possible to work on the last found possitions (if the possitions were modified since the last resize).
The problem I'm having is that I'm using a splitter control, that resizes the controls by itself. When the dialog gets resized the controls possitions/sizes are reseted to their original ratios by EasySize.
Thanks! the code is great.
|
|
|
|

|
for this incredibly useful code.
I have uploaded a new version here:
http://www.codeproject.com/script/profile/upload/15759/EasySizeHD2.zip
I based my changes on the version by boulwiss. The changes I made:
- Added automatic support for
DeferWindowPos() - this required changing END_EASYSIZE_MAP macro to END_EASYSIZE_MAP(theClass)
- Merged gripper code by gniemcew
- Added macro
EASYSIZE_MINSIZE2 for OnGetMinMaxInfo() handler
- Merged modifications by Jubjub to add support for
ES_KEEPRATIO. See this message for details.
- Initialized some local variables and removed others to eliminate compiler warnings at level 4
Best wishes.
Hans
|
|
|
|

|
Tout OK en 5mn, alors que c'est un problème récurent des MFC.
Un grand merci
A great Frensh Thank You
|
|
|
|

|
Greate, thank you!
|
|
|
|

|
it do not work if there is a menu on the dialog
BOOL CWLDlg::OnInitDialog()
{
.......
CMenu mymenu;
mymenu.LoadMenu(IDR_MAINMENU);
SetMenu(&mymenu);
..........
return TRUE;
}
aaaaaaaaaaaaaaaaaaa
|
|
|
|

|
How can i resize the dialog if the dialog contains ToolBars?
|
|
|
|

|
Without changing almost all of the code, it seems to be impossible to add (or remove) dialog elements at run-time, e.g. a couple of sliders for a volume controller or similar. This limitation should be noted.
A solution may moving own elements after UPDATE_EASYSIZE belonging to
invisible container rectangles.
|
|
|
|

|
I cannot get this to work when I have a dialog inside a tab ctrl. For example, I have a formview window that contains a tabctrl. The tabctrl is a place holder for dialog ctrls. When I resize the formview, I also pass the resize info to the dialog ctrl to call the EasySize macros. Nothing resizes when I do this. Is there an easy solution to this or am I stuck having to code this manually.
Thanks!
|
|
|
|

|
Hey,
Make my life easy. But I found that if you resize the dialog window, it flickes and flicking is enough to visulise it.
Can you tell how to make it flicker free or have less flicking
Thanks.
Manish Mishra
|
|
|
|

|
I found a solution for the form view problem (and it's working great for me). The problem is that when OnInitalUpdate gets called the form (eventhough created) has a width and height of zero. So what I did was put an if statment in the OnSize where the first time around I call INIT_EASYSIZE, and from there on I call UPDATE_EASYSIZE. Also you have to call SetScrollSizes(MM_TEXT,0,0) in order to get rid of the scrollbars.
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
if (m_bFirst && IsWindowVisible()&& GetWindow(GW_CHILD)!=NULL)
{
INIT_EASYSIZE;
m_bFirst = FALSE;
SetScrollSizes(MM_TEXT,CSize(0,0));
UPDATE_EASYSIZE;
}
else if (!m_bFirst)
{
SetScrollSizes(MM_TEXT,CSize(0,0));
UPDATE_EASYSIZE;
}
}
Hope this helps.
Ali Rafiee
|
|
|
|

|
Very easy to use in Dialogs with less contols. A nice piece of code. You got a five;)
|
|
|
|

|
Very convenient solution. You get a five.
|
|
|
|

|
First of all - I like your solution to create resizeable dialogs!
But unfortunately the flicker of some controls is not bearable;
at least it does not look professional.
Seems that others here have dealt with that problem, without
finding a real solution. My solution will not be the real salvation as well,
but for those who are desperatly searching here is my result:
1.) Add this macro to Easysize.h
#define EASYSIZE_EXCLUDE_ERASEBKGND(ID)\
{CRect rect; this->GetDlgItem(ID)->GetWindowRect(&rect);\
ScreenToClient(rect); pDC->ExcludeClipRect(rect);}
2.) Overwrite the OnEraseBkgnd()
3.) Now add to OnEraseBkgnd() for every flickering control:
EASYSIZE_EXCLUDE_ERASEBKGND(CTRL_ID);
For example:
EASYSIZE_EXCLUDE_ERASEBKGND(IDC_MYICON1);
EASYSIZE_EXCLUDE_ERASEBKGND(IDC_MYICON2);
EASYSIZE_EXCLUDE_ERASEBKGND(IDC_MIDRECT);
This does not work for frames - I dont know why...
But they are not really flickering anyway.
|
|
|
|

|
Not so intuitive to use... Complex layouts give you a splitting headache, but once it is set up, this piece of code is great
Pixi
|
|
|
|

|
Hallo
Ich have I dialog with a tabctrl. the tabctrl ist resized perfectly! but the dialogs in the tabctrl are not resized?! why?! where is my mistake?! It only resize the tabctrl but the content of the tabctrl not
greetz
Thorsten
|
|
|
|

|
Hi Marc.R,
Congratulation to you for having written this wonderful code. I have used it and it work just fine except when I maximize or minimize the window. I just get a blank ,gryed window. I can force an update and restore the window if I grab the resizing handle and move it slightly. I have found a workaround by only allowing UPDATE_EASYSIZE to execute for (nType of SIZE_RESTORED in OnSize function.
void CThreadDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
//
// have problem ( with UPDATE_EASYSIZE ) updating the dialog
// window when all nTypes are processed
// this works except when dialog is maximized
//
if(nType == SIZE_RESTORED)
{
UPDATE_EASYSIZE;
}
}
I am probably misusing your code, but I can’t figure out how I am doing this. Do you have any idea?
|
|
|
|

|
This has been very helpful to me.
Very easy to use.
Thanks, Marc!
|
|
|
|

|
Does EasySize work on FormViews?
I've used it in a dialog, and it works perfectly.
I'm trying now to use it in a FormView, and something just doesn't work when I declare the EASYSIZE macro for the controls.
Any ideas?
|
|
|
|

|
Any ideea how to hide some controls after defining them to "easysize"?
I have a big PictureControl that resizes width and height, and some buttons under it. I wanna use MoveWindow() of course to hide the blank spot when i hide the buttons, but the big PicControl now resizes to keep the distance from the bottom, natural. So ... how do i hide some items, w/o leaving a empty space there ?
|
|
|
|

|
EASYSIZE seems to work with all dialogs i have tried it on with the exception of the "Sample Text" control in a dialog derived from CFontDialog. (This control ID is defined in FONT.DLG as stc5).
Any idea why CFontDialog behaves in this peculiar way??
gjr
|
|
|
|

|
Hi Marc.R,
I think your article and your code is great. Its very useful and very easy to use (ie the name of the article). I've had several instances when I needed to be able to resize controls in proportion to the size of the dialog. For example, if I have 2 list controls next to each other or equal dimension and I resize the dialog, I needed them to become larger but still be the same size as each other.
With that, I started to try to understand your code. After some trial'n'error during the learning process, I finally added another option to the resizing. Initially I called it ES_KEEPPROPORTION, but I then saw some messages on here, and ES_KEEPRATIO seemed more logical.
I don't know how to message you directly, so I'll add a link here and if you wish, you may modify your own code or not. I thought it may be useful to some of the other readers.
EasySize with ES_KEEPRATIO
I've tested it as much as I could. Good luck in using it, and I hope it comes in handy.
Jubjub
|
|
|
|

|
Very intuitive interface.
None
|
|
|
|

|
Is this message handler a VC7 thing? If so, can I get the same functionality from something in VC6?
|
|
|
|

|
I dug around for a while looking for an easy way to do this, and yours definitely lives up to the name. Cool code. Thanks!
|
|
|
|

|
would you please show me a resizer dialog with only one CEdit control directly without class.I wanna know how to resize and move a control in dialog .thanks !
|
|
|
|

|
I liked the idea of what you did, and it does work quite well. However, the code looked really ugly, missing linebreaks and all, so I went over it a little, introduced a couple of sub-macros etc. This does not add any extra functionality, but might make future extension/bugfixing easier, and should be interesting for anyone who wants to know what their program actually does.
The code is available for download here: ftp://ftp.pyogenesis.net/pub/fknauf/c++/EasySize.h
|
|
|
|

|
Hi,
I'm sittign on this problems for several hours now and I'm not able to resize 5 Editboxes over a Dialog. Could you write a solution for this problem?
|
|
|
|

|
great!
can we save the new size and positions of dialog and controls in registry?
if i open twice , i want get the new sized dialog....
|
|
|
|

|
how to use EasySize in in FormVIew?;P
|
|
|
|

|
Hey, first of all Great job!! Works good and very easy to integrate.
I have a problem when I try to minimize/maximize the Dialog.... the control items, especially buttons get displaced. Would appreciate any help.
Thanks.
|
|
|
|

|
hi, it's a great job
i transfomed the code to reduce the number of lines insertd by the macro.
you can download the source here : http://3iconsulting.free.fr/easysize.zip
ALI AYACH
-- modified at 3:55 Friday 4th May, 2007
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
An easy way to position controls in resizable dialogs or property pages using just a few macros
| Type | Article |
| Licence | |
| First Posted | 10 Dec 2001 |
| Views | 411,110 |
| Downloads | 15,635 |
| Bookmarked | 243 times |
|
|