BlackBox for Windows

blackbox.exe API|DLL exports


 

available to Plugin developers

ReadBool 

MakeMenuNOP 

GetTask 

ReadInt 

MakeMenuItem 

GetActiveTask 

ReadString 

GetBlackboxPath 

GetTaskListSize 

ReadColor 

bbrcPath 

GetTaskWorkspace 

ReadValue 

extensionsrcPath 

SetTaskWorkspace 

menuPath 

MakeSubmenu 

bbLean family only

WriteBool 

plugrcPath 

MakePathMenu

WriteInt 

stylePath 

DisableLastItem

WriteString 

GetBBWnd 

BBMessageBox

WriteColor 

GetBBVersion 

MenuExists

GetOSInfo 

MakeMenu 

DeleteSetting

GetUnderExplorer 

DelMenu 

RenameSetting

GetSettingPtr 

Tokenize 

GetToolbarInfo

FileExists 

BBTokenize 

GetMonitorRect

FileOpen 

BBExecute 

EnumTray

FileClose 

Log 

GetBlackboxEditor

FileRead 

MBoxErrorFile 

SetDesktopMargin

ReadNextCommand 

MBoxErrorValue 

MakeNamedMenu

GetDesktopInfo 

ShowMenu 

GetTaskListPtr

ConfigFileExists 

ParseItem 

GetTaskLocation

MakeSticky 

IsInString 

SetTaskLocation

RemoveSticky 

StrRemoveEncap 

EnumTasks

CheckSticky 

ReplaceEnvVars 

GetAppByWindow

ReplaceShellFolders 

MakeMenuItemString 

FoundLastValue

IsAppWindow 

MakeGradient 

FindConfigFile

MakeStyleGradient 

CreateBorder 

EnumDesks

SnapWindowToEdge 

CreateStyleFont 

dbg_printf

SetTransparency 

GetTrayIcon 

xoblite only

MakeMenuItemInt 

GetTraySize 

ParseFontString  only

CheckFontSubstitution  only



 


BBAPI.cpp

 

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

// API: GetBBWnd

// Purpose: Returns the handle to the main Blackbox window

// In: None

// Out: HWND = Handle to the Blackbox window

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

 

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

// API: GetOSInfo

// Purpose: Retrieves info about the current OS

// In: None

// Out: LPCSTR = Returns a readable string containing the OS name

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

 

LPCSTR GetOSInfo(void)

{

    if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)

    {

        if (osInfo.dwMinorVersion >= 90)

            return "Windows ME";

        if (osInfo.dwMinorVersion >= 10)

            return "Windows 98";

        return "Windows 95";

    }

    if (osInfo.dwMajorVersion == 5)

    {

        if (osInfo.dwMinorVersion >= 1)

            return "Windows XP";

        return "Windows 2000";

    }

    static char osinfo_buf[33];

sprintf(osinfo_buf, "Windows NT %d.%d", (int)osInfo.dwMajorVersion, (int)osInfo.dwMinorVersion);

    return osinfo_buf;

}

 

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

// API: GetBlackboxPath

// Purpose: Copies the path of the Blackbox executable to the specified buffer

// In: LPSTR pszPath = Location of the buffer for the path

// In: int nMaxLen = Maximum length for the buffer

// Out: bool = Returns status of completion

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

 

LPSTR WINAPI GetBlackboxPath(LPSTR pszPath, int nMaxLen)

{

GetModuleFileName(NULL, pszPath, nMaxLen);

*(char*)get_file(pszPath) = 0;

    return pszPath;

}

 

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

// Function: NextToken

// Purpose: Copy the first token of 'string' seperated by the delim to 'buf'

//          and move the rest of 'string' down.

// returns: 'buf'

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

 

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

// API: Tokenize

// Purpose: Retrieve the first string seperated by the delim and return a pointer to the rest of the string

// In: LPCSTR string = String to be parsed

// In: LPSTR buf = String where the tokenized string will be placed

