void LoadPopupThread() { unsigned threadId; hThread = mir_forkthreadex(PopupThread, NULL, &threadId); HookEvent(ME_AV_AVATARCHANGED, sttAvatarChanged); }
void InitMessagePump() { WNDCLASS popup_win_class = { 0 }; popup_win_class.lpfnWndProc = PopupWindowProc; popup_win_class.hInstance = hInst; popup_win_class.lpszClassName = POP_WIN_CLASS; popup_win_class.hCursor = LoadCursor(NULL, IDC_ARROW); RegisterClass(&popup_win_class); InitServices(); hMPEvent = CreateEvent(0, TRUE, 0, 0); CloseHandle(mir_forkthreadex(MessagePumpThread, hMPEvent, &message_pump_thread_id)); WaitForSingleObject(hMPEvent, INFINITE); CloseHandle(hMPEvent); }
void TSAPI CreateTrayMenus(int mode) { if (mode) { mir_sntprintf(g_eventName, 100, _T("tsr_evt_%d"), GetCurrentThreadId()); g_hEvent = CreateEvent(NULL, FALSE, FALSE, g_eventName); isAnimThreadRunning = TRUE; hTrayAnimThread = (HANDLE)mir_forkthreadex(TrayAnimThread, NULL, 16000, NULL); PluginConfig.g_hMenuTrayUnread = CreatePopupMenu(); PluginConfig.g_hMenuFavorites = CreatePopupMenu(); PluginConfig.g_hMenuRecent = CreatePopupMenu(); PluginConfig.g_hMenuTrayContext = GetSubMenu(PluginConfig.g_hMenuContext, 6); ModifyMenu(PluginConfig.g_hMenuTrayContext, 0, MF_BYPOSITION | MF_POPUP, (UINT_PTR)PluginConfig.g_hMenuFavorites, CTranslator::get(CTranslator::GEN_FAVORITES)); ModifyMenu(PluginConfig.g_hMenuTrayContext, 2, MF_BYPOSITION | MF_POPUP, (UINT_PTR)PluginConfig.g_hMenuRecent, CTranslator::get(CTranslator::GEN_RECENT_SESSIONS)); LoadFavoritesAndRecent(); } else { isAnimThreadRunning = FALSE; SetEvent(g_hEvent); WaitForSingleObject(hTrayAnimThread, 5000); CloseHandle(hTrayAnimThread); CloseHandle(g_hEvent); g_hEvent = 0; hTrayAnimThread = 0; if (PluginConfig.g_hMenuTrayUnread != 0) { DestroyMenu(PluginConfig.g_hMenuTrayUnread); PluginConfig.g_hMenuTrayUnread = 0; } if (PluginConfig.g_hMenuFavorites != 0) { DestroyMenu(PluginConfig.g_hMenuFavorites); PluginConfig.g_hMenuFavorites = 0; } if (PluginConfig.g_hMenuRecent != 0) { DestroyMenu(PluginConfig.g_hMenuRecent); PluginConfig.g_hMenuRecent = 0; } } }
//======================================================= //SetStatus //======================================================= INT_PTR SetStatus(WPARAM wParam,LPARAM lParam) { if (wParam == ID_STATUS_OFFLINE) { diffstat=0; //PostThreadMessage(ConnectionCheckThreadId,WM_QUIT ,(WPARAM)0, (LPARAM)0); SetEvent(killCheckThreadEvent); } else if (wParam == ID_STATUS_ONLINE) { diffstat=0; ResetEvent(killCheckThreadEvent); if (!hConnectionCheckThread) hConnectionCheckThread = (HANDLE)mir_forkthreadex(checkthread, 0, (unsigned int*)&ConnectionCheckThreadId); } else { int retv=0; if (settingStatus[wParam - ID_STATUS_ONLINE]) retv= SetStatus(ID_STATUS_OFFLINE,lParam); else retv= SetStatus(ID_STATUS_ONLINE,lParam); //LNEnableMenuItem(hMenuHandle ,TRUE); diffstat=wParam; return retv; // the status has been changed to unknown (maybe run some more code) } //broadcast the message //oldStatus = currentStatus; if (currentStatus!=wParam) ProtoBroadcastAck(PLUGINNAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)currentStatus,wParam); currentStatus = wParam; return 0; }
void InitMessagePump() { WNDCLASS popup_win_class = {0}; popup_win_class.lpfnWndProc = PopupWindowProc; popup_win_class.hInstance = hInst; popup_win_class.lpszClassName = POP_WIN_CLASS; popup_win_class.hCursor = LoadCursor(NULL, IDC_ARROW); RegisterClass(&popup_win_class); HMODULE hUserDll = GetModuleHandle(_T("user32.dll")); if (hUserDll) { MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes"); MyAnimateWindow=(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll,"AnimateWindow"); MyMonitorFromPoint = (HMONITOR (WINAPI*)(POINT, DWORD))GetProcAddress(hUserDll, "MonitorFromPoint"); #ifdef _UNICODE MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR, LPMONITORINFO))GetProcAddress(hUserDll, "GetMonitorInfoW"); #else MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR, LPMONITORINFO))GetProcAddress(hUserDll, "GetMonitorInfoA"); #endif } CloseHandle(mir_forkthreadex(MessagePumpThread, NULL, 0, &message_pump_thread_id)); }
/* create thread */ int pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(__stdcall * thread_start) (void *), void *param) { tid->hThread = (HANDLE)mir_forkthreadex((pThreadFuncEx)*(void**)&thread_start, param, 0, (unsigned *)&tid->dwThreadId); return 0; }
void LoadPopupThread() { unsigned threadId; hThread = mir_forkthreadex(PopupThread, NULL, &threadId); }