Archive

Posts Tagged ‘windows api’

How to Set / Remove the Form’s StayOnTop Style

December 15th, 1999 m3Rlin No comments

To set or remove the form’s StayOnTop style you can just set the form’s FormStyle property. But this has side effects. For example: if you modify the form’s system menu using the Windows API. After the form’s style is changed the system menu will return to it’s normal state. You can get around this in a very easy and easy way: using the SetWindowPos() function.

  (* hStyle - (HWND) The form's style. This can be:
  ** - HWND_NOTOPMOST - Removes the StayOnTop atribute.
  ** - HWND_TOPMOST - Sets the StayOnTop atribute
  *)
  SetWindowPos(Handle, hStyle, Left, Top, Width, Height, SWP_SHOWWINDOW);

How to Remove the Form’s Caption

December 15th, 1999 m3Rlin No comments

You may have wanted to create a form that doesn’t have a caption bar, just like the one’s you may see in setup programs. Delphi VCL doesn’t give you but you can also use the Windows API :-)
Just add this code to you form’s OnCreate method:

SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and not WS_CAPTION);
Height := Height - GetSystemMetrics(SM_CYCAPTION);

That’s right! Just two lines of code…