2006. október 15., vasárnap

Set the position of a help window


Problem/Question/Abstract:

If you open a help file from your application, the help window always initializes at the same position. How do you change that, for instance to position a help window side by side with your form?

Answer:

You can use the Winhelp macro PositionWindow.

procedure TForm1.Button1Click(Sender: TObject);
var
  command: array[0..255] of Char;
begin
  command := 'PW(0, 0, 512, 512, 1, "main")';
  application.helpcommand(HELP_COMMAND, Longint(@command));
end;

What it does:

The code example above uses the HELP_COMMAND constant to execute a macro. The macro we use here is "PositionWindow" or - short - "PW". It defines the upper left corner (x1, y1) as (0,0) and the lower right corner (x2, y2) as (512,512).
The following parameter is the integer constant for "SW_SHOWNORMAL". Winhelp does not recognize the string "sw_shownormal" in the macro string. The last parameter is the name of the window.

One word about the coordinates:

The position and size of a help window always relates to a virtual screen size of 1024 x 1024 pixel, regardless of the screen resolution. If you set the size to (0, 0, 1024, 512), the help window would cover exactly the upper half of the screen.

Nincsenek megjegyzések:

Megjegyzés küldése