MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / Initialize

Method Initialize

src/windows/NotificationViewer.cpp:23–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23void NotificationViewer::Initialize(HWND hWnd)
24{
25 RECT rect{};
26 GetWindowRect(hWnd, &rect);
27 int width = rect.right - rect.left;
28 int height = rect.bottom - rect.top;
29 int xPos = m_appearXY.x;
30 int yPos = m_appearXY.y;
31 if (m_bRightJustify) {
32 xPos -= width;
33 }
34 MoveWindow(hWnd, xPos, yPos, width, height, false);
35
36 SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_hInstance, MAKEINTRESOURCE(DMIC(IDI_NOTIFICATION))));
37
38 HWND child = GetDlgItem(hWnd, IDC_NOTIFS_MARK_AS_READ);
39 int sm = GetSystemMetrics(SM_CXSMICON);
40 HICON hico = (HICON)ri::LoadImage(g_hInstance, MAKEINTRESOURCE(DMIC(IDI_MARK_READ)), IMAGE_ICON, sm, sm, LR_SHARED | LR_CREATEDIBSECTION);
41 SendMessage(child, BM_SETIMAGE, IMAGE_ICON, (LPARAM) hico);
42
43 child = GetDlgItem(hWnd, IDC_MESSAGE_LIST);
44
45 GetWindowRect(child, &rect);
46 ScreenToClientRect(hWnd, &rect);
47 DestroyWindow(child);
48
49 SAFE_DELETE(m_pMessageList);
50
51 m_pMessageList = MessageList::Create(hWnd, &rect);
52 m_pMessageList->SetManagedByOwner(true);
53 m_pMessageList->SetTopDown(true);
54 m_pMessageList->SetGuild(0);
55 m_pMessageList->SetChannel(0);
56
57 const auto& notifs = GetNotificationManager()->GetNotifications();
58 if (notifs.empty())
59 {
60 MessagePtr msg = MakeMessage();
61 msg->m_type = MessageType::NO_NOTIFICATIONS;
62 msg->m_snowflake = 1;
63 m_pMessageList->AddMessage(msg);
64 }
65 else for (const auto& notif : notifs)
66 {
67 MessagePtr msg = MakeMessage();
68 msg->m_type = MessageType::DEFAULT;
69 msg->m_avatar = notif.m_avatarLnk;
70 msg->m_message = notif.m_contents;
71 msg->m_snowflake = notif.m_sourceMessage;
72 msg->m_anchor = notif.m_sourceChannel;
73 msg->m_bRead = notif.m_bRead;
74 msg->SetTime(notif.m_timeReceived);
75
76 // special handling for the author
77 std::string guildName = "Unknown", channelName = "Unknown";
78 Guild* pGuild = GetDiscordInstance()->GetGuild(notif.m_sourceGuild);
79 if (pGuild) {
80 guildName = pGuild->m_name;

Callers

nothing calls this directly

Calls 14

ScreenToClientRectFunction · 0.85
GetNotificationManagerFunction · 0.85
MakeMessageFunction · 0.85
GetDiscordInstanceFunction · 0.85
SetManagedByOwnerMethod · 0.80
SetTopDownMethod · 0.80
SetChannelMethod · 0.80
SetTimeMethod · 0.80
GetGuildMethod · 0.80
GetTypeSymbolMethod · 0.80
SetGuildMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected