Page 1 of 2

Aero effect

Posted: Wed Dec 11, 2013 7:28 pm
by meneale
Hello, searching in the web i found methods to make window border bigger and possible to put object inside this area.
But ever i try do it on my application it 'crash' using this command line:
calldll32("DwmExtendFrameIntoClientArea","Dwmapi.dll",getformhandle("Main"),{0,0,0,10})

Re: Aero effect

Posted: Thu Dec 12, 2013 3:31 pm
by srvet_claudio
Hi Meneale.
This is the code for call this function:

Code: Select all

#include "hmg.ch"

Function Main

   DEFINE WINDOW Form_1; 
      AT 0,0; 
      WIDTH 400; 
      HEIGHT 400 ;
      TITLE 'Minimum: Windows Vista';
      MAIN

      @ 150,150 BUTTON Button_1 CAPTION "Set 2" ACTION DwmExtendFrameIntoClientArea (Form_1.HANDLE, -1, 0, 0, 0)

   END WINDOW

// DwmExtendFrameIntoClientArea ( hWnd,          cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight)
   DwmExtendFrameIntoClientArea ( Form_1.HANDLE,          50,           50,         50,            50)

   CENTER WINDOW Form_1
   ACTIVATE WINDOW Form_1
Return Nil



#pragma BEGINDUMP

#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"


#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <Uxtheme.h>
#include "hbapi.h"


VOID *hDWMAPI = NULL;
typedef HRESULT (WINAPI * func_DwmExtendFrameIntoClientArea) (HWND, const MARGINS *);

BOOL HMG_DWMAPI ()
{
   if (hDWMAPI == NULL)
       hDWMAPI = LoadLibrary( _TEXT("Dwmapi.dll") );
   if (hDWMAPI)
      return TRUE;
   else
      return FALSE;
}

//        DwmExtendFrameIntoClientArea (hWnd, cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight)
HB_FUNC ( DWMEXTENDFRAMEINTOCLIENTAREA )
{
   HWND    hWnd = (HWND) hb_parnl (1);
   HRESULT nRet = ( HRESULT ) NULL;
   MARGINS MarInset;
   
   MarInset.cxLeftWidth    = (int) hb_parnl (2);
   MarInset.cxRightWidth   = (int) hb_parnl (3);
   MarInset.cyTopHeight    = (int) hb_parnl (4);
   MarInset.cyBottomHeight = (int) hb_parnl (5);
   
   if( HMG_DWMAPI() )
   {
      func_DwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = ( func_DwmExtendFrameIntoClientArea ) GetProcAddress( hDWMAPI, "DwmExtendFrameIntoClientArea" );
      if( pDwmExtendFrameIntoClientArea )
         nRet = ( HRESULT ) pDwmExtendFrameIntoClientArea ( hWnd, &MarInset );
   }
   hb_retl( ( nRet == S_OK ) );
} 

#pragma ENDDUMP

Re: Aero effect

Posted: Thu Dec 12, 2013 6:37 pm
by Javier Tovar
Hola Cludio,

No logro apreciar el efecto. Utilizo Win 7.

Antes de pulsar el botón:
Pant1.jpg
Pant1.jpg (51.93 KiB) Viewed 5612 times
Después de pulsar el botón:
Pant2.jpg
Pant2.jpg (28.2 KiB) Viewed 5612 times
O qué es lo que se espera?

Saludos

Aero effect

Posted: Thu Dec 12, 2013 7:05 pm
by Pablo César
Javier Tovar wrote:No logro apreciar el efecto. Utilizo Win 7.
+1

Re: Aero effect

Posted: Thu Dec 12, 2013 7:17 pm
by meneale
Thanks Claudio,
And about the problem is because the form has a backcolor, and works if you turn it to full transparency, but the window back is 'untouchable'

Code: Select all

#include "hmg.ch"

Function Main

   DEFINE WINDOW Form_1; 
      AT 0,0; 
      WIDTH 400; 
      HEIGHT 400 ;
      TITLE 'Minimum: Windows Vista';
      BACKCOLOR {255,0,255} ;
      ON INIT SetColorTransparency( getformhandle("form_1"), 0xff00ff );
      MAIN

      @ 150,150 BUTTON Button_1 CAPTION "Set 2" ACTION DwmExtendFrameIntoClientArea (Form_1.HANDLE, -1, 0, 0, 0)

   END WINDOW

// DwmExtendFrameIntoClientArea ( hWnd,          cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight)
   DwmExtendFrameIntoClientArea ( Form_1.HANDLE,          50,           50,         50,            50)

   CENTER WINDOW Form_1
   ACTIVATE WINDOW Form_1
Return Nil

#define GWL_EXSTYLE (-20) 

#define WS_EX_LAYERED 524288 
#define LWA_COLORKEY 1 
#define LWA_ALPHA 2 

/* 
*/ 
SetWindowLong( hWnd, GWL_EXSTYLE, HB_BITOR( 0, WS_EX_LAYERED ) ) 

nRet := SetLayeredWindowAttributes( hWnd, 0, nAlpha, LWA_ALPHA ) 
IF VALTYPE(nRet) == 'N' 
	lRet := ( nRet > 0 ) 
ENDIF 

RETURN( lRet ) 

/* 
*/ 
FUNCTION SetColorTransparency( hWnd, nColor ) 
LOCAL nRet, lRet := .F. 

SetWindowLong( hWnd, GWL_EXSTYLE, HB_BITOR( 0, WS_EX_LAYERED ) ) 

nRet := SetLayeredWindowAttributes( hWnd, nColor, 0, LWA_COLORKEY ) 
IF VALTYPE(nRet) == 'N' 
	lRet := ( nRet > 0 ) 
ENDIF 

RETURN( lRet ) 


#pragma BEGINDUMP

#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"


#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <Uxtheme.h>
#include "hbapi.h"


VOID *hDWMAPI = NULL;
typedef HRESULT (WINAPI * func_DwmExtendFrameIntoClientArea) (HWND, const MARGINS *);

BOOL HMG_DWMAPI ()
{
   if (hDWMAPI == NULL)
       hDWMAPI = LoadLibrary( _TEXT("Dwmapi.dll") );
   if (hDWMAPI)
      return TRUE;
   else
      return FALSE;
}

//        DwmExtendFrameIntoClientArea (hWnd, cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight)
HB_FUNC ( DWMEXTENDFRAMEINTOCLIENTAREA )
{
   HWND    hWnd = (HWND) hb_parnl (1);
   HRESULT nRet = ( HRESULT ) NULL;
   MARGINS MarInset;
   
   MarInset.cxLeftWidth    = (int) hb_parnl (2);
   MarInset.cxRightWidth   = (int) hb_parnl (3);
   MarInset.cyTopHeight    = (int) hb_parnl (4);
   MarInset.cyBottomHeight = (int) hb_parnl (5);
   
   if( HMG_DWMAPI() )
   {
      func_DwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = ( func_DwmExtendFrameIntoClientArea ) GetProcAddress( hDWMAPI, "DwmExtendFrameIntoClientArea" );
      if( pDwmExtendFrameIntoClientArea )
         nRet = ( HRESULT ) pDwmExtendFrameIntoClientArea ( hWnd, &MarInset );
   }
   hb_retl( ( nRet == S_OK ) );
} 

#pragma ENDDUMP

Re: Aero effect

Posted: Thu Dec 12, 2013 7:51 pm
by Javier Tovar
OK, ya salio como lo puso el amigo meneale...

Saludos

Re: Aero effect

Posted: Thu Dec 12, 2013 7:55 pm
by srvet_claudio
Pablo César wrote:
Javier Tovar wrote:No logro apreciar el efecto. Utilizo Win 7.
+1
This demo is equivalent to the previous code of Meneale.

Code: Select all

#include "hmg.ch"

Function Main

   DEFINE WINDOW Form_1; 
      AT 0,0; 
      WIDTH 400; 
      HEIGHT 400 ;
      TITLE 'Minimum: Windows Vista';
      ON INIT (SET WINDOW Form_1 TRANSPARENT TO COLOR BLUE );
      BACKCOLOR BLUE;
      MAIN

      @ 150,150 BUTTON Button_1 CAPTION "Set 2" ACTION DwmExtendFrameIntoClientArea (Form_1.HANDLE, -1, 0, 0, 0)

   END WINDOW

// DwmExtendFrameIntoClientArea ( hWnd,          cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight)
   DwmExtendFrameIntoClientArea ( Form_1.HANDLE,          50,           50,         50,            50)

   CENTER WINDOW Form_1
   ACTIVATE WINDOW Form_1
Return Nil



#pragma BEGINDUMP

#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"


#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <Uxtheme.h>
#include "hbapi.h"


VOID *hDWMAPI = NULL;
typedef HRESULT (WINAPI * func_DwmExtendFrameIntoClientArea) (HWND, const MARGINS *);

BOOL HMG_DWMAPI ()
{
   if (hDWMAPI == NULL)
       hDWMAPI = LoadLibrary( _TEXT("Dwmapi.dll") );
   if (hDWMAPI)
      return TRUE;
   else
      return FALSE;
}

//        DwmExtendFrameIntoClientArea (hWnd, cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight)
HB_FUNC ( DWMEXTENDFRAMEINTOCLIENTAREA )
{
   HWND    hWnd = (HWND) hb_parnl (1);
   HRESULT nRet = ( HRESULT ) NULL;
   MARGINS MarInset;
   
   MarInset.cxLeftWidth    = (int) hb_parnl (2);
   MarInset.cxRightWidth   = (int) hb_parnl (3);
   MarInset.cyTopHeight    = (int) hb_parnl (4);
   MarInset.cyBottomHeight = (int) hb_parnl (5);
   
   if( HMG_DWMAPI() )
   {
      func_DwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = ( func_DwmExtendFrameIntoClientArea ) GetProcAddress( hDWMAPI, "DwmExtendFrameIntoClientArea" );
      if( pDwmExtendFrameIntoClientArea )
         nRet = ( HRESULT ) pDwmExtendFrameIntoClientArea ( hWnd, &MarInset );
   }
   hb_retl( ( nRet == S_OK ) );
} 

#pragma ENDDUMP

Re: Aero effect

Posted: Thu Dec 12, 2013 8:37 pm
by Javier Tovar
Ok Claudio, excelente!

Gracias por compartir :D

Saludos

Aero effect

Posted: Thu Dec 12, 2013 8:43 pm
by Pablo César
Now ok, both examples.

Thank very much for sharing Meneale and Claudio !

Looks very nice windows ! :)

Re: Aero effect

Posted: Sun Dec 15, 2013 1:37 pm
by bpd2000
Pablo César wrote:Now ok, both examples.

Thank very much for sharing Meneale and Claudio !

Looks very nice windows ! :)
+1