Back to index

lightning-sunbird  0.9+nobinonly
Functions
utils.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

HKEY openRegistry ()
BOOL IsNewMimeType (LPSTR szMimeType)
void SetDlgItemTextWrapped (HWND hWnd, int iID, LPSTR szText)

Function Documentation

BOOL IsNewMimeType ( LPSTR  szMimeType)

Definition at line 46 of file utils.cpp.

{
  ULONG keysize = 512;
  char keybuf[512];

  PrfQueryProfileString(HINI_USERPROFILE, OS2INI_PLACE, mime, "", keybuf, keysize);
  if (keybuf[0] != '\0') {
    return FALSE;
  }
  else 
  {
    if (!(PrfWriteProfileString(HINI_USERPROFILE, OS2INI_PLACE, mime, "(none)")))
      WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Error adding MIME type value", "Default Plugin", 0, MB_OK);
    return TRUE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 44 of file utils.cpp.

{
  HKEY phkResult;

  if(RegCreateKey(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS)
    MessageBox(0, "Error creating Default Plugin registry key", "Default Plugin", MB_OK);

  return phkResult;
}

Here is the caller graph for this function:

void SetDlgItemTextWrapped ( HWND  hWnd,
int  iID,
LPSTR  szText 
)

Definition at line 85 of file utils.cpp.

{
  HWND hWndStatic = WinWindowFromID(hWnd, iID);
  if(!szText || !*szText)
  {
    WinSetDlgItemText(hWnd, iID, "");
    return;
  }

  RECTL rc;
  WinQueryWindowRect(hWndStatic, &rc);

  int iStaticLength = rc.xRight - rc.xLeft;
  int iStringLength = getWindowStringLength(hWndStatic, szText);

  if(iStringLength <= iStaticLength)
  {
    WinSetDlgItemText(hWnd, iID, szText);
    return;
  }

  int iBreaks = iStringLength/iStaticLength;
  if(iBreaks <= 0)
    return;

  char * pBuf = new char[iStringLength + iBreaks + 1];
  if(pBuf == NULL)
    return;

  strcpy(pBuf, "");

  int iStart = 0;
  int iLines = 0;
  for(int i = 0; i < iStringLength; i++)
  {
    char * sz = &szText[iStart];
    int iIndex = i - iStart;
    char ch = sz[iIndex + 1];

    sz[iIndex + 1] = '\0';

    int iLength = getWindowStringLength(hWndStatic, sz);

    if(iLength < iStaticLength)
    {
      sz[iIndex + 1] = ch;
      if(iLines == iBreaks)
      {
        strcat(pBuf, sz);
        break;
      }
      continue;
    }

    sz[iIndex + 1] = ch;  // restore zeroed element
    i--;                  // go one step back

    ch = sz[iIndex];
    sz[iIndex] = '\0';    // terminate string one char shorter

    strcat(pBuf, sz);    // append the string
    strcat(pBuf, " ");   // append space character for successful wrapping

    iStart += strlen(sz);// shift new start position
    sz[iIndex] = ch;      // restore zeroed element
    iLines++;             // count lines
  }

  WinSetDlgItemText(hWnd, iID, pBuf);

  delete [] pBuf;
}

Here is the call graph for this function:

Here is the caller graph for this function: