IsAppThemed()

IsAppThemed()

Postby Juan Gálvez » Wed Sep 15, 2010 9:52 am

Hola Antonio,

Estoy probando FWH 10.08 y observo que IsAppThemed() sigue devolviendo .T. aún sin temas activos.

¿ Recuerdas nuestra última conversación ?

¿ Cómo quedará finalmente ?

Gracias y saludos
Juan
Juan Gálvez
 
Posts: 14
Joined: Fri Oct 21, 2005 10:05 am

Re: IsAppThemed()

Postby Antonio Linares » Wed Sep 15, 2010 10:13 am

Juan,

Este es el código fuente de la función IsAppThemed() de FWH. Si encontramos la manera de mejorarla, bienvenida sea :-)
Code: Select all  Expand view
BOOL _IsAppThemed( void )
{
   static BOOL bInit = FALSE;
   static BOOL bIsThemed = FALSE;

   InitThemes();

   if( pIsAppThemed && ! bInit )
   {
      WIN32_FIND_DATA fd;
    
      bInit = TRUE;
      bIsThemed = ( ( ( BOOL ) FindResource( GetResources(), MAKEINTRESOURCE( 1 ),
                  MAKEINTRESOURCE( 24 ) ) ) ||
                  ( ( BOOL ) FindResource( GetInstance(), MAKEINTRESOURCE( 1 ),
                  MAKEINTRESOURCE( 24 ) ) ) || pIsAppThemed() );
                 
      if( ! bIsThemed )
      {
         char AppName[ 256 ];
         HANDLE hFind;
       
         GetModuleFileName( NULL, AppName, 255 );
         lstrcat( AppName, ".Manifest" );
         
         if( ( hFind = FindFirstFile( AppName, &fd ) ) != INVALID_HANDLE_VALUE )
         {
            bIsThemed = TRUE;
            FindClose( hFind );
         }
      }      
   }

   if( pIsAppThemed != NULL )
      return bIsThemed;
   else
      return FALSE;
}
 

la función InitThemes() se encarga de cargar la DLL y de inicializar el valor de pIsAppThemed, que es un puntero a función.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41320
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: IsAppThemed()

Postby Antonio Linares » Wed Sep 15, 2010 10:16 am

Code: Select all  Expand view
typedef BOOL ( __stdcall * PFNISAPPTHEMED ) ( void );

static PFNISAPPTHEMED pIsAppThemed = NULL;
static HMODULE hDLL = NULL;

static void InitThemes( void )
{
   static BOOL bInit = FALSE;

   if( bInit )
      return;
   else
      bInit = TRUE;

   if( hDLL == NULL )
   {
      if( hDLL = LoadLibrary( "UXTHEME.DLL" ) )
      {
         pIsAppThemed = ( PFNISAPPTHEMED ) GetProcAddress( hDLL, "IsAppThemed" );
      }
   }
}
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41320
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: IsAppThemed()

Postby Antonio Linares » Sat Sep 25, 2010 7:45 am

Juan,

Has modificado la función ?

Le has encontrado algún fallo ?

gracias,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41320
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: IsAppThemed()

Postby carlos vargas » Tue Oct 19, 2010 4:58 am

Antonio, una consulta, viendo el codigo puesto por ti,

static PFNISAPPTHEMED pIsAppThemed = NULL;

lo defines como una variable estatica, pero luego mas adelante lo usas como una funcion, es correcto, esto? o es una funcion realmente y no puedes postear el codigo?

bIsThemed = ( ( ( BOOL ) FindResource( GetResources(), MAKEINTRESOURCE( 1 ), MAKEINTRESOURCE( 24 ) ) ) ||
( ( BOOL ) FindResource( GetInstance(), MAKEINTRESOURCE( 1 ), MAKEINTRESOURCE( 24 ) ) ) || pIsAppThemed() ) /*funcion o var?*/



