Rewritten GuildView and a new user panel

This commit is contained in:
snow32a
2026-06-22 01:19:00 +03:00
parent 74d5442108
commit eda60e8a8f
6 changed files with 263 additions and 174 deletions
+7 -14
View File
@@ -187,13 +187,6 @@ BOOL IsStartMsg(ChatWnd *cwnd, int i) {
return TRUE;
}
}
BOOL ShouldGoUp(ChatWnd *cwnd, int i) {
if (i > 0) {
return (IsStartMsg(cwnd, i - 1) && !IsStartMsg(cwnd, i));
} else {
return FALSE;
}
}
LRESULT CALLBACK ChatWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam) {
@@ -225,12 +218,12 @@ LRESULT CALLBACK ChatWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
SetBrushOrgEx(hdc, 0, 0, NULL);
typedef struct {
int TextContentHeight;
int UnpaddedMessageHeight;
int ClampedUnpaddedMessageHeight;
int UnclampedTotalMessageHeight;
int TotalMessageHeight;
int MessageHeightForUse;
unsigned int TextContentHeight;
unsigned int UnpaddedMessageHeight;
unsigned int ClampedUnpaddedMessageHeight;
unsigned int UnclampedTotalMessageHeight;
unsigned int TotalMessageHeight;
unsigned int MessageHeightForUse;
BOOL StartMsg;
BOOL PushBack;
} MessageDetails;
@@ -258,7 +251,7 @@ LRESULT CALLBACK ChatWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
}
if (msgdet[i].PushBack) {
// 15 is for the username field
msgdet[i].UnpaddedMessageHeight =
15 + msgdet[i].TextContentHeight;
+138 -104
View File
@@ -30,7 +30,8 @@ void GuildView_SetIcon(HWND hwnd, HDC icon, char *id) {
GuildWnd *guildwnd = GetGuildControlDetails(hwnd);
for (int i = 0; i < guildwnd->uigldcnt; i++) {
if (strcmp(guildwnd->uiglds[i].id, id) == 0) {
guildwnds->uiglds[i].icon = icon;
guildwnd->uiglds[i].icon = icon;
InvalidateRect(hwnd, NULL, TRUE);
break;
}
}
@@ -40,6 +41,7 @@ void GuildView_SetMentionCount(HWND hwnd, char *id, int cnt) {
for (int i = 0; i < guildwnd->uigldcnt; i++) {
if (strcmp(guildwnd->uiglds[i].id, id) == 0) {
guildwnds->uiglds[i].MentionCount = cnt;
InvalidateRect(hwnd, NULL, TRUE);
break;
}
}
@@ -47,7 +49,8 @@ void GuildView_SetMentionCount(HWND hwnd, char *id, int cnt) {
}
void GuildView_SetDMsIcon(HWND hwnd, HDC icon) {
GuildWnd *guildwnd = GetGuildControlDetails(hwnd);
guildwnds->dmsicon = icon;
guildwnd->dmsicon = icon;
InvalidateRect(hwnd, NULL, TRUE);
}
LRESULT CALLBACK GuildWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
@@ -60,6 +63,12 @@ LRESULT CALLBACK GuildWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
guildwnds[guildwndcount - 1].uiglds = NULL;
guildwnds[guildwndcount - 1].hWnd = hwnd;
guildwnds[guildwndcount - 1].scrollOffset = 0;
guildwnds[guildwndcount - 1].GuildSize = 48;
guildwnds[guildwndcount - 1].selIndex = -2;
SetWindowLongPtr(hwnd, GWL_STYLE,
GetWindowLongPtr(hwnd, GWL_STYLE) | WS_VSCROLL);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
return 0;
break;
case WM_PAINT: {
@@ -69,132 +78,157 @@ LRESULT CALLBACK GuildWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
FillRect(hdc, &ctlrect, (HBRUSH)(COLOR_3DFACE + 1));
int starty;
int x =
(ctlrect.right - ctlrect.left) /
2 -
gwnd->GuildSize / 2;
SetStretchBltMode(hdc, HALFTONE);
RECT rc = ctlrect;
int ctlw = ctlrect.right - ctlrect.left;
int guildsize = ctlw - 16;
int dmregy = 8 + gwnd->GuildSize + 8 + 10;
int hry = 8 + gwnd->GuildSize + 8;
int dmregstarty = 8;
rc.left += 8;
rc.right = rc.left + guildsize;
rc.top += 8;
rc.bottom = rc.top + guildsize;
HBITMAP hdmsbmp = GetCurrentObject(gwnd->dmsicon, OBJ_BITMAP);
BITMAP dmsbmp;
GetObject(hdmsbmp, sizeof(BITMAP), &dmsbmp);
if (gwnd->dmsicon) {
StretchBlt(hdc, x, dmregstarty-gwnd->scrollOffset,
gwnd->GuildSize, gwnd->GuildSize, gwnd->dmsicon, 0, 0, dmsbmp.bmWidth, dmsbmp.bmHeight,
SRCCOPY);
COLORREF hrup = GetSysColor(COLOR_3DHILIGHT);
COLORREF hrdown = GetSysColor(COLOR_3DSHADOW);
HPEN penhrup = CreatePen(PS_SOLID, 1, hrup);
HPEN penhrdown = CreatePen(PS_SOLID, 1, hrdown);
HPEN oldPen = SelectPen(hdc, penhrdown);
BITMAP bmpInfo;
HBITMAP hSrcBmp =
(HBITMAP)GetCurrentObject(gwnd->dmsicon, OBJ_BITMAP);
GetObject(hSrcBmp, sizeof(BITMAP), &bmpInfo);
MoveToEx(hdc, x, hry, NULL);
LineTo(hdc, x + gwnd->GuildSize, hry);
StretchBlt(hdc, rc.left, rc.top, guildsize, guildsize,
gwnd->dmsicon, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight,
SRCCOPY);
} else {
FillRect(hdc, &rc, (HBRUSH)(COLOR_3DSHADOW + 1));
}
HPEN hPenDark = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
HPEN hPenLight =
CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
HPEN hOldPen;
SelectPen(hdc, penhrup);
hOldPen = SelectObject(hdc, hPenDark);
MoveToEx(hdc, rc.left, rc.top + guildsize + 8, NULL);
LineTo(hdc, rc.right, rc.top + guildsize + 8);
MoveToEx(hdc, x, hry+1, NULL);
LineTo(hdc, x + gwnd->GuildSize, hry + 1);
SelectPen(hdc,oldPen);
SelectObject(hdc, hPenLight);
MoveToEx(hdc, rc.left, rc.top + guildsize + 1 + 8, NULL);
LineTo(hdc, rc.right, rc.top + guildsize + 1 + 8);
SelectObject(hdc, hOldPen);
DeleteObject(hPenDark);
DeleteObject(hPenLight);
int gldstarty=dmregy-gwnd->scrollOffset;
for (int i = 0; i < gwnd->uigldcnt; i++) {
RECT rc = ctlrect;
rc.left += 8;
rc.right = rc.left + guildsize;
rc.top += i * (guildsize + 8) + 8 + guildsize + 10 + 8;
rc.bottom = rc.top + guildsize;
if (i == gwnd->selIndex) {
RECT rcs = rc;
rcs.left = ctlrect.left;
rcs.right = ctlrect.right;
rcs.top -= 4;
rcs.bottom += 4;
FillRect(hdc, &rcs, (HBRUSH)(COLOR_HIGHLIGHT + 1));
GUIGuild gld = gwnd->uiglds[i];
if (gwnd->selIndex == i) {
RECT lprc;
lprc.left = 0;
lprc.right = ctlrect.right;
lprc.top = (gwnd->GuildSize + 8) * i + gldstarty-4;
lprc.bottom = lprc.top + gwnd->GuildSize+8;
FillRect(hdc, &lprc, (HBRUSH)(COLOR_HIGHLIGHT + 1));
}
if (gwnd->uiglds[i].icon) {
BITMAP bmpInfo;
HBITMAP hSrcBmp =
(HBITMAP)GetCurrentObject(gwnd->uiglds[i].icon, OBJ_BITMAP);
GetObject(hSrcBmp, sizeof(BITMAP), &bmpInfo);
StretchBlt(hdc, rc.left, rc.top, guildsize, guildsize,
gwnd->uiglds[i].icon, 0, 0, bmpInfo.bmWidth,
bmpInfo.bmHeight, SRCCOPY);
if (gld.icon) {
int srcw, srch;
HBITMAP hbmp = GetCurrentObject(gld.icon, OBJ_BITMAP);
BITMAP bmp;
GetObject(hbmp, sizeof(BITMAP), &bmp);
srcw = bmp.bmWidth;
srch = bmp.bmHeight;
StretchBlt(hdc, x, (gwnd->GuildSize+8) * i + gldstarty, gwnd->GuildSize,
gwnd->GuildSize, gld.icon, 0, 0, srcw, srch,
SRCCOPY);
} else {
FillRect(hdc, &rc, (HBRUSH)(COLOR_3DSHADOW + 1));
}
if (gwnd->uiglds[i].MentionCount) {
HBRUSH indicatorbrush = CreateSolidBrush((COLORREF)0x000000FF);
RECT lprc;
lprc.left = x;
lprc.right = x + gwnd->GuildSize;
lprc.top = (gwnd->GuildSize + 8) * i + gldstarty;
lprc.bottom = lprc.top + gwnd->GuildSize;
RECT rc = ctlrect;
rc.left += 8;
rc.right = rc.left + guildsize;
rc.top += i * (guildsize + 8) + 8 + guildsize + 10 + 8;
rc.bottom = rc.top + guildsize;
rc.top = i * (guildsize + 8) + 8 + guildsize + 10 + 8 + guildsize - 16;
rc.left = rc.left + guildsize - 16;
FillRect(hdc, &rc, indicatorbrush);
char unreadtxt[16];
wsprintf(unreadtxt,"%i",gwnd->uiglds[i].MentionCount);
DrawText(hdc,unreadtxt,strlen(unreadtxt),&rc,DT_SINGLELINE | DT_CENTER | DT_VCENTER);
FillRect(hdc, &lprc, (HBRUSH)(COLOR_3DSHADOW + 1));
char *initials = malloc(2);
initials[0] = gld.title[0];
int sizeofinitials = 1;
for (char *c = gld.title + 1; *c; c++) {
if (*(c - 1) == ' ') {
sizeofinitials++;
initials=realloc(initials, sizeofinitials+1);
initials[sizeofinitials-1]=*c;
}
}
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, RGB(255, 255, 255));
SetBkColor(hdc,TRANSPARENT);
DrawTextA(hdc,initials,sizeofinitials,&lprc,DT_SINGLELINE | DT_VCENTER | DT_CENTER);
free(initials);
}
}
EndPaint(hwnd, &ps);
// Set scroll stuff
int contentHeight = gwnd->uigldcnt * (gwnd->GuildSize+8)+dmregy;
RECT rc;
GetClientRect(hwnd, &rc);
SCROLLINFO si = {sizeof(si), SIF_RANGE | SIF_PAGE | SIF_POS,
0, contentHeight - 1,
rc.bottom, gwnd->scrollOffset};
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
return 0;
break;
}
case WM_VSCROLL:
{
GuildWnd *gwnd = GetGuildControlDetails(hwnd);
SCROLLINFO si = { sizeof(si), SIF_ALL };
GetScrollInfo(hwnd, SB_VERT, &si);
switch (LOWORD(wParam))
{
case SB_LINEUP: si.nPos -= 20; break;
case SB_LINEDOWN: si.nPos += 20; break;
case SB_PAGEUP: si.nPos -= si.nPage; break;
case SB_PAGEDOWN: si.nPos += si.nPage; break;
case SB_THUMBTRACK: si.nPos = si.nTrackPos; break;
}
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
GetScrollInfo(hwnd, SB_VERT, &si);
gwnd->scrollOffset = si.nPos;
InvalidateRect(hwnd, NULL, FALSE);
return 0;
}
case WM_LBUTTONUP: {
GuildWnd *gwnd = GetGuildControlDetails(hwnd);
RECT ctlrect;
GetClientRect(hwnd, &ctlrect);
int ctlw = ctlrect.right - ctlrect.left;
int guildsize = ctlw - 16;
if (GET_Y_LPARAM(lParam) < guildsize + 10 + 8) {
if (gwnd->selIndex != 1) {
gwnd->selIndex = -1;
int x = GET_X_LPARAM(lParam);
int y = GET_Y_LPARAM(lParam)+gwnd->scrollOffset;
NMGUILDVIEW nm = {0};
nm.hdr.hwndFrom = hwnd;
nm.hdr.idFrom = GetDlgCtrlID(hwnd);
nm.hdr.code = GVN_ITEMCLICK;
nm.index = GUILDVIEW_DMS;
nm.guild = (GUIGuild){NULL};
nm.pt = (POINT){GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
NMGUILDVIEW nm = {0};
SendMessage(GetParent(hwnd), WM_NOTIFY, (WPARAM)nm.hdr.idFrom,
(LPARAM)&nm);
InvalidateRect(hwnd, NULL, FALSE);
nm.hdr.hwndFrom = hwnd;
nm.hdr.idFrom = GetDlgCtrlID(hwnd);
nm.hdr.code = GVN_ITEMCHANGED;
if (y < 8 + gwnd->GuildSize && gwnd->selIndex != GUILDVIEW_DMS) {
gwnd->selIndex = GUILDVIEW_DMS;
nm.index = GUILDVIEW_DMS;
nm.guild = (GUIGuild){0};
} else if (y > 8 + gwnd->GuildSize + 8 + 10) {
nm.index = (y - 16 - 10 - gwnd->GuildSize) / (gwnd->GuildSize + 8);
if (nm.index == gwnd->selIndex) {
return 0;
}
gwnd->selIndex=nm.index;
nm.guild = gwnd->uiglds[nm.index];
} else {
int index = (GET_Y_LPARAM(lParam) - 8 - guildsize - 10 - 8) /
(guildsize + 8);
if (index != gwnd->selIndex) {
NMGUILDVIEW nm = {0};
nm.hdr.hwndFrom = hwnd;
nm.hdr.idFrom = GetDlgCtrlID(hwnd);
nm.hdr.code = GVN_ITEMCLICK;
nm.index = index;
nm.guild = gwnd->uiglds[index];
nm.pt = (POINT){GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
gwnd->selIndex = index;
SendMessage(GetParent(hwnd), WM_NOTIFY, (WPARAM)nm.hdr.idFrom,
(LPARAM)&nm);
InvalidateRect(hwnd, NULL, FALSE);
}
return 0;
}
nm.pt.x = x;
nm.pt.y = y;
SendMessage(GetParent(hwnd), WM_NOTIFY, nm.hdr.idFrom, (LPARAM)&nm);
InvalidateRect(hwnd, NULL, true);
return 0;
}
}
+2 -1
View File
@@ -1,7 +1,7 @@
#include <windows.h>
#include "../hmap/hashmap.h"
#define GVN_ITEMCLICK (0U - 1800U)
#define GVN_ITEMCHANGED (0U - 1800U)
#define GUILDVIEW_MAGIC 0xACC0
#define GUILDVIEW_DMS -1
typedef struct {
@@ -26,6 +26,7 @@ typedef struct {
int contentHeight;
HDC dmsicon;
int selIndex;
int GuildSize;
} GuildWnd;
LRESULT CALLBACK GuildWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
+10 -1
View File
@@ -32,6 +32,7 @@ static int ChannelCompare(const void *a, const void *b, void *udata) {
static void ChannelFree(void *item) {}
extern void onDiscordGuildLoad(DiscordGuild *guild, char *id);
extern void onDiscordUpdatedGuildReadState(DiscordGuild gld);
extern void onDiscordReady(DiscordUser user, DiscordGuild *guilds, int guildscount);
int DiscordSendMessage(const char *channelID, const char *content) {
cJSON *payload = cJSON_CreateObject();
cJSON *name = cJSON_CreateString(content);
@@ -313,7 +314,6 @@ void HandleREADY(cJSON *json) {
onDiscordGuildLoad(g, id);
}
cJSON *readstates = cJSON_GetObjectItem(data, "read_state");
for (int i = 0; i < cJSON_GetArraySize(readstates); i++) {
cJSON *readstate = cJSON_GetArrayItem(readstates, i);
@@ -343,6 +343,15 @@ void HandleREADY(cJSON *json) {
}
}
}
cJSON *jsonusr = cJSON_GetObjectItem(data, "user");
DiscordUser curuser = {0};
curuser.Username = cJSON_GetObjectItem(jsonusr, "username")->valuestring;
cJSON *jsondispname = cJSON_GetObjectItem(jsonusr, "global_name");
curuser.DisplayName = jsondispname ? jsondispname->valuestring : NULL;
cJSON *jsonavatar = cJSON_GetObjectItem(jsonusr, "avatar");
curuser.avatar = jsonavatar ? jsonavatar->valuestring : NULL;
curuser.id = cJSON_GetObjectItem(jsonusr, "id")->valuestring;
onDiscordReady(curuser,NULL,0);
}
extern void onDiscordReceiveMessage(DiscordMessage msg);
void HandleMessageCreate(cJSON *json) {
-3
View File
File diff suppressed because one or more lines are too long
+105 -50
View File
@@ -29,6 +29,10 @@ static HWND hDMsList;
static HWND hGSel;
static HWND hPfpArea;
static HWND hMemList;
static HWND hPfpAreaPfp;
static HWND hPfpAreaDispName;
static HWND hPfpAreaUserName;
static HIMAGELIST hSidePfps;
HINSTANCE hInstance;
SSL *GatewaySSL;
@@ -127,6 +131,61 @@ void onDiscordGuildLoad(DiscordGuild *guild, char *id) {
free(path);
}
}
HBITMAP ResizeBitmap(HBITMAP hOrig, int w, int h) {
BITMAP bm;
GetObject(hOrig, sizeof(bm), &bm);
HDC hdcScreen = GetDC(NULL);
HDC hdcSrc = CreateCompatibleDC(hdcScreen);
HDC hdcDst = CreateCompatibleDC(hdcScreen);
HBITMAP hResized = CreateCompatibleBitmap(hdcScreen, w, h);
SelectObject(hdcSrc, hOrig);
SelectObject(hdcDst, hResized);
SetStretchBltMode(hdcDst, HALFTONE);
SetBrushOrgEx(hdcDst, 0, 0, NULL);
StretchBlt(hdcDst, 0, 0, w, h, hdcSrc, 0, 0, bm.bmWidth, bm.bmHeight,
SRCCOPY);
DeleteDC(hdcSrc);
DeleteDC(hdcDst);
ReleaseDC(NULL, hdcScreen);
DeleteObject(hOrig);
return hResized;
}
void onDiscordReady(DiscordUser user, DiscordGuild *guilds, int guildscount) {
if (user.avatar) {
char tempPath[MAX_PATH];
DWORD len = GetTempPathA(MAX_PATH, tempPath);
char *path = malloc(MAX_PATH + strlen(user.id) + 1);
wsprintfA(path, "%s%s.png", tempPath, user.avatar);
if (GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES) {
path = DiscordFetchTmpPfp(user.id,
user.avatar); // testing
}
RECT ClientRect;
GetClientRect(hPfpAreaPfp, &ClientRect);
int DestW = ClientRect.right - ClientRect.left;
int DestH = ClientRect.bottom - ClientRect.top;
SendMessage(hPfpAreaPfp, STM_SETIMAGE, IMAGE_BITMAP,
(LPARAM)ResizeBitmap(LoadPNGBitmap(path),DestW,DestH));
free(path);
}
if (user.DisplayName) {
SetWindowText(hPfpAreaDispName, user.DisplayName);
SetWindowText(hPfpAreaUserName, user.Username);
} else {
SetWindowText(hPfpAreaDispName, user.Username);
ShowWindow(hPfpAreaUserName, SW_HIDE);
}
}
void onDiscordUpdatedGuildReadState(DiscordGuild guild) {
GuildView_SetMentionCount(hGSel, guild.id, guild.MentionCount);
}
@@ -162,7 +221,7 @@ LRESULT CALLBACK MsgBarSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (!(GetKeyState(VK_SHIFT) &
0x8000)) // if no shift then do cool stuff
{
char *msgcontent = malloc(GetWindowTextLength(hMsg) + 1);
char msgcontent[GetWindowTextLength(hMsg) + 1];
GetWindowText(hMsg, msgcontent, GetWindowTextLength(hMsg) + 1);
DiscordSendMessage(curChannel, msgcontent);
@@ -173,35 +232,17 @@ LRESULT CALLBACK MsgBarSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
return CallWindowProc(msgoldwndproc, hwnd, msg, wParam, lParam);
}
HBITMAP ResizeBitmap(HBITMAP hOrig, int w, int h) {
BITMAP bm;
GetObject(hOrig, sizeof(bm), &bm);
HDC hdcScreen = GetDC(NULL);
HDC hdcSrc = CreateCompatibleDC(hdcScreen);
HDC hdcDst = CreateCompatibleDC(hdcScreen);
HBITMAP hResized = CreateCompatibleBitmap(hdcScreen, w, h);
SelectObject(hdcSrc, hOrig);
SelectObject(hdcDst, hResized);
SetStretchBltMode(hdcDst, HALFTONE);
SetBrushOrgEx(hdcDst, 0, 0, NULL);
StretchBlt(hdcDst, 0, 0, w, h, hdcSrc, 0, 0, bm.bmWidth, bm.bmHeight,
SRCCOPY);
DeleteDC(hdcSrc);
DeleteDC(hdcDst);
ReleaseDC(NULL, hdcScreen);
DeleteObject(hOrig);
return hResized;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam) {
switch (uMsg) {
case WM_CREATE:
NONCLIENTMETRICS ncm = {sizeof(NONCLIENTMETRICS)};
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
HFONT SysFont = CreateFontIndirect(&ncm.lfMessageFont);
ncm.lfMessageFont.lfWeight = FW_BOLD;
HFONT BoldSysFont = CreateFontIndirect(&ncm.lfMessageFont);
InitHTTP();
OpenWebSocket("gateway.discord.gg", "/?encoding=json&v=9", &GatewaySSL);
@@ -213,7 +254,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
WS_CHILD | WS_VISIBLE | LVS_LIST, // Window style
// Size and position
0, 0, 75, rc.bottom - rc.top - 80,
0, 0, 90, rc.bottom - rc.top - 80,
hwnd, // Parent window
(HMENU)102, // Menu
@@ -225,10 +266,10 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
hChTree = CreateWindowExA(WS_EX_CLIENTEDGE, WC_TREEVIEWA, NULL,
WS_CHILD | WS_VISIBLE | TVS_HASLINES |
TVS_LINESATROOT | TVS_HASBUTTONS,
75, 0, 128, rc.bottom - rc.top - 80, hwnd,
90, 0, 128, rc.bottom - rc.top - 80, hwnd,
(HMENU)103, hInstance, NULL);
hDMsList = CreateWindowExA(
WS_EX_CLIENTEDGE, WC_LISTVIEWA, NULL, WS_CHILD | WS_VISIBLE, 75, 0,
WS_EX_CLIENTEDGE, WC_LISTVIEWA, NULL, WS_CHILD | WS_VISIBLE, 90, 0,
128, rc.bottom - rc.top - 80, hwnd, (HMENU)103, hInstance, NULL);
ShowWindow(hDMsList, SW_HIDE);
hMsgList = CreateWindowEx(0, // Optional window styles.
@@ -237,7 +278,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
WS_CHILD | WS_VISIBLE, // Window style
// Size and position
75 + 128, 0, rc.right - 128 - 75,
75 + 128, 0, rc.right - 128 - 90,
rc.bottom - rc.top - 25,
hwnd, // Parent window
@@ -245,20 +286,31 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
hInstance, // Instance handle
NULL); // Additional application data
hPfpArea = CreateWindowEx(
0, // Optional window styles.
"BUTTON", // Window class
"User Profile", // Window text
ES_MULTILINE | WS_CHILD | WS_VISIBLE | BS_GROUPBOX, // Window style
hPfpArea =
CreateWindowEx(0, // Optional window styles.
"BUTTON", // Window class
"User Profile", // Window text
WS_CHILD | WS_VISIBLE | BS_GROUPBOX, // Window style
// Size and position
0, rc.bottom - rc.top - 80, 128 + 75, 80,
// Size and position
0, rc.bottom - rc.top - 80, 128 + 89, 80,
hwnd, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
hwnd, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
hPfpAreaPfp = CreateWindowExA(
0, "STATIC", "", SS_BITMAP | WS_CHILD | WS_VISIBLE,
12, 24, 36, 36, hPfpArea, NULL, GetModuleHandle(NULL), NULL);
hPfpAreaDispName = CreateWindowExA(
0, "STATIC", "Display Name", WS_CHILD | WS_VISIBLE, 54, 24, 144, 16,
hPfpArea, NULL, GetModuleHandle(NULL), NULL);
SendMessage(hPfpAreaDispName, WM_SETFONT, (WPARAM)BoldSysFont, 0);
hPfpAreaUserName = CreateWindowExA(
0, "STATIC", "Username", WS_CHILD | WS_VISIBLE, 54, 38, 144, 16,
hPfpArea, NULL, GetModuleHandle(NULL), NULL);
SendMessage(hPfpAreaUserName, WM_SETFONT, (WPARAM)SysFont, 0);
SendMessage(hPfpArea, WM_SETFONT, (WPARAM)regfont, 0);
hMsg = CreateWindowEx(WS_EX_CLIENTEDGE, // Optional window styles.
"EDIT", // Window class
@@ -267,8 +319,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
WS_VISIBLE, // Window style
// Size and position
128 + 75, rc.bottom - rc.top - 25,
rc.right - rc.left - 128 - 75 - 25, 25,
128 + 89, rc.bottom - rc.top - 25,
rc.right - rc.left - 128 - 89 - 25, 25,
hwnd, // Parent window
(HMENU)104, // Menu
@@ -300,11 +352,11 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
int height = HIWORD(lParam);
SetWindowPos(hPfpArea, NULL, 0, height - 80, 0, 0,
SWP_NOSIZE | SWP_NOZORDER);
SetWindowPos(hGSel, NULL, 0, 0, 75, height - 80, SWP_NOZORDER);
SetWindowPos(hMsg, NULL, 128 + 75, height - 25, width - 128 - 75 - 25,
SetWindowPos(hGSel, NULL, 0, 0, 90, height - 80, SWP_NOZORDER);
SetWindowPos(hMsg, NULL, 128 + 90, height - 25, width - 128 - 90 - 25,
25, SWP_NOZORDER);
SetWindowPos(hChTree, NULL, 75, 0, 128, height - 80, SWP_NOZORDER);
SetWindowPos(hMsgList, NULL, 128 + 75, 0, width - 128 - 75, height - 25,
SetWindowPos(hChTree, NULL, 90, 0, 128, height - 80, SWP_NOZORDER);
SetWindowPos(hMsgList, NULL, 128 + 90, 0, width - 128 - 90, height - 25,
SWP_NOZORDER);
SetWindowPos(hSend, NULL, width - 25, height - 25, 25, 25,
SWP_NOZORDER | SWP_NOSIZE);
@@ -340,13 +392,13 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
char tempPath[MAX_PATH];
DWORD len = GetTempPathA(MAX_PATH, tempPath);
char path[MAX_PATH +
strlen(dms[i].receipents[0].avatar) + 1];
strlen(dms[i].receipents[0].avatar) + 1];
wsprintfA(path, "%s%s.png", tempPath,
dms[i].receipents[0].avatar);
if (GetFileAttributesA(path) ==
INVALID_FILE_ATTRIBUTES) {
char* path2 = DiscordFetchTmpPfp(
char *path2 = DiscordFetchTmpPfp(
dms[i].receipents[0].id,
dms[i].receipents[0].avatar); // testing
ImageList_Add(
@@ -377,6 +429,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
tvInsert.item.stateMask = TVIS_EXPANDED;
tvInsert.item.iImage =
dms[i].receipents[0].avatar ? pfpidx : 0;
tvInsert.item.iSelectedImage =
dms[i].receipents[0].avatar ? pfpidx : 0;
HTREEITEM lres = (HTREEITEM)SendMessage(
hChTree, TVM_INSERTITEM, 0, (LPARAM)&tvInsert);
if (dms[i].receipents[0].avatar) {
@@ -492,6 +546,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
FillRect(hdc, &ps.rcPaint, (HBRUSH)(COLOR_BTNFACE + 1));
EndPaint(hwnd, &ps);
return 0;
break;
}