コード例 #1
0
LRESULT CALLBACK message_event(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static const int message_blackboxmessages[] = {BB_RECONFIGURE, BB_BROADCAST, BB_DESKCLICK, BB_DRAGTODESKTOP, BB_HIDEMENU, BB_TASKSUPDATE,BB_WORKSPACE,0};

    switch(msg)
    {
    case WM_CREATE:
        //Register the window to recieve BlackBox events
        SendMessage(plugin_hwnd_blackbox, BB_REGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)message_blackboxmessages);
        break;

    case WM_DESTROY:
        //Unregister to recieve BlackBox events
        SendMessage(plugin_hwnd_blackbox, BB_UNREGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)message_blackboxmessages);
        break;

    case BB_DRAGTODESKTOP:
        if (NULL == plugin_desktop_drop_command) return false;
        if (!(wParam & 1))
        {
            variables_set(false,"DroppedFile", (const char *)lParam);
            message_interpret(plugin_desktop_drop_command, false, NULL);
        }
        return true;
    case BB_TASKSUPDATE:
        controls_updatetasks();
        break;
    case BBI_POSTCOMMAND:
        SendMessage(plugin_hwnd_blackbox, BB_BROADCAST, 0, lParam);
        delete (char *)lParam;
        break;

    case BB_RECONFIGURE:
        plugin_reconfigure(false);
        break;

    case BB_DESKCLICK:
        if (lParam == 0)
            controls_clickraise();
        break;

    case BB_BROADCAST:
        message_interpret((const char *)lParam, true, NULL);
        break;

    case WM_TIMER:
        KillTimer(hwnd, wParam);
        if (1 == wParam)
            config_backup(config_path_mainscript);
        break;

    default:
        return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}
コード例 #2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//plugin_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int plugin_message(int tokencount, char *tokens[], bool from_core, module* caller)
{
	char *filename;

	if (tokencount == 3 && !stricmp(tokens[2], szBActionSave))
	{
		config_save(config_path_mainscript);
		return 0;
	}
	else if (!stricmp(tokens[2], szBActionSaveAs))
	{
		if (tokencount == 4)
		{
			config_save(tokens[3]);
		}
		else
		{       
			if ((filename = dialog_file(szFilterScript, "Save Configuration Script", ".rc", config_path_plugin, true)))
			{
				config_save(filename);
			}           
		}       
		return 0;
	}
	else if (tokencount == 3 && !stricmp(tokens[2], szBActionRevert))
	{
		plugin_reconfigure(true);
		return 0;
	}
	else if (!stricmp(tokens[2], szBActionLoad))
	{
		if (tokencount == 4)
		{
			config_load2(tokens[3], caller);
			return 0;
		}
		else if (tokencount == 3)
		{
			if ((filename = dialog_file(szFilterScript, "Load Configuration Script", ".rc", config_path_plugin, false)))
			{
				config_load2(filename, caller);
			}
			return 0;
		}
		else if (tokencount == 6)
		{
			if (0 == stricmp(tokens[4], "from"))
			{
				config_load(tokens[5], caller, tokens[3]);
				return 0;
			} else if (0 == stricmp(tokens[4], "into"))
			{
				config_load(tokens[3], module_get(tokens[5]));
				return 0;
			}
		}
		else if (tokencount == 8 && 0 == stricmp(tokens[4], "from") && 0 == stricmp(tokens[6], "into"))
		{
			config_load(tokens[5], module_get(tokens[7]), tokens[3]);
			return 0;
		}
	}
	else if (!stricmp(tokens[2], szBActionAbout))
	{
		if (tokencount == 3)
		{
			MessageBox(NULL, szPluginAbout, szVersion, MB_OK|MB_SYSTEMMODAL);
			return 0;
		}
		else if (tokencount == 4 && !stricmp(tokens[3], "LastControl"))
		{
			MessageBox(NULL, szPluginAboutLastControl, szAppName, MB_OK|MB_SYSTEMMODAL);
			return 0;
		}
		else if (tokencount == 4 && !stricmp(tokens[3], "QuickHelp"))
		{
			MessageBox(NULL, szPluginAboutQuickRef, szAppName, MB_OK|MB_SYSTEMMODAL);
			return 0;
		}
	}
	else if (!stricmp(tokens[2], szBActionEdit))
	{
		//SendMessage(plugin_hwnd_blackbox, BB_EDITFILE, (WPARAM)-1, (LPARAM) config_path_mainscript);
		//return 0;
		char temp[MAX_PATH]; GetBlackboxEditor(temp);
		BBExecute(NULL, "",temp , config_path_mainscript, NULL, SW_SHOWNORMAL, false);
		return 0;
	}
	else if (tokencount == 5 && !stricmp(tokens[2], szBActionSetPluginProperty))
	{
		for (struct plugin_properties *p = plugin_properties; p->key; p++)
			if (p->data && 0 == stricmp(tokens[3], p->key)) {
				switch (p->type) {
					case M_BOL:
						if (config_set_bool(tokens[4], (bool*)p->data)) break; return 1;
					case M_INT:
						if (config_set_int(tokens[4], (int*)p->data)) break; return 1;
					case M_STR:
						if (config_set_str(tokens[4], (char**)p->data)) break; return 1;
					default: return 1;
				}
				if (p->update) control_invalidate();
				if (from_core) menu_update_global();
				return 0;
			}
	}
	else if (tokencount == 4 && !stricmp(tokens[2], szBActionOnLoad) )
	{
		config_set_str(tokens[3],&(globalmodule.actions[MODULE_ACTION_ONLOAD]));
		return 0;
	}
	else if (tokencount == 4 && !stricmp(tokens[2], szBActionOnUnload) )
	{
		config_set_str(tokens[3],&(globalmodule.actions[MODULE_ACTION_ONUNLOAD]));
		return 0;
	}
	return 1;
}