Ejemplo n.º 1
0
VOID GetScoresFromIni ( VOID )
{
    ULONG bMax;

    hini = PrfOpenProfile(habMain, "MAKMAN.INI");

    bMax = 15*100;
    PrfQueryProfileData(hini, szAppName, "ScoreNames", topNames, &bMax);
    bMax = 15 * sizeof(long);
    PrfQueryProfileData(hini, szAppName, "Scores", topScores, &bMax);

    PrfCloseProfile(hini);
}
// Ini_file - файл настроек.
VOID Arranger_ReadSettings( HINI Ini_file )
{
 // Читаем настройки.
 ULONG Byte = 0; ULONG Byte_data = 0;

 Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", "Arrange VIO windows", &Byte_data, &Byte ) ) Arranger.Settings.Arrange_VIO_windows  = Byte_data;
 Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", "Arrange FC2 windows", &Byte_data, &Byte ) ) Arranger.Settings.Arrange_FC2_windows  = Byte_data;
 Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", "Arrange WindowList",  &Byte_data, &Byte ) ) Arranger.Settings.Arrange_WindowList   = Byte_data;
 Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", "Arrange WPS windows", &Byte_data, &Byte ) ) Arranger.Settings.Arrange_WPS_windows  = Byte_data;
 Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", "Arrange Browsers", &Byte_data, &Byte ) ) Arranger.Settings.Arrange_Browser_windows = Byte_data;

 // Возврат.
 return;
}
Ejemplo n.º 3
0
/*************************************************************
* Get all names
*************************************************************/
PBYTE GetAllProfileNames(PSZ pszApp, HINI hini, PULONG pulProfileSize)
{
PBYTE pBuffer;

   if (!PrfQueryProfileSize(hini,
      pszApp,
      NULL,
      pulProfileSize))
      return NULL;

   pBuffer = malloc(*pulProfileSize);
   if (!pBuffer)
      return NULL;

   if (!PrfQueryProfileData(hini,
      pszApp,
      NULL,
      pBuffer,
      pulProfileSize))
      {
      free(pBuffer);
      return NULL;
      }

   return pBuffer;
}
Ejemplo n.º 4
0
void QueryFontFromINI(char* fontType, char* fontName, ULONG ulLength)
{
  ULONG ulMaxNameL = ulLength;

  /* We had to switch to using PrfQueryProfileData because */
  /* some users have binary font data in their INI files */
  BOOL rc = PrfQueryProfileData(HINI_USER, "PM_SystemFonts", fontType,
                                fontName, &ulMaxNameL);
  /* If there was no entry in the INI, default to something */
  if (rc == FALSE) {
    /* Different values for DBCS vs. SBCS */
    if (!IsDBCS()) {
      /* WarpSans is only available on Warp 4 and above */
      if (gIsWarp4)
        strcpy(fontName, "9.WarpSans");
      else
        strcpy(fontName, "8.Helv");
    } else {
      /* WarpSans is only available on Warp 4 and above */
      if (gIsWarp4)
        strcpy(fontName, "9.WarpSans Combined");
      else
        strcpy(fontName, "10.Helv Combined");
    }
  } else {
    /* null terminate fontname */
    fontName[ulMaxNameL] = '\0';
  }
}
Ejemplo n.º 5
0
/*
	query_profile_data
	Read configuration data from the selected INI file.
	There should be no reason to alter the code.
*/
ULONG	query_profile_data()
{
	HINI	ini_file;
	BOOL	fSuccess;
	ULONG	size;

	if(*ini_filename){
		ini_file = PrfOpenProfile(hab, (PSZ)ini_filename);
		if(ini_file == NULLHANDLE)
			ini_file = HINI_USER;
	}else
		ini_file = HINI_USER;

	size = sizeof(configuration_data);
	fSuccess = PrfQueryProfileData(ini_file,
	  (PSZ)application_name, (PSZ)modulename,
	  (PSZ)&configuration_data, &size);

	if(ini_file != HINI_USER)
		PrfCloseProfile(ini_file);
	if(fSuccess == FALSE)
		return 0;
	else
		return size;
}
Ejemplo n.º 6
0
ZExport (ZProfile &) ZProfile::getValues (ZStringlist & aList)
{
  ZFUNCTRACE_DEVELOP ("ZProfile::getValues(ZStringlist& aList)");
  aList.drop ();
#ifdef ZC_WIN
  openPath (zFalse);
  char buffer[MAX_PATH];
  long bufsize;
  for (unsigned long key = 0;; key++)
      {
        bufsize = sizeof (buffer);
        if (RegEnumValue ((HKEY) iPathHandle, key, buffer,
                          (LPDWORD) & bufsize, NULL, NULL, NULL,
                          NULL) != ERROR_SUCCESS)
          break;
        aList.addAsLast (buffer);
      }                         // for
#endif
#ifdef ZC_OS2
  if (!iPath.size ())
    return *this;               // os/2 has no values at this level

  openRoot ();

  // get size of list (not including the terminating 0)
  unsigned long size;
  if (!PrfQueryProfileSize (iRootHandle, iPath, 0, &size))
    throwSysErr (PrfQueryProfileSizeName);

  if (size)
      {
        // create buffer
        ZString buf (0, size++);

        // read list of values
        if (!PrfQueryProfileData (iRootHandle, iPath, 0, buf, &size))
          throwSysErr (PrfQueryProfileDataName);

        // parse values into stringlist
        char *s = buf;
        while (size)
            {
              ZString key;
              while (*s && size)
                  {
                    key += *s++;
                    size--;
                  }
              if (key.size ())
                aList.addAsLast (key);
              if (size)
                  {
                    s++;
                    size--;
                  }
            }                   // while
      }                         // if
#endif
  return *this;
}                               // getValues
Ejemplo n.º 7
0
void Dde_Server::Initiate ( HWND Owner, HWND Client, PDDEINIT pDdeInit ) {

  /**************************************************************************
   * Prepare to respond with a WM_DDE_INITIATEACK.                          *
   **************************************************************************/

   HMQ Queue = WinQueryWindowULong ( Owner, QWL_HMQ ) ;
   char Text [10] ;
   ULONG Size = 10 ;
   int Country = 1 ;
   if ( PrfQueryProfileData ( HINI_USERPROFILE, PSZ("PM_National"), PSZ("iCountry"), Text, &Size ) )
      Country = atoi ( Text ) ;

   CONVCONTEXT Conv ;
   Conv.cb = sizeof(Conv) ;
   Conv.fsContext = DDECTXT_CASESENSITIVE ;
   Conv.idCountry = Country ;
   Conv.usCodepage = WinQueryCp ( Queue ) ;
   Conv.usLangID = 0 ;
   Conv.usSubLangID = 0 ;

  /**************************************************************************
   * Respond if appropriate.                                                *
   **************************************************************************/

   Application.Initiate ( Owner, Client, pDdeInit, Conv ) ;
}
Ejemplo n.º 8
0
/*************************************************************
* Get the data from the profile
*************************************************************/
PVOID GetProfileData(PSZ pszApp, PSZ pszKey, HINI hini, PULONG pulProfileSize)
{
PBYTE pBuffer;

   if (!PrfQueryProfileSize(hini,
      pszApp,
      pszKey,
      pulProfileSize))
      {
      return NULL;
      }

   pBuffer = malloc(*pulProfileSize);
   if (!pBuffer)
      return NULL;

   if (!PrfQueryProfileData(hini,
      pszApp,
      pszKey,
      pBuffer,
      pulProfileSize))
      {
      free(pBuffer);
      return NULL;
      }
   return pBuffer;
}
Ejemplo n.º 9
0
/*************************************************************************\
 * function ReadProfile()
 * Tries to open the file "bermuda.ini" and sets game specific options taken
 * from the profile data. If the file isn't found or the data is invalid
 * FALSE is returned otherwise the function returns TRUE.
\*************************************************************************/
BOOL ReadProfile( HAB hab )
{
	CHAR pszVersionFound[MaxVersionLen] = "";
	ULONG lNumRead;
	ULONG tmpLineStyle;
	BOOL  tmpSound;
	HINI hini;
	PSZ pszIniNameCopy;


	pszIniNameCopy = (PSZ)alloca( strlen( pszIniName ) + 1);
	strcpy( pszIniNameCopy, pszIniName );
	if ( !(hini = PrfOpenProfile( hab, pszIniNameCopy )) ) goto Error;

	// query version string
	PrfQueryProfileString( hini, pszAppName, PrfKeys.pszVersion, NULL,
								  pszVersionFound, MaxVersionLen );
	// and compare with current version								  
	if ( strcmp( pszVersion, pszVersionFound ) != 0 ){
		PrfCloseProfile( hini );
		return FALSE;
	}

	// retrieve line style settings
	lNumRead = sizeof( ULONG );
	if( !PrfQueryProfileData( hini, pszAppName, PrfKeys.pszLineStyle,
		 &tmpLineStyle, &lNumRead ) ) goto Error;
	InfoData.SetLineStyle( tmpLineStyle );		 
	// retrieve sound flag
	lNumRead = sizeof( BOOL );
	if( !PrfQueryProfileData( hini, pszAppName, PrfKeys.pszSound,
		 &tmpSound, &lNumRead ) )
		 goto Error;
	Sound::SetSoundWanted( tmpSound );		 

	if ( !RestoreWindowPos( hini, pszAppName, PrfKeys.pszWinPos, hwndFrame )
		) goto Error;
	PrfCloseProfile( hini );
	return TRUE;

Error:
	PrfCloseProfile( hini );
	return FALSE;
}
Ejemplo n.º 10
0
BOOL Profile::GetString ( char *ItemName, char* &Item ) {

   if ( !IsReady() ) {
      Item = 0 ;
      return ( FALSE ) ;
   } /* endif */

   #ifdef __OS2__

      ULONG TrueSize ;
      if ( !PrfQueryProfileSize ( Handle, PSZ(Name), PSZ(ItemName), &TrueSize ) ) {
         Item = 0 ;
         return ( FALSE ) ;
      } /* endif */

      Item = new char [TrueSize+1] ;
      if ( Item == 0 ) {
         Log ( "Profile::GetString: Unable to allocate memory to hold string.  App %s, Item %s, TrueSize %i.", Name, ItemName, TrueSize ) ;
         return ( FALSE ) ;
      } /* endif */

      if ( !PrfQueryProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, &TrueSize ) ) {
         char Message [512] ;
         Log ( "Profile::GetString: Could not get INI item.  App %s, Item %s, TrueSize %i.  %s", Name, ItemName, TrueSize, InterpretWinError(0,Message) ) ;
         delete [] Item ;
         Item = 0 ;
         return ( FALSE ) ;
      } /* endif */

      Item[TrueSize] = 0 ;

   #else // __NT__

      char *Buffer = new char [0x1000] ;
      int Returned ( 0 ) ;
      if ( ProfileName[0] ) {
         Returned = GetPrivateProfileString ( Name, ItemName, "", Buffer, 0x1000, ProfileName ) ;
      } else {
         Returned = GetProfileString ( Name, ItemName, "", Buffer, 0x1000 ) ;
      } /* endif */

      Item = new char [Returned+1] ;
      if ( Item == 0 ) {
         Log ( "Profile::GetString: Unable to allocate memory to hold string.  App %s, Item %s, TrueSize %i.", Name, ItemName, Returned ) ;
         return ( FALSE ) ;
      } /* endif */

      strcpy ( Item, Buffer ) ;

      delete [] Buffer ;

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Ejemplo n.º 11
0
BOOL Profile::GetItem ( char *ItemName, void *Item, int Size ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

   #ifdef __OS2__

      ULONG HowBig ;
      if ( !PrfQueryProfileSize ( Handle, PSZ(Name), PSZ(ItemName), &HowBig ) ) 
         return ( FALSE ) ;

      if ( Size != HowBig ) {
         Log ( "Profile::GetItem: Could not get INI item.  App %s, Item %s.  Wrong size.", Name, ItemName ) ;
         return ( FALSE ) ;
      } /* endif */

      if ( !PrfQueryProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, &HowBig ) ) {
         char Message [512] ;
         Log ( "Profile::GetItem: Could not get INI item.  App %s, Item %s, size %i.  %s", Name, ItemName, HowBig, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */

   #else // __NT__

      char *Buffer = new char [Size*2+2] ;

      int Returned ( 0 ) ;
      if ( ProfileName[0] ) {
         Returned = GetPrivateProfileString ( Name, ItemName, "", Buffer, Size*2+2, ProfileName ) ; 
      } else {
         Returned = GetProfileString ( Name, ItemName, "", Buffer, Size*2+2 ) ; 
      } /* endif */

      if ( Returned != Size*2 ) {
         delete [] Buffer ;
         Log ( "Profile::GetItem: Could not get INI item.  App %s, Item %s.  Wrong size.", Name, ItemName ) ;
         return ( FALSE ) ;
      } /* endif */

      for ( int i=0; i<Size; i++ ) {
         ((char*)Item)[i] = ( Buffer[i*2+0] > '9' ? Buffer[i*2+0]-'A'+10 : Buffer[i*2+0]-'0' ) << 4 ;
         ((char*)Item)[i] |= ( Buffer[i*2+1] > '9' ? Buffer[i*2+1]-'A'+10 : Buffer[i*2+1]-'0' ) ;
      } /* endfor */

      delete [] Buffer ;

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Ejemplo n.º 12
0
BOOL CopyProfile(HINI hSourceProfile,HINI hDestinationProfile)
{
    int iAppIndex;
    int iKeyIndex;
    char *pKeyNames;
    char *pAppNames;
    char *pAppName;
    char *pKeyName;
    ULONG ulAppSize;
    ULONG ulDataSize;
    ULONG ulKeySize;
    void *pData;

    PrfQueryProfileSize(hSourceProfile,0L,0L,&ulAppSize);
    if ((pAppNames = malloc(ulAppSize + 1)) == NULL)
        return(FALSE);
    PrfQueryProfileString(hSourceProfile,0L,0L,0L,pAppNames,ulAppSize);
    iAppIndex = 0;
    while (iAppIndex < ulAppSize)
    {
        pAppName = &pAppNames[iAppIndex];
        PrfQueryProfileSize(hSourceProfile,pAppName,0L,&ulKeySize);
        if ((pKeyNames = malloc(ulKeySize + 1)) == NULL)
        {
            free (pAppNames);
            return(FALSE);
        }
        PrfQueryProfileString(hSourceProfile,pAppName,0L,0L,pKeyNames,ulKeySize);
        iKeyIndex = 0;
        while (iKeyIndex < ulKeySize)
        {
            pKeyName = &pKeyNames[iKeyIndex];
            PrfQueryProfileSize(hSourceProfile,pAppName,pKeyName,&ulDataSize);
            if ((pData = malloc(ulDataSize + 1)) != NULL)
            {
                PrfQueryProfileData(hSourceProfile,pAppName,pKeyName,pData,&ulDataSize);
                PrfWriteProfileData(hDestinationProfile,pAppName,pKeyName,pData,ulDataSize);
                free(pData);
            }
            while(pKeyNames[iKeyIndex++] != 0);
            if (pKeyNames[iKeyIndex] == 0)
                break;;
        }
        free(pKeyNames);
        while(pAppNames[iAppIndex++] != 0);
        if (pAppNames[iAppIndex] == 0)
            break;;
    }
    free(pAppNames);
    return(TRUE);
}
Ejemplo n.º 13
0
static void LoadSWP (char *name,SWP *swp) {

  ULONG size;

  size = sizeof(SWP);
  PrfQueryProfileData(prof,
                      appname,
                      name,
                      swp,
                      &size);
  if(swp->x + swp->cx > xScreen)
    swp->x = xScreen - swp->cx;
  if(swp->y + swp->cy > yScreen)
    swp->y = yScreen - swp->cy;
}
Ejemplo n.º 14
0
//===========================================================================
//
// Parameters --------------------------------------------------------------
// HWND hwnd : window handle
// VOID
// Return value ------------------------------------------------------------
// BOOL : TRUE/FALSE (success/error)
// VOID
//===========================================================================
static
PWPSCLASSLIST getWPSClassData(HWND hwnd) {
   PWPSCLASSLIST p;
   ULONG cb = 0x10000;
   if (NULL == (p = malloc(cb))) {
      notifyError(hwnd, SZERR_ALLOC);
      return NULL;
   } /* endif */
   if (!PrfQueryProfileData(HINI_SYSTEM,
                            PRF_WPSCLASSESAPP, PRF_WPSCLASSESKEY, p, &cb)) {
      notifyError(hwnd, SZERR_GETCLASSLISTDATA);
      free(p);
      return NULL;
   } /* endif */
   return p;
}
Ejemplo n.º 15
0
/*************************************************************************\
 * function RestoreWindowPos
 * Analoguous to StoreWindowPos but the contrary action.
\*************************************************************************/
BOOL RestoreWindowPos( const HINI hini, const PSZ pszAppName,
										const PSZ pszKeyName, const HWND hwnd )
{
	LONG lWinPos[4];
	ULONG ulDataLen = 4 * sizeof( LONG );

	/* Overwrite the values of swp.cy, swp.cx, swp.y and swp.x. */
	if ( !PrfQueryProfileData( hini, pszAppName, pszKeyName,
										lWinPos, &ulDataLen )
		) return FALSE;
	/* Set new position */
	if ( !WinSetWindowPos( hwnd, NULLHANDLE,
								  lWinPos[0], lWinPos[1], lWinPos[2], lWinPos[3],
								  SWP_SIZE | SWP_MOVE )
		) return FALSE;
	return TRUE;
}
Ejemplo n.º 16
0
BOOL Profile::GetString ( char *ItemName, char *Item, int MaxSize ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

   #ifdef __OS2__

      ULONG TrueSize ;
      if ( !PrfQueryProfileSize ( Handle, PSZ(Name), PSZ(ItemName), &TrueSize ) ) 
         return ( FALSE ) ;

      ULONG HowBig = min ( TrueSize+1, MaxSize ) ;
      if ( !PrfQueryProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, &HowBig ) ) {
         char Message [512] ;
         Log ( "Profile::GetString: Could not get INI item.  App %s, Item %s, TrueSize %i, MaxSize %i.  %s", Name, ItemName, TrueSize, MaxSize, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */

      Item[HowBig] = 0 ;

   #else // __NT__

      char *Buffer = new char [MaxSize+1] ;
      int Returned ( 0 ) ;
      if ( ProfileName[0] ) {
         Returned = GetPrivateProfileString ( Name, ItemName, "", Buffer, MaxSize+1, ProfileName ) ;
      } else {
         Returned = GetProfileString ( Name, ItemName, "", Buffer, MaxSize+1 ) ;
      } /* endif */

      if ( Returned >= MaxSize ) {
         delete [] Buffer ;
         Log ( "Profile::GetString: Could not get INI item.  App %s, Item %s.  Too large.", Name, ItemName ) ;
         return ( FALSE ) ;
      } /* endif */

      strcpy ( Item, Buffer ) ;

      delete [] Buffer ;

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Ejemplo n.º 17
0
/*
	load_configuration_data
	Load all module configuration data from the INI-file into the
	configuration_data structure, if not done already loaded.
*/
void	load_configuration_data(void)
{
	if(configuration_data_loaded == FALSE){
		// data not loaded yet
		ULONG	size;
		BOOL	fSuccess;
		// get name of the saver module (stored as resource string)
		if(WinLoadString(hab, hmodDLL, IDS_MODULENAME,
		  SAVER_NAME_MAXLEN, (PSZ)modulename) == 0){
			// resource string not found. indicate error by
			// setting module name to empty string (the name
			// "" is interpreted as an error by SSDLL.DLL and
			// the module does not show up in the list box).
			strcpy(modulename, "");
			return;
		}
		// load data from INI-file. the key name is the name of the
		// saver module
		size = sizeof(configuration_data);
		fSuccess = PrfQueryProfileData(HINI_USER,
		  (PSZ)application_name, (PSZ)modulename,
		  (PSZ)&configuration_data, &size);
		if(!fSuccess || size != sizeof(configuration_data) || configuration_data.version != MODULEVERSION){
			// if entry is not found or entry has invalid size or
			// entry has wrong version number, create a new entry
			// with default values and write it to the INI-file
			configuration_data.version = MODULEVERSION;
			configuration_data.enabled = TRUE;
			configuration_data.animation_speed = CONFIGURATION_DEFAULT_ANIMATIONSPEED;
/*
			$$$$$ insert code here $$$$$
			If you have added data to the configuration_data
			structure, insert code here to set the default
			values for your data items.

			$$$$$ for example $$$$$
			configuration_data.count = CONFIGURATION_DEFAULT_COUNT;
*/
			configuration_data.drunken = DRUNKEN;
			PrfWriteProfileData(HINI_USER, (PSZ)application_name, (PSZ)modulename, (PSZ)&configuration_data, sizeof(configuration_data));
		}
		configuration_data_loaded = TRUE;
	}
}
Ejemplo n.º 18
0
void        DrvInit( HWND hwnd)

{
    ULONG   ul;

    ul = sizeof(ulDrvOpts);
    if (!PrfQueryProfileData( HINI_USERPROFILE, CAMINI_APP, CAMINI_DRVOPTS,
                              &ulDrvOpts, &ul) || ul != sizeof(ulDrvOpts))
        ulDrvOpts = 0;

    ulDrvOpts &= CAMDRV_MASK;
    if (CAM_IS_NOLVM)
        DrvSetUseLvm( hwnd, FALSE);

    ul = ulDrvOpts & CAMDRV_EJECTMASK;
    if (!ul)
        ul = IDM_EJECTDLG;
    else
    if (ul == CAMDRV_NEVEREJECT)
        ul = IDM_EJECTNEVER;
    else
    if (ul == CAMDRV_ALWAYSEJECT)
        ul = IDM_EJECTALWAYS;
    else {
        // if both "always" & "never" eject are on, turn both off
        ulDrvOpts &= ~CAMDRV_EJECTMASK;
        ul = IDM_EJECTDLG;
    }

    WinSendDlgItemMsg( hwnd, FID_MENU, MM_SETITEMATTR,
                       MPFROM2SHORT( ul, TRUE),
                       MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED));


    if (!(ulDrvOpts & CAMDRV_NOLVM))
        WinSendDlgItemMsg( hwnd, FID_MENU, MM_SETITEMATTR,
                           MPFROM2SHORT( IDM_AUTOMOUNT, TRUE),
                           MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED));

    return;
}
Ejemplo n.º 19
0
/* Helper function to query font from INI file */
static void
QueryFontFromINI(char* fontType, char* fontName, ULONG ulLength)
{
  ULONG ulMaxNameL = ulLength;

  // We must use PrfQueryProfileData here, because some users have
  // binary font data in their INI files.
  if (PrfQueryProfileData(HINI_USER,
                          (PCSZ)"PM_SystemFonts",
                          (PCSZ)fontType,
                          fontName, &ulMaxNameL)) {
    // PrfQueryProfileData does not nul-terminate for us.
    fontName[ulMaxNameL] = '\0';
  } else {
    // If there was no entry in the INI, default to something sensible.
    // Make sure to use a DBCS-capable font in a DBCS-capable environment.
    if (IsDBCS()) {
      strcpy(fontName, "9.WarpSans Combined");
    } else {
      strcpy(fontName, "9.WarpSans");
    }
  }
}
Ejemplo n.º 20
0
void        RestoreSort( void)

{
    USHORT  ausSort[2];
    ULONG   ctr;

    // if the ini entry is missing or defective, use default values
    if (PrfQueryProfileSize( HINI_USERPROFILE, CAMINI_APP,
                             CAMINI_SORT, &ctr) == FALSE ||
        ctr != sizeof( ausSort) ||
        PrfQueryProfileData( HINI_USERPROFILE, (PCSZ)CAMINI_APP,
                             CAMINI_SORT, ausSort, &ctr) == FALSE)
    {
        ausSort[0] = FALSE;
        ausSort[1] = FALSE;
    }

    // set the sort sense, and sort indicators
    sSortSense = (ausSort[0] ? -1 : 1);
    SetSortIndicators( ausSort[1]);

    return;
}
Ejemplo n.º 21
0
//called to allocate memory and setup initial settings
BOOL CBZInit(HINI hIni, char szName[], char szClass[], PVOID * pData)
{
    PLUGINSHARE *pPluginShare;
    PLUGINSHARE *pPluginData;
    char szReadName[64];
    char szShareName[64];
    ULONG szData;

    // alloc window words for the plugin's data
    if ((DosAllocMem((PPVOID) (pData),
                     sizeof(PLUGINSHARE),
                     PAG_READ | PAG_WRITE | PAG_COMMIT)) != NO_ERROR)
    {
        return FALSE;
    }

    //initialize the plugin's data to zeros.
    memset(*pData, 0, sizeof(PLUGINSHARE));

    pPluginData = (PLUGINSHARE *) * pData;

    strcpy(szShareName, PLUGIN_SHARE);
    strcat(szShareName, szClass);

    //custom name was specified, try to load the custom config for it.
    if (strlen(szName) > 0)
    {
        strcpy(szReadName, szName);
        strcat(szReadName, "_");
        strcat(szReadName, szClass);
        strcat(szReadName, "_CBZLINESPlugin");
        szData = sizeof(PLUGINSHARE);

        // get shared mem
        if (!PrfQueryProfileData(hIni,
                                 "CustomOptionsData",
                                 szReadName,
                                 pPluginData,
                                 &szData))
        {
            // if shared mem is not available, use defaults!
            if (DosGetNamedSharedMem((PPVOID) & pPluginData, szShareName, PAG_READ) != NO_ERROR)
            {
                //use some defaults?
                pPluginData->lActiveLineColor = 121 * 65536 + 127;
                pPluginData->lActiveShadowColor = 255 * (65536 + 1);
                pPluginData->lInactiveLineColor = 100 * (65536 + 256 + 1);
                pPluginData->lInactiveShadowColor = 204 * (65536 + 256 + 1);
                pPluginData->bActiveEnabled = TRUE;
                pPluginData->bInactiveEnabled = TRUE;
                pPluginData->lLineStyle = 7;

                if (!PrfWriteProfileData(hIni,
                                         "CustomOptionsData",
                                         szReadName,
                                         pPluginData,
                                         sizeof(PLUGINSHARE)))
                {
                    //not a fatal error
                }
            }
        }

    }                           //end if (szName > 0)

    else
    {
        //Load defaults!  No custom name specified.

        // if shared mem is not available, try allocating it!
        if (DosGetNamedSharedMem((PPVOID) & pPluginShare, szShareName, PAG_READ) != NO_ERROR)
        {
            //try Allocating the SharedMem space for this plugin!
            if (DosAllocSharedMem((PPVOID) & pPluginShare,
                                  szShareName,
                                  sizeof(PLUGINSHARE),
                             PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
                return (FALSE); //ignore this plugin... It must be broken?

            // clear it
            memset(pPluginShare, 0, sizeof(PLUGINSHARE));

            szData = sizeof(PLUGINSHARE);

            // get shared mem
            strcpy(szReadName, szClass);
            strcat(szReadName, "_CBZLINESPlugin");
            if (!PrfQueryProfileData(hIni,
                                     "UserOptionsData",
                                     szReadName,
                                     pPluginShare,
                                     &szData))
            {
                pPluginShare->lActiveLineColor = 121 * 65536 + 127;
                pPluginShare->lActiveShadowColor = 255 * (65536 + 1);
                pPluginShare->lInactiveLineColor = 100 * (65536 + 256 + 1);
                pPluginShare->lInactiveShadowColor = 204 * (65536 + 256 + 1);
                pPluginShare->bActiveEnabled = TRUE;
                pPluginShare->bInactiveEnabled = TRUE;
                pPluginShare->lLineStyle = 7;

                if (!PrfWriteProfileData(hIni,
                                         "UserOptionsData",
                                         szReadName,
                                         pPluginShare,
                                         sizeof(PLUGINSHARE)))
                {
                    //not a fatal error.
                }
            }
        }                       //end if

        //copy from shared memory to each windows window words.
        pPluginData->lActiveLineColor = pPluginShare->lActiveLineColor;
        pPluginData->lActiveShadowColor = pPluginShare->lActiveShadowColor;
        pPluginData->lInactiveLineColor = pPluginShare->lInactiveLineColor;
        pPluginData->lInactiveShadowColor = pPluginShare->lInactiveShadowColor;
        pPluginData->bActiveEnabled = pPluginShare->bActiveEnabled;
        pPluginData->bInactiveEnabled = pPluginShare->bInactiveEnabled;
        pPluginData->lLineStyle = pPluginShare->lLineStyle;
    }                           //end else

    return TRUE;
}
/****************************************************************\
 *
 *--------------------------------------------------------------
 *
 *  Name:ClkCreate()
 *
 *  Purpose:Intialize a newly created client window
 *
 *
 *
 *  Usage:
 *
 *  Method:
 *          -
 *
 *          -
 *          -
 *
 *          -
 *          -
 *
 *  Returns:
 *          1 - if sucessful execution completed
 *          0 - if error
\****************************************************************/
VOID ClkCreate ( HWND hwnd )
{
    LONG cxScreen , cyScreen;  /* screen dimensions */
    LONG xLeft , yBottom ;      /* frame window location */
    ULONG cbBuf;
    LONG cyHeight;
    LONG cxWidth;

    hwndClient = hwnd;

    WinLoadString(hab, NULLHANDLE, IDS_TITLE,  0, (PSZ)szTitle   );
    WinLoadString(hab, NULLHANDLE, IDS_HELPTITLE, 256, (PSZ)szHelpTitle);
    GetCountryDependent();
    /* we are called before the global hwndFrame is valid */
    hwndFrame = WinQueryWindow ( hwnd , QW_PARENT) ;
    hwndTitleBar = WinWindowFromID ( hwndFrame , FID_TITLEBAR ) ;
    hwndSysMenu = WinWindowFromID ( hwndFrame , FID_SYSMENU ) ;
    hwndMinMax = WinWindowFromID ( hwndFrame , FID_MINMAX ) ;

    /* load our menus */
    hwndMenu = WinLoadMenu (hwndFrame, NULLHANDLE, IDR_MAIN);
    /* determine screen dimensions */
    /* open a device context and create a presentation space */

    hdc = WinOpenWindowDC (hwnd);
    hps = GpiCreatePS (hab, hdc, &sizl, PU_ARBITRARY | GPIT_MICRO |
            GPIA_ASSOC);

    /*
     * Create our off-screen 'buffer'.
     */
    hdcBuffer = DevOpenDC ( (HAB)0L, OD_MEMORY, "*", 0L, NULL, hdc);
    hpsBuffer = GpiCreatePS (hab, hdcBuffer, &sizl, PU_ARBITRARY |
                               GPIT_MICRO | GPIA_ASSOC);

    GpiCreateLogColorTable (hpsBuffer, 0, LCOLF_RGB, 0, 0, (PLONG)NULL);

    /* get the device resolutions so we can make the face appear circular */
    DevQueryCaps (hdc, (LONG)CAPS_VERTICAL_RESOLUTION,(LONG) 1L, &cyRes);
    DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION, 1L, &cxRes);
    DevQueryCaps (hdc, CAPS_COLOR_PLANES, 1L, &cColorPlanes);
    DevQueryCaps (hdc, CAPS_COLOR_BITCOUNT, 1L, &cColorBitcount);

    cxScreen = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
    cyScreen = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);

    /*
     * Calculate an initial window position and size.
     */
    xLeft = cxScreen / 8;
    yBottom = cyScreen / 2;
    cxWidth = cxScreen / 3;
    cyHeight = cyScreen / 2;
    WinSetWindowPos (hwndFrame, NULLHANDLE, xLeft, yBottom,
                       cxWidth, cyHeight,
                       SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);

    cbBuf = sizeof(cp);
    if (!PrfQueryProfileData(HINI_USER, SZ_APPNAME, SZ_KEYNAME, &cp, &cbBuf))
    {
        cp.usMajorTickPref = CLKTM_ALWAYS;
        cp.usMinorTickPref = CLKTM_NOTICONIC;
        cp.clrBackground = 0x00008080;
        cp.clrFace = 0x00008080;
        cp.clrHourHand = RGB_RED;
        cp.clrMinuteHand = RGB_RED;
        cp.fControlsHidden = FALSE;
        cp.usDispMode = DM_TIME | DM_ANALOG | DM_SECONDHAND;
        cp.alarm.uchHour = 0;
        cp.alarm.uchMinutes = 0;
        cp.alarm.usMode = 0;
        SetRGBColors();
        /* position the window and make it visible */
        WinSetWindowPos( hwndFrame , NULLHANDLE ,
                           xLeft , yBottom ,
                           cxWidth , cyHeight ,
                           SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);
        WinQueryWindowPos(hwndFrame, &cp.swp);
    }
    else
    { /*Protect against garbage swp*/

        cp.swp.hwnd = hwndFrame;
        cp.swp.hwndInsertBehind = HWND_TOP;

        cp.swp.fl = (cp.swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE)) | SWP_SIZE | SWP_MOVE | SWP_ACTIVATE;
        SetRGBColors();
        WinSetMultWindowPos(hab, &cp.swp, 1);
    }

    if (cp.fControlsHidden)
        ClkHideFrameControls (hwndFrame);

    /*
     * Check relevant items.
     */
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TIME, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_TIME)?  MIA_CHECKED
                                      : ~MIA_CHECKED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_DATE, TRUE),
                MPFROM2SHORT( MIA_DISABLED,
                              ( (!(cp.usDispMode & DM_TIME))?  MIA_DISABLED
                                      : ~MIA_DISABLED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_DATE, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_DATE)?  MIA_CHECKED
                                      : ~MIA_CHECKED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TIME, TRUE),
                MPFROM2SHORT( MIA_DISABLED,
                              ( ((!(cp.usDispMode & DM_DATE) || (cp.usDispMode & DM_ANALOG)))?  MIA_DISABLED
                                      : ~MIA_DISABLED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( (cp.usDispMode & DM_DIGITAL)
                                                          ?IDM_DIGITAL
                                                          :IDM_ANALOG,
                               TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              MIA_CHECKED));

    WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(IDM_SECONDHAND, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_SECONDHAND) ? MIA_CHECKED
                                      : ~MIA_CHECKED)));


    /*
     * Disable these items if the digital clock is visible
     * since they won't apply.
     */
    if (cp.usDispMode & DM_DIGITAL)
    {
        WinSendMsg (hwndMenu, MM_SETITEMATTR,
                MPFROM2SHORT(IDM_SECONDHAND, TRUE),
                MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));

        WinSendMsg (hwndMenu, MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TICKS, TRUE), MPFROM2SHORT( MIA_DISABLED,
                MIA_DISABLED));
    }

    /* have we been asked to start as an icon? */
    if (fStartAsIcon)
        WinSetWindowPos(hwndFrame, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE);

    WinShowWindow(hwndFrame, TRUE);

    /* get the time in a format for dislaying */
    DosGetDateTime(&dt);
    dt.hours = (UCHAR )(dt.hours * (UCHAR) 5) % (UCHAR) 60 + dt.minutes / (UCHAR)12;

    /* start a timer */
    WinStartTimer (hab, hwnd, IDR_MAIN, 1000);

    WinLoadString(hab, NULLHANDLE, IDS_TITLE, 80, (PSZ)szTitle);
    GetCountryDependent();

}
Ejemplo n.º 23
0
ZExport (ZString) ZProfile::value (const ZString & aValueName)
{
  ZFUNCTRACE_DEVELOP ("ZProfile::value(const ZString& aValueName)");
#ifdef ZC_WIN
  openPath (zFalse);

  DWORD dataType, size;
  if (!RegQueryValueEx ((HKEY) iPathHandle, aValueName, 0,
                        &dataType, NULL, &size) == ERROR_SUCCESS)
    ZTHROWEXC (ValueNotFound);

  if (size)
      {
        ZString str (0, size);
        RegQueryValueEx ((HKEY) iPathHandle, aValueName, 0,
                         NULL, (LPBYTE) (char *) str, (LPDWORD) & size);

        switch (dataType)
            {
            case 1:            // String
            case 2:            // ExpandString
            case 7:            // MultiString
              if (str.size () > 0 && str[str.size ()] == 0)
                return str.subString (1, str.size ());
            default:;
            }                   // switch
      }                         // if
#endif
#ifdef ZC_OS2
  if (!iPath.size ())
    ZTHROWEXC (MissingPath);
  if (!aValueName.size ())
    ZTHROWEXC (MissingValueName);
  openRoot ();

  // query size of data
  unsigned long size;
  if (!PrfQueryProfileSize (iRootHandle, iPath, aValueName, &size))
    throwSysErr (PrfQueryProfileSizeName);

  if (size > 0)
      {
        ZString buf (0, size++);

        // try to get as string first
        PrfQueryProfileString (iRootHandle, iPath, aValueName, "", buf, size);
        ERRORID err = WinGetLastError (iHab);
        if (err == 0)
            {
              if (buf[buf.size ()] == 0
                  && buf.subString (1, buf.size () - 1).isPrintable ())
                return buf.subString (1, buf.size () - 1);
              return buf;
            }                   // if

        if (ERRORIDERROR (err) != PMERR_INVALID_ASCIIZ)
          throwSysErr (PrfQueryProfileStringName);

        // try to get binary data
        if (!PrfQueryProfileData (iRootHandle, iPath, aValueName, buf, &size))
          throwSysErr (PrfQueryProfileDataName);
        return buf;
      }                         // if
#endif
  return ZString ();
}                               // value
Ejemplo n.º 24
0
/*--------------------------------------------------------------------------------------*\
 * Procedure opens the profile and reads the UPS structure from.                        *
 * Req:                                                                                 *
 *      pHini ......... A pointer to the handle of the profile                          *
 *      pHab .......... A pointer to extract the anchor block of the window             *
 *      pUps .......... A pointer to the UPS structure                                  *
 * Returns:                                                                             *
 *      TRUE/FALSE .... If called sucessfully/unsucessfully                             *
\*--------------------------------------------------------------------------------------*/
BOOL    Read_Profile(HINI *pHini, HAB *pHab, UPS *pUps)
{
ULONG   ulSize;
UCHAR   *uc='\0';
                                        /* First open the profile */
*pHini=PrfOpenProfile(*pHab, pucSD2Profile);
while(TRUE)
    {
    ulSize=sizeof(UCHAR);
    if(PrfQueryProfileData(             /* Query binary data from profile */
        *pHini,                         /* Handle of profile */
        SD2_CLASSNAME,                  /* Application name */
        "IDUBC_Hours",                  /* Key name */
        &pUps->IDUBC_Hours,             /* Value data */
        &ulSize)==FALSE)                /* Size of value data */
        { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUBC_Minutes",
        &pUps->IDUBC_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUAS_Hours",
        &pUps->IDUAS_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUAS_Minutes",
        &pUps->IDUAS_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUASD_Hours",
        &pUps->IDUASD_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUASD_Minutes",
        &pUps->IDUASD_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUS_Hours",
        &pUps->IDUS_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUS_Minutes",
        &pUps->IDUS_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(ULONG);
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "GRP_Mode",
        &pUps->GRP_Mode,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(Ups.IDS_PgmName);
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmName",
        uc,
        pUps->IDS_PgmName,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmDirectory",
        uc,
        pUps->IDS_PgmDirectory,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmInputs",
        uc,
        pUps->IDS_PgmInputs,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(Ups.IDS_UserInfo);
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_UserInfo",
        uc,
        pUps->IDS_UserInfo,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    return(PrfCloseProfile(*pHini));    /* Close and return result */
    }
if(*pHini==NULLHANDLE)
    {
                                        /* SHUTDOWN.INI missing logging into logfile */
    DosGetDateTime(&UPS_Current);
    UPS_LogfileIO(LF_INIFILE_MISSING, MPFROMP(&UPS_Current));
    pUps->IDUBC_Hours=0;                /* Assume default values */
    pUps->IDUBC_Minutes=10;
    pUps->IDUAS_Hours=0;
    pUps->IDUAS_Minutes=1;
    pUps->IDUASD_Hours=0;
    pUps->IDUASD_Minutes=4;
    pUps->IDUS_Hours=0;
    pUps->IDUS_Minutes=7;
    pUps->GRP_Mode=IDM_LPT1;
    strcpy(pUps->IDS_PgmName, "CMD.EXE");
    strcpy(pUps->IDS_PgmDirectory, "");
    strcpy(pUps->IDS_PgmInputs, "");
    strcpy(pUps->IDS_UserInfo, "An error occured accessing SHUTDOWN.INI, please correct "\
        "as soon as possible!");
    return(FALSE);
    }
}
Ejemplo n.º 25
0
static  BOOL    saveProfile(HAB hab)
{
#ifdef DEBUG
    TRACE("in saveProfile ... ") ;
#endif

    int     entry, i, id ;
    HINI    hini  ;
    BOOL    stat  ;
    ULONG   len   ;
    UCHAR   key[32] ;

#ifdef DEBUG
    TRACE("done in saveProfile\n") ;
#endif

    /*
     * save to profile
     */

    if ((hini = PrfOpenProfile(hab, ProfilePath)) == NULLHANDLE) {

#ifdef DEBUG
        TRACE("saveProfile - failed to open %s\n", ProfilePath) ;
#endif

        return FALSE ;
    }

    /*
     * re-load new profile
     */

    len = sizeof(profOrder) ;
    stat = PrfQueryProfileData(hini, ProgramName, "ORDER", profOrder, &len) ;

    if (stat != TRUE || len != sizeof(profOrder)) {
        memset(profOrder, 0xff, sizeof(profOrder)) ;
    }

    for (i = 0 ; i < MAXHOSTS ; i++) {
        if ((id = profOrder[i]) == 0xff) {
            continue ;
        }
        sprintf(key, "HOST%02d", id) ;
        len = sizeof(HOSTREC) ;
        stat = PrfQueryProfileData(hini,
                    ProgramName, key, &profHosts[id], &len) ;
        if (stat != TRUE || len != sizeof(HOSTREC)) {
            profOrder[i] = 0xff ;
        }
    }

    /*
     * select new entry
     */

    if ((entry = saveParam()) < 0) {
        PrfCloseProfile(hini) ;
        return FALSE ;
    }

    /*
     * save new order and host data
     */

    sprintf(key, "HOST%02d", entry) ;
    PrfWriteProfileData(hini, ProgramName,
                "ORDER", profOrder, sizeof(profOrder)) ;
    PrfWriteProfileData(hini, ProgramName,
                key, &profHosts[entry], sizeof(HOSTREC)) ;

    PrfCloseProfile(hini) ;

#ifdef DEBUG
    TRACE("saveProfile ... saved to %d\n", entry) ;
#endif

    return TRUE ;
}
Ejemplo n.º 26
0
static  BOOL    loadProfile(HAB hab)
{
    HINI    hini ;
    BOOL    stat ;
    ULONG   len  ;
    int     i, id ;
    UCHAR   key[32] ;

#ifdef DEBUG
    TRACE("loadProfile [%s]\n", ProfilePath) ;
#endif

    /*
     * load host order
     */

    if ((hini = PrfOpenProfile(hab, ProfilePath)) == NULLHANDLE) {

#ifdef DEBUG
        TRACE("loadProfile - failed to open %s\n", ProfilePath) ;
#endif

        return FALSE ;
    }

    len = sizeof(profOrder) ;
    stat = PrfQueryProfileData(hini, ProgramName, "ORDER", profOrder, &len) ;

    if (stat != TRUE || len != sizeof(profOrder)) {
        PrfCloseProfile(hini) ;
        memset(profOrder, 0xff, sizeof(profOrder)) ;

#ifdef DEBUG
        TRACE("loadProfile - failed to read Order\n") ;
#endif

        return FALSE ;
    }

    /*
     * load host informations
     */

    for (i = 0 ; i < MAXHOSTS ; i++) {
        if ((id = profOrder[i]) == 0xff) {
            continue ;
        }
        sprintf(key, "HOST%02d", id) ;
        len = sizeof(HOSTREC) ;
        stat = PrfQueryProfileData(hini,
                    ProgramName, key, &profHosts[id], &len) ;
        if (stat != TRUE || len != sizeof(HOSTREC)) {
            PrfCloseProfile(hini) ;
            memset(profOrder, 0xff, sizeof(profOrder)) ;

#ifdef DEBUG
            TRACE("loadProfile - failed to read Host Data %d\n", id) ;
#endif

            return FALSE ;
        }
    }
    PrfCloseProfile(hini) ;

    /*
     * modified with command line arguments
     */

    for (i = 0 ; i < MAXHOSTS ; i++) {
        if ((id = profOrder[i]) == 0xff) {
            continue ;
        }
        if (argFormat32) {
            profHosts[id].format = PIXFMT_32 ;
        }
        if (argFormat8) {
            profHosts[id].format = PIXFMT_8 ;
        }
        if (argFormatTiny) {
            profHosts[id].format = PIXFMT_TINY ;
        }
        if (argFormatGray) {
            profHosts[id].format = PIXFMT_GRAY ;
        }
        if (argEncodeRaw) {
            profHosts[id].encode = rfbEncodingRaw ;
        }
        if (argEncodeRre) {
            profHosts[id].encode = rfbEncodingRRE ;
        }
        if (argEncodeCor) {
            profHosts[id].encode = rfbEncodingCoRRE ;
        }
        if (argEncodeHex) {
            profHosts[id].encode = rfbEncodingHextile ;
        }
        if (argOptShared) {
            profHosts[id].shared = TRUE ;
        }
        if (argOptViewonly) {
            profHosts[id].viewonly = TRUE ;
        }
        if (argOptDeiconify) {
            profHosts[id].deiconify = TRUE ;
        }
    }

    /*
     * also modify current session parameters
     */

    if (argServer) {
        strcpy(SessServerName, argServer) ;
    }
    if (argFormat32) {
        SessPixelFormat = PIXFMT_32 ;
    }
    if (argFormat8) {
        SessPixelFormat = PIXFMT_8 ;
    }
    if (argFormatTiny) {
        SessPixelFormat = PIXFMT_TINY ;
    }
    if (argFormatGray) {
        SessPixelFormat = PIXFMT_GRAY ;
    }
    if (argEncodeRaw) {
        SessPreferredEncoding = rfbEncodingRaw ;
    }
    if (argEncodeRre) {
        SessPreferredEncoding = rfbEncodingRRE ;
    }
    if (argEncodeCor) {
        SessPreferredEncoding = rfbEncodingCoRRE ;
    }
    if (argEncodeHex) {
        SessPreferredEncoding = rfbEncodingHextile ;
    }
    if (argOptShared) {
        SessOptShared = TRUE ;
    }
    if (argOptViewonly) {
        SessOptViewonly = TRUE ;
    }
    if (argOptDeiconify) {
        SessOptDeiconify = TRUE ;
    }

#ifdef DEBUG
    TRACE("loadProfile ... done\n") ;
#endif

    return TRUE ;
}
Ejemplo n.º 27
0
/****************************************************************************
   Main Message Cue Dialog Procedure
*****************************************************************************/
MRESULT EXPENTRY MainDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    {
        BOOL    Handled = TRUE;
        MRESULT mReturn  = 0;
        ULONG   ulScrWidth, ulScrHeight;
        RECTL   Rectl;
        POINTL  Pointl;
        HINI    hini;
        ULONG   temp;

        switch (msg)
            {

                /* Called on startup */
                case WM_INITDLG:
                    ulScrWidth  = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
                    ulScrHeight = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
                    UPDATE_HOURS = TRUE;
                    UPDATE_DATE = TRUE;
                    DTSWITCH = FALSE;
                    hini = HINI_USERPROFILE;
                    Pointl.x = Pointl.y = 10;
                    if(PrfQueryProfileSize(hini,pAppname,pKeyname,(PULONG)&temp) &&temp)
                        { 
                            if(temp == sizeof(POINTL)) PrfQueryProfileData(hini, pAppname,
                                                       pKeyname, &Pointl, (PULONG)&temp);
                        }
                    WinQueryWindowRect (hWnd, &Rectl);
/*
                    WinSetWindowPos (hWnd, HWND_TOP, Pointl.x,
                            Pointl.y, 0, 0, SWP_SHOW | SWP_MOVE | SWP_ACTIVATE);
*/
                    WinSetWindowPos (hWnd, HWND_TOP, (ulScrWidth-Rectl.xRight)/2,
                            (ulScrHeight-Rectl.yTop) - 10, 0, 0, SWP_SHOW | SWP_MOVE | SWP_ACTIVATE);
                    /* A neat little trick to float the window on top... */
                    WinFocusChange(HWND_DESKTOP,HWND_TOP,0);
                    timerID = WinStartTimer(hab, hWnd, 1, 1000L);
                    break;
                case WM_TIMER:
                    if(SHORT1FROMMP(mp1) == timerID)
                        {
                            while(DosGetDateTime( &(datetime[DTSWITCH?1:0]) ));
                            UPDATE_HOURS = (    (datetime[DTSWITCH?1:0].minutes != datetime[DTSWITCH?0:1].minutes)
                                             || (datetime[DTSWITCH?1:0].hours   != datetime[DTSWITCH?0:1].hours  ) );
                            UPDATE_DATE |= (    (datetime[DTSWITCH?1:0].day     != datetime[DTSWITCH?0:1].day    )
                                             || (datetime[DTSWITCH?1:0].weekday != datetime[DTSWITCH?0:1].weekday)
                                             || (datetime[DTSWITCH?1:0].month   != datetime[DTSWITCH?0:1].month  )
                                             || (datetime[DTSWITCH?1:0].year    != datetime[DTSWITCH?0:1].year   ) );
                            ClockSetDateString( &(datetime[DTSWITCH?1:0]));
                            DTSWITCH = !DTSWITCH;
                            if(UPDATE_HOURS)
                                {
                                    WinSetDlgItemText (hWnd, IDD_TIME, szHours);
                                    if(UPDATE_DATE)
                                        { 
                                            WinSetWindowText(hWndFrame,(PSZ)szTitle);
                                            UPDATE_DATE = FALSE;
                                        }
                                            UPDATE_HOURS = FALSE;
                                }
                            WinSetDlgItemText (hWnd, IDD_SEC, szSecs);
                        }
                    Handled = FALSE;
                    break;
                case WM_SYSCOMMAND:
                case WM_COMMAND:
                    switch (LOUSHORT(mp1))
                      {
                            case SC_CLOSE:
                                hini = HINI_USERPROFILE;
                                WinStopTimer(hab, hWnd, timerID);
                                Pointl.x = Pointl.y = 0;
                                WinMapWindowPoints(hWnd, HWND_DESKTOP, &Pointl, 1);
                                temp = sizeof(POINTL);
                                PrfWriteProfileData(hini, pAppname, pKeyname, &Pointl, temp);
                                WinPostMsg(hWnd, WM_QUIT, 0L, 0L);
                                break;
                            default:
                                Handled = (msg == WM_COMMAND);
                                break;
                        }
                    break; // forget this break and you are in dead trouble !!!
                default:
                    Handled = FALSE;
                    break;
            }
        if (!Handled) mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);
        return (mReturn);
    }
