как это должно выглядеть в Дельфи?

Форум для программистов

как это должно выглядеть в Дельфи?

Сообщение dAnIK SeNT » Вт янв 14, 2003 8:36 pm

Вот руководство по написанию плагинов для PowerPro. Кто шарит в Дельфи и C++ - не скажете, как все это адекватно перевести в Дельфи?
<!--QuoteBegin--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE </td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->
How to Program Plugins
The remainder of this help section is intended only for programmers of plug-ins.

A plugin is a dll which PowerPro loads dynamically. The services are the exported routines.
Within the dll, the service names must be in lower case. Neither the plug-in name nor the service name can contain blanks. You can see sample plugins in the plugins zip file in the PowerPro folder.
The service declarations should be

Код: выделить все
_declspec(dllexport) void showmenu(LPSTR unused1, LPSTR unused2,

int (*GetVar)(LPSTR szVar, LPSTR szVal), void (*SetVar)(LPSTR szVar, LPSTR szVal), DWORD* pFlags, UINT nargs, LPSTR* szArgs, PPROSERVICES* ppsv)


(assuming chars are one byte). Remember that lower case must be used for service names.
The variables unused1 and unused2 are for compatibility with older version of the Plugin interface and are not used for newly written plugins.
The functions GetVar and SetVar access the variable given in the first string and get/set the value in the second string. Each variable occupies 264 bytes and is stored as a null terminated string within that fixed-length 264 byte buffer. GetVar will also return the values for system keywords like pprofolder. GetVar returns 1 if the variable exists; 0 if it does not, but in this case the variable name is created and assigned the empty string.
The 32 bit unsigned values pointed at by pFlags holds PowerPro’s 32 flags. Flag 0 is in the least significant bit. You can change or read any flag.
The variable nargs is a value between 0 and 9 to indicate the number of arguments used to call the plugin service. Pointers to the arguments are stored in string array szArgs.. Argument 1 is at *(szArgs+1), argument 2 is at *(szArgs+2), and so on.
You can return a result from you plugin by setting the 264 byte buffer at *szArgs. If you do not want to return a result, set **szArgs to '\0';
The pointer ppsv points to a PPROSERVICES structure which is a list of function pointers:
Код: выделить все
typedef struct tagPProServices

{

void (*ErrMessage)(LPSTR, LPSTR);

BOOL (*MatchCaption)(HWND, LPSTR);

HWND (*FindMatchingWindow)(LPSTR,BOOL);

BOOL (*IsRolled)(HWND hw);

BOOL (*IsTrayMinned)(HWND hw);}

void (*GetExeFullPath) (HWND hw, LPSTR szt);

void (*RollUp)(HWND hw);

void (*TrayMin)(HWND hw);

void (*SendKeys)(LPSTR sz);

}

PPROSERVICES;
Use the call (ppsv->ErrMessage)(LPSTR, LPSTR) to show an error message consisting of the
first string and then the second string; if the plugin is called from a script, the user will have the
opportunity to stop all scripts.
Use the call (ppsv->MatchCaption)(hwnd, szCaptionList) to use PowerPro's caption list matching engine to see if the window with handle hwnd matches the caption list string.
Use the call (ppsv->FindMatchingWindow)(szCaptionList, bHidden) to use PowerPro's caption matching engine to find the first window matching the caption list szCaptionlist; set bHidden to 1 to include invisible windows.
Use the call (ppsv->GetExeFullPath)( hw, sz) to get full path to exe of window hw.
Use the call (ppsv->RollUp)( hw) to rollup window hw if it is not already rolled up and to show it otherwise.
Use the call (ppsv->TrayMin)( hw) to tray minimize window hw if it is not tray minimized and to show it otherwise.)
Use the call (ppsv->SendKeys)( sz) to send keys using sz; this is equivalent to using *keys command on sz. The string sz cannot contain more than 260 characters.
You can use (*GetVar)("pproversion", szVer) to access the PowerPro version as a four digit string.
You can send commands back to PowerPro using two methods: One is to create a full command line, including a full path to PowerPro, and WinExec it. The other is to create the PowerPro command only (without the path to PowerPro) and using a special SendMessage WM_COPYDATA. The advantage of the WM_COPYDATA is speed and the fact that the command is executed synchronously, that is you know it is done when the SendMessage returns. (Note: PowerPro uses a  WM_COPYDATA message, rather than a plain WM_USER+xxx, because this message is sometimes needed to cross process boundaries).
The following code shows how to use the WM_COPYDATA message by running a *menu Show command on the menu name stored in variable MenuName.
Код: выделить все
#define VAR_SIZE 264

char szCommand[VAR_SIZE+24];

char szName[VAR_SIZE+1];

COPYDATASTRUCT cd;

strcpy(szCommand, "*Menu Show ");

(*GetVar)("MenuName", szName);

strcat(szCommand, szName);

cd.dwData = 1;

cd.cbData = strlen(szCommand)+1;

cd.lpData=szCommand;

SendMessage(g_hwndPowerPro, WM_COPYDATA, 0, (LPARAM)&cd);

Here g_hwndPowerPro has been set to the PowerPro hidden control window:

g_hwndPowerPro = FindWindow("PowerProMain",NULL);


PowerPro normally does not free a loaded plug-in until PowerPro exits. This can be awkward when debugging. So you can force PowerPro to unload using FreeLibrary by using a service name of unload, eg plugin.unload.
PowerPro provides two ways for plugins to hook into expression processing. For samples, see the str plugin including with PowerPro. The two hooks are to save memory if multiple plugins are loaded, consider using the dll msvcrt.dll of standard dll services by compiling with library MSVCRT.LIB and link options /nodefaultlib:"libcmt".
<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
яНЯЕД ОН СОПЪФЙЕ: Athlon 64 X2 5200+ @2,86GHz / nF 570 SLI (ASUS M2N SLI Deluxe) / 4 Gb RAM (4x1Gb Kingston) / 2,9Tb SATAII (0,50+0,64+0,75+1,00Tb WD) / ASUS 8800 GTS512 / 2x NEC-Optiarc AD-7173 / Thermaltake ToughPower 650W / 2x30W Microlab Solo-2 / 20" LCD Benq FP202W (wide) / openSUSE 11.1 / KDE 4.2.1
<!--coloro:Navy--><span style="color:Navy"><!--/coloro-->оН БЯЕЛ БНОПНЯЮЛ - Б email. б ICQ ОНЪБКЪЧЯЭ ПЮГ Б ОНКЦНДЮ.<!--colorc--></span><!--/colorc-->
dAnIK SeNT
Маршал
 
Сообщений: 5101
Зарегистрирован: Чт мар 28, 2002 7:48 pm
Откуда: яяяп
Пункты репутации: 0

Вернуться в Программирование

Кто сейчас на форуме

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 18

cron