Home |  Help | Modules | Media Max 
| Media Max Demo Questions | Download | Contacts   

Media Max SDK


  Each program, which can be run by Media Max should have a module designed for its operation. There are two types of modules for Media Max by now:

1. Modules for program control.
2. Modules for running system functions of the operation system.

  Press the "MODE" button on the remote control board to alternatively switch on those two module types (operating modes). Under the "Application" operation mode, Media Max operates only the modules used for program running. In that mode Media Max supervises through the modules whether there is a started application with a started module at the moment. During the first second Media Max calls for each module the function responsible for finding the program, which that module has been designed for. If that function finds out that at the moment the program, which the respective module has been designed for, is active, it returns "TRUE" as a result of its calling out. If at the moment there is no application started, which there is a module for, that function returns a "FALSE" result. In case a function has returned "TRUE" result, Media Max begins sending the commands coming from the remote control board, to the module, whose function for finding the program has returned the "TRUE" result. At a certain moment Media Max can send the commands from the board to one module only. A module is active until another module takes the control. That means that Media Max operates the last activated programme even if it is not in focus at that moment. If a module finds out a program, which it has been designed for, that module becomes active immediately until another module, which has been created for that programme, finds the programme out thus becoming active in turn.

The mode, in which Media Max is started, is the "Application" mode. On pressing the "MODE" button, Media Max starts operating with the first system module it finds out. An example is the mouse simulation module, which is a system module. On each consecutive pressing of the "MODE" button, the next system module is set up. If all system modules are browsed, we again get into "Application" mode. Thus using the "MODE" button, one can alternatively switch on to every module. Media Max can operate 255 different modules.

   Each module is a DLL file, which is set up on starting the Media Max.

   Below one can see the framework of a DLL file, which is the module itself. In that code only the basic parts of the DLL file of a module are shown without giving a code for the separate functions. The goal is to show a module structure and the different functions of the DLL library.



#include "definition.h"

//This structure is used for transmitting data
//about the module to Media Max //some of the fields are not obligatory
struct plugindata { // HWND of the Media Max window HWND mmhWnd; // HWND of the programme being run HWND apphWnd; // HINSTANCE of the DLL file HINSTANCE dllhIns; // File name of the programme being run char appfileName [MAX_STR_LEN]; // Module name char pluginName [MAX_STR_LEN]; // Name of the programme being run char appName [MAX_STR_LEN]; // Version of the module char pluginversion [MAX_STR_LEN]; // Module description char description [MAX_STR_LEN]; // The name, under which the module
//will be recorded in the INI file
//That name is set by Media Max and is the same as
//the file name
//but without its extension (*.dll)
char keyname [MAX_STR_LEN]; // Module type // If it has a value of 1 - it's a system module;
// If its value is 2 - it's a programme
control module (for running programs)
DWORD plugintype; }; //Variable of the data transmitting structure //between Media Max and the module plugindata myData; //Declaring of the DLL file export functions extern "C" __declspec (dllexport) plugindata* GetPlugInData(); extern "C" __declspec (dllexport) void SetPlugInData(plugindata* data); extern "C" __declspec (dllexport) BOOL MessageProc(UINT message); extern "C" __declspec (dllexport) char* ScreenTextProc(UINT message); extern "C" __declspec (dllexport) BOOL IsAppRun(); extern "C" __declspec (dllexport) DWORD InitProc(); extern "C" __declspec (dllexport) DWORD QuitProc(); extern "C" __declspec (dllexport) DWORD ConfigProc(); //The inlet function of the DLL file BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } //This function is called every other second by Media Max //and it defines whether the program, //designed for that module, is active BOOL IsAppRun () { } // That function is called by Media Max to derive //the command in the monitor on pressing the button on //the remote control board char* ScreenTextProc (UINT message) { } //In that function the necessary actions are executed //to transform each pressing of the button on the //remote control board into a command //to the respective programme BOOL MessageProc (UINT message) { //If there is no valid HWND to the window of the programme //being run, the function is left. //The only exception is made for the "IR_STANDBY" command //as on starting the programme //with the "STANDBY" button //there is still no valid HWND. } //It submits the structure containing the module data to Media Max plugindata* GetPlugInData () { } //Media Max complements the data //to the module structure through that function void SetPlugInData (plugindata* data) { } // Module initialisation function
//It is called by Media Max on loading the module
DWORD InitProc () { } //This function is called before destroying
//the module by Media Max
DWORD QuitProc () { } //This function is called when the module is to be configured DWORD ConfigProc () { }
 

  The "pugindata" structure is used for data exchange between a definite module and Media Max. Some of its fileds are filled up by the module itself, and some of them - by Media Max on loading that module. This structure has the following fields:

     - mmhWnd -In this field the HWND is recorded in the Media Max window. The field is filled up by Media Max.
     - apphWnd -In this field the HWND is recorded in the window of the programme being run and is filled up by the module.
     - dllhInst - HINSTANCE of the DLL file. It is filled up by Media Max on the module loading.
     - appfileName - the EXE file name of the programme being run. It's filled up by the module. This field is not obligatory.
     - pluginName - the module name. This is the name of the module in the list of modules displayed in the dialogue for adjusting the Media Max settings. It's filled up by the module.
     - appName - the name of the program, which is to be run. It's filled up by the module; it's not obligatory.
     - pluginversion - the module version. It's filled up by the module; it's not obligatory.
     - description - description of the module. It's filled up by the module; it's not obligatory.
     - keyname - This is the name under which the settings of the module are recorded in INI file of Media Max. The field value is the same as the name of the DLL file but without the extension (DLL). It's filled up by Media Max.
     - plugintype - Module type. By now, it can assume a value of 1 or 2, depending on the type of module we want to produce. The field is filled up by the module. It's obligatory to be filled up.

A module for Media Max should contain the following obligatory functions:
     - BOOL IsAppRun () - This function is used for finding a started application, which the module has been designed for. It's not important how the the started application will be found; what is important is that this function should return a "TRUE" result if an application is found, or "FALSE" result in the the other cases. This function is constantly being called by Media Max every other second. This is intended to immediately find a new started application equipped with a module and if such is found, to load its module immediately to enable the running of the application.

It is recommended that the module should return a "TRUE" response only in case the application, which the module has been designed for, is in focus. If the module is designed to return a "TRUE" result every time or no matter whether its application is in focus, in that case, if there is one more module loaded, the two modules will not be able to operate at the same time. This is due to the fact that after browsing the modules, Media Max starts working only with the last module, which has returned a "TRUE" result no matter of the fact that other modules have also returned the same result before.

If the module you are creating is "a system" module, this function is not used, so it should always return a "FALSE" response.

   - char* ScreenTextProc (UINT message) - This function is called by Media Max when a command has been received from the remote control board before processing the command, that is, before it is transmitted to the command processing function of the respective module. When this function is called as a parameter, the code of the received command is transmitted. This is the function, which "decides" whether the command is to be shown in the screen of the monitor (with large green letters) or not. If the command should be shown, it must return a string to the text /as a result/, which must appear in the screen with the respective command.


   - BOOL MessageProc (UINT message) - This function is the most important in a module. In this function the commands are being transformed by Media Max into commands to the respective programme after they have been processed and filtered. It's not important how those commands will be performed - it depends on the module and the programme to be run. The command can be transmitted to the respective programme as a message (WM_COMMAND), as a note that a button has been pressed (WM_KEYDOWN, WM_KEYUP), as a mouse command, etc. What exactly will be transmitted to the programme to be run depends on the programme itself and on the person who is creating the module. If a command has been processed by the module, the function should return a "TRUE" result; or "FALSE" in any other case.


   - plugindata* GetPlugInData () - This function is called by Media Max to get an indicator to the "pugindata" structure of the module. After that the data can be recorded in it.

   - void SetPlugInData (plugindata* data) - This function records data in the "pugindata" structure of the module.

    - DWORD InitProc () - This function is called by Media Max right after the loading of the module to enable the module to initiate its data.

   - DWORD QuitProc () - This function is called by Media Max before the module is relieved.

 - DWORD ConfigProc () - This function is called by Media Max on pressing the "Module configuration" button in the dialogue for Media Max configuration.

  It is obligatory to include the "definition.h" file in each module. This file contains the commands being sent from Media Max to the module.




