powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Как добавить классы для WebBrowser
7 сообщений из 7, страница 1 из 1
Как добавить классы для WebBrowser
    #39942598
Алексей222
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Ума и знаний не хватает что бы добавить во эти данные в форму
https://stackoverflow.com/questions/25843845/how-to-have-delphi-twebbrowser-component-running-in-ie9-mode

Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
type TBrowserEmulationAdjuster = class
  private
      class function GetExeName(): String; inline;
   public const
      // Quelle: https://msdn.microsoft.com/library/ee330730.aspx, Stand: 2017-04-26
      IE11_default   = 11000;
      IE11_Quirks    = 11001;
      IE10_force     = 10001;
      IE10_default   = 10000;
      IE9_Quirks     = 9999;
      IE9_default    = 9000;
      /// <summary>
      /// Webpages containing standards-based !DOCTYPE directives are displayed in IE7
      /// Standards mode. Default value for applications hosting the WebBrowser Control.
      /// </summary>
      IE7_embedded   = 7000;
   public
      class procedure SetBrowserEmulationDWORD(const value: DWORD);
end platform;

class function TBrowserEmulationAdjuster.GetExeName(): String;
begin
    Result := TPath.GetFileName( ParamStr(0) );
end;

class procedure TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(const value: DWORD);
const registryPath = 'Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION';
var
    registry:   TRegistry;
    exeName:   String;
begin
    exeName := GetExeName();

    registry := TRegistry.Create(KEY_SET_VALUE);
    try
       registry.RootKey := HKEY_CURRENT_USER;
       Win32Check( registry.OpenKey(registryPath, True) );
       registry.WriteInteger(exeName, value)
    finally
       registry.Destroy();
    end;

//Then add to your OnCreate of the Form:

TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(TBrowserEmulationAdjuster.IE11_Quirks);


Выдает одни ошибки
Что то не так делаю
Подскажите пожалуйста

Модератор: Пользуйтесь тегом (кнопкой) SRC для оформления кода, пожалуйста.
...
Рейтинг: 0 / 0
Как добавить классы для WebBrowser
    #39942645
Фотография Кроик Семён
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Алексей222,
KinsT_UA под "для начала код оформить бы в читабельном виде" вот что имел ввиду:
Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
unit Unit4;

interface

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

type
  TForm4 = class(TForm)
    WebBrowser1: TWebBrowser;
    procedure FormCreate(Sender: TObject);
    end;

    { Private declarations }
  public
  private
  type TBrowserEmulationAdjuster = class
  private
      class function GetExeName(): String; inline;
   public const
      // Quelle: https://msdn.microsoft.com/library/ee330730.aspx, Stand: 2017-04-26
      IE11_default   = 11000;
      IE11_Quirks    = 11001;
      IE10_force     = 10001;
      IE10_default   = 10000;
      IE9_Quirks     = 9999;
      IE9_default    = 9000;
      /// <summary>
      /// Webpages containing standards-based !DOCTYPE directives are displayed in IE7
      /// Standards mode. Default value for applications hosting the WebBrowser Control.
      /// </summary>
      IE7_embedded   = 7000;
   public
      class procedure SetBrowserEmulationDWORD(const value: DWORD);
end platform;
    { Public declarations }
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}
 class function TBrowserEmulationAdjuster.GetExeName(): String;
begin
    Result := TPath.GetFileName( ParamStr(0) );
end;

class procedure TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(const value: DWORD);
const registryPath = 'Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION';
var
    registry:   TRegistry;
    exeName:   String;
begin
    exeName := GetExeName();

    registry := TRegistry.Create(KEY_SET_VALUE);
    try
       registry.RootKey := HKEY_CURRENT_USER;
       Win32Check( registry.OpenKey(registryPath, True) );
       registry.WriteInteger(exeName, value)
    finally
       registry.Destroy();
    end;
procedure TForm4.FormCreate(Sender: TObject);
begin
TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(TBrowserEmulationAdjuster.IE11_Quirks);
end;

end.
...
Рейтинг: 0 / 0
Как добавить классы для WebBrowser
    #39942652
Алексей222
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Выдаёт ошибки
[dcc32 Error] Unit4.pas(17): E2029 '=' expected but identifier 'private' found
[dcc32 Error] Unit4.pas(18): E2029 ';' expected but 'TYPE' found
[dcc32 Error] Unit4.pas(38): E2029 'IMPLEMENTATION' expected but ';' found
[dcc32 Error] Unit4.pas(43): E2029 Declaration expected but 'IMPLEMENTATION' found
[dcc32 Fatal Error] Unit4.pas(43): E2226 Compilation terminated; too many errors
...
Рейтинг: 0 / 0
Как добавить классы для WebBrowser
    #39942663
KinsT_UA
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Кроик Семён, таки да!
Именно об этом :)

Алексей222, может быть ты сформулируешь свою проблему?

Иначе, твой вопрос звучит так:
Как мне заставить работать код, взятый со стековерфлоу из ответа даже не отмеченного галочкой?
...
Рейтинг: 0 / 0
Как добавить классы для WebBrowser
    #39942667
KinsT_UA
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Подозреваю, что должно быть как-то так...
Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs
  { ТО, ЧЕГО В СУПЕ НЕ ХВАТАЛО }
  , System.Win.Registry, System.IOUtils;

type

  { ОБРАТИ ВНИМАНИЕ НА ТО КУДА ДОБАВЛЕН КЛАСС }

  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TBrowserEmulationAdjuster = class
  private
    class function GetExeName(): String; inline;
  public const
    // Quelle: https://msdn.microsoft.com/library/ee330730.aspx, Stand: 2017-04-26
    IE11_default   = 11000;
    IE11_Quirks    = 11001;
    IE10_force     = 10001;
    IE10_default   = 10000;
    IE9_Quirks     = 9999;
    IE9_default    = 9000;
    /// <summary>
    /// Webpages containing standards-based !DOCTYPE directives are displayed in IE7
    /// Standards mode. Default value for applications hosting the WebBrowser Control.
    /// </summary>
    IE7_embedded   = 7000;
  public
    class procedure SetBrowserEmulationDWORD(const value: DWORD);
  end platform;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TBrowserEmulationAdjuster }

class function TBrowserEmulationAdjuster.GetExeName: String;
begin
  Result := TPath.GetFileName( ParamStr(0) );
end;

class procedure TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(const value: DWORD);
const registryPath = 'Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION';
var
  registry:   TRegistry;
  exeName:   String;
begin
  exeName := GetExeName();

  registry := TRegistry.Create(KEY_SET_VALUE);
  try
     registry.RootKey := HKEY_CURRENT_USER;
     Win32Check( registry.OpenKey(registryPath, True) );
     registry.WriteInteger(exeName, value)
  finally
     registry.Destroy();
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(TBrowserEmulationAdjuster.IE11_Quirks);
end;

end.

...
Рейтинг: 0 / 0
Как добавить классы для WebBrowser
    #39942960
Фотография _Vasilisk_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Алексей222
Выдаёт ошибки
Просто пора похоронить Делфи 7
...
Рейтинг: 0 / 0
Как добавить классы для WebBrowser
    #39942997
bk0010
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
_Vasilisk_
Алексей222
Выдаёт ошибки
Просто пора похоронить Делфи 7
Руки прочь!
...
Рейтинг: 0 / 0
7 сообщений из 7, страница 1 из 1
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Как добавить классы для WebBrowser
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]