when the application start, the EDIT is placed in front of RICHEDIT
when i resize the form, the EDIT and RICHEDIT is placed normally where i wanted to (bellow RICHEDIT)
is there any wrong in the codes or missing something - to make the position of EDIT is bellow of RICHEDIT at start?
please can somebody help me?
thx for any opinion and forgive my bad english ^^
Just call OnSize() from OnInitDialog(), or better yet, make a new function and call it once in OnInitDIalog(), and call it from OnSize() whenever OnSize() is called.
DO NOT call OnSize directly
It is a message handler for handling WM_SIZE message. It will not do any harm in this case but it creates a habbit of calling handlers and you can do harm doing that.
CFormView class does not have OnInitDialog. OnInitDialog is also a part of a message handler but is handled differently in a CDialog class and CFormView class.
Your algorithm is based on original position of the control in a resource editor. Use dimentions that are delivered by system to a OnSize handler. You should change code to something like that:
Above will position both windows with margins of 5 pixels from each side of the splitter.
As you can see, I have changed parts of your code:
Do not pass NULL to a SetWindowPos. At least pass SWP_NOZORDER, if you want to move and resize controls. In general: use flags to tell SetWindowPos what you want to do.
Do not use GetDlgItem(IDC_EDIT)->CallSomeFunction. You do not know if GetDlgItem will return a valid pointer. If not, you are cooked; your application will crash. Also, you are calling function three times while assigning return value to a local variable requires only one call.
You mau be better off using BeginDeferWindowPos , DeferWindowPos, EndDeferWindowPos:
Bookmarks