// In: LPSTR delims = The delimeter that signifies the seperation of the tokens in the string

// Out: LPSTR = Returns a pointer to the entire remaining string

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

 

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

// API: BBTokenize

// Purpose: Assigns a specified number of string variables and outputs the remaining to a variable

// In: LPCSTR szString = The string to be parsed

// In: LPSTR lpszBuffers[] = A pointer to the location for the tokenized strings

// In: DWORD dwNumBuffers = The amount of tokens to be parsed

// In: LPSTR szExtraParameters = A pointer to the location for the remaining string

// Out: int = Number of tokens parsed

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

 

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

// API: StrRemoveEncap

// Purpose: Removes the first and last characters of a string

// In: LPSTR string = The string to be altered

// Out: LPSTR = A pointer to the altered string

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

 

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

// API: IsInString

// Purpose: Checks a given string to an occurance of the second string

// In: LPCSTR = string to search

// In: LPCSTR = string to search for

// Out: bool = found or not

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

 

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

// tiny cache reader: first checks, if the file had already been read, if not,

// reads the file into a malloc'ed buffer, then for each line separates

// keyword from value, cuts off leading and trailing spaces, strlwr's the

// keyword and adds both to a list of below defined structures, where k is

// the offset to the start of the value-string. Comments or other non-keyword

// lines have a "" keyword and the line as value.

 

// added checking for external updates by the user.

 

// added *wild*card* processing, it first looks for an exact match, if it

// cant find any, returns the first wildcard value, that matches, or null,

// if none...

 

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

 

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

// API: FoundLastValue

// Purpose: Was the last read value actually in the rc-file?

// returns: 0=no 1=yes 2=wildcard matched

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

 

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

// API: ReadValue

// Purpose: Searches the given file for the supplied keyword and returns a

// pointer to the value - string

// In: LPCSTR path = String containing the name of the file to be opened

// In: LPCSTR szKey = String containing the keyword to be looked for

// In: LONG ptr: optional: an index into the file to start search.

// Out: LPSTR = Pointer to the value string of the keyword

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

 

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

// API: DeleteSetting

 

bool DeleteSetting(LPCSTR path, LPCSTR szKey)

 

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

// API: RenameSetting

 

bool RenameSetting(LPCSTR path, LPCSTR szKey, LPCSTR new_keyword)

 

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

 

// API: WriteString

 

void WriteString(LPCSTR fileName, LPCSTR szKey, LPCSTR value)

 

// API: WriteBool

 

void WriteBool(LPCSTR fileName, LPCSTR szKey, bool value)

 

// API: WriteInt

 

void WriteInt(LPCSTR fileName, LPCSTR szKey, int value)

 

// API: WriteColor

 

void WriteColor(LPCSTR fileName, LPCSTR szKey, COLORREF value)

 

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

 

// API: ReadBool

 

bool ReadBool(LPCSTR fileName, LPCSTR szKey, bool bDefault)

 

// API: ReadInt

 

int ReadInt(LPCSTR fileName, LPCSTR szKey, int nDefault)

 

// API: ReadString

 

LPCSTR ReadString(LPCSTR fileName, LPCSTR szKey, LPCSTR szDefault)

 

// API: ReadColor

 

COLORREF ReadColor(LPCSTR fileName, LPCSTR szKey, LPCSTR defaultString)

 

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

// API: FileExists

// Purpose: Checks for a files existence

// In: LPCSTR = file to set as check for

// Out: bool = whether found or not

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

 

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

// API: FileOpen

// Purpose: Opens file for parsing

// In: LPCSTR = file to open

// Out: FILE* = the file itself

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

 

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

// API: FileClose

// Purpose: Close selected file

// In: FILE *fp = The file you wish to close

// Out: bool = Returns the status of completion

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

 

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

// API: FileRead

// Purpose: Read's a line from given FILE and returns boolean on status

// In: FILE *stream = FILE to parse

// In: LPSTR string = Pointer to returned line from the file

// Out: bool = Status (true if read, false if not)

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

 

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

// API: ReadNextCommand

// Purpose: Reads the next line of the file

// In: FILE* = File to be parsed

// In: LPSTR = buffer to assign next line to

// DWORD = maximum size of line to be outputted

// Out: bool = whether there was a next line to parse

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

 

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

// API: ReplaceShellFolders

// Purpose: replace shell folders in a string path, like DESKTOP\...

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

 

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

// API: ReplaceEnvVars

// Purpose: parses a given string and replaces all %VAR% with the environment

//          variable value if such a value exists

// In: LPSTR = string to replace env vars in

// Out: void = None

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

 

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

// API: GetBlackboxEditor

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

 

void GetBlackboxEditor(LPSTR editor)

 

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

// API: FindConfigFile

// Purpose: Look for a config file in the Blackbox, UserAppData and

// (optionally) plugin directories

// In:  LPSTR = pszOut = the location where to put the result

// In:  LPCSTR = filename to look for, LPCSTR = plugin directory or NULL

// Out: bool = true of found, FALSE otherwise

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

 

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

// API: ConfigFileExists

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

 

LPCSTR ConfigFileExists(LPCSTR filename, LPCSTR pluginDir)

 

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

// API: bbrcPath

// Purpose: Returns the handle to the blackboxrc file that is being used

// In: LPCSTR = file to set as default bbrc file (defaults to NULL if not specified)

// Out: LPCSTR = full path of file

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

 

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

// API: extensionsrcPath

// Purpose: Returns the handle to the extensionsrc file that is being used

// In: LPCSTR = file to set as default extensionsrc file (defaults to NULL if not specified)

// Out: LPCSTR = full path of file

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

 

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

// API: plugrcPath

// In: LPCSTR = file to set as default plugins rc file (defaults to NULL if not specified)

// Purpose: Returns the handle to the plugins rc file that is being used

// Out: LPCSTR = full path of file

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

 

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

// API: menuPath

// Purpose: Returns the handle to the menu file that is being used

// In: LPCSTR = file to set as default menu file (defaults to NULL if not specified)

// Out: LPCSTR = full path of file

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

 

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

// API: stylePath

// Purpose: Returns the handle to the style file that is being used

// In: LPCSTR = file to set as default style file (defaults to NULL if not specified)

// Out: LPCSTR = full path of file

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

 

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

// API: Log

// Purpose: Appends given line to Blackbox.log file

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

 

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

// API: MBoxErrorFile

// Purpose: Gives a message box proclaming missing file

// In: LPCSTR = missing file

// Out: int = return value of messagebox

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

 

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

// API: MBoxErrorValue

// Purpose: Gives a message box proclaming a given value

// In: LPCSTR = value

// Out: int = return value of messagebox

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

 

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

// API: BBExecute

// Purpose: A safe execute routine

// In: HWND = owner

// In: LPCSTR = operation (eg. "open")

// In: LPCSTR = command to run

// In: LPCSTR = arguments

// In: LPCSTR = directory to run from

// In: int = show status

// In: bool = suppress error messages

// //Out: HINSTANCE = instance of file running

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

 

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

// API: IsAppWindow

// Purpose: checks given hwnd to see if it's an app

// In: HWND = hwnd to check

// Out: bool = if app or not

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

 

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

// API: MakeStyleGradient

// Purpose:  Make a gradient from style Item

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

 

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

// API: ParseItem

// Purpose: parses a given string and assigns settings to a StyleItem class

// In: LPCSTR = item to parse out

// In: StyleItem* = class to assign values to

// Out: void = None

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

 

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

// API: MakeSticky

// API: RemoveSticky

// API: CheckSticky

// Purpose:  make a plugin-window appear on all workspaces

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

 

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

// API: GetUnderExplorer

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

 

bool GetUnderExplorer()

 

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

// API: SetTransparency

// Purpose: Wrapper, win9x conpatible

