Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WinHelp's SetWinPos

Posted on 2000-03-28
7
Medium Priority
?
574 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 800 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

705 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