============================================================================
Blackbox for Windows: "How to get the current workspace name and number"
Copyright  2001-2003 The Blackbox for Windows Development Team
============================================================================

// On workspace changes, blackbox.exe sends a BB_DESKTOPINFO message
// with lParam pointing to a DesktopInfo structure of the new Desktop.

// whith

	class DesktopInfo
	{
	public:
		char name[32];  // name of the desktop
		bool isCurrent; // if it's the current desktop (always true with this call)
		int number;     // desktop number
		int ScreensX;   // total number of desktops
		strlist *deskNames; // list of all desktop names
	};


// use this function to get info about the desktop settings at any time:

	void GetDesktopInfo(DesktopInfo *deskInfo);


============================================================================
// example:

int msgs[] = { BB_DESKTOPINFO, BB_RECONFIGURE, 0 };

// ==========

void ShowDeskStatus(DesktopInfo *deskInfo)
{
	char temp[256]; int x;
	x = sprintf(
		temp,
		"Current Desk:"
		"\n Number: %d  Name: %s"
		"\n"
		"\nAll Desktops:"
		"\n Number: %d  Names:"
		,
		deskInfo->number, deskInfo->name, deskInfo->ScreensX);

	for (struct strlist *s = deskInfo->deskNames; s; s=s->next)
		x+=sprintf(temp+x, " %s", s->str);

	MessageBox(NULL, temp, "Desktop Info", MB_OK|MB_TOPMOST);
}

// ==========

int beginPlugin(HINSTANCE hInstance)
{
	// CreateWindowEx stuff here ......

	// register the BB_DESKTOPINFO message
	SendMessage(GetBBWnd(), BB_REGISTERMESSAGE, (WPARAM)hMainWnd, (LPARAM)msgs);
	return 0;
}

void endPlugin(HINSTANCE hInstance)
{
	SendMessage(GetBBWnd(), BB_UNREGISTERMESSAGE, (WPARAM)hMainWnd, (LPARAM)msgs);
}

// ==========



LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case BB_DESKTOPINFO:
		{
			// on Workspace changes, show the info
			DesktopInfo* pInfo = (DesktopInfo*)lParam;
			ShowDeskStatus(pInfo);
		}
		break;

		case BB_RECONFIGURE:
		{
			// on reconfigure, get the info with the API call
			DesktopInfo Info;
			GetDesktopInfo(&Info);
			ShowDeskStatus(&Info);
		}
		break;

		default:
			return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}

// ==========