// In:      HWND, alpha

// Out:     bool

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

 

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

// API: GetMonitorRect

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

 

HMONITOR GetMonitorRect(void *from, RECT *r, int flags)

 

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

// API: SetDesktopMargin

// Purpose:  Set a margin for e.g. toolbar, bbsystembar, etc

// In:       hwnd to associate the margin with, location, margin-width

// Out:      void

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

 

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

// API: SnapWindowToEdge

// Purpose:Snaps a given windowpos at a specified distance

// In: WINDOWPOS* = WINDOWPOS recieved from WM_WINDOWPOSCHANGING

// In: int = distance to snap to

// In: bool = use screensize of workspace

// Out: void = none

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

 

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

// Function: ParseFontString

// Purpose: Parses a Name/Height/WeightShadow format font string

// In: LPSTR string, StyleItem *item

// Out: void = None

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

 

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

// Function: CheckFontSubstitution

// Purpose: Replaces *nix-only fonts with (hopefully) Windows equivalents

// In: LPSTR = string to replace font names in

// Out: void = None

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

 

 

BImage.cpp

 

 

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

// API: MakeGradient

// Purpose: creates a gradient and fills it with the specified options

// In: HDC = handle of the device context to fill

// In: RECT = rect you wish to fill

// In: int = type of gradient (eg. B_HORIZONTAL)

// In: COLORREF = first colour to use

// In: COLORREF = second colour to use

// In: bool = whether to interlace (darken every other line)

// In: int = style of bevel (eg. BEVEL_FLAT)

// In: int = position of bevel (eg. BEVEL1)

// In: int = not used

// In: COLORREF = border color

// In: int = width of border around bitmap

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

 

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

// API: CreateBorder

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

 

extern "C" void CreateBorder(HDC hdc, RECT *prect, COLORREF borderColour, int borderWidth)

 

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

// API: MakeGradientBitmap

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

 

extern "C" HBITMAP MakeGradientBitmap(int width, int height, int type, COLORREF colour_from, COLORREF colour_to, bool interlaced, int bevelStyle, int bevelPosition)

 

 

 

Settings.cpp

 

 

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

// API: CreateStyleFont

// Purpose: Create a Font, possible substitutions have been already applied.

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

 

HFONT CreateStyleFont(StyleItem * si)

 

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

// API: GetSettingPtr - retrieve a pointer to a setting var/struct

 

void * GetSettingPtr(int i)

 

 

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

// API: GetToolbarInfo

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

 

ToolbarInfo * GetToolbarInfo(void)

 

 

Utils.cpp

 

 

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

// API: BBMessageBox

// Purpose:  standard BB-MessageBox

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

 

int BBMessageBox(int flg, const char *fmt, ...)

 

 

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

// API: GetAppByWindow

// Purpose:

// In:

// Out:

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

 

int GetAppByWindow(HWND Window, LPSTR processName)

 

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

// API: dbg_printf

 

void dbg_printf (const char *fmt, ...)

 

 

Tray.cpp

 

 

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

// API: GetTraySize

 

int GetTraySize()

 

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

// API: GetTrayIcon

 

systemTray* GetTrayIcon(int idx)

 

 

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

// API: EnumTray

 

void EnumTray (TRAYENUMPROC lpEnumFunc, LPARAM lParam)

 

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

// API: CleanTray

 

void CleanTray()

 

 

Workspaces.cpp

 

 

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

// API: GetTaskListSize - returns the number of currently registered tasks

 

int GetTaskListSize(void)

 

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

// API: GetTaskListPtr - returns the raw task-list

 

struct tasklist *GetTaskListPtr(void)

 

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

// API: GetTask - returns the HWND of the task by index

 

HWND GetTask(int index)

 

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

// API: GetActiveTask - returns index of current active task or -1, if none or BB

 

int GetActiveTask(void)

 

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

// API: GetTaskWorkspace - returns the workspace of the task by HWND

 