Ejemplo n.º 28
0
//************************************************************************************************
// The allmighty StartupThread
//************************************************************************************************
void _Optlink StartupThread(void *pArg)
{
   AnchorBlock    ab;
   MessageQueue   mq(ab);
   PINITDATA      pinit = (PINITDATA)pArg;
   int            i;
   USHORT         usDeviceIndex = 0;     // default use default deviceindex
   USHORT         usVolume = 75;         // default 75% volume
   ULONG          ulError = 0;           // mci error
   MCI_OPEN_PARMS mciOpenParms;
   BOOL           fDeviceOpen = FALSE;

   //*********************************************************************************************
   // Set the lowest posible priority to make us systemfriendly
   //*********************************************************************************************
   DosSetPriority(PRTYS_THREAD, PRTYC_IDLETIME, PRTYD_MINIMUM, 0);


   //*********************************************************************************************
   // Clear some evetual garbage, just in case....
   //*********************************************************************************************
   WinSetWindowPtr(pinit->hWnd, QWP_PLAYLIST, NULL);
   WinSetWindowPtr(pinit->hWnd, QWP_CURRENTENTRY, NULL);
   WinSetWindowULong(pinit->hWnd, QWL_PLAYLISTENTRIES, 0);
   WinSetWindowUShort(pinit->hWnd, QWS_DEVICEID, 0);
   WinSetWindowULong(pinit->hWnd, QWL_LOOP, 0);   // do not loop by default


   //*********************************************************************************************
   // Parse the commandline
   //*********************************************************************************************
   for(i = 1; i < pinit->argc; i++)
   {
      switch(pinit->argv[i][0])
      {
         case '/':
         case '-':
            switch(pinit->argv[i][1])
            {
               case 'i':
               case 'I':
                  usDeviceIndex = (USHORT)atoi(&pinit->argv[i][2]);
                  break;

               case 'l':
               case 'L':
                  WinSetWindowULong(pinit->hWnd, QWL_LOOP, 1);
                  break;

               case 'v':
               case 'V':
                  usVolume = (USHORT)atoi(&pinit->argv[i][2]);
                  break;
            }
            break;

         default:
            AddToPlaylist(pinit->hWnd, pinit->argv[i]);
            break;
      }
   }

   // make sure we're at the first entry of the playlist
   WinSetWindowPtr(pinit->hWnd, QWP_CURRENTENTRY, WinQueryWindowPtr(pinit->hWnd, QWP_PLAYLIST));


   //*********************************************************************************************
   // open the waveaudio device
   //*********************************************************************************************
   memset((void*)&mciOpenParms, 0, sizeof(mciOpenParms));

   mciOpenParms.pszDeviceType = (PSZ)MAKEULONG(MCI_DEVTYPE_WAVEFORM_AUDIO, usDeviceIndex);
   ulError = mciSendCommand((USHORT)0, MCI_OPEN, MCI_WAIT | MCI_OPEN_TYPE_ID, (PVOID)&mciOpenParms, 0);

   if(LOUSHORT(ulError) == MCIERR_SUCCESS)
   {
      fDeviceOpen = TRUE;
      WinSetWindowUShort(pinit->hWnd, QWS_DEVICEID, mciOpenParms.usDeviceID);
   }

   if((fDeviceOpen == TRUE) && (WinQueryWindowULong(pinit->hWnd, QWL_PLAYLISTENTRIES) != 0))
   {
      MCI_SET_PARMS        msp;

      msp.ulLevel = usVolume;
      msp.ulAudio = MCI_SET_AUDIO_ALL;
      ulError = mciSendCommand(mciOpenParms.usDeviceID, MCI_SET, MCI_WAIT | MCI_SET_AUDIO | MCI_SET_VOLUME, (PVOID)&msp, 0);

      if(LOUSHORT(ulError) == MCIERR_SUCCESS)
      {
         WinSendMsg(WinWindowFromID(pinit->hWnd, SLRD_VOLUME), SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPFROMSHORT(usVolume));
         WinEnableWindow(WinWindowFromID(pinit->hWnd, SLRD_VOLUME), TRUE);
      }

      if((BOOL)WinSendMsg(pinit->hWnd, WMU_LOAD, NULL, NULL))
      {
         WinSendMsg(pinit->hWnd, WMU_PLAY, NULL, NULL);
      }
   }


   //*********************************************************************************************
   // free the initdata buffer
   //*********************************************************************************************
   delete pinit;

   // show the window
   SWP   swp;
   ULONG pulBufferMax = sizeof(swp);
   if(PrfQueryProfileData(HINI_USERPROFILE, "WavePlayer", "WindowPosition", (PVOID)&swp, &pulBufferMax))
      WinSetWindowPos(WinQueryWindow(pinit->hWnd, QW_PARENT), HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_SHOW | SWP_MOVE | SWP_SIZE);
   else
      WinShowWindow(WinQueryWindow(pinit->hWnd, QW_PARENT), TRUE);

   // bye, bye!
   _endthread();
}
Ejemplo n.º 29
0
BOOL launchPad::lpBuildObjectList(char * chrFolderID)
{
  WPObject* wpObject;

  char chrText[200];  
  ULONG ul;

  SOMClass *folderClass;
  WPFolder *wpFolder;
  char chrPath[CCHMAXPATH];
  ULONG ulBufferSize;
  HINI hIni;
  char * memPtr;
  HOBJECT *hObjectArray;
  int a;
  LPObject *lpoTemp;
  WPObject * wpTempObject;


  /* Get toolbar folder */
  if(somIsObj(wpParentFolder)) {
    folderClass=wpParentFolder->somGetClass();
    if(somIsObj(folderClass))
      wpFolder=(WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrFolderID, FALSE);
    if(!somIsObj(wpFolder))
      return FALSE;
  }
  
  /* Build ini name */
  ulBufferSize=sizeof(chrPath);
  wpFolder->wpQueryRealName(chrPath, &ulBufferSize, TRUE);
  strcat(chrPath,"\\objects.ini");/* Ini-File containing the hobjects */
  
  do{
    /* Open the ini-file */
    if((hIni=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),chrPath))==NULLHANDLE)
      break; 
 
    if(!PrfQueryProfileSize(hIni,"objects","handles", &ulBufferSize))
      break;

    if(ulBufferSize==0)
      break;/* No entries yet */

    if((memPtr=(char*)malloc(ulBufferSize))==NULL)
      break;
    
    ulNumObjects=ulBufferSize/sizeof(HOBJECT);    

    if(!PrfQueryProfileData(hIni,"objects","handles", memPtr, &ulBufferSize)){
      free(memPtr);
      break;
    }

    hObjectArray=(HOBJECT*)memPtr;
    ulBufferSize=ulNumObjects;
    for(a=0;a<ulBufferSize && lpoTemp; a++)
      {
        wpTempObject=((M_WPObject*)folderClass)->wpclsQueryObject(hObjectArray[a]);
        if(somIsObj(wpTempObject)) {
          if((lpoTemp=new LPObject(wpTempObject->wpQueryIcon()))!=NULL) {
            lpoTemp->wpObject=wpTempObject;
            wpTempObject->wpLockObject();
            lpoTemp->hObject=hObjectArray[a];
            //            lpoTemp->hPtr=wpTempObject->wpQueryIcon();
            /* Title of the object */
            strncpy(lpoTemp->chrName, wpTempObject->wpQueryTitle(),sizeof(lpoTemp->chrName));
            lpoTemp->lpParent=this;
            
            lpoTemp->lpoNext=lpoObjectList;
            lpoObjectList=lpoTemp;
          }
        }
        else {
          ulNumObjects--;
        }
      }/* for */
    
    free(hObjectArray);
    
    PrfCloseProfile(hIni);
    return TRUE;
  }while(TRUE);

  if(hIni)
    PrfCloseProfile(hIni);
  return FALSE;

}
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Keyboard_FireFox_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Keyboard_ffx;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( KeyMapper.Settings.Define_Dash ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_FireFox.Settings.Dash, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( KeyMapper.Settings.Define_Ctrl_Dash ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_FireFox.Settings.Ctrl_Dash, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Проверяем другие настройки.
   case SM_CHECK_OTHER_SETTINGS:
    {
     CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
     HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

     if( Ini_file )
      {
       ULONG Byte = 0; ULONG Byte_data = 0;
       ULONG CopyPaste_keys_in_VIO = 0; ULONG Mouse_in_VIO = 0;

       Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", INI_CLIPPER_VIO_COPYPASTE, &Byte_data, &Byte ) ) CopyPaste_keys_in_VIO = Byte_data;
       Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", INI_CLIPPER_VIO_MOUSE, &Byte_data, &Byte ) ) Mouse_in_VIO = Byte_data;

       if( !CopyPaste_keys_in_VIO && !Mouse_in_VIO ) WinEnableControl( Window, Keyboard_FireFox.Settings.Dash, 0 );
      }
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Keyboard_FireFox.Settings.Dash )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) KeyMapper.Settings.Define_Dash = 0;
           else KeyMapper.Settings.Define_Dash = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_FireFox.Settings.Ctrl_Dash )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) KeyMapper.Settings.Define_Ctrl_Dash = 0;
           else KeyMapper.Settings.Define_Ctrl_Dash = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Define Dash", &KeyMapper.Settings.Define_Dash, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Define Ctrl + Dash", &KeyMapper.Settings.Define_Ctrl_Dash, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}