summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Ping/src/pingthread.cpp669
1 files changed, 339 insertions, 330 deletions
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp
index 26c9aad06c..7c834c572a 100644
--- a/plugins/Ping/src/pingthread.cpp
+++ b/plugins/Ping/src/pingthread.cpp
@@ -26,7 +26,7 @@ COLORREF bk_col = RGB(255, 255, 255);
////////////////
#define TM_AUTOALPHA 1
-static int transparentFocus=1;
+static int transparentFocus = 1;
/////////////////
bool get_thread_finished() {
@@ -52,18 +52,19 @@ void set_list_changed(bool f) {
}
void SetProtoStatus(TCHAR *pszLabel, char *pszProto, int if_status, int new_status) {
- if(strcmp(pszProto, Translate("<all>")) == 0) {
+ if (strcmp(pszProto, Translate("<all>")) == 0) {
int num_protocols;
PROTOACCOUNT **pppDesc;
- ProtoEnumAccounts(&num_protocols,&pppDesc);
- for(int i = 0; i < num_protocols; i++) {
+ ProtoEnumAccounts(&num_protocols, &pppDesc);
+ for (int i = 0; i < num_protocols; i++) {
SetProtoStatus(pszLabel, pppDesc[i]->szModuleName, if_status, new_status);
}
- } else {
- if(ProtoServiceExists(pszProto, PS_GETSTATUS)) {
- if(ProtoCallService(pszProto, PS_GETSTATUS, 0, 0) == if_status) {
- if(options.logging) {
+ }
+ else {
+ if (ProtoServiceExists(pszProto, PS_GETSTATUS)) {
+ if (ProtoCallService(pszProto, PS_GETSTATUS, 0, 0) == if_status) {
+ if (options.logging) {
TCHAR buf[1024];
mir_sntprintf(buf, SIZEOF(buf), TranslateT("%s - setting status of protocol '%S' (%d)"), pszLabel, pszProto, new_status);
CallService(PLUG "/Log", (WPARAM)buf, 0);
@@ -74,7 +75,7 @@ void SetProtoStatus(TCHAR *pszLabel, char *pszProto, int if_status, int new_stat
}
}
-DWORD WINAPI sttCheckStatusThreadProc( void *vp)
+void __cdecl sttCheckStatusThreadProc(void *vp)
{
clock_t start_t = clock(), end_t;
while (!get_thread_finished())
@@ -85,7 +86,7 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
if (wait > 0)
WaitForSingleObjectEx(hWakeEvent, wait, TRUE);
- if(get_thread_finished()) break;
+ if (get_thread_finished()) break;
start_t = clock();
@@ -101,7 +102,7 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
size_t size = data_list.size();
size_t index = 0;
- for(; index < size; index++)
+ for (; index < size; index++)
{
mir_cslock lck(data_list_cs);
size_t c = 0;
@@ -124,15 +125,15 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
}
- if(get_thread_finished()) break;
- if(get_list_changed()) break;
+ if (get_thread_finished()) break;
+ if (get_list_changed()) break;
- if(pa.status != PS_DISABLED) {
- if(!options.no_test_icon) {
+ if (pa.status != PS_DISABLED) {
+ if (!options.no_test_icon) {
mir_cslock lck(data_list_cs);
- for(pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
+ for (pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
{
- if(i->item_id == pa.item_id)
+ if (i->item_id == pa.item_id)
{
i->status = PS_TESTING;
}
@@ -142,13 +143,13 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
CallService(PLUG "/Ping", 0, (LPARAM)&pa);
- if(get_thread_finished()) break;
- if(get_list_changed()) break;
+ if (get_thread_finished()) break;
+ if (get_list_changed()) break;
mir_cslock lck(data_list_cs);
- for(pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
+ for (pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
{
- if(i->item_id == pa.item_id)
+ if (i->item_id == pa.item_id)
{
i->responding = pa.responding;
i->round_trip_time = pa.round_trip_time;
@@ -156,13 +157,13 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
history_entry.second = time(0);
history_map[i->item_id].push_back(history_entry);
// maintain history (-1 represents no response)
- while(history_map[i->item_id].size() >= MAX_HISTORY)
+ while (history_map[i->item_id].size() >= MAX_HISTORY)
//history_map[i->item_id].pop_front();
history_map[i->item_id].remove(history_map[i->item_id].begin().val());
- if(pa.responding)
+ if (pa.responding)
{
- if(pa.miss_count > 0)
+ if (pa.miss_count > 0)
pa.miss_count = -1;
else
pa.miss_count--;
@@ -170,7 +171,7 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
}
else
{
- if(pa.miss_count < 0)
+ if (pa.miss_count < 0)
pa.miss_count = 1;
else
pa.miss_count++;
@@ -184,33 +185,34 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
}
}
- if(pa.responding) {
+ if (pa.responding) {
count++;
- if(pa.miss_count == -1 - options.retries ||
+ if (pa.miss_count == -1 - options.retries ||
(((-pa.miss_count) % (options.retries + 1)) == 0 && !options.block_reps))
{
reply = true;
- if(options.show_popup2 && ServiceExists(MS_POPUP_SHOWMESSAGE)) {
+ if (options.show_popup2 && ServiceExists(MS_POPUP_SHOWMESSAGE)) {
ShowPopup(TranslateT("Ping Reply"), pa.pszLabel, 1);
}
}
- if(pa.miss_count == -1 - options.retries && options.logging) {
+ if (pa.miss_count == -1 - options.retries && options.logging) {
TCHAR buf[512];
mir_sntprintf(buf, SIZEOF(buf), TranslateT("%s - reply, %d"), pa.pszLabel, pa.round_trip_time);
CallService(PLUG "/Log", (WPARAM)buf, 0);
}
SetProtoStatus(pa.pszLabel, pa.pszProto, pa.get_status, pa.set_status);
- } else {
+ }
+ else {
- if(pa.miss_count == 1 + options.retries ||
+ if (pa.miss_count == 1 + options.retries ||
((pa.miss_count % (options.retries + 1)) == 0 && !options.block_reps))
{
timeout = true;
- if(options.show_popup)
+ if (options.show_popup)
ShowPopup(TranslateT("Ping Timeout"), pa.pszLabel, 0);
}
- if(pa.miss_count == 1 + options.retries && options.logging) {
+ if (pa.miss_count == 1 + options.retries && options.logging) {
TCHAR buf[512];
mir_sntprintf(buf, SIZEOF(buf), TranslateT("%s - timeout"), pa.pszLabel);
CallService(PLUG "/Log", (WPARAM)buf, 0);
@@ -221,25 +223,24 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp)
}
}
- if(timeout) SkinPlaySound("PingTimeout");
- if(reply) SkinPlaySound("PingReply");
+ if (timeout) SkinPlaySound("PingTimeout");
+ if (reply) SkinPlaySound("PingReply");
- if(!get_list_changed()) {
+ if (!get_list_changed()) {
upCount = count;
total = index;
- } else {
+ }
+ else {
total = 0;
}
}
-
- return 0;
}
-void start_ping_thread() {
- DWORD tid;
-
- if(status_update_thread) CloseHandle(status_update_thread);
- status_update_thread = CreateThread(0, 0, sttCheckStatusThreadProc, 0, 0, &tid);
+void start_ping_thread()
+{
+ if (status_update_thread)
+ CloseHandle(status_update_thread);
+ status_update_thread = mir_forkthread(sttCheckStatusThreadProc, 0);
}
void stop_ping_thread() {
@@ -253,7 +254,7 @@ void stop_ping_thread() {
}
bool FrameIsFloating() {
- if(frame_id == -1)
+ if (frame_id == -1)
return true; // no frames, always floating
return (CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLOATING, frame_id), 0) != 0);
@@ -261,7 +262,7 @@ bool FrameIsFloating() {
int FillList(WPARAM wParam, LPARAM lParam) {
- if(options.logging)
+ if (options.logging)
CallService(PLUG "/Log", (WPARAM)_T("ping address list reload"), 0);
PINGLIST pl;
@@ -274,7 +275,7 @@ int FillList(WPARAM wParam, LPARAM lParam) {
SendMessage(list_hwnd, LB_RESETCONTENT, 0, 0);
int index = 0;
- for(pinglist_it j = data_list.begin(); j != data_list.end(); ++j, index++)
+ for (pinglist_it j = data_list.begin(); j != data_list.end(); ++j, index++)
{
SendMessage(list_hwnd, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)&(*j));
}
@@ -288,7 +289,7 @@ int FillList(WPARAM wParam, LPARAM lParam) {
SetEvent(hWakeEvent);
- if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && options.attach_to_clist)
+ if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && options.attach_to_clist)
UpdateFrame();
return 0;
@@ -296,7 +297,7 @@ int FillList(WPARAM wParam, LPARAM lParam) {
INT_PTR PingPlugShowWindow(WPARAM wParam, LPARAM lParam)
{
- if(hpwnd)
+ if (hpwnd)
{
if (frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_SHFRAME))
CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
@@ -308,13 +309,13 @@ INT_PTR PingPlugShowWindow(WPARAM wParam, LPARAM lParam)
#define TIMER_ID 11042
void CALLBACK TimerProc(
- HWND hwnd, // handle to window
- UINT uMsg, // WM_TIMER message
- UINT_PTR idEvent, // timer identifier
- DWORD dwTime // current system time
-)
+ HWND hwnd, // handle to window
+ UINT uMsg, // WM_TIMER message
+ UINT_PTR idEvent, // timer identifier
+ DWORD dwTime // current system time
+ )
{
- if(frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+ if (frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
{
TCHAR TBcapt[255];
if (total > 0)
@@ -322,13 +323,14 @@ void CALLBACK TimerProc(
else
mir_sntprintf(TBcapt, SIZEOF(TBcapt), _T("Ping"));
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBNAME | FO_TCHAR,frame_id),(LPARAM)TBcapt);
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME | FO_TCHAR,frame_id),(LPARAM)TBcapt);
- CallService(MS_CLIST_FRAMES_UPDATEFRAME,frame_id,FU_TBREDRAW);
- } else {
-// if(options.attach_to_clist) {
-// AttachToClist(true);
-// }
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_TBNAME | FO_TCHAR, frame_id), (LPARAM)TBcapt);
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_TBTIPNAME | FO_TCHAR, frame_id), (LPARAM)TBcapt);
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME, frame_id, FU_TBREDRAW);
+ }
+ else {
+ // if(options.attach_to_clist) {
+ // AttachToClist(true);
+ // }
}
}
@@ -345,7 +347,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
LPARAM lp;
int sel;
- switch(msg)
+ switch (msg)
{
case WM_MEASUREITEM:
@@ -356,10 +358,10 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
case WM_DRAWITEM:
dis = (LPDRAWITEMSTRUCT)lParam;
- if(dis->hwndItem == list_hwnd) {
+ if (dis->hwndItem == list_hwnd) {
HBRUSH ttbrush = 0;
COLORREF tcol;
- if(dis->itemID != -1) {
+ if (dis->itemID != -1) {
mir_cslock lck(data_list_cs);
itemData = *(PINGADDRESS *)dis->itemData;
@@ -367,25 +369,26 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
//dis->rcItem.bottom = dis->rcItem.top + options.row_height;
LONG x, y;
- if(context_point_valid) {
+ if (context_point_valid) {
RECT r;
GetWindowRect(list_hwnd, &r);
x = LOWORD(context_point) - r.left,
- y = HIWORD(context_point) - r.top;
+ y = HIWORD(context_point) - r.top;
}
GetClientRect(hwnd, &r);
- if((dis->itemState & ODS_SELECTED && dis->itemState & ODS_FOCUS)
+ if ((dis->itemState & ODS_SELECTED && dis->itemState & ODS_FOCUS)
|| (context_point_valid && (x >= dis->rcItem.left && x <= dis->rcItem.right) && (y >= dis->rcItem.top && y <= dis->rcItem.bottom)))
{
- tcol = db_get_dw(NULL,"CLC","SelBkColour", GetSysColor(COLOR_HIGHLIGHT));
+ tcol = db_get_dw(NULL, "CLC", "SelBkColour", GetSysColor(COLOR_HIGHLIGHT));
SetBkColor(dis->hDC, tcol);
FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol)));
- tcol = db_get_dw(NULL,"CLC","SelTextColour", GetSysColor(COLOR_HIGHLIGHTTEXT));
+ tcol = db_get_dw(NULL, "CLC", "SelTextColour", GetSysColor(COLOR_HIGHLIGHTTEXT));
SetTextColor(dis->hDC, tcol);
- } else {
+ }
+ else {
tcol = bk_col;
SetBkColor(dis->hDC, tcol);
FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol)));
@@ -399,231 +402,236 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
dis->rcItem.left += options.indent;
//DrawIconEx(dis->hDC,dis->rcItem.left,(dis->rcItem.top + dis->rcItem.bottom - GetSystemMetrics(SM_CYSMICON))>>1,hIcon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
//DrawIconEx(dis->hDC,dis->rcItem.left,(dis->rcItem.top + dis->rcItem.bottom - GetSystemMetrics(SM_CYSMICON))>>1,hIcon,0, 0, 0, NULL, DI_NORMAL);
- DrawIconEx(dis->hDC,dis->rcItem.left,dis->rcItem.top + ((options.row_height - 16)>>1),hIcon,0, 0, 0, NULL, DI_NORMAL);
+ DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top + ((options.row_height - 16) >> 1), hIcon, 0, 0, 0, NULL, DI_NORMAL);
- GetTextExtentPoint32(dis->hDC, itemData.pszLabel, (int)mir_tstrlen(itemData.pszLabel),&textSize);
- TextOut(dis->hDC,dis->rcItem.left + 16 + 4,(dis->rcItem.top + dis->rcItem.bottom - textSize.cy)>>1,itemData.pszLabel,(int)mir_tstrlen(itemData.pszLabel));
+ GetTextExtentPoint32(dis->hDC, itemData.pszLabel, (int)mir_tstrlen(itemData.pszLabel), &textSize);
+ TextOut(dis->hDC, dis->rcItem.left + 16 + 4, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, itemData.pszLabel, (int)mir_tstrlen(itemData.pszLabel));
- if(itemData.status != PS_DISABLED) {
+ if (itemData.status != PS_DISABLED) {
TCHAR buf[256];
- if(itemData.responding) {
+ if (itemData.responding) {
mir_sntprintf(buf, SIZEOF(buf), TranslateT("%d ms"), itemData.round_trip_time);
GetTextExtentPoint32(dis->hDC, buf, (int)mir_tstrlen(buf), &textSize);
- TextOut(dis->hDC,dis->rcItem.right - textSize.cx - 2,(dis->rcItem.top + dis->rcItem.bottom -textSize.cy)>>1,buf,(int)mir_tstrlen(buf));
- } else if(itemData.miss_count > 0) {
+ TextOut(dis->hDC, dis->rcItem.right - textSize.cx - 2, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, buf, (int)mir_tstrlen(buf));
+ }
+ else if (itemData.miss_count > 0) {
mir_sntprintf(buf, SIZEOF(buf), _T("[%d]"), itemData.miss_count);
GetTextExtentPoint32(dis->hDC, buf, (int)mir_tstrlen(buf), &textSize);
- TextOut(dis->hDC,dis->rcItem.right - textSize.cx - 2,(dis->rcItem.top + dis->rcItem.bottom -textSize.cy)>>1,buf,(int)mir_tstrlen(buf));
+ TextOut(dis->hDC, dis->rcItem.right - textSize.cx - 2, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, buf, (int)mir_tstrlen(buf));
}
}
SetBkMode(dis->hDC, OPAQUE);
}
- if(ttbrush) DeleteObject(ttbrush);
+ if (ttbrush) DeleteObject(ttbrush);
return TRUE;
}
//return DefWindowProc(hwnd, msg, wParam, lParam);
return TRUE;
case WM_CTLCOLORLISTBOX:
- {
- if(tbrush) DeleteObject(tbrush);
+ {
+ if (tbrush) DeleteObject(tbrush);
- return (BOOL)(tbrush = CreateSolidBrush(bk_col));
- }
+ return (BOOL)(tbrush = CreateSolidBrush(bk_col));
+ }
- case WM_ERASEBKGND:
- {
- RECT r;
- GetClientRect(hwnd, &r);
- if(!tbrush) tbrush = CreateSolidBrush(bk_col);
- FillRect((HDC)wParam, &r, tbrush);
- }
- return TRUE;
+ case WM_ERASEBKGND:
+ {
+ RECT r;
+ GetClientRect(hwnd, &r);
+ if (!tbrush) tbrush = CreateSolidBrush(bk_col);
+ FillRect((HDC)wParam, &r, tbrush);
+ }
+ return TRUE;
case WM_CONTEXTMENU:
- {
- context_point = lParam;
- context_point_valid = true;
- InvalidateRect(list_hwnd, 0, FALSE);
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)),
- submenu = GetSubMenu(menu, 0);
-
- POINT pt = {LOWORD(context_point),HIWORD(context_point)};
-
- RECT r;
- GetClientRect(list_hwnd, &r);
- ScreenToClient(list_hwnd, &pt);
-
- DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
- bool found = false;
- if(HIWORD(item) == 0) {
- int count = LOWORD(item);
- mir_cslock lck(data_list_cs);
- if(count >= 0 && count < (int)data_list.size()) {
- itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
- found = true;
- }
+ {
+ context_point = lParam;
+ context_point_valid = true;
+ InvalidateRect(list_hwnd, 0, FALSE);
+ HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)),
+ submenu = GetSubMenu(menu, 0);
+
+ POINT pt = { LOWORD(context_point), HIWORD(context_point) };
+
+ RECT r;
+ GetClientRect(list_hwnd, &r);
+ ScreenToClient(list_hwnd, &pt);
+
+ DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
+ bool found = false;
+ if (HIWORD(item) == 0) {
+ int count = LOWORD(item);
+ mir_cslock lck(data_list_cs);
+ if (count >= 0 && count < (int)data_list.size()) {
+ itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
+ found = true;
}
+ }
- if(found) {
- EnableMenuItem(submenu, ID_MENU_GRAPH, MF_BYCOMMAND | MF_ENABLED);
- EnableMenuItem(submenu, ID_MENU_EDIT, MF_BYCOMMAND | MF_ENABLED);
- EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_ENABLED);
- if(itemData.status == PS_DISABLED) {
- ModifyMenu(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_MENU_TOGGLE, TranslateT("Enable"));
- } else {
- ModifyMenu(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_MENU_TOGGLE, TranslateT("Disable"));
- }
- } else {
- EnableMenuItem(submenu, ID_MENU_GRAPH, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(submenu, ID_MENU_EDIT, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_GRAYED);
+ if (found) {
+ EnableMenuItem(submenu, ID_MENU_GRAPH, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(submenu, ID_MENU_EDIT, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_ENABLED);
+ if (itemData.status == PS_DISABLED) {
+ ModifyMenu(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_MENU_TOGGLE, TranslateT("Enable"));
}
+ else {
+ ModifyMenu(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_MENU_TOGGLE, TranslateT("Disable"));
+ }
+ }
+ else {
+ EnableMenuItem(submenu, ID_MENU_GRAPH, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(submenu, ID_MENU_EDIT, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_GRAYED);
+ }
- TranslateMenu(submenu);
+ TranslateMenu(submenu);
- //ClientToScreen(list_hwnd, &pt);
- GetCursorPos(&pt);
- BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
- DestroyMenu(menu);
- if(ret) {
- SendMessage(hwnd, WM_COMMAND, ret, 0);
- }
- context_point_valid = false;
- InvalidateRect(list_hwnd, 0, FALSE);
+ //ClientToScreen(list_hwnd, &pt);
+ GetCursorPos(&pt);
+ BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
+ DestroyMenu(menu);
+ if (ret) {
+ SendMessage(hwnd, WM_COMMAND, ret, 0);
}
+ context_point_valid = false;
+ InvalidateRect(list_hwnd, 0, FALSE);
+ }
- return TRUE;
+ return TRUE;
case WM_SYSCOLORCHANGE:
- SendMessage(list_hwnd,msg,wParam,lParam);
+ SendMessage(list_hwnd, msg, wParam, lParam);
return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_CREATE:
- list_hwnd = CreateWindow(_T("LISTBOX"), _T(""),
+ list_hwnd = CreateWindow(_T("LISTBOX"), _T(""),
//(WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT| LBS_STANDARD | WS_CLIPCHILDREN | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY)
- (WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY)
- & ~WS_BORDER, 0, 0, 0, 0, hwnd, NULL, hInst,0);
+ (WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY)
+ & ~WS_BORDER, 0, 0, 0, 0, hwnd, NULL, hInst, 0);
- if (db_get_b(NULL,"CList","Transparent",0))
+ if (db_get_b(NULL, "CList", "Transparent", 0))
{
- if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
- } else {
+ }
+ else {
#ifdef WS_EX_LAYERED
SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
#endif
#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)db_get_b(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA);
#endif
}
}
// timer to update titlebar
- if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+ if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
SetTimer(hwnd, TIMER_ID, 1000, TimerProc);
PostMessage(hwnd, WM_SIZE, 0, 0);
return TRUE;
case WM_ACTIVATE:
- if(wParam==WA_INACTIVE) {
- if((HWND)wParam!=hwnd)
- if(db_get_b(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT))
- if(transparentFocus)
- SetTimer(hwnd, TM_AUTOALPHA,250,NULL);
+ if (wParam == WA_INACTIVE) {
+ if ((HWND)wParam != hwnd)
+ if (db_get_b(NULL, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT))
+ if (transparentFocus)
+ SetTimer(hwnd, TM_AUTOALPHA, 250, NULL);
}
else {
- if(db_get_b(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT)) {
- KillTimer(hwnd,TM_AUTOALPHA);
+ if (db_get_b(NULL, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) {
+ KillTimer(hwnd, TM_AUTOALPHA);
#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)db_get_b(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA);
#endif
- transparentFocus=1;
+ transparentFocus = 1;
}
}
- return DefWindowProc(hwnd,msg,wParam,lParam);
+ return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_SETCURSOR:
- if(db_get_b(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT)) {
- if (!transparentFocus && GetForegroundWindow()!=hwnd) {
+ if (db_get_b(NULL, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) {
+ if (!transparentFocus && GetForegroundWindow() != hwnd) {
#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)db_get_b(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA);
#endif
- transparentFocus=1;
- SetTimer(hwnd, TM_AUTOALPHA,250,NULL);
+ transparentFocus = 1;
+ SetTimer(hwnd, TM_AUTOALPHA, 250, NULL);
}
}
- return DefWindowProc(hwnd,msg,wParam,lParam);
+ return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_TIMER:
- if ((int)wParam==TM_AUTOALPHA)
- { int inwnd;
+ if ((int)wParam == TM_AUTOALPHA)
+ {
+ int inwnd;
- if (GetForegroundWindow()==hwnd) {
- KillTimer(hwnd,TM_AUTOALPHA);
- inwnd=1;
+ if (GetForegroundWindow() == hwnd) {
+ KillTimer(hwnd, TM_AUTOALPHA);
+ inwnd = 1;
}
else {
POINT pt;
HWND hwndPt;
- pt.x=(short)LOWORD(GetMessagePos());
- pt.y=(short)HIWORD(GetMessagePos());
- hwndPt=WindowFromPoint(pt);
- inwnd=(hwndPt==hwnd || GetParent(hwndPt)==hwnd);
+ pt.x = (short)LOWORD(GetMessagePos());
+ pt.y = (short)HIWORD(GetMessagePos());
+ hwndPt = WindowFromPoint(pt);
+ inwnd = (hwndPt == hwnd || GetParent(hwndPt) == hwnd);
}
- if (inwnd!=transparentFocus)
+ if (inwnd != transparentFocus)
{ //change
- transparentFocus=inwnd;
+ transparentFocus = inwnd;
#ifdef LWA_ALPHA
- if(transparentFocus) SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)db_get_b(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
- else SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)db_get_b(NULL,"CList","AutoAlpha",SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA);
+ if (transparentFocus) SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ else SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA);
#endif
}
- if(!transparentFocus) KillTimer(hwnd,TM_AUTOALPHA);
+ if (!transparentFocus) KillTimer(hwnd, TM_AUTOALPHA);
return TRUE;
}
return FALSE;
case WM_SHOWWINDOW:
{
- static int noRecurse=0;
- if(lParam) break;
- if(noRecurse) break;
- if(!db_get_b(NULL,"CLUI","FadeInOut",0))
+ static int noRecurse = 0;
+ if (lParam) break;
+ if (noRecurse) break;
+ if (!db_get_b(NULL, "CLUI", "FadeInOut", 0))
break;
#ifdef WS_EX_LAYERED
- if(GetWindowLongPtr(hwnd,GWL_EXSTYLE)&WS_EX_LAYERED) {
- DWORD thisTick,startTick;
- int sourceAlpha,destAlpha;
- if(wParam) {
- sourceAlpha=0;
- destAlpha=(BYTE)db_get_b(NULL,"CList","Alpha",SETTING_AUTOALPHA_DEFAULT);
+ if (GetWindowLongPtr(hwnd, GWL_EXSTYLE)&WS_EX_LAYERED) {
+ DWORD thisTick, startTick;
+ int sourceAlpha, destAlpha;
+ if (wParam) {
+ sourceAlpha = 0;
+ destAlpha = (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT);
#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 0, LWA_ALPHA);
#endif
- noRecurse=1;
- ShowWindow(hwnd,SW_SHOW);
- noRecurse=0;
+ noRecurse = 1;
+ ShowWindow(hwnd, SW_SHOW);
+ noRecurse = 0;
}
else {
- sourceAlpha=(BYTE)db_get_b(NULL,"CList","Alpha",SETTING_AUTOALPHA_DEFAULT);
- destAlpha=0;
+ sourceAlpha = (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT);
+ destAlpha = 0;
}
- for(startTick=GetTickCount();;) {
- thisTick=GetTickCount();
- if(thisTick>=startTick+200) break;
+ for (startTick = GetTickCount();;) {
+ thisTick = GetTickCount();
+ if (thisTick >= startTick + 200) break;
#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)(sourceAlpha+(destAlpha-sourceAlpha)*(int)(thisTick-startTick)/200), LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)(sourceAlpha + (destAlpha - sourceAlpha)*(int)(thisTick - startTick) / 200), LWA_ALPHA);
#endif
}
#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)destAlpha, LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)destAlpha, LWA_ALPHA);
#endif
}
else {
-// if(wParam) SetForegroundWindow(hwnd);
- AnimateWindow(hwnd,200,AW_BLEND|(wParam?0:AW_HIDE));
+ // if(wParam) SetForegroundWindow(hwnd);
+ AnimateWindow(hwnd, 200, AW_BLEND | (wParam ? 0 : AW_HIDE));
//SetWindowPos(label,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
}
#endif
@@ -636,86 +644,86 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
/*
case WM_PAINT:
- {
- paintDC = BeginPaint(hwnd, &paintStruct); //
- //SelectObject(paintDC,TitleBarFont);
- //SetBkMode(paintDC,TRANSPARENT);
+ {
+ paintDC = BeginPaint(hwnd, &paintStruct); //
+ //SelectObject(paintDC,TitleBarFont);
+ //SetBkMode(paintDC,TRANSPARENT);
- //paintStruct.fErase=TRUE;
- //color=RGB(1,1,1);
- //brush=CreateSolidBrush(RGB(200,20,20));
+ //paintStruct.fErase=TRUE;
+ //color=RGB(1,1,1);
+ //brush=CreateSolidBrush(RGB(200,20,20));
- //GetClientRect(hwnd,&rect);
- //FillRect(paintDC,&rect,brush);
- //TextOut(paintDC,4,4,"cl1 Bottom window",sizeof("cl1 Bottom window")-1);
- //DeleteObject(brush);
- EndPaint(hwnd, &paintStruct); //
+ //GetClientRect(hwnd,&rect);
+ //FillRect(paintDC,&rect,brush);
+ //TextOut(paintDC,4,4,"cl1 Bottom window",sizeof("cl1 Bottom window")-1);
+ //DeleteObject(brush);
+ EndPaint(hwnd, &paintStruct); //
- };
- return TRUE;
+ };
+ return TRUE;
*/
case WM_COMMAND:
//CreateServiceFunction("PingPlug/DisableAll", PingPlugDisableAll);
//CreateServiceFunction("PingPlug/EnableAll", PingPlugEnableAll);
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case ID_MENU_GRAPH:
- if(context_point_valid) {
+ if (context_point_valid) {
WORD x = LOWORD(context_point),
y = HIWORD(context_point);
RECT r;
GetWindowRect(list_hwnd, &r);
DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(x - r.left, y - r.top));
- if(HIWORD(item) == 0) {
+ if (HIWORD(item) == 0) {
int count = LOWORD(item);
bool found = false;
mir_cslock lck(data_list_cs);
- if(count >= 0 && count < (int)data_list.size()) {
+ if (count >= 0 && count < (int)data_list.size()) {
itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
found = true;
}
- if(found)
+ if (found)
CallService(PLUG "/ShowGraph", (WPARAM)itemData.item_id, (LPARAM)itemData.pszLabel);
}
}
return TRUE;
case ID_MENU_TOGGLE:
- if(context_point_valid) {
+ if (context_point_valid) {
WORD x = LOWORD(context_point),
y = HIWORD(context_point);
RECT r;
GetWindowRect(list_hwnd, &r);
DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(x - r.left, y - r.top));
- if(HIWORD(item) == 0) {
+ if (HIWORD(item) == 0) {
int count = LOWORD(item);
bool found = false;
mir_cslock lck(data_list_cs);
- if(count >= 0 && count < (int)data_list.size()) {
+ if (count >= 0 && count < (int)data_list.size()) {
itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
found = true;
}
- if(found)
+ if (found)
CallService(PLUG "/ToggleEnabled", (WPARAM)itemData.item_id, 0);
}
}
return TRUE;
case ID_MENU_EDIT:
- if(context_point_valid) {
+ if (context_point_valid) {
WORD x = LOWORD(context_point),
y = HIWORD(context_point);
RECT r;
GetWindowRect(list_hwnd, &r);
DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(x - r.left, y - r.top));
PINGADDRESS *temp = 0;
- if(HIWORD(item) == 0) {
+ if (HIWORD(item) == 0) {
int count = LOWORD(item);
mir_cslock lck(data_list_cs);
- if(count >= 0 && count < (int)data_list.size()) {
+ if (count >= 0 && count < (int)data_list.size()) {
temp = (PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
}
- if(temp) {
+ if (temp) {
itemData = *temp;
- if(Edit(hwnd, itemData)) {
+ if (Edit(hwnd, itemData)) {
mir_cslock lck(data_list_cs);
*temp = itemData;
CallService(PLUG "/SetAndSavePingList", (WPARAM)&data_list, 0);
@@ -731,43 +739,43 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
CallService(PLUG "/EnableAll", 0, 0);
return TRUE;
case ID_MENU_OPTIONS:
- {
- OPENOPTIONSDIALOG oop = {0};
- oop.cbSize = sizeof(oop);
- oop.pszGroup = "Network";
- oop.pszPage = "Ping";
- oop.pszTab = "Settings";
- Options_Open(&oop);
- }
- return TRUE;
+ {
+ OPENOPTIONSDIALOG oop = { 0 };
+ oop.cbSize = sizeof(oop);
+ oop.pszGroup = "Network";
+ oop.pszPage = "Ping";
+ oop.pszTab = "Settings";
+ Options_Open(&oop);
+ }
+ return TRUE;
case ID_MENU_DESTINATIONS:
- {
- OPENOPTIONSDIALOG oop = {0};
- oop.cbSize = sizeof(oop);
- oop.pszGroup = "Network";
- oop.pszPage = "Ping";
- oop.pszTab = "Hosts";
- Options_Open(&oop);
- }
- return TRUE;
+ {
+ OPENOPTIONSDIALOG oop = { 0 };
+ oop.cbSize = sizeof(oop);
+ oop.pszGroup = "Network";
+ oop.pszPage = "Ping";
+ oop.pszTab = "Hosts";
+ Options_Open(&oop);
+ }
+ return TRUE;
}
- if (HIWORD( wParam ) == LBN_DBLCLK) {
+ if (HIWORD(wParam) == LBN_DBLCLK) {
sel = SendMessage(list_hwnd, LB_GETCURSEL, 0, 0);
- if(sel != LB_ERR) {
+ if (sel != LB_ERR) {
lp = SendMessage(list_hwnd, LB_GETITEMDATA, sel, 0);
- if(lp != LB_ERR) {
+ if (lp != LB_ERR) {
PINGADDRESS *pItemData = (PINGADDRESS *)lp;
mir_cslock lck(data_list_cs);
- if(pItemData) {
+ if (pItemData) {
DWORD item_id = pItemData->item_id;
int wake = CallService(PLUG "/DblClick", (WPARAM)item_id, 0);
InvalidateRect(list_hwnd, 0, FALSE);
- if(wake) SetEvent(hWakeEvent);
+ if (wake) SetEvent(hWakeEvent);
- if(options.logging) {
+ if (options.logging) {
TCHAR buf[1024];
mir_sntprintf(buf, SIZEOF(buf), _T("%s - %s"), pItemData->pszLabel, (wake ? TranslateT("enabled") : TranslateT("double clicked")));
CallService(PLUG "/Log", (WPARAM)buf, 0);
@@ -781,81 +789,81 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_MOVE: // needed for docked frames in clist_mw (not needed in clist_modern)
- if(FrameIsFloating())
+ if (FrameIsFloating())
break;
case WM_SIZE:
- {
+ {
//PostMessage(label, WM_SIZE, wParam, lParam);
- GetClientRect(hwnd,&rect);
+ GetClientRect(hwnd, &rect);
//SetWindowPos(list_hwnd, 0, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);
//InvalidateRect(list_hwnd, &rect, FALSE);
- int winheight = rect.bottom - rect.top,
- itemheight = SendMessage(list_hwnd, LB_GETITEMHEIGHT, 0, 0),
- count = SendMessage(list_hwnd, LB_GETCOUNT, 0, 0),
+ int winheight = rect.bottom - rect.top,
+ itemheight = SendMessage(list_hwnd, LB_GETITEMHEIGHT, 0, 0),
+ count = SendMessage(list_hwnd, LB_GETCOUNT, 0, 0),
#ifdef min
- height = min(winheight - winheight % itemheight, itemheight * count);
+ height = min(winheight - winheight % itemheight, itemheight * count);
#else
- height = std::min(winheight - winheight % itemheight, itemheight * count);
+ height = std::min(winheight - winheight % itemheight, itemheight * count);
#endif
- SetWindowPos(list_hwnd, 0, rect.left, rect.top, rect.right-rect.left, height, SWP_NOZORDER);
- InvalidateRect(list_hwnd, 0, FALSE);
- }
- InvalidateRect(hwnd, 0, TRUE);
- return DefWindowProc(hwnd, msg, wParam, lParam);
+ SetWindowPos(list_hwnd, 0, rect.left, rect.top, rect.right - rect.left, height, SWP_NOZORDER);
+ InvalidateRect(list_hwnd, 0, FALSE);
+ }
+ InvalidateRect(hwnd, 0, TRUE);
+ return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_DESTROY:
- if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
Utils_SaveWindowPosition(hwnd, 0, PLUG, "main_window");
}
KillTimer(hwnd, TIMER_ID);
- if(tbrush) DeleteObject(tbrush);
+ if (tbrush) DeleteObject(tbrush);
DestroyWindow(list_hwnd);
return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_CLOSE:
- if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
Utils_SaveWindowPosition(hwnd, 0, PLUG, "main_window");
ShowWindow(hwnd, SW_HIDE);
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
-/*
- case WM_POWERBROADCAST:
+ /*
+ case WM_POWERBROADCAST:
- if(options.logging) {
+ if(options.logging) {
std::ostringstream oss;
switch(wParam) {
case PBT_APMSUSPEND:
- CallService("PingPlug/Log", (WPARAM)"system suspend", 0);
- break;
+ CallService("PingPlug/Log", (WPARAM)"system suspend", 0);
+ break;
case PBT_APMRESUMESUSPEND:
- oss << "system resume";
- if(lParam == PBTF_APMRESUMEFROMFAILURE)
- oss << " [suspend failure!]";
- CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
- break;
+ oss << "system resume";
+ if(lParam == PBTF_APMRESUMEFROMFAILURE)
+ oss << " [suspend failure!]";
+ CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
+ break;
case PBT_APMRESUMEAUTOMATIC:
- oss << "system resume (automatic)";
- if(lParam == PBTF_APMRESUMEFROMFAILURE)
- oss << " [suspend failure!]";
- CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
- break;
+ oss << "system resume (automatic)";
+ if(lParam == PBTF_APMRESUMEFROMFAILURE)
+ oss << " [suspend failure!]";
+ CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
+ break;
case PBT_APMRESUMECRITICAL:
- oss << "system resume (critical)";
- if(lParam == PBTF_APMRESUMEFROMFAILURE)
- oss << " [suspend failure!]";
- CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
- break;
+ oss << "system resume (critical)";
+ if(lParam == PBTF_APMRESUMEFROMFAILURE)
+ oss << " [suspend failure!]";
+ CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
+ break;
}
- }
- break;
-*/
+ }
+ break;
+ */
default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
+ return DefWindowProc(hwnd, msg, wParam, lParam);
};
@@ -863,7 +871,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
};
int ReloadFont(WPARAM, LPARAM) {
- if(hFont) DeleteObject(hFont);
+ if (hFont) DeleteObject(hFont);
LOGFONT log_font;
CallService(MS_FONT_GETT, (WPARAM)&font_id, (LPARAM)&log_font);
@@ -883,17 +891,17 @@ int RefreshWindow(WPARAM, LPARAM) {
}
void UpdateFrame() {
- if(IsWindowVisible(hwnd_clist) != IsWindowVisible(hpwnd))
+ if (IsWindowVisible(hwnd_clist) != IsWindowVisible(hpwnd))
ShowWindow(hpwnd, IsWindowVisible(hwnd_clist) ? SW_SHOW : SW_HIDE);
- if(!IsWindowVisible(hpwnd)) return;
+ if (!IsWindowVisible(hpwnd)) return;
RECT r_clist;
GetWindowRect(hwnd_clist, &r_clist);
RECT r_frame;
GetWindowRect(hpwnd, &r_frame);
int height = (int)list_size * options.row_height;
- if(GetWindowLongPtr(hpwnd, GWL_STYLE) & WS_BORDER) {
+ if (GetWindowLongPtr(hpwnd, GWL_STYLE) & WS_BORDER) {
RECT r_frame_client;
GetClientRect(hpwnd, &r_frame_client);
height += (r_frame.bottom - r_frame.top) - (r_frame_client.bottom - r_frame_client.top);
@@ -905,11 +913,11 @@ void UpdateFrame() {
// Subclass procedure
LRESULT APIENTRY ClistSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- if(uMsg == WM_SIZE || uMsg == WM_MOVE)
+ if (uMsg == WM_SIZE || uMsg == WM_MOVE)
UpdateFrame();
- if(uMsg == WM_NCCALCSIZE) { // possible window style change
- if(GetWindowLongPtr(hwnd_clist, GWL_STYLE) != GetWindowLong(hpwnd, GWL_STYLE)
+ if (uMsg == WM_NCCALCSIZE) { // possible window style change
+ if (GetWindowLongPtr(hwnd_clist, GWL_STYLE) != GetWindowLong(hpwnd, GWL_STYLE)
|| GetWindowLongPtr(hwnd_clist, GWL_STYLE) != GetWindowLongPtr(hpwnd, GWL_STYLE))
{
SetWindowLongPtr(hpwnd, GWL_STYLE, GetWindowLongPtr(hwnd_clist, GWL_STYLE));
@@ -918,7 +926,7 @@ LRESULT APIENTRY ClistSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
}
}
- if(uMsg == WM_SHOWWINDOW)
+ if (uMsg == WM_SHOWWINDOW)
ShowWindow(hpwnd, wParam);
return mir_callNextSubclass(hwnd, ClistSubclassProc, uMsg, wParam, lParam);
@@ -926,9 +934,9 @@ LRESULT APIENTRY ClistSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
void AttachToClist(bool attach)
{
- if(!hpwnd) return;
+ if (!hpwnd) return;
- if(attach) {
+ if (attach) {
SetWindowLongPtr(hpwnd, GWL_STYLE, GetWindowLongPtr(hwnd_clist, GWL_STYLE));
SetWindowLongPtr(hpwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd_clist, GWL_EXSTYLE));
SetWindowPos(hpwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
@@ -950,35 +958,36 @@ void InitList()
WNDCLASS wndclass;
- wndclass.style = 0;
- wndclass.lpfnWndProc = FrameWindowProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
- wndclass.hIcon = hIconResponding;
- wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
- wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
- wndclass.lpszMenuName = NULL;
+ wndclass.style = 0;
+ wndclass.lpfnWndProc = FrameWindowProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = hIconResponding;
+ wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
+ wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = _T(PLUG) _T("WindowClass");
RegisterClass(&wndclass);
- if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
- hpwnd=CreateWindow(_T(PLUG) _T("WindowClass"), _T("Ping"), (WS_BORDER | WS_CHILD | WS_CLIPCHILDREN), 0, 0, 0, 0, hwnd_clist, NULL, hInst, NULL);
+ if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ hpwnd = CreateWindow(_T(PLUG) _T("WindowClass"), _T("Ping"), (WS_BORDER | WS_CHILD | WS_CLIPCHILDREN), 0, 0, 0, 0, hwnd_clist, NULL, hInst, NULL);
- CLISTFrame frame = {0};
- frame.name=PLUG;
- frame.cbSize=sizeof(CLISTFrame);
- frame.hWnd=hpwnd;
- frame.align=alBottom;
- frame.Flags=F_VISIBLE | F_SHOWTB | F_SHOWTBTIP;
- frame.height=30;
- frame.TBname=Translate("Ping");
+ CLISTFrame frame = { 0 };
+ frame.name = PLUG;
+ frame.cbSize = sizeof(CLISTFrame);
+ frame.hWnd = hpwnd;
+ frame.align = alBottom;
+ frame.Flags = F_VISIBLE | F_SHOWTB | F_SHOWTBTIP;
+ frame.height = 30;
+ frame.TBname = Translate("Ping");
- frame_id=CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&frame,0);
- } else {
- hpwnd=CreateWindowEx(WS_EX_TOOLWINDOW, _T(PLUG) _T("WindowClass"),_T("Ping"),
- (WS_POPUPWINDOW | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN),
- 0,0,400,300,hwnd_clist,NULL,hInst,NULL);
+ frame_id = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&frame, 0);
+ }
+ else {
+ hpwnd = CreateWindowEx(WS_EX_TOOLWINDOW, _T(PLUG) _T("WindowClass"), _T("Ping"),
+ (WS_POPUPWINDOW | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN),
+ 0, 0, 400, 300, hwnd_clist, NULL, hInst, NULL);
Utils_RestoreWindowPosition(hpwnd, 0, PLUG, "main_window");
@@ -990,11 +999,11 @@ void InitList()
mi.ptszPopupName = LPGENT("Ping");
mi.position = 3000320001;
mi.hIcon = 0;//LoadIcon( hInst, 0);
- mi.ptszName = LPGENT( "Show/Hide &Ping Window" );
+ mi.ptszName = LPGENT("Show/Hide &Ping Window");
mi.pszService = PLUG "/ShowWindow";
Menu_AddMainMenuItem(&mi);
- if(options.attach_to_clist) AttachToClist(true);
+ if (options.attach_to_clist) AttachToClist(true);
else ShowWindow(hpwnd, SW_SHOW);
}
@@ -1021,7 +1030,7 @@ void InitList()
_tcsncpy(bk_col_id.name, _T("Background"), SIZEOF(bk_col_id.name));
strncpy(bk_col_id.dbSettingsGroup, "PING", sizeof(bk_col_id.dbSettingsGroup));
strncpy(bk_col_id.setting, "BgColor", sizeof(bk_col_id.setting));
- bk_col_id.defcolour = RGB(0,0,0);
+ bk_col_id.defcolour = RGB(0, 0, 0);
ColourRegisterT(&bk_col_id);
HookEvent(ME_FONT_RELOAD, ReloadFont);
@@ -1035,5 +1044,5 @@ void InitList()
void DeinitList() {
DestroyWindow(hpwnd);
stop_ping_thread();
- if(hFont) DeleteObject(hFont);
+ if (hFont) DeleteObject(hFont);
} \ No newline at end of file