MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Samples / Initialize

Method Initialize

SampleApps/WebView2APISample/Toolbar.cpp:22–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22void Toolbar::Initialize(AppWindow* appWindow)
23{
24 m_appWindow = appWindow;
25 HWND mainWindow = m_appWindow->GetMainWindow();
26
27 m_items[Item_BackButton] = CreateWindow(
28 L"button", L"Back", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 0, 0, 0, 0,
29 mainWindow, (HMENU)IDE_BACK, nullptr, 0);
30 m_items[Item_ForwardButton] = CreateWindow(
31 L"button", L"Forward", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 0, 0, 0, 0,
32 mainWindow, (HMENU)IDE_FORWARD, nullptr, 0);
33 m_items[Item_ReloadButton] = CreateWindow(
34 L"button", L"Reload", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 0, 0, 0, 0,
35 mainWindow, (HMENU)IDE_ADDRESSBAR_RELOAD, nullptr, 0);
36 m_items[Item_CancelButton] = CreateWindow(
37 L"button", L"Cancel", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 0, 0, 0, 0,
38 mainWindow, (HMENU)IDE_CANCEL, nullptr, 0);
39 m_items[Item_AddressBar] = CreateWindow(
40 L"edit", nullptr, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL, 0, 0, 0, 0,
41 mainWindow, (HMENU)IDE_ADDRESSBAR, nullptr, 0);
42 m_items[Item_GoButton] = CreateWindow(
43 L"button", L"Go", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | BS_DEFPUSHBUTTON,
44 0, 0, 0, 0, mainWindow, (HMENU)IDE_ADDRESSBAR_GO, nullptr, 0);
45
46 UpdateDpiAndTextScale();
47 RECT availableBounds = { 0 };
48 GetClientRect(mainWindow, &availableBounds);
49 Resize(availableBounds);
50
51 DisableAllItems();
52}
53
54void Toolbar::SetItemEnabled(Item item, bool enabled)
55{

Callers 2

AppWindowMethod · 0.45
SettingsComponentMethod · 0.45

Calls 1

GetMainWindowMethod · 0.45

Tested by

no test coverage detected