Page 1 of 1

Round Button

Posted: Sat Nov 07, 2020 6:23 am
by AUGE_OHR
hi,

under Xbase++ i can use API SetWindowRgn(() to make a round Button

Code: Select all

   hHwnd := oObj:GetHwnd()
   aTmp  := oObj:Currentsize()

   nLeftRect   := 0       +nFrame
   nTopRect    := aTmp[2] -nFrame
   nRightRect  := aTmp[1] -nFrame
   nBottomRect := 0       +nFrame

   // now construct a Region and call its API function
   //
   hRgn := CreateEllipticRgn(nLeftRect,nTopRect,nRightRect,nBottomRect)
   SetWindowRgn(hHwnd,hRgn,.t.)
now it try it under harbour but work only on Form, not on Control :o

Code: Select all

#pragma BEGINDUMP
#define WINVER 0x0501  // minimum requirements: Windows XP
#include <mgdefs.h>

HB_FUNC ( MAKEROUND )
{
   HWND hWnd = ( HWND ) hb_parnl( 1 );
   HRGN hrgn;
   if ( hb_parni(6)==0)
          SetWindowRgn(GetActiveWindow(),NULL,TRUE);
   else
     {
     if ( hb_parni(6)==1 )
        hrgn=CreateRectRgn(hb_parni(2),hb_parni(3),hb_parni(4),hb_parni(5));
     else
        hrgn=CreateEllipticRgn(hb_parni(2),hb_parni(3),hb_parni(4),hb_parni(5));
     SetWindowRgn(hWnd,hrgn,TRUE);
     // Should be hb_parnl(1) instead of GetActiveWindow()
     }
}
#pragma ENDDUMP
who can help me please
KREIS.ZIP
(2.44 KiB) Downloaded 151 times