Beispiel #1
0
//===== Load =====
//Initializes the services provided and the link to those needed
//Called when the plugin is loaded into Miranda
MIRAPI int Load(void)
{
	DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0);

	mir_getMTI(&MText);
	mir_getLP(&pluginInfoEx);

	CreateServiceFunction(MS_POPUP_GETSTATUS, GetStatus);

	#if defined(_DEBUG)
		PopupOptions.debug = db_get_b(NULL, MODULNAME, "debug", FALSE);
	#else
		PopupOptions.debug = false;
	#endif
	LoadGDIPlus();

	//Transparent and animation routines
	hDwmapiDll = LoadLibrary(_T("dwmapi.dll"));
	MyDwmEnableBlurBehindWindow = 0;
	if (hDwmapiDll)
		MyDwmEnableBlurBehindWindow = (HRESULT (WINAPI *)(HWND, DWM_BLURBEHIND *))GetProcAddress(hDwmapiDll, "DwmEnableBlurBehindWindow");

	PopupHistoryLoad();
	LoadPopupThread();
	if (!LoadPopupWnd2()) {
		MessageBox(0, TranslateT("Error: I could not register the Popup Window class.\r\nThe plugin will not operate."), _T(MODULNAME_LONG), MB_ICONSTOP | MB_OK);
		return 0; //We couldn't register our Window Class, don't hook any event: the plugin will act as if it was disabled.
	}
	RegisterOptPrevBox();

	// Register in DBEditor++
	UpgradeDb();

	HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
	HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
	HookEvent(ME_SYSTEM_PRESHUTDOWN, OkToExit);

	hbmNoAvatar = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_NOAVATAR));

	if (!OptionLoaded)
		LoadOptions();

	//Service Functions
	hEventNotify = CreateHookableEvent(ME_POPUP_FILTER);

	CreateServiceFunction(MS_POPUP_ADDPOPUP,             Popup_AddPopup);
	CreateServiceFunction(MS_POPUP_ADDPOPUPW,            Popup_AddPopupW);
	CreateServiceFunction(MS_POPUP_ADDPOPUP2,            Popup_AddPopup2);

	CreateServiceFunction(MS_POPUP_CHANGETEXTW,          Popup_ChangeTextW);

	CreateServiceFunction(MS_POPUP_CHANGEW,              Popup_ChangeW);
	CreateServiceFunction(MS_POPUP_CHANGEPOPUP2,         Popup_Change2);

	CreateServiceFunction(MS_POPUP_GETCONTACT,           Popup_GetContact);
	CreateServiceFunction(MS_POPUP_GETPLUGINDATA,        Popup_GetPluginData);
	CreateServiceFunction(MS_POPUP_ISSECONDLINESHOWN,    Popup_IsSecondLineShown);

	CreateServiceFunction(MS_POPUP_SHOWMESSAGE,          Popup_ShowMessage);
	CreateServiceFunction(MS_POPUP_SHOWMESSAGEW,         Popup_ShowMessageW);
	CreateServiceFunction(MS_POPUP_QUERY,                Popup_Query);

	CreateServiceFunction(MS_POPUP_REGISTERACTIONS,      Popup_RegisterActions);
	CreateServiceFunction(MS_POPUP_REGISTERNOTIFICATION, Popup_RegisterNotification);

	CreateServiceFunction(MS_POPUP_UNHOOKEVENTASYNC,     Popup_UnhookEventAsync);

	CreateServiceFunction(MS_POPUP_REGISTERVFX,          Popup_RegisterVfx);

	CreateServiceFunction(MS_POPUP_REGISTERCLASS,        Popup_RegisterPopupClass);
	CreateServiceFunction(MS_POPUP_UNREGISTERCLASS,      Popup_UnregisterPopupClass);
	CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS,        Popup_CreateClassPopup);

	//load icons / create hook
	InitIcons();
	HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
	//add menu items
	InitMenuItems();

	return 0;
}
Beispiel #2
0
//===== Load =====
//Initializes the services provided and the link to those needed
//Called when the plugin is loaded into Miranda
MIRAPI int Load(PLUGINLINK *link)
{
	char ver[1024];
	pluginLink=link;

	g_popup.isOsUnicode = (GetVersion() & 0x80000000) == 0;

	CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM) sizeof(ver), (LPARAM) ver);
	g_popup.isMirUnicode = strstr(ver, "Unicode") != NULL;

	hGetStatus = CreateServiceFunction(MS_POPUP_GETSTATUS, GetStatus);

	DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0);

	mir_getLI	(&li);
	mir_getMMI	(&mmi);
	mir_getUTFI	(&utfi);
	mir_getMTI	(&MText);
	mir_getLP(&pluginInfoEx);

	#if defined(_DEBUG)
		PopUpOptions.debug = DBGetContactSettingByte(NULL, MODULNAME, "debug", FALSE);
	#else
		PopUpOptions.debug = false;
	#endif
	LoadGDIPlus();

	//Transparent and animation routines
	OSVERSIONINFO osvi = { 0 };
	BOOL bResult = FALSE;
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	bResult = GetVersionEx(&osvi);