int GetTaskWorkspace(HWND hwnd)

 

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

// API: SetTaskWorkspace - set the workspace of the task by HWND

 

void SetTaskWorkspace(HWND hwnd, int wkspc)

 

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

// API: GetTaskLocation - retrieve the desktop and the original coords for a window

 

bool GetTaskLocation(HWND hwnd, struct taskinfo *t)

 

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

// API: SetTaskLocation - move a window and it's popups to another desktop and/or position

 

bool SetTaskLocation(HWND hwnd, struct taskinfo *t, UINT flags)

 

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

// API: EnumTasks

 

void EnumTasks (TASKENUMPROC lpEnumFunc, LPARAM lParam)

 

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

// API: GetDesktopInfo

 

void GetDesktopInfo(DesktopInfo *deskInfo)

 

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

// API: EnumDesks

 

void EnumDesks (DESKENUMPROC lpEnumFunc, LPARAM lParam)

 

 

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

//

//    PluginMenu API – Menu.cpp

//

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

 

 

// API: MakeNamedMenu

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

 

Menu *MakeNamedMenu(LPCSTR HeaderText, LPCSTR IDString, bool popup)

 

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

// API: MakeMenu

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

 

Menu *MakeMenu(LPCSTR HeaderText)

 

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

// API: ShowMenu

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

 

void ShowMenu(Menu *PluginMenu)

 

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

// API: DelMenu

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

 

void DelMenu(Menu *PluginMenu) { } // not required anymore.

 

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

// API: MakeSubmenu

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

 

MenuItem* MakeSubmenu(Menu *ParentMenu, Menu *ChildMenu, LPCSTR Title)

 

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

// API: MakeSubmenu with Icon

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

 

MenuItem* MakeSubmenu(Menu *ParentMenu, Menu *ChildMenu, LPCSTR Title, LPCSTR Icon)

 

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

// API: MakeMenuItem

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

 

MenuItem *MakeMenuItem(Menu *PluginMenu, LPCSTR Title, LPCSTR Cmd, bool ShowIndicator)

 

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

// API: MakeMenuItem with Icon

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

 

MenuItem *MakeMenuItem(Menu *PluginMenu, LPCSTR Title, LPCSTR Cmd, bool ShowIndicator, LPCSTR Icon)

 

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

// Create the one item submenu for MakeMenuItemInt and MakeMenuItemString

 

MenuItem * make_helper_menu(Menu *PluginMenu, LPCSTR Title, int menuID, MenuItem *Item)

 

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

// API: MakeMenuItemInt

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

 

MenuItem *MakeMenuItemInt(Menu *PluginMenu, LPCSTR Title, LPCSTR Cmd, int val, int minval, int maxval)

 

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

// API: MakeMenuItemString

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

 

MenuItem *MakeMenuItemString(Menu *PluginMenu, LPCSTR Title, LPCSTR Cmd, LPCSTR init_string)

 

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

// API: MakeMenuNOP

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

 

MenuItem* MakeMenuNOP(Menu *PluginMenu, LPCSTR Title)

 

 

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

// API: MakeMenuSEP

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

 

MenuItem* MakeMenuSEP(Menu *PluginMenu)

 

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

// API: MakeMenuVOL

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

 

MenuItem* MakeMenuVOL(Menu *PluginMenu, LPCSTR Title)

 

 

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

// API: MakePathMenu

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

 

MenuItem* MakePathMenu(Menu *ParentMenu, LPCSTR Title, LPCSTR path, LPCSTR Cmd)

 

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

// API: MakePathMenu with Icon

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

 

MenuItem* MakePathMenu(Menu *ParentMenu, LPCSTR Title, LPCSTR path, LPCSTR Cmd, LPCSTR Icon)

 

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

// API: MenuExists

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

 

bool MenuExists(const char* IDString_part)

 

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

// API: DisableLastItem - set 'menu.frame.disabledColor' for item

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

 

void DisableLastItem(Menu *PluginMenu)