Ok so to answer my question:
The code above (see question) gives a way too high value for Size.cx because MESSAGE_SIZE is 1000 and not the size of the actual string so I used strMessage.c_str and strMessage.size() instead. This still gave some small inaccuracies with the output, I assumed this was because the wrong font was used, so I manually made a font. Now it gives a correct value for Size.cx. The code now looks like this:
int iHorExt=0;
SIZE Size;
int iCurHorExt=0 // iCurHorExt is actually a global var to prevent it from being reset to 0 evertime the code executes
string strMessage="Random user input here!"
HDC hdc=GetDC(hDlg);
//Random font
HFONT hFont=CreateFont(15, 5, NULL, NULL, FW_MEDIUM, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_ROMAN, "Times New Roman");
//change font of the control
SendDlgItemMessage(hDlg, IDC_LIST1, WM_SETFONT, (WPARAM)hFont, true);
SelectObject(hdc, hFont);
int iResult=GetTextExtentPoint32(hdc, strMessage.c_str(), strMessage.size(), &Size);
if(iResult!=0)
{
iHorExt=Size.cx;
if(iHorExt>iCurHorExt)
{
iCurHorExt=iHorExt;
}
}
later in the code:
SendDlgItemMessage(hDlg, IDC_LIST1, LB_SETHORIZONTALEXTENT, iCurHorExt, NULL);
Edit:
SelectObject(hdc, (HFONT)SendDlgItemMessage(hDlg, IDC_LIST1, WM_GETFONT, NULL, NULL));
Works too and doesn't require you to make a font or edit the font of the control