// MLU layer for ansi release
#if !defined(_UNICODE)
	MySetLayeredWindowAttributes = 0;
	MyUpdateLayeredWindow = 0;
	MyAnimateWindow = 0;
	MyDrawTextW = 0;
	MyDrawTextExW = 0;
	MySetWindowTextW = 0;
	MySendMessageW = 0;
	MyCallWindowProcW = 0;
	MyCreateWindowExW = 0;

	MyGetMonitorInfo = 0;
	MyMonitorFromWindow = 0;

	hUserDll = LoadLibrary(_T("user32.dll"));
	if (hUserDll) {
		MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes");
		MyUpdateLayeredWindow = (BOOL (WINAPI *)(HWND, HDC, POINT *, SIZE *, HDC, POINT *, COLORREF, BLENDFUNCTION *, DWORD))GetProcAddress(hUserDll, "UpdateLayeredWindow");
		MyAnimateWindow = (BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll,"AnimateWindow");
		MyDrawTextW = (int (WINAPI *)(HDC, LPCWSTR, int, LPRECT, UINT))GetProcAddress(hUserDll,"DrawTextW");
		MyDrawTextExW = (int (WINAPI*)(HDC,LPCWSTR,int,LPRECT,UINT,LPDRAWTEXTPARAMS))GetProcAddress(hUserDll,"DrawTextExW");
		MySetWindowTextW = (BOOL (WINAPI*)(HWND, LPCWSTR))GetProcAddress(hUserDll,"SetWindowTextW");
		MySendMessageW = (LRESULT (WINAPI *)(HWND, UINT, WPARAM, LPARAM))GetProcAddress(hUserDll,"SendMessageW");
		MyCallWindowProcW = (LRESULT (WINAPI  *)(WNDPROC, HWND, UINT, WPARAM, LPARAM))GetProcAddress(hUserDll,"CallWindowProcW");
		MyCreateWindowExW = (HWND (WINAPI*)(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID))GetProcAddress(hUserDll,"CreateWindowExW");

		if (LOWORD(GetVersion())!=4) { //Windows 98, ME, 2000, XP, and later support multimonitor configuration.
			if (bResult) {
				if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
				{ //2000 or XP
					#ifdef UNICODE
						MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR,LPMONITORINFO))GetProcAddress(hUserDll,("GetMonitorInfoW"));
					#else
						MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR,LPMONITORINFO))GetProcAddress(hUserDll,("GetMonitorInfoA"));
					#endif //UNICODE
				} else
				{ //98 or ME
					// attempt to fix multimonitor on 9x
					MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR,LPMONITORINFO))GetProcAddress(hUserDll,("GetMonitorInfoA"));
					if (!MyGetMonitorInfo)
						MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR,LPMONITORINFO))GetProcAddress(hUserDll,("GetMonitorInfo"));
				}
			} //There's no need for an else branch.
			if (MyGetMonitorInfo)
				MyMonitorFromWindow = (HMONITOR (WINAPI*)(HWND,DWORD))GetProcAddress(hUserDll, ("MonitorFromWindow"));
		}
	}

	hGdiDll = LoadLibrary(_T("gdi32.dll"));
	if (hGdiDll) {
		MyGetTextExtentPoint32W = (BOOL (WINAPI *)(HDC, LPCWSTR, int, LPSIZE))GetProcAddress(hGdiDll,"GetTextExtentPoint32W");
	}
	else{
		MyGetTextExtentPoint32W = 0;
	}
	hMsimgDll = LoadLibrary(_T("msimg32.dll"));
	MyAlphaBlend = 0;
	MyTransparentBlt = 0;
	if (hMsimgDll)
	{
		MyTransparentBlt = (BOOL (WINAPI *)(HDC, int, int, int, int, HDC, int, int, int, int, UINT))
			GetProcAddress(hMsimgDll, "TransparentBlt");
		MyAlphaBlend = (BOOL (WINAPI *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION))
			GetProcAddress(hMsimgDll, "AlphaBlend");
	}
#endif

	hDwmapiDll = LoadLibrary(_T("dwmapi.dll"));
	MyDwmEnableBlurBehindWindow = 0;
	if (hDwmapiDll) {
		MyDwmEnableBlurBehindWindow = (HRESULT (WINAPI *)(HWND, DWM_BLURBEHIND *))
			GetProcAddress(hDwmapiDll, "DwmEnableBlurBehindWindow");
	}

	PopupHistoryLoad();
	LoadPopupThread();
	if (!LoadPopupWnd2())
	{
		MessageBox(0, TranslateTS(
			_T("Error: I could not register the PopUp Window class.\r\n")
			_T("The plugin will not operate.")
			),
			_T(MODULNAME_LONG), MB_ICONSTOP|MB_OK);
		return 0; //We couldn't register our Window Class, don't hook any event: the plugin will act as if it was disabled.
	}
	RegisterOptPrevBox();

	// Register in DBEditor++
	DBVARIANT dbv;
	if (DBGetContactSetting(NULL, "KnownModules", MODULNAME, &dbv))
		DBWriteContactSettingString(NULL, "KnownModules", pluginInfoEx.shortName, MODULNAME);
	DBFreeVariant(&dbv);
	
	hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
	hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
	hOkToExit = HookEvent(ME_SYSTEM_OKTOEXIT, OkToExit);
//	hEventStatusChanged = HookEvent(ME_CLIST_STATUSMODECHANGE,StatusModeChanged);

	hbmNoAvatar = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_NOAVATAR));

	if(!OptionLoaded){
		LoadOptions();
	}

	//Service Functions
	for (int i = SIZEOF(popupServices); i--; )
		popupServices[i].handle = CreateServiceFunction(popupServices[i].name, popupServices[i].func);

	//load icons / create hook
	InitIcons();
	hIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED,IconsChanged);
	//add menu items
	InitMenuItems();

	return 0;
}