Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > Tools

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 09-09-2008, 04:21 AM
Samuel Samuel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 247
Default Hide Toolbars in AcroPDF

Hi,

In order to hide only some Toolbar in AcroPDF I made the following code:

1 - Is there a better way to do this?
2 - How can I hide some buttons inside one of the toolbars?

Thanks
Sam

[DELPHI]function EnumProc(wnd: HWND; Lines: TStrings): BOOL; stdcall;
var
buf, Caption: array[0..255] of char;
begin
Result := True;
GetClassName(wnd, buf, SizeOf(buf) - 1);
SendMessage(wnd, WM_GETTEXT, 256, Integer(@Caption));
Lines.Add(Format('HWND: %d, ID: %d, ClassName: %s, Caption: %s',
[wnd, GetDlgCtrlID(wnd), buf, Caption]));
end;

procedure TLixoPDFForm.MyButton7Click(Sender: TObject);
Var
Lines : TStringList;
St : String;
hControl : HWND;
I, Count : Integer;
Hidden : Boolean;
begin
PDF1.src := edPDF.Text;

Lines := TStringList.Create;
Hidden := FALSE;
Repeat
EnumChildWindows(PDF1.Handle, @EnumProc, Integer(Lines));

Count := 0;
For I := 0 To Lines.Count-1 Do
Begin
If Pos('ToolBarView', Lines[I]) > 0 Then inc(Count);
If (Count = 6) Or (Count = 8) Or (Count = 12) Then
Begin
St := AfterSt(Lines[I], 'HWND: ');
St := BeforeCh(st, ',');
Hidden := TRUE;
hControl := StrToInt(St);
ShowWindow(hControl, SW_HIDE);
End;
End;
Application.ProcessMessages;
until Hidden;
Lines.Free;

end;[/DELPHI]
Reply With Quote
  #2  
Old 09-09-2008, 05:21 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default RE: Hide Toolbars in AcroPDF

This is very similar like I did...
But instead of string-slicing, you can pass objectlists aswell.

Some sample I recently used (for another project):
Code:
type
  TComponentItem = class
  private
    FHwnd: THandle;
    FClassName: String;
    FCaption: String;
    FLeft: Integer;
    FTop: Integer;
  public
    constructor Create(Hwnd: THandle; ClassName, Caption: String;
      Left, Top: Integer);
    property Hwnd: THandle read FHwnd;
    property ClassName: String read FClassName;
    property Caption: String read FCaption;
    property Left: Integer read FLeft;
    property Top: Integer read FTop;
  end;

  TComponentList = class(TObjectList)
  private
    function GetItem(Index: Integer): TComponentItem;
    procedure SetItem(Index: Integer; Value: TComponentItem);
  public
    function IndexOf(ClassName, Caption: String;
      Occurrence: Integer = -1): Integer; overload;
    function IndexOf(ClassName: String; Left, Top: Integer;
      Occurrence: Integer = -1): Integer; overload;
    property Items[Index: Integer]: TComponentItem read GetItem
      write SetItem; default;
  end;

function EnumChildWindowsCallback(Hwnd: THandle;
  Items: TObjectList): Boolean; stdcall;
var
  caption: array [0..MAX_PATH - 1] of Char;
  classname: array [0..MAX_PATH - 1] of Char;
  placement: WINDOWPLACEMENT;
begin
  SendMessage(Hwnd, WM_GETTEXT, SizeOf(caption), LongInt(@caption));
  GetClassName(Hwnd, classname, SizeOf(classname) - 1);
  placement.length := SizeOf(WINDOWPLACEMENT);
  GetWindowPlacement(Hwnd, @placement);
  GetWindowLong(Hwnd, GWL_ID);
  Items.Add(TComponentItem.Create(Hwnd, classname, caption,
            placement.rcNormalPosition.Left, placement.rcNormalPosition.Top));
  Result := True;
end;

// And to call it:
procedure TForm1.Button1Click(Sender: TObject);
var
  componentlist: TComponentList;
begin
  componentlist := TComponentList.Create(True);
  try
    EnumChildWindows(AHandle, @EnumChildWindowsCallback, LPARAM(componentlist));
    // Either loop through the components or use your own IndexOf routines to get the correct item...
  finally
    componentlist.Free();
  end;
end;
I left the implementation of the TComponentItem and TComponentList classes up to you, but it's very straight-forward... You can see by looking at the names and the parameters what the methods should do...

And as for the hide some buttons of one of the toolbars question:
If you don't find the handles directly (I don't have adobe anymore so I cannot test this) try enumchildwindow on the handle of the toolbar and see what components come out of this routine...


Objective reality is a delirium caused by lack of alcohol in blood.
There is no place like 127.0.0.1
Reply With Quote
  #3  
Old 09-09-2008, 05:53 AM
mshkolnik mshkolnik is offline
Senior Member
 
Join Date: Jul 2001
Posts: 4,195
Default RE: Hide Toolbars in AcroPDF

You can use the PDF Open Parameters in the .Src property of the ActiveX control when telling it what PDF to open.

Find the info here:
http://www.adobe.com/devnet/acrobat/...parameters.pdf

With best regards, Mike Shkolnik
http://www.scalabium.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:09 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.