Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make a Delphi VCL form sizable without changing the BorderStyle?

I have just spent quite a lot of time trying to make the Tools/Environment Options dialog of the Delphi 6/7 IDE sizable from within GExperts. Everything seemed to work fine until I found that changing the form's BorderStyle to bsSizable closes and recreates the handle of the form and in the process loses the content of the list box for the palette configuration. (The Items property is empty afterwards.)

Changing the form's size (by setting the height and width) as such works fine, but allowing the user to adjust the size runs into the aforementioned problem.

Is there any way to make a Delphi form sizable without changing the BorderStyle?

like image 434
dummzeuch Avatar asked Dec 13 '15 18:12

dummzeuch


1 Answers

"Wnd" being the dialog handle, you can transform the dialog to an overlapped window with a sizing frame:

SetWindowLong(Wnd, GWL_STYLE,
    GetWindowLong(Wnd, GWL_STYLE) and not WS_POPUP or WS_THICKFRAME);

remove the dialog frame:

SetWindowLong(Wnd, GWL_EXSTYLE,
    GetWindowLong(Wnd, GWL_EXSTYLE) and not WS_EX_DLGMODALFRAME);

then attach the appropriate system menu item for sizing messages to be processed:

AppendMenu(GetSystemMenu(Wnd, False), MF_STRING, SC_SIZE, 'Size');

and have the new frame drawn:

SetWindowPos(Wnd, 0, 0, 0, 0, 0,
    SWP_NOSIZE or SWP_NOMOVE or SWP_NOZORDER or SWP_FRAMECHANGED);
like image 164
Sertac Akyuz Avatar answered Oct 19 '22 00:10

Sertac Akyuz