summaryrefslogtreecommitdiff
path: root/src/core/stdmsg/src/msglog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/stdmsg/src/msglog.cpp')
-rw-r--r--src/core/stdmsg/src/msglog.cpp361
1 files changed, 161 insertions, 200 deletions
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp
index 866b808102..b5c4d6c1fa 100644
--- a/src/core/stdmsg/src/msglog.cpp
+++ b/src/core/stdmsg/src/msglog.cpp
@@ -78,20 +78,17 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA
return 0;
lineLen = (int)_tcslen(line) * 9 + 8;
- if (*cbBufferEnd + lineLen > *cbBufferAlloced)
- {
+ if (*cbBufferEnd + lineLen > *cbBufferAlloced) {
cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024);
- *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
+ *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced);
}
d = *buffer + *cbBufferEnd;
strcpy(d, "{\\uc1 ");
d += 6;
- for (; *line; line++, textCharsCount++)
- {
- if (*line == '\r' && line[1] == '\n')
- {
+ for (; *line; line++, textCharsCount++) {
+ if (*line == '\r' && line[1] == '\n') {
memcpy(d, "\\par ", 5);
line++;
d += 5;
@@ -100,26 +97,20 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA
memcpy(d, "\\par ", 5);
d += 5;
}
- else if (*line == '\t')
- {
+ else if (*line == '\t') {
memcpy(d, "\\tab ", 5);
d += 5;
}
- else if (*line == '\\' || *line == '{' || *line == '}')
- {
+ else if (*line == '\\' || *line == '{' || *line == '}') {
*d++ = '\\';
- *d++ = (char) *line;
+ *d++ = (char)*line;
}
- else if (*line == '[' && (g_dat.flags & SMF_SHOWFORMAT))
- {
+ else if (*line == '[' && (g_dat.flags & SMF_SHOWFORMAT)) {
int i, found = 0;
- for (i = 0; i < SIZEOF(bbcodes); ++i)
- {
- if (line[1] == bbcodes[i][1])
- {
+ for (i = 0; i < SIZEOF(bbcodes); ++i) {
+ if (line[1] == bbcodes[i][1]) {
size_t lenb = _tcslen(bbcodes[i]);
- if (!_tcsnicmp(line, bbcodes[i], lenb))
- {
+ if (!_tcsnicmp(line, bbcodes[i], lenb)) {
size_t len = strlen(bbcodefmt[i]);
memcpy(d, bbcodefmt[i], len);
d += len;
@@ -129,18 +120,14 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA
}
}
}
- if (!found)
- {
- if (!_tcsnicmp(line, _T("[url"), 4))
- {
+ if (!found) {
+ if (!_tcsnicmp(line, _T("[url"), 4)) {
TCHAR* tag = _tcschr(line + 4, ']');
- if (tag)
- {
+ if (tag) {
TCHAR *tagu = (line[4] == '=') ? line + 5 : tag + 1;
TCHAR *tage = _tcsstr(tag, _T("[/url]"));
if (!tage) tage = _tcsstr(tag, _T("[/URL]"));
- if (tage)
- {
+ if (tage) {
*tag = 0;
*tage = 0;
d += sprintf(d, "{\\field{\\*\\fldinst HYPERLINK \"%s\"}{\\fldrslt %s}}", mir_t2a(tagu), mir_t2a(tag + 1)); //!!!!!!!!!!
@@ -149,35 +136,31 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA
}
}
}
- else if (!_tcsnicmp(line, _T("[color="), 7))
- {
+ else if (!_tcsnicmp(line, _T("[color="), 7)) {
TCHAR* tag = _tcschr(line + 7, ']');
- if (tag)
- {
+ if (tag) {
line = tag;
found = 1;
}
}
- else if (!_tcsnicmp(line, _T("[/color]"), 8))
- {
+ else if (!_tcsnicmp(line, _T("[/color]"), 8)) {
line += 7;
found = 1;
}
}
- if (!found)
- {
- if (*line < 128) *d++ = (char) *line;
+ if (!found) {
+ if (*line < 128) *d++ = (char)*line;
else d += sprintf(d, "\\u%d ?", *line); //!!!!!!!!!!
}
}
- else if (*line < 128) *d++ = (char) *line;
+ else if (*line < 128) *d++ = (char)*line;
else d += sprintf(d, "\\u%d ?", *line); //!!!!!!!!!!
}
*(d++) = '}';
*d = 0;
- *cbBufferEnd = (int) (d - *buffer);
+ *cbBufferEnd = (int)(d - *buffer);
return textCharsCount;
}
@@ -197,7 +180,7 @@ static char *CreateRTFHeader(SrmmWindowData *dat)
ReleaseDC(NULL, hdc);
bufferEnd = 0;
bufferAlloced = 1024;
- buffer = (char *) mir_alloc(bufferAlloced);
+ buffer = (char *)mir_alloc(bufferAlloced);
buffer[0] = '\0';
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl");
@@ -226,7 +209,7 @@ static char *CreateRTFTail(SrmmWindowData *dat)
bufferEnd = 0;
bufferAlloced = 1024;
- buffer = (char *) mir_alloc(bufferAlloced);
+ buffer = (char *)mir_alloc(bufferAlloced);
buffer[0] = '\0';
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}");
return buffer;
@@ -245,19 +228,19 @@ static char *SetToStyle(int style)
int DbEventIsForMsgWindow(DBEVENTINFO *dbei)
{
- DBEVENTTYPEDESCR *et = ( DBEVENTTYPEDESCR* )CallService(MS_DB_EVENT_GETTYPE, ( WPARAM )dbei->szModule, ( LPARAM )dbei->eventType );
+ DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType);
return et && (et->flags & DETF_MSGWINDOW);
}
int DbEventIsShown(DBEVENTINFO * dbei, SrmmWindowData *dat)
{
switch (dbei->eventType) {
- case EVENTTYPE_MESSAGE:
- return 1;
- case EVENTTYPE_JABBER_CHATSTATES:
- case EVENTTYPE_JABBER_PRESENCE:
- case EVENTTYPE_FILE:
- return (dbei->flags & DBEF_READ) == 0;
+ case EVENTTYPE_MESSAGE:
+ return 1;
+ case EVENTTYPE_JABBER_CHATSTATES:
+ case EVENTTYPE_JABBER_PRESENCE:
+ case EVENTTYPE_FILE:
+ return (dbei->flags & DBEF_READ) == 0;
}
return DbEventIsForMsgWindow(dbei);
}
@@ -274,7 +257,7 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE
if (dbei.cbBlob == -1)
return NULL;
- dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob);
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
db_event_get(hDbEvent, &dbei);
if (!DbEventIsShown(&dbei, dat)) {
mir_free(dbei.pBlob);
@@ -282,14 +265,14 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE
}
if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
db_event_markRead(hContact, hDbEvent);
- CallService(MS_CLIST_REMOVEEVENT, hContact, (LPARAM) hDbEvent);
+ CallService(MS_CLIST_REMOVEEVENT, hContact, (LPARAM)hDbEvent);
}
else if (dbei.eventType == EVENTTYPE_JABBER_CHATSTATES || dbei.eventType == EVENTTYPE_JABBER_PRESENCE) {
db_event_markRead(hContact, hDbEvent);
}
bufferEnd = 0;
bufferAlloced = 1024;
- buffer = (char *) mir_alloc(bufferAlloced);
+ buffer = (char *)mir_alloc(bufferAlloced);
buffer[0] = '\0';
if (!dat->bIsAutoRTL && !streamData->isEmpty)
@@ -304,7 +287,7 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE
streamData->isEmpty = 0;
if (dat->bIsAutoRTL) {
- if(dbei.flags & DBEF_RTL)
+ if (dbei.flags & DBEF_RTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrch\\rtlch");
else
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlch\\ltrch");
@@ -331,7 +314,7 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\f0\\fs14");
while (bufferAlloced - bufferEnd < logIconBmpSize[i])
bufferAlloced += 1024;
- buffer = (char *) mir_realloc(buffer, bufferAlloced);
+ buffer = (char *)mir_realloc(buffer, bufferAlloced);
CopyMemory(buffer + bufferEnd, pLogIconBmpBits[i], logIconBmpSize[i]);
bufferEnd += logIconBmpSize[i];
}
@@ -354,13 +337,13 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE
if (!(g_dat.flags & SMF_HIDENAMES) && dbei.eventType != EVENTTYPE_JABBER_CHATSTATES && dbei.eventType != EVENTTYPE_JABBER_PRESENCE) {
TCHAR* szName;
- CONTACTINFO ci = {0};
+ CONTACTINFO ci = { 0 };
if (dbei.flags & DBEF_SENT) {
ci.cbSize = sizeof(ci);
ci.szProto = dbei.szModule;
ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
// CNF_DISPLAY always returns a string type
szName = ci.pszVal;
}
@@ -378,71 +361,67 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s :", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
switch (dbei.eventType) {
- default:
- case EVENTTYPE_MESSAGE:
- {
- TCHAR* msg = DbGetEventTextT( &dbei, CP_ACP );
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG));
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, msg);
+ TCHAR *msg, *szName;
+ default:
+ case EVENTTYPE_MESSAGE:
+ msg = DbGetEventTextT(&dbei, CP_ACP);
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG));
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, msg);
+ mir_free(msg);
+ break;
+
+ case EVENTTYPE_JABBER_CHATSTATES:
+ case EVENTTYPE_JABBER_PRESENCE:
+ if (dbei.flags & DBEF_SENT) {
+ CONTACTINFO ci = { sizeof(ci) };
+ ci.hContact = NULL;
+ ci.szProto = dbei.szModule;
+ ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- mir_free(msg);
- break;
+ // CNF_DISPLAY always returns a string type
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci))
+ szName = NEWTSTR_ALLOCA(ci.pszVal);
+ else
+ szName = _T("");
+
+ mir_free(ci.pszVal);
}
- case EVENTTYPE_JABBER_CHATSTATES:
- case EVENTTYPE_JABBER_PRESENCE:
- {
- TCHAR *msg, *szName;
- CONTACTINFO ci = {0};
-
- if (dbei.flags & DBEF_SENT) {
- ci.cbSize = sizeof(ci);
- ci.hContact = NULL;
- ci.szProto = dbei.szModule;
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
-
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
- // CNF_DISPLAY always returns a string type
- szName = ci.pszVal;
- }
- }
- else szName = pcli->pfnGetContactDisplayName(hContact, 0);
+ else szName = pcli->pfnGetContactDisplayName(hContact, 0);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(MSGFONTID_NOTICE));
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, szName);
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, _T(" "));
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(MSGFONTID_NOTICE));
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, szName);
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, _T(" "));
- msg = DbGetEventTextT( &dbei, CP_ACP );
- if ( msg ) {
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, msg);
- mir_free( msg );
- }
- mir_free(ci.pszVal);
- break;
+ msg = DbGetEventTextT(&dbei, CP_ACP);
+ if (msg) {
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, msg);
+ mir_free(msg);
}
- case EVENTTYPE_FILE:
- {
- char* filename = (char*)dbei.pBlob + sizeof(DWORD);
- char* descr = filename + strlen( filename ) + 1;
- TCHAR* ptszFileName = DbGetEventStringT( &dbei, filename );
-
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(MSGFONTID_NOTICE));
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced,
- (dbei.flags & DBEF_SENT) ? TranslateT("File sent") : TranslateT("File received"));
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, ": ");
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, ptszFileName);
- mir_free( ptszFileName );
-
- if ( *descr != 0 ) {
- TCHAR* ptszDescr = DbGetEventStringT( &dbei, descr );
- AppendToBuffer( &buffer, &bufferEnd, &bufferAlloced, " (" );
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, ptszDescr);
- AppendToBuffer( &buffer, &bufferEnd, &bufferAlloced, ")" );
- mir_free( ptszDescr );
- }
- break;
- } }
+ break;
+
+ case EVENTTYPE_FILE:
+ char* filename = (char*)dbei.pBlob + sizeof(DWORD);
+ char* descr = filename + strlen(filename) + 1;
+ TCHAR* ptszFileName = DbGetEventStringT(&dbei, filename);
+
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(MSGFONTID_NOTICE));
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced,
+ (dbei.flags & DBEF_SENT) ? TranslateT("File sent") : TranslateT("File received"));
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, ": ");
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, ptszFileName);
+ mir_free(ptszFileName);
+
+ if (*descr != 0) {
+ TCHAR* ptszDescr = DbGetEventStringT(&dbei, descr);
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " (");
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, ptszDescr);
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, ")");
+ mir_free(ptszDescr);
+ }
+ break;
+ }
- if(dat->bIsAutoRTL)
+ if (dat->bIsAutoRTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
mir_free(dbei.pBlob);
@@ -453,51 +432,46 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
{
struct LogStreamData *dat = (struct LogStreamData *) dwCookie;
- if (dat->buffer == NULL)
- {
+ if (dat->buffer == NULL) {
dat->bufferOffset = 0;
- switch (dat->stage)
- {
- case STREAMSTAGE_HEADER:
- dat->buffer = CreateRTFHeader(dat->dlgDat);
- dat->stage = STREAMSTAGE_EVENTS;
- break;
-
- case STREAMSTAGE_EVENTS:
- if (dat->eventsToInsert)
- {
- do
- {
- dat->buffer = CreateRTFFromDbEvent(dat->dlgDat, dat->hContact, dat->hDbEvent, dat);
- if (dat->buffer)
- dat->hDbEventLast = dat->hDbEvent;
- dat->hDbEvent = db_event_next(dat->hContact, dat->hDbEvent);
- if (--dat->eventsToInsert == 0)
- break;
- } while (dat->buffer == NULL && dat->hDbEvent);
+ switch (dat->stage) {
+ case STREAMSTAGE_HEADER:
+ dat->buffer = CreateRTFHeader(dat->dlgDat);
+ dat->stage = STREAMSTAGE_EVENTS;
+ break;
+
+ case STREAMSTAGE_EVENTS:
+ if (dat->eventsToInsert) {
+ do {
+ dat->buffer = CreateRTFFromDbEvent(dat->dlgDat, dat->hContact, dat->hDbEvent, dat);
if (dat->buffer)
- {
- dat->isEmpty = 0;
+ dat->hDbEventLast = dat->hDbEvent;
+ dat->hDbEvent = db_event_next(dat->hContact, dat->hDbEvent);
+ if (--dat->eventsToInsert == 0)
break;
- }
}
- dat->stage = STREAMSTAGE_TAIL;
- //fall through
- case STREAMSTAGE_TAIL:
- dat->buffer = CreateRTFTail(dat->dlgDat);
- dat->stage = STREAMSTAGE_STOP;
- break;
- case STREAMSTAGE_STOP:
- *pcb = 0;
- return 0;
+ while (dat->buffer == NULL && dat->hDbEvent);
+ if (dat->buffer) {
+ dat->isEmpty = 0;
+ break;
+ }
+ }
+ dat->stage = STREAMSTAGE_TAIL;
+ //fall through
+ case STREAMSTAGE_TAIL:
+ dat->buffer = CreateRTFTail(dat->dlgDat);
+ dat->stage = STREAMSTAGE_STOP;
+ break;
+ case STREAMSTAGE_STOP:
+ *pcb = 0;
+ return 0;
}
dat->bufferLen = (int)strlen(dat->buffer);
}
*pcb = min(cb, dat->bufferLen - dat->bufferOffset);
CopyMemory(pbBuff, dat->buffer + dat->bufferOffset, *pcb);
dat->bufferOffset += *pcb;
- if (dat->bufferOffset == dat->bufferLen)
- {
+ if (dat->bufferOffset == dat->bufferLen) {
mir_free(dat->buffer);
dat->buffer = NULL;
}
@@ -506,8 +480,8 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
{
- EDITSTREAM stream = {0};
- struct LogStreamData streamData = {0};
+ EDITSTREAM stream = { 0 };
+ struct LogStreamData streamData = { 0 };
SrmmWindowData *dat = (SrmmWindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
CHARRANGE oldSel, sel;
POINT scrollPos;
@@ -516,7 +490,7 @@ void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
HWND hwndLog = GetDlgItem(hwndDlg, IDC_LOG);
SendMessage(hwndLog, WM_SETREDRAW, FALSE, 0);
- SendMessage(hwndLog, EM_EXGETSEL, 0, (LPARAM) & oldSel);
+ SendMessage(hwndLog, EM_EXGETSEL, 0, (LPARAM)& oldSel);
streamData.hContact = dat->hContact;
streamData.hDbEvent = hDbEventFirst;
streamData.dlgDat = dat;
@@ -525,44 +499,38 @@ void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
stream.pfnCallback = LogStreamInEvents;
stream.dwCookie = (DWORD_PTR)&streamData;
- if (!streamData.isEmpty)
- {
+ if (!streamData.isEmpty) {
bottomScroll = (GetFocus() != hwndLog);
- if (bottomScroll && (GetWindowLongPtr(hwndLog, GWL_STYLE) & WS_VSCROLL))
- {
- SCROLLINFO si = {0};
+ if (bottomScroll && (GetWindowLongPtr(hwndLog, GWL_STYLE) & WS_VSCROLL)) {
+ SCROLLINFO si = { 0 };
si.cbSize = sizeof(si);
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
GetScrollInfo(hwndLog, SB_VERT, &si);
bottomScroll = (si.nPos + (int)si.nPage) >= si.nMax;
}
if (!bottomScroll)
- SendMessage(hwndLog, EM_GETSCROLLPOS, 0, (LPARAM) & scrollPos);
+ SendMessage(hwndLog, EM_GETSCROLLPOS, 0, (LPARAM)& scrollPos);
}
- if (fAppend)
- {
+ if (fAppend) {
sel.cpMin = sel.cpMax = -1;
- SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM) & sel);
+ SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM)& sel);
}
strcpy(szSep2, fAppend ? "\\par\\sl0" : "\\sl1000");
strcpy(szSep2_RTL, fAppend ? "\\rtlpar\\rtlmark\\par\\sl1000" : "\\sl1000");
- SendMessage(hwndLog, EM_STREAMIN, fAppend ? SFF_SELECTION | SF_RTF : SF_RTF, (LPARAM) & stream);
- if (bottomScroll)
- {
+ SendMessage(hwndLog, EM_STREAMIN, fAppend ? SFF_SELECTION | SF_RTF : SF_RTF, (LPARAM)& stream);
+ if (bottomScroll) {
sel.cpMin = sel.cpMax = -1;
- SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM) & sel);
- if (GetWindowLongPtr(hwndLog, GWL_STYLE) & WS_VSCROLL)
- {
+ SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM)& sel);
+ if (GetWindowLongPtr(hwndLog, GWL_STYLE) & WS_VSCROLL) {
SendMessage(hwndDlg, DM_SCROLLLOGTOBOTTOM, 0, 0);
PostMessage(hwndDlg, DM_SCROLLLOGTOBOTTOM, 0, 0);
}
}
- else
- {
- SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM) & oldSel);
- SendMessage(hwndLog, EM_SETSCROLLPOS, 0, (LPARAM) & scrollPos);
+ else {
+ SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM)& oldSel);
+ SendMessage(hwndLog, EM_SETSCROLLPOS, 0, (LPARAM)& scrollPos);
}
SendMessage(hwndLog, WM_SETREDRAW, TRUE, 0);
@@ -575,52 +543,45 @@ void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
#define RTFPICTHEADERMAXSIZE 78
void LoadMsgLogIcons(void)
{
- HICON hIcon;
- HBITMAP hBmp, hoBmp;
- HDC hdc, hdcMem;
- BITMAPINFOHEADER bih = { 0 };
- int widthBytes, i;
- RECT rc;
- HBRUSH hBkgBrush;
- int rtfHeaderSize;
- PBYTE pBmpBits;
+ HBRUSH hBkgBrush = CreateSolidBrush(db_get_dw(NULL, SRMMMOD, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR));
- hBkgBrush = CreateSolidBrush(db_get_dw(NULL, SRMMMOD, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR));
- bih.biSize = sizeof(bih);
+ BITMAPINFOHEADER bih = { sizeof(bih) };
bih.biBitCount = 24;
bih.biCompression = BI_RGB;
bih.biHeight = 10;
bih.biPlanes = 1;
bih.biWidth = 10;
- widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
+ int widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
+
+ RECT rc;
rc.top = rc.left = 0;
rc.right = bih.biWidth;
rc.bottom = bih.biHeight;
- hdc = GetDC(NULL);
- hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
- hdcMem = CreateCompatibleDC(hdc);
- pBmpBits = (PBYTE) mir_alloc(widthBytes * bih.biHeight);
- for (i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
- hIcon = Skin_GetIconByHandle(iconList[i].hIcolib);
+ HDC hdc = GetDC(NULL);
+ HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
+ HDC hdcMem = CreateCompatibleDC(hdc);
+ PBYTE pBmpBits = (PBYTE)mir_alloc(widthBytes * bih.biHeight);
+
+ for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
+ HICON hIcon = Skin_GetIconByHandle(iconList[i].hIcolib);
size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2;
- pLogIconBmpBits[i] = (PBYTE) mir_alloc(size);
+ pLogIconBmpBits[i] = (PBYTE)mir_alloc(size);
//I can't seem to get binary mode working. No matter.
- rtfHeaderSize = mir_snprintf((char*)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
- hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp);
+ int rtfHeaderSize = mir_snprintf((char*)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
+ HBITMAP hoBmp = (HBITMAP)SelectObject(hdcMem, hBmp);
FillRect(hdcMem, &rc, hBkgBrush);
DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, NULL, DI_NORMAL);
Skin_ReleaseIcon(hIcon);
SelectObject(hdcMem, hoBmp);
- GetDIBits(hdc, hBmp, 0, bih.biHeight, pBmpBits, (BITMAPINFO *) & bih, DIB_RGB_COLORS);
- {
- int n;
- for (n = 0; n < sizeof(BITMAPINFOHEADER); n++)
- sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); //!!!!!!!!!!!!!
- for (n = 0; n < widthBytes * bih.biHeight; n += 4)
- sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!!
- }
+ GetDIBits(hdc, hBmp, 0, bih.biHeight, pBmpBits, (BITMAPINFO *)& bih, DIB_RGB_COLORS);
+
+ for (int n = 0; n < sizeof(BITMAPINFOHEADER); n++)
+ sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE)& bih)[n]); //!!!!!!!!!!!!!
+ for (int n = 0; n < widthBytes * bih.biHeight; n += 4)
+ sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!!
+
logIconBmpSize[i] = rtfHeaderSize + (bih.biSize + widthBytes * bih.biHeight) * 2 + 1;
pLogIconBmpBits[i][logIconBmpSize[i] - 1] = '}';
}