Aero effect

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
meneale
Posts: 51
Joined: Sat Jan 12, 2013 2:05 am
Location: Campinas -SP, Brasil

Aero effect

Post 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})
Attachments
Like this
Like this
frameintoclientarea.PNG (127.9 KiB) Viewed 5711 times
AMD Phenom II X6 1090T 3.2GHz (OverClock 3.9GHz) | Windows 8.1 Pro 64-bit
4GB DDR3 | GTX 550 Ti 1GB | MSI 880GMA-E35
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Aero effect

Post 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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Aero effect

Post 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 5597 times
Después de pulsar el botón:
Pant2.jpg
Pant2.jpg (28.2 KiB) Viewed 5597 times
O qué es lo que se espera?

Saludos
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Aero effect

Post by Pablo César »

Javier Tovar wrote:No logro apreciar el efecto. Utilizo Win 7.
+1
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
meneale
Posts: 51
Joined: Sat Jan 12, 2013 2:05 am
Location: Campinas -SP, Brasil

Re: Aero effect

Post 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
Attachments
Final effect
Final effect
dwm.jpg (24.37 KiB) Viewed 5587 times
AMD Phenom II X6 1090T 3.2GHz (OverClock 3.9GHz) | Windows 8.1 Pro 64-bit
4GB DDR3 | GTX 550 Ti 1GB | MSI 880GMA-E35
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Aero effect

Post by Javier Tovar »

OK, ya salio como lo puso el amigo meneale...

Saludos
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Aero effect

Post 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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Aero effect

Post by Javier Tovar »

Ok Claudio, excelente!

Gracias por compartir :D

Saludos
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Aero effect

Post by Pablo César »

Now ok, both examples.

Thank very much for sharing Meneale and Claudio !

Looks very nice windows ! :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Aero effect

Post by bpd2000 »

Pablo César wrote:Now ok, both examples.

Thank very much for sharing Meneale and Claudio !

Looks very nice windows ! :)
+1
BPD
Convert Dream into Reality through HMG
Post Reply