//Content of the "definition.h" file
#define IR_PLAY WM_USER + 300 //PLAY button #define IR_STOP WM_USER + 301 //STOP button #define IR_VOLUP WM_USER + 302 //VOL+ button #define IR_VOLDOWN WM_USER + 303 //VOL- button #define IR_DSC WM_USER + 304 //MUTE button #define IR_REWIND WM_USER + 305 //REWIND button #define IR_FFWD WM_USER + 306 //FFWD button #define IR_PAUSE WM_USER + 307 //PAUSE button #define IR_PREV WM_USER + 308 //PREV button #define IR_SIDE WM_USER + 309 #define IR_NEXT WM_USER + 310 //NEXT button #define IR_DISC WM_USER + 311 //ZOOM/JMP button #define IR_SLEEP WM_USER + 312 //SLEEP button #define IR_NEWS WM_USER + 313 //MIN/MAX button #define IR_TAPE1 WM_USER + 314 #define IR_TAPE2 WM_USER + 315 #define IR_STANDBY WM_USER + 316 //STANDBY button #define IR_MODE WM_USER + 317 //MODE button #define IR_TUNER WM_USER + 318 #define IR_COMMON1 WM_USER + 319 //1 button #define IR_COMMON2 WM_USER + 320 //2 button #define IR_COMMON3 WM_USER + 321 //3 button #define IR_COMMON4 WM_USER + 322 //4 button #define IR_COMMON5 WM_USER + 323 //5 button #define IR_COMMON6 WM_USER + 324 //6 button #define IR_COMMON7 WM_USER + 325 //7 button #define IR_COMMON8 WM_USER + 326 //8 button #define IR_COMMON9 WM_USER + 327 //9 button #define IR_COMMON10 WM_USER + 328 //0 button #define IR_COMMON11 WM_USER + 329 //-/-- button #define IR_COMMON12 WM_USER + 330 #define IR_COMMON13 WM_USER + 331 #define IR_COMMON14 WM_USER + 332 #define IR_COMMON15 WM_USER + 333
 

   On Media Max installation, the installing programme saves the route to Media Max.exe in "HKEY_CURRENT_USER\Software\AlphaIntellect\MediaMax".

    The settings of each module can be recorded in the "plugin.ini" file.

    Media Max loads the modules, which are available in the "Plugin" directory.


  The example below is for the "CD Player" programme, which is installed together with Windows 98. Don't take it as a model of module creation. The example is intended to show as many versions for programme running by Media Max as possible.



#include "definition.h"

//Except for the "definition.h" file,  the rest of the files
//are not obligatory for the module and their including
//depends only on what will be performed
//with that module
#include "movie_plugin_1.h" #include "resource.h" #include "windows.h" #include "commdlg.h" #include "shellapi.h" #include "mmsystem.h" //The maximum length of the strings #define MAX_STR_LEN 1024 //The name of the section in the INI file where
//the module data will be recorded
#define INI_SECTION "CD Player" //The route to the file is recorded with this key #define INI_KEY "apppath" //The default value #define INI_DEF "No data!" //The strings shown in the dialogue for
//module settings
#define STR_LOAD "If you want to start CD Player
//on pressing the STANDBY button,
//enter the route to the "cdplayer.exe" - file"
//Text of the button for opening "Open dialog" #define STR_BROWSE_BTN "Find" //Text of the "OK" button #define STR_OK_BTN "Ok" //?????? ?? "CANCEL" ?????? #define STR_CANCEL_BTN "Cancel" //Description of the module #define STR_PRGDATA "Module data :" //The name of the file of the program being run #define STR_EXEFILE "File of the application being run: cdplayer.exe" //Version of the application being run #define STR_APPVER "Version of the application being run : 1.0" //Module version #define STR_PLGVER "Version of the module to run CD Player : 1.0" //Owner name #define STR_MAKER "Alpha Intellect. All rights reserved!" //WEB site #define STR_WEB "www.mediamax2.com" //e-mail #define STR_MAIL "alpha@acvilon.com" //Data about the module are
//being transmitted to Media Max though thus structure;
//some of the fields are not obligatory
struct plugindata { // HWND of the Media Max window HWND mmhWnd; // HWND of the programme being run HWND apphWnd; // HINSTANCE of the DLL file HINSTANCE dllhIns; // Name of the file of the programme being run char appfileName [MAX_STR_LEN]; // Name of the module char pluginName [MAX_STR_LEN]; // Name of the programme being run char appName [MAX_STR_LEN]; // Module version char pluginversion [MAX_STR_LEN]; // Module description char description [MAX_STR_LEN]; // The name under which the module
//will be recorded into the INI file
char keyname [MAX_STR_LEN]; // Module type
//if it has a value of 1 - it's a system module;
//if it has a value of 2 - it's a module for programme running.
DWORD plugintype; }; //Variables for the fonts LOGFONT lf; HFONT hf; //Variables for recording into the INI file OPENFILENAME Ofn; char strFile [MAX_STR_LEN]; char szFile [MAX_STR_LEN]; char pluginPath [MAX_STR_LEN]; char* ppos; //A variable of the structure for data transmission
//between Media Max and the module
plugindata myData; //HWND to the window of a button
//it is used in this module only
HWND buttonHwnd; //HWND to the window of the program being run HWND mainHwnd; char screentext [MAX_STR_LEN]; //These variables are used to delay
//the transmitting of commands from the remote control board
//to the programme being run
__int64 dTime; __int64 cTime; __int64 bTime; //The period during which it is forbidden to send commands __int64 period; //These variables are used to control
//the sound volume of the CD Player, as it has no such resources
//and uses "Master Volume Control" of Windows
UINT nNumMixers; HMIXER hMixer; MIXERCAPS mxcaps; DWORD soundMinimum; DWORD soundMaximum; DWORD volumeControlID; BOOL audio_flag; DWORD volume_value; DWORD volume_step; //The function for message processing of the dialogue
//for module settings adjustment
LRESULT CALLBACK Properties
Dlg (HWND, UINT, WPARAM, LPARAM); //Declaring the export functions of the DLL file extern "C" __declspec (dllexport) plugindata* GetPlugInData(); extern "C" __declspec (dllexport) void SetPlugInData(plugindata* data); extern "C" __declspec (dllexport) BOOL MessageProc(UINT message); extern "C" __declspec (dllexport) char* ScreenTextProc(UINT message); extern "C" __declspec (dllexport) BOOL IsAppRun(); extern "C" __declspec (dllexport) DWORD InitProc(); extern "C" __declspec (dllexport) DWORD QuitProc(); extern "C" __declspec (dllexport) DWORD ConfigProc(); //The inlet function of the DLL file BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } //The next several functions serve for sound control //****************************************************** //initialises the sound devices BOOL soundInitialize() { nNumMixers = mixerGetNumDevs(); hMixer = NULL; ZeroMemory(&mxcaps, sizeof(MIXERCAPS)); soundMinimum = 0; soundMaximum = 0; volumeControlID = 0; if (nNumMixers != 0) { if (mixerOpen(&hMixer, 0, NULL, NULL, MIXER_OBJECTF_MIXER ) != MMSYSERR_NOERROR) { return FALSE; } if (mixerGetDevCaps(reinterpret_cast(hMixer), &mxcaps, sizeof(MIXERCAPS)) != MMSYSERR_NOERROR) { return FALSE; } } return TRUE; } //Closes the open sound devices BOOL soundUninitialize() { BOOL bSucc = TRUE; if (hMixer != NULL) { bSucc = (mixerClose(hMixer) == MMSYSERR_NOERROR); hMixer = NULL; } return bSucc; } //Finds the main sound control device BOOL soundGetMasterVolumeControl() { if (hMixer == NULL) { return FALSE; } MIXERLINE mxl; mxl.cbStruct = sizeof(MIXERLINE); mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; if (mixerGetLineInfo(reinterpret_cast(hMixer), &mxl, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE) != MMSYSERR_NOERROR) { return FALSE; } MIXERCONTROL mxc; MIXERLINECONTROLS mxlc; mxlc.cbStruct = sizeof(MIXERLINECONTROLS); mxlc.dwLineID = mxl.dwLineID; mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; mxlc.cControls = 1; mxlc.cbmxctrl = sizeof(MIXERCONTROL); mxlc.pamxctrl = &mxc; if (mixerGetLineControls(reinterpret_cast(hMixer), &mxlc, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE) != MMSYSERR_NOERROR) { return FALSE; } soundMinimum = mxc.Bounds.dwMinimum; soundMaximum = mxc.Bounds.dwMaximum; volume_step = mxc.Bounds.dwMaximum / 20; volumeControlID = mxc.dwControlID; return TRUE; } // Receives the value of the sound volume BOOL soundGetMasterVolumeValue(DWORD &dwVal) { if (hMixer == NULL) { return FALSE; } MIXERCONTROLDETAILS_UNSIGNED mxcdVolume; MIXERCONTROLDETAILS mxcd; mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mxcd.dwControlID = volumeControlID; mxcd.cChannels = 1; mxcd.cMultipleItems = 0; mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); mxcd.paDetails = &mxcdVolume; if (mixerGetControlDetails(reinterpret_cast(hMixer), &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR) { return FALSE; } dwVal = mxcdVolume.dwValue; return TRUE; } // Sets a new sound volume value BOOL soundSetMasterVolumeValue(DWORD dwVal) { if (hMixer == NULL) { return FALSE; } MIXERCONTROLDETAILS_UNSIGNED mxcdVolume = { dwVal }; MIXERCONTROLDETAILS mxcd; mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mxcd.dwControlID = volumeControlID; mxcd.cChannels = 1; mxcd.cMultipleItems = 0; mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); mxcd.paDetails = &mxcdVolume; if (mixerSetControlDetails(reinterpret_cast(hMixer), &mxcd, MIXER_OBJECTF_HMIXER | MIXER_SETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR) { return FALSE; } return TRUE; } //*********************************************** //End of the sound control functions //The main part of the module code starts from here //************************************************ //This function is called by Media Max every other second
//and it is used to define whether a programme,
//for which there is a module designed, is active
BOOL IsAppRun () { mainHwnd = FindWindow ("SJE_CdPlayerClass",NULL); myData.apphWnd = mainHwnd; if (mainHwnd != 0) { if (mainHwnd == GetForegroundWindow()) return TRUE; } return FALSE; } // This function is called by Media Max to display
//the command on the monitor on pressing a button on the
//remote control board
char* ScreenTextProc (UINT message) { strcpy (screentext,""); switch (message) { case IR_VOLUP: strcpy (screentext, "VOL +"); break; case IR_VOLDOWN: strcpy (screentext, "VOL -"); break; case IR_PLAY: strcpy (screentext, "PLAY"); break; case IR_STOP: strcpy (screentext, "STOP"); break; case IR_PREV: strcpy (screentext, "PREV"); break; case IR_NEXT: strcpy (screentext, "NEXT"); break; case IR_PAUSE: strcpy (screentext, "PAUSE"); break; case IR_REWIND: strcpy (screentext, "REWIND"); break; case IR_FFWD: strcpy (screentext, "FFWD"); break; case IR_DISC: strcpy (screentext, "FULL SCR"); break; case IR_SLEEP: strcpy (screentext, "SLEEP"); break; case IR_NEWS: strcpy (screentext, "MIN/MAX"); break; case IR_DSC: strcpy (screentext, "MUTE"); break; case IR_COMMON1: strcpy (screentext, "1"); break; case IR_COMMON2: strcpy (screentext, "2"); break; case IR_CPMMON3: strcpy (screentext, "3"); break; case IR_COMMON4: strcpy (screentext, "4"); break; case IR_COMMON5: strcpy (screentext, "5"); break; case IR_COMMON6: strcpy (screentext, "6"); break; case IR_COMMON7: strcpy (screentext, "7"); break; case IR_COMMON8: strcpy (screentext, "8"); break; case IR_COMMON9: strcpy (screentext, "9"); break; case IR_COMMON10: strcpy (screentext, "0"); break; case IR_COMMON11: strcpy (screentext, "-/--"); break; case IR_STANDBY: //strcpy (screentext, ""); break; } return screentext; } //The necessary actions are performed in that function
//so that each pressing of the button on the remote
//control board will be transformed into a command
//to the respective programme
BOOL MessageProc (UINT message) { //If there is no valid HWND to the
   //window of the programme being run
//the function is left
//and the only exception is made for the "IR_STANDBY" command,
//as on starting the programme
//with the "STANDBY" button,
//there is no valid HWND yet.
if ((mainHwnd == NULL) && (message != IR_STANDBY)) return FALSE; switch (message) { //Increasing the sound volume case IR_VOLUP: //Taking the timer value QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); //If the new command has arrived before the expiration of
//the period, it is not processed
if ((cTime - bTime) > period) { if (audio_flag) { soundGetMasterVolumeValue(volume_value); if ((volume_value + volume_step) < soundMaximum) volume_value += volume_step; soundSetMasterVolumeValue (volume_value); } //It takes the new value of the timer QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); //It saves it in "bTime" bTime = cTime; } break; //Decreasing of the sound volume case IR_VOLDOWN: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period) { if (audio_flag) { if ((volume_value - volume_step) > soundMinimum) volume_value -= volume_step; soundSetMasterVolumeValue (volume_value); } QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; // PLAY command case IR_PLAY: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { SendMessage (mainHwnd, WM_COMMAND, (WPARAM) 0x000003e8, (LPARAM) 0x00000000); QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; // STOP command case IR_STOP: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { SendMessage (mainHwnd, WM_COMMAND, (WPARAM) 0x000003e9, (LPARAM) 0x00000000); QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; // PREV command case IR_PREV: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { SendMessage (mainHwnd, WM_COMMAND, (WPARAM) 0x000003eb, (LPARAM) 0x00000000); QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; // NEXT command case IR_NEXT: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { SendMessage (mainHwnd, WM_COMMAND, (WPARAM) 0x000003ee, (LPARAM) 0x00000000); QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; // PAUSE command case IR_PAUSE: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { SendMessage (mainHwnd, WM_COMMAND, (WPARAM) 0x000003e9, (LPARAM) 0x00000000); QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; // REWIND command case IR_REWIND: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period) { buttonHwnd = GetDlgItem (mainHwnd, 1004); SendMessage (buttonHwnd, WM_LBUTTONDOWN, (WPARAM) 0x00000001, (LPARAM) 0x000a0008); SendMessage (buttonHwnd, WM_LBUTTONUP, (WPARAM) 0x00000000, (LPARAM) 0x000a0008); bTime = cTime; } break; // FFWD command case IR_FFWD: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period) { buttonHwnd = GetDlgItem (mainHwnd, 1005); SendMessage (buttonHwnd, WM_LBUTTONDOWN, (WPARAM) 0x00000001, (LPARAM) 0x000a0008); SendMessage (buttonHwnd, WM_LBUTTONUP, (WPARAM) 0x00000000, (LPARAM) 0x000a0008); QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; // STOP command case IR_DISC: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { SendMessage (mainHwnd, WM_COMMAND, (WPARAM) 0x000003ea, (LPARAM) 0x00000000); QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } return FALSE; break; // SLEEP command //This function returns "FALSE" response because it is
//processed by Media Max
case IR_SLEEP: return FALSE; break; //A command to MAXIMIZE or MINIMIZE the window
//of the programme being run
case IR_NEWS: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { if (mainHwnd != 0) if (IsIconic(mainHwnd)) { ShowWindow (mainHwnd, SW_SHOWNORMAL); } else { ShowWindow (mainHwnd, SW_MINIMIZE); } QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; //ZOOM/JMP command - in that module it is used
//for opening the door of the CD-ROM device
case IR_DSC: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { SendMessage (mainHwnd, WM_COMMAND, (WPARAM) 0x000003ef, (LPARAM) 0x00000000); QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; //STANDBY command - this command is
      //sent to the module only in case
//"Defined in the module" has been
      //chosen in the Media Max settings
case IR_STANDBY: QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); if ((cTime - bTime) > period*8) { //if the programme has already
            //been started, it is stopped
//with the "Alt+F4"combination of buttons
mainHwnd = FindWindow ("SJE_CdPlayerClass",NULL); if (mainHwnd != NULL) { keybd_event( VK_MENU ,0 ,0 ,0 ); keybd_event( VK_F4 ,0 ,0 ,0 ); keybd_event( VK_F4 ,0 ,KEYEVENTF_KEYUP,0 ); keybd_event( VK_MENU ,0 ,KEYEVENTF_KEYUP ,0 ); } else { //If the programme has not been started yet,
//but the route to it was recorded
//in the INI file, it is started from there.
if (MAX_STR_LEN > GetModuleFileName (NULL, pluginPath, MAX_STR_LEN)) { ppos = strrchr (pluginPath,92); *ppos = 0; strcat (pluginPath, "\\plugin\\plugin.ini"); if (0 != GetPrivateProfileString (INI_SECTION, INI_KEY, INI_DEF, szFile, MAX_STR_LEN, pluginPath)) { ShellExecute (myData.mmhWnd, NULL, szFile, NULL, NULL,SW_SHOWNORMAL ); } } } QueryPerformanceCounter ((LARGE_INTEGER *) &cTime); bTime = cTime; } break; } return TRUE; } //It transmits the module data structure to Media Max plugindata* GetPlugInData () { return &myData; } //With this function Media Max fills up the data
//about the module structure
void SetPlugInData (plugindata* data) { memcpy (&myData, data, sizeof(plugindata)); } // The Module Initialisation function
//is called by Media Max on loading the module
DWORD InitProc () { double d_buffer; //The name of the EXE file of the programme being run strcpy (myData.appfileName, "cdplayer.exe"); //The name of that module strcpy (myData.pluginName, "CD Player1.0"); //The programme name strcpy (myData.appName, "CD Player"); //Module version strcpy (myData.pluginversion, "v1.0"); //Module description strcpy (myData.description, "Media Max plugin module (CD Player) - v1.2 2001 "); //Module type myData.plugintype = 2; //The timer frequency of the main board is loaded QueryPerformanceFrequency((LARGE_INTEGER *)&dTime); //The period of command transmission prohibition is calculated -
//its value not being critical -
//and a value is adjusted so that the commands
//will not be transmitted too fast
d_buffer = 1000000/(double)dTime; d_buffer = 41000 / d_buffer; period = (__int64)d_buffer; audio_flag = FALSE; //It initialises the sound devices if (soundInitialize()) { audio_flag = TRUE; soundGetMasterVolumeControl(); soundGetMasterVolumeValue(volume_value); } return 0; } //This function is called before destroying
//the module by Media Max
DWORD QuitProc () { soundUninitialize(); return 0; } //This function is called when the module will be configured DWORD ConfigProc () { DialogBox (myData.dllhIns, (LPCTSTR)IDD_DIALOG1, myData.mmhWnd, (DLGPROC) PropertiesDlg); return 0; } //It loads the strings of the settings adjustment dialogue;
//it also loads the control fonts
DWORD LoadStringData (HWND hDlg, char* strdata, UINT itemnum) { HWND itemhWnd; if (hf == NULL) return 0; itemhWnd = GetDlgItem (hDlg, itemnum); SendMessage (itemhWnd, WM_SETFONT, (WPARAM) hf, (LPARAM) TRUE); SetDlgItemText (hDlg, itemnum, strdata); return 0; } //The message processing function of the
//settings adjustment dialogue
LRESULT CALLBACK PropertiesDlg (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: memset(&lf, 0, sizeof(LOGFONT)); lf.lfHeight = -10; lf.lfWeight = FW_NORMAL; lf.lfCharSet = RUSSIAN_CHARSET; strcpy((LPSTR)&(lf.lfFaceName), "MS Sans Serif"); hf = CreateFontIndirect(&lf); if (MAX_STR_LEN > GetModuleFileName (NULL, pluginPath, MAX_STR_LEN)) { ppos = strrchr (pluginPath,92); *ppos = 0; strcat (pluginPath, "\\plugin\\plugin.ini"); if (0 != GetPrivateProfileString (INI_SECTION, INI_KEY, INI_DEF, szFile, MAX_STR_LEN, pluginPath)) { SetDlgItemText (hDlg, IDC_EDIT1, szFile); } } LoadStringData (hDlg, STR_LOAD, IDC_LOAD); LoadStringData (hDlg, STR_BROWSE_BTN, IDC_BUTTON1); LoadStringData (hDlg, STR_OK_BTN, IDOK); LoadStringData (hDlg, STR_CANCEL_BTN, IDCANCEL); LoadStringData (hDlg, STR_PRGDATA, IDC_PRGDATA); LoadStringData (hDlg, STR_EXEFILE, IDC_EXEFILE); LoadStringData (hDlg, STR_APPVER, IDC_APPVER); LoadStringData (hDlg, STR_PLGVER, IDC_PLGVER); LoadStringData (hDlg, STR_MAKER, IDC_MAKER); LoadStringData (hDlg, STR_WEB, IDC_WEB); LoadStringData (hDlg, STR_MAIL, IDC_MAIL); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BUTTON1: szFile[0] = '\0'; Ofn.lStructSize = sizeof(OPENFILENAME); Ofn.hwndOwner = NULL;//hWnd; Ofn.lpstrFilter = "Application\0*.exe\0\0"; Ofn.lpstrCustomFilter = (LPSTR)NULL; Ofn.nMaxCustFilter = 0L; Ofn.nFilterIndex = 1L; Ofn.lpstrFile = szFile; Ofn.nMaxFile = sizeof(strFile); Ofn.lpstrFileTitle = strFile; Ofn.nMaxFileTitle = sizeof("Open"); Ofn.lpstrInitialDir = (LPSTR) NULL; Ofn.lpstrTitle = (LPSTR)NULL; Ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; Ofn.nFileOffset = 0; Ofn.nFileExtension = 0; Ofn.lpstrDefExt = "exe"; Ofn.lpstrInitialDir = "c:\\Program Files" ; if (0 != GetOpenFileName(&Ofn)) { SetDlgItemText (hDlg, IDC_EDIT1, szFile); } break; case IDOK: //It records the new settings of
               //the module into the INI file.
if (0 == GetDlgItemText (hDlg, IDC_EDIT1, szFile, MAX_STR_LEN)) return FALSE; if (MAX_STR_LEN > GetModuleFileName (NULL, pluginPath, MAX_STR_LEN)) { ppos = strrchr (pluginPath,92); *ppos = 0; strcat (pluginPath, "\\plugin\\plugin.ini"); WritePrivateProfileString (INI_SECTION, INI_KEY, szFile, pluginPath); } if (hf != NULL) DeleteObject (hf); EndDialog(hDlg, LOWORD(wParam)); break; case IDCANCEL: if (hf != NULL) DeleteObject (hf); EndDialog(hDlg, LOWORD(wParam)); break; } break; } return FALSE; }
 




  These are the main points in creating modules for Media Max. If you have any questions/problems, don't hesitate to contact our team to help you solve them. You can use our e-mail: alpha@acvilon.com




   Home | Help | Modules | Media Max |  Media Max Demo | Questions | Download | Contacts   

2000-2003 Alpha Intellect All rights reserved.