home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / bp_3_94 / vbwin / makro / bptools.c < prev    next >
C/C++ Source or Header  |  1994-04-26  |  2KB  |  86 lines

  1. //************************************************************************
  2. //
  3. //    Dateiname: bptools.c
  4. //    Diverse Funktion zur Unterstⁿtzung einer Makrosprache
  5. //    in Visual Basic
  6. //
  7. //    Autor: Torsten Zimmermann
  8. //
  9. //************************************************************************
  10.  
  11. #include <windows.h>
  12. #include <vbapi.h>
  13. #include <dos.h>
  14. #include "bptools.h"
  15.  
  16.                      
  17. void WINAPI VBCombo_SelectString(HCTL hCombo, LPSTR lpstr)
  18. {
  19.     HWND hwnd = VBGetControlHwnd(hCombo);
  20.     if(IsWindow(hwnd))
  21.     {
  22.     DWORD dwIndex = SendMessage(hwnd, CB_FINDSTRING, 0, (DWORD)(LPSTR)lpstr);
  23.     if((int)dwIndex != CB_ERR)
  24.        SendMessage(hwnd, CB_SETCURSEL, (WPARAM)dwIndex, 0L);
  25.     }
  26. }
  27.  
  28. void WINAPI VBCombo_ClearString(HCTL hCombo)
  29. {
  30.     HWND hwnd = VBGetControlHwnd(hCombo);
  31.         if(IsWindow(hwnd))
  32.          SendMessage(hwnd, CB_SETCURSEL, -1, 0L);
  33. }
  34.  
  35.  
  36. short WINAPI DiskInfo (short nDiskID, LPLONG lBytesTotal, LPLONG lBytesFree)
  37. {
  38.     struct diskfree_t    df;
  39.     long        bpc;
  40.  
  41.     if(_dos_getdiskfree(nDiskID, &df) == 0)
  42.     {
  43.         //Bytes per Cluster
  44.         bpc = df.bytes_per_sector * df.sectors_per_cluster;
  45.         *lBytesTotal = df.total_clusters * bpc;
  46.         *lBytesFree = df.avail_clusters * bpc;
  47.             return -1;
  48.     }
  49.         else return 0;
  50. }
  51.  
  52. int WINAPI VBEdit_GetLineCount(HCTL hctl)
  53. {
  54.     HWND hwnd = VBGetControlHwnd(hctl);
  55.     if(!IsWindow(hwnd)) return (0);
  56.     return (int) SendMessage(hwnd, EM_GETLINECOUNT, 0, 0L);
  57. }
  58.  
  59. void WINAPI VBEdit_InvertLine(HCTL hctl, int iIndex)
  60. {
  61.         int    istart, iend;
  62.     HWND hwnd = VBGetControlHwnd(hctl);
  63.     if(IsWindow(hwnd))
  64.         {
  65.     istart = SendMessage(hwnd, EM_LINEINDEX, iIndex, 0L);
  66.     iend = istart + SendMessage(hwnd, EM_LINELENGTH, istart, 0L);
  67.     SendMessage(hwnd, EM_SETSEL, 0, MAKELPARAM(istart,iend));
  68.     SetFocus(hwnd);
  69.         }
  70. }
  71.  
  72. HLSTR WINAPI VBEdit_GetLine(HCTL hctl, int iIndex)
  73. {
  74.     char cBuffer[128];
  75.         WORD cbCount;
  76.     HWND hwnd = VBGetControlHwnd(hctl);
  77.     if(IsWindow(hwnd))
  78.     {
  79.        *(WORD *)cBuffer = sizeof(cBuffer);
  80.        cbCount = SendMessage(hwnd, EM_GETLINE, iIndex, (DWORD)(LPSTR)cBuffer);
  81.        cBuffer[cbCount] = '\0';
  82.     }
  83.     return VBCreateHlstr(cBuffer, lstrlen(cBuffer));
  84.         
  85. }
  86.