Solved

WinHelp's SetWinPos

Posted on 2000-03-28
7
569 Views
Last Modified: 2008-03-10
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.
0
Comment
Question by:JasonC
  • 5
7 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2666093
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));
 
0
 

Author Comment

by:JasonC
ID: 2666996
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?
0
 

Author Comment

by:JasonC
ID: 2667001
I think i just worked out the Help class thing, is that the name of the help window to use?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:JasonC
ID: 2667187
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.
0
 
LVL 1

Accepted Solution

by:
halser earned 200 total points
ID: 2675930
The SetWinPos command is known not to work in all circumstances. You should try the code below.


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.

By the way, this is an excerpt from "All about help files in Borland Delphi", available at http://www.ec-software.com/tutorial.htm 


Alex


0
 

Author Comment

by:JasonC
ID: 2676908
Thanks halsar, that worked perfectly, I'll have to reject inthe and select your answer.

Cheers
Jason
0
 

Author Comment

by:JasonC
ID: 2676916
thanks again!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now