Link to home
Start Free TrialLog in
Avatar of JasonC
JasonC

asked on

WinHelp's SetWinPos

How do I use the HELP_SETWINPOS switch in the WINHELP command. Can someone give me an example? I don't think I am using the HelpWinInfo type properly.
Avatar of inthe
inthe

hi
here a couple of examples:

procedure xHelp;
const
//your classname of help window
  hclass:pChar = 'TFormHelp';
var
  i: integer;
  wi: ^HelpWinInfo;
begin
  i:=SizeOf(tHelpWinInfo)+SizeOf(hclass)-2;
  GetMem(wi,i);
  try
    With wi^ do
    begin
      wStructSize:=i;
      x:=10;
      y:=10;
      dx:=200;
      dy:=200;
      wMax:=sw_ShowNormal;
      Move(hclass^,rgchMember,StrLen(hclass)+1);
    end;
    Application.HelpCommand(help_SetWinPos,longint(wi));
   finally
    FreeMem(wi,i);
  end;
end;


from peter below usenet posting:

The THelpWinInfo record is in fact a data structure that cannot be mapped to a Pascal record type properly because it has a variable length. The last member takes the class name of your help window and that will usually be considerably longer than the one character (plus #0) allowed in the THelpWinINfo record declaration. Simply declare a variation with a larger char field:
 
  TMyHelpWinInfo = record
    wStructSize: Integer;
    x: Integer;
    y: Integer;
    dx: Integer;
    dy: Integer;
    wMax: Integer;
    rgchMember: array[0..127] of AnsiChar;
  end;
 

var
WinPos : TMyHelpWinInfo;
begin
 with WinPos do begin
              wStructSize := sizeOf( Winpos);
  x:= 0;
  y:= 0;
  dx:= 512;
  dy:= 512;
  wMax:= SW_SHOWNORMAL;
StrLCopy( rgchMember, PChar(myHelpwindowClassname ),127 );           end;
Application.HelpCommand(HELP_SETWINPOS, LongInt(@WinPos));
 
Avatar of JasonC

ASKER

Sounds good, but still didn't work, now I do have some questions, which is probably why it doesn't work.

1. Should I specify any size settings in the help compiler, like auto height, left, right, width and height?

2. What is the Help Class? I am using the winHelp command, not the Application.HelpCommand, so how do I get this help class?
Avatar of JasonC

ASKER

I think i just worked out the Help class thing, is that the name of the help window to use?
Avatar of JasonC

ASKER

It seems to work ok using Win 2000, but doesn't work in Win 95 or 98, I haven't reid Win NT 4.0 yet.

Here is the code I'm using. One thing I have noticed is that in your declaration of the wi, you have:

wi : ^HelpWinInfo ;

should it be

wi : ^THelpWinInfo ;


procedure GetHelp ;
const hclass : PChar = 'Dialog' ;
var I, Myhan : Integer ;
    DTLeft, DTRight, DTTop, DTBottom : Integer ;
    AppBarInfo : TAppBarData ;
    MyWinInfo : ^THelpWinInfo ;

begin
    I := SizeOf(THelpWinInfo) + SizeOf(hclass) - 2 ;
    GetMem(MyWinInfo, I) ;
    try
      with MyWinInfo^ do begin
        wStructSize := I ;
        x := Round((1024 / Screen.Width) * DTLeft) ;
        y := Round((1024 / Screen.Height) * DTTop) ;
        dx := Round((1024 / Screen.Width) * DTRight) ;
        dy := Round((1024 / Screen.Height) * DTBottom) ;
        wMax := SW_ShowNormal ;
        Move(hclass^, rgchMember, StrLen(hclass) + 1) ;
        end ;
    WinHelp(Parent, 'OlEnvLab.hlp>Dialog', HELP_CONTEXT, AlternateContext) ;
    WinHelp(Parent, 'OlEnvLab.hlp', HELP_SETWINPOS, Longint(MyWinInfo)) ;
    finally
      FreeMem(MyWinInfo, I) ;
    end ;
end ;

The Sizes are worked out from the desktop and my dialog position. The whole idea around this is to have the help window as large as possible while not covering my current dialog.
ASKER CERTIFIED SOLUTION
Avatar of halser
halser

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JasonC

ASKER

Thanks halsar, that worked perfectly, I'll have to reject inthe and select your answer.

Cheers
Jason
Avatar of JasonC

ASKER

thanks again!