otra cosa, pudieras postear el codigo de estas funciones para "poder compilar y hacer pruebas", please, no sueltas como lo has hecho.
se que son func restringidas, pero talvez ayude alguien a encontrar la solucion.
por ejemplo si es posible un archivo theme_test.c conteniendo lo necesario para compilar y probar.

salu2
carlos vargas

Code: Select all  Expand view

BOOL _IsAppThemed( void )
{
   static BOOL bInit = FALSE;
   static BOOL bIsThemed = FALSE;

   InitThemes();

   if( pIsAppThemed && ! bInit )
   {
      WIN32_FIND_DATA fd;
   
      bInit     = TRUE;
      bIsThemed = ( ( ( BOOL ) FindResource( GetResources(), MAKEINTRESOURCE( 1 ), MAKEINTRESOURCE( 24 ) ) ) ||
                    ( ( BOOL ) FindResource( GetInstance(),  MAKEINTRESOURCE( 1 ), MAKEINTRESOURCE( 24 ) ) ) || pIsAppThemed() )         /*ACA pIsAppThemed es funcion o var, creo que deberia ser una var*/

    ....
 



salu2
carlos vargas
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1688
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: IsAppThemed()

Postby Antonio Linares » Tue Oct 19, 2010 7:04 am

Carlos,

Esa variable contendrá un puntero cargado desde uxtheme.dll al que se puede llamar como si fuese una función :-)

En él código que he publicado esta todo. Solo tienes que compilarlo :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41320
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: IsAppThemed()

Postby Patricio Avalos Aguirre » Wed Oct 27, 2010 3:30 pm

Estimados

he colocado esta funcion en mi sistema

Code: Select all  Expand view
function IsAppThemed()
return( .f. )
 


puede producir algun problema posterior

lo comento porque con esta funcion elimino el problema de presionar la tecla ALT y desaparezcan la informacion en pantalla
aunque tenga en el recurso MANIFIEST

Code: Select all  Expand view
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    type="win32"
    name="MyOrganization.MyDivision.MyApp"
    version="1.0.0.0"
    processorArchitecture="X86"
    />
    <description>Verbal description of MyApp.</description>
    <dependency>
    <dependentAssembly>
    <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="X86"
        publicKeyToken="6595b64144ccf1df"
        language="*"
    />
    </dependentAssembly>
    </dependency>
</assembly>
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
User avatar
Patricio Avalos Aguirre
 
Posts: 1059
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: IsAppThemed()

Postby carlos vargas » Mon Nov 08, 2010 9:21 pm

Pues he probado con winxp/win7 y las respuestas de la funciones isappthemed y istheme active son correctas con thema y sin thema,
con el manifest en el exe incrustado o como archivo externo, por lo que no hallo falla. :-(
aunque aprendi algunas consillas en c como los punteros a funciones. ;-)
aca dejo los ficheros de prueba por si algien les mete mano.

theme.prg
Code: Select all  Expand view

#include "fivewin.ch"

procedure main()
   
   ?"Hola Mundo"
   ?"IsAppThemed:",IsAppThemed()   //original de fwh
   ?"IsActive:",IsThemeActive()         //original de fwh
   
   ?"IsAppThemed:",IsAppThemed2()  //las aca incluidas
   ?"IsActive:",IsThemeActive2()        //las aca incluidas

   CloseTheme()
   
return

#pragma BEGINDUMP


/*----------------------------------------------------------------------------*/

#include "hbapi.h"
#include "windows.h"
#include "uxtheme.h"

/*----------------------------------------------------------------------------*/

typedef BOOL ( __stdcall * PFNISAPPTHEMED ) ( void );
typedef BOOL ( __stdcall * PFNISTHEMEACTIVE ) ( void );

static HMODULE        hDLL         = NULL;
static PFNISAPPTHEMED pIsAppThemed = NULL;

static void InitThemes( void );
BOOL _IsAppThemed( void );
BOOL _IsThemeActive( void );
BOOL _CloseTheme(void);

/*----------------------------------------------------------------------------*/

HB_FUNC( ISAPPTHEMED2 )
{
   hb_retl( _IsAppThemed() );
}

HB_FUNC( ISTHEMEACTIVE2 )
{
   hb_retl( _IsThemeActive() );
}

HB_FUNC( CLOSETHEME )
{
   hb_retl( _CloseTheme() );
}

/*----------------------------------------------------------------------------*/

static void InitThemes( void )
{
   /*inicializa variable estatica*/
   static BOOL bInit = FALSE;

   /*valida con variable estatica que la funcion se ejecute solo una vez*/
   if( bInit )
   {
      return;
   }
   else
   {
      bInit = TRUE;
   }


   if( hDLL == NULL )
   {

      /*carga dll que manipula los temas*/
      if( hDLL = LoadLibrary( "UXTHEME.DLL" ) )
      {

         /*obtiene puntero a funcion IsAppThemed contenida en la dll cargada previamente*/
         pIsAppThemed = ( PFNISAPPTHEMED ) GetProcAddress( hDLL, "IsAppThemed" );

      }

   }

}

/*----------------------------------------------------------------------------*/

BOOL _IsAppThemed( void )
{
   /*inicializa variables estaticas*/
   static BOOL bInit     = FALSE;
   static BOOL bIsThemed = FALSE;

   /*obtiene puntero de la funcion IsAppThemed*/
   InitThemes();

   if( pIsAppThemed && ! bInit )
   {

      WIN32_FIND_DATA fd;

      bInit     = TRUE;
      bIsThemed = ( ( ( BOOL ) FindResource( GetResources(), MAKEINTRESOURCE( 1 ), MAKEINTRESOURCE( 24 ) ) ) ||
                  (   ( BOOL ) FindResource( GetInstance(),  MAKEINTRESOURCE( 1 ), MAKEINTRESOURCE( 24 ) ) ) || pIsAppThemed() );

      if( ! bIsThemed )
      {
         char AppName[ 256 ];
         HANDLE hFind;

         GetModuleFileName( NULL, AppName, 255 );
         lstrcat( AppName, ".Manifest" );

         if( ( hFind = FindFirstFile( AppName, &fd ) ) != INVALID_HANDLE_VALUE )
         {
            bIsThemed = TRUE;
            FindClose( hFind );
         }

      }

   }

   if( pIsAppThemed != NULL )
   {
      return bIsThemed;
   }
   else
   {
      return FALSE;
   }

}

/*----------------------------------------------------------------------------*/

BOOL _IsThemeActive( void )
{
   PFNISTHEMEACTIVE pIsThemeActive = NULL;  

   if( hDLL != 0 )
   {
      /*puntero a funcion IsThemeActive*/
      pIsThemeActive = ( PFNISTHEMEACTIVE ) GetProcAddress( hDLL, "IsThemeActive" );
   
      /*ejecuta funcion*/
      if( pIsThemeActive() )
      {
         return TRUE;
      }
   
   }
   return FALSE;

}

/*----------------------------------------------------------------------------*/

BOOL _CloseTheme( void )
{
   BOOL bClose = FALSE;

   if( hDLL != 0 )
   {
      bClose = FreeLibrary( hDLL );  
   }

   return bClose;
}

#pragma ENDDUMP


/* codigo tomado de internet como ejemplo.
bool bReturn = false;
HMODULE hDll = ::LoadLibrary(_T("UxTheme.dll"));
if( hDll )
{
typedef BOOL(*THEMEACTIVE)(VOID);

THEMEACTIVE pIsThemeActive = (THEMEACTIVE)GetProcAddress(hDll, "IsThemeActive");
if( pIsThemeActive )
bReturn = pIsThemeActive();
::FreeLibrary( hDll );
}
return bReturn;

*/

 


theme.rc
Code: Select all  Expand view

// Generated by ResEdit 1.5.4
// Copyright (C) 2006-2010
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"




//
// Manifest resources
//
1                  RT_MANIFEST    ".\\manifest.xml"
 


y el archivo manifest.xml
Code: Select all  Expand view

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1688
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 6 guests