Solved

WinHelp's SetWinPos

Posted on 2000-03-28
7
568 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
APK file name 7 64
delphi exception 7 58
indy Tmemory stream non latin charcter issue 2 82
oracle global variables 4 53
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

16 Experts available now in Live!

Get 1:1 Help Now