Solved

WinHelp's SetWinPos

Posted on 2000-03-28
7
570 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
proper way to parse text with delphi 7 121
build html 5 client that connect to indy Tidtcpserver 3 396
Downloading email attachments 2 73
JAudiorecorder record freezing the app 29 67
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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