?
Solved

How to open a new windows chrome resized and disabled the toolbar?

Posted on 2016-09-11
3
Medium Priority
?
327 Views
Last Modified: 2016-09-25
Hello guys,

I need to call a new google chrome window in size 500 x 500, toolbar disable,

I am trying some codes that I found but I am not having success.

I can open a new windows, it is ok.  But I can't open it in my size 500, 500, when the windows is created, if I have one open, the new windows is created with the same size.

this is my simple code, please take a look at this:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, StrUtils, ShellApi;

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    Label1: TLabel;
    Edit1: TEdit;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function crGetDefaultBrowser: string;
var
  Path: array [0 .. 255] of char;
  Buff: array [0 .. 255] of WideChar;
  Filename: PWideChar;
  crGetTempPath: string;
begin
  GetTempPath(255, Buff);
  crGetTempPath := Buff;
  Filename := PWideChar(crGetTempPath + 'default.html');
  CloseHandle(CreateFile(Filename, GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_ALWAYS,
    FILE_ATTRIBUTE_NORMAL, 0));
  FindExecutable(Filename, nil, Path);
  DeleteFile(Filename);
  Result := Path;
end;

function crOpenBrowser(url: string): LongWord;
var
  Startupinfo: TStartupInfo;
  Processinfo: Tprocessinformation;
begin
  Fillchar(Startupinfo, Sizeof(Startupinfo), #0);
  Startupinfo.cb := Sizeof(Startupinfo);
  Startupinfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
  Startupinfo.wShowWindow := SW_SHOWNORMAL;

  if not Createprocess(nil, PWideChar(crGetDefaultBrowser + '  --cast-initial-screen-height=300 --cast-initial-screen-width=300 --window-position=20,20  --window-size=300,300 --new-window --url=' + ' ' + url ), nil, nil, False,
    CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, Startupinfo, Processinfo) then
    Result := WAIT_FAILED;

  if Processinfo.Hprocess <> 0 then
    CloseHandle(Processinfo.Hprocess);
  if Processinfo.Hthread <> 0 then
    CloseHandle(Processinfo.Hthread);
end;

//http://peter.sh/experiments/chromium-command-line-switches/


procedure TForm1.BitBtn1Click(Sender: TObject);
begin

  crOpenBrowser('www.bol.com.br');

end;

end.

Open in new window



here you can get the chrome parameter list
http://peter.sh/experiments/chromium-command-line-switches/#window-size

and here you can get some examples as it could be in other language:
https://github.com/s-haines/chrome-window-positioner/blob/master/src/main.js

I appreciate a lot a help on this
Alex
0
Comment
Question by:hidrau
[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
3 Comments
 
LVL 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 600 total points
ID: 41795732
FindExecutable returns LaunchWinApp for me, even if chrome is my default browser

chrome seems to ignore the settings for window sizing
0
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 1400 total points
ID: 41796973
Maybe you want to embed G. Chrome into your app. Following this chromiumembedded framework - you can. There is a Delphi component to simplify this process....
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 41815221
Thanks a lot
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

752 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