home *** CD-ROM | disk | FTP | other *** search
/ Freelog 27 / Freelog027.iso / bestof / powerpro / ppro32.dat / plugsamp.c < prev    next >
C/C++ Source or Header  |  2001-06-08  |  1KB  |  71 lines

  1.  
  2. /*
  3.     
  4. Sample dll for PowerPro Plug-in
  5. */
  6.  
  7. #define VAR_SIZE 264
  8.  
  9.  
  10. #include <windows.h>
  11. #include <stdio.h>
  12.  
  13. static HWND g_hwndPowerPro;
  14.  
  15.  
  16. // Main DLL entry point.  Save handle to main PowerPro window.
  17. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
  18. {
  19.  
  20.     if(dwReason == DLL_PROCESS_ATTACH)
  21.     {
  22.         g_hwndPowerPro = FindWindow("PowerProMain",NULL);
  23.     }
  24.     else if(dwReason == DLL_PROCESS_DETACH)
  25.     {
  26.         // Detaching process
  27.     }
  28.  
  29.     return TRUE;
  30. }
  31.  
  32. //Show the menu whose name is given in variable M
  33. _declspec(dllexport) void showmenu(LPSTR szv, LPSTR szx)
  34. {
  35.     char szCommand[VAR_SIZE];
  36.     COPYDATASTRUCT cd;
  37.     
  38.     strcpy(szCommand, "*Menu Show ");
  39.     strcat(szCommand, szv + ('M'-'A')*VAR_SIZE);
  40.     cd.dwData = 1;
  41.     cd.cbData = strlen(szCommand)+1;
  42.     cd.lpData=szCommand;
  43.     SendMessage(g_hwndPowerPro, WM_COPYDATA, 0, (LPARAM)&cd);
  44.  
  45.  
  46. }
  47.  
  48.  
  49. // Change variable x1 to contents of variable whose letter is in variable x
  50. _declspec(dllexport) void changevar(LPSTR szv, LPSTR szx)
  51. {
  52.     LPSTR pX = szv + ('X' - 'A') * VAR_SIZE;
  53.     char szbuf[VAR_SIZE+24];
  54.     char c = (*pX);
  55.     if ('a' <= c && c<= 'z')
  56.         c -= 'a' - 'A';
  57.     if (c<'A' || c>'Z')
  58.         MessageBox(NULL, "Variable X is not a letter","PowerPro",MB_OK|MB_TOPMOST);
  59.     else
  60.     {
  61.         strcpy(szx + ('1' - '0')*VAR_SIZE, szv + (c - 'A') * VAR_SIZE);
  62.         strcpy(szbuf,"Variable X1 reset to Variable ");
  63.         strcat(szbuf,pX);
  64.         MessageBox(NULL,szbuf,"PowerPro",MB_OK|MB_TOPMOST);
  65.     }
  66. }
  67.  
  68.  
  69.  
  70.  
  71.