I am making a messagebox using a RichEdit control. I am having difficulty when resizing the form at run time if the user stritches or shrinks the form. I have gotton the RichEdit control to resize but the two Command Buttons get lost (hidden) when the form is resized.
The form has only the RichEdit control and a couple of Command buttons.
How do I get the Command Buttons keep their relative positions when the form is resized?
Marty,
Relative to what? Bottom, Bottom-Center? It also would have been helpful to see the relevant parts of your code.
Here is some code to tie two controls to the bottom-center of the window. It doesn't have any provisions for the form being sized too small however.
Function FORM1_WM_SIZE ( _
hWndForm As Dword, _ ' handle of Form
fwSizeType As Long, _ ' type of resizing request
nWidth As Long, _ ' new width of client area
nHeight As Long _ ' new height of client area
) As Long
Select Case fwSizeType
Case %SIZE_MINIMIZED
'do nothing
Case %SIZE_RESTORED, %SIZE_MAXIMIZED
MoveWindow HWND_FORM1_COMMAND1,nWidth/2-58,nHeight-30,48,24, %TRUE
MoveWindow HWND_FORM1_COMMAND2,nWidth/2+9,nHeight-30,48,24, %TRUE
End Select
End Function
In your case, you might want the command buttons to be relative to the bottom-center of the RichEdit control. That would require some more calls to get those values. Then you could use that information as such:
MoveWindow HWND_FORM1_COMMAND1,RichEdit_Left+(RichEdit_Width/2)-58, RichEdit_Top+RichEdit_Height+15,48,24, %TRUE
David
David,
Thanks for the help.