CreateEllipticRgn / CreateRectRgn

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

CreateEllipticRgn / CreateRectRgn

Post by AUGE_OHR »

hi,

i wonder that i found nothing about CreateEllipticRgn / CreateRectRgn

https://docs.microsoft.com/en-us/window ... llipticrgn
https://docs.microsoft.com/en-us/window ... aterectrgn

this is my Xbase++ Code to make a "Mask" for a Control

Code: Select all

FUNCTION API_SetRegion( oXbp, aRegion )
LOCAL nDLL,nDLL2, hRgn,hAdd, nX, hComb, nRet
   IF EMPTY( aRegion )
      RETURN NIL
   Endif

   nDLL := DLLLOAD( 'GDI32.DLL' )
   If nDll <> 0
      /* Create first region */
      hRgn := DLLCALL( nDLL, DLL_STDCALL,"CreateRectRgn", aRegion[1,1],;
                                                          aRegion[1,2],;
                                                          aRegion[1,3],;
                                                          aRegion[1,4] )
      FOR nX := 2 to Len( aRegion )
         /*create all the other regions and combine them with the first*/
         hAdd := DLLCALL( nDLL, DLL_STDCALL,"CreateRectRgn", aRegion[nX,1],;
                                                             aRegion[nX,2],;
                                                             aRegion[nX,3],;
                                                             aRegion[nX,4] )

         nRet := DLLCALL( nDll, DLL_STDCALL, "CombineRgn", hRgn, hRgn, hAdd, RGN_OR )

         /*discard this region (no longer needed) */
         DLLCALL( nDll, DLL_STDCALL,"DeleteObject", hAdd )
      NEXT

      nDll2 := DLLLoad( 'USER32.DLL' )
      /*call windows to create the region */
      DLLCALL( nDll2, DLL_STDCALL, "SetWindowRgn", oXbp:GetHwnd(), hRgn, 1 )
      DLLUNLOAD(nDll)
      DLLUNLOAD( nDll2 )

   ENDIF
RETURN NIL
as you see it need an Handle of Control ( oXbp:GetHwnd() )
this is where i fail as harbour / HMG Newbie :(

btw. how to create a Form :idea:
1.) without Titlebar
2.) no Frame
3.) "inside" Transparent
4.) place a Bitmap "inside"

need : Handle of Form for this
CreateRectRgn.jpg
CreateRectRgn.jpg (228.95 KiB) Viewed 4316 times
have fun
Jimmy
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: CreateEllipticRgn / CreateRectRgn

Post by andyglezl »

btw. how to create a Form :idea:
1.) without Titlebar
2.) no Frame
3.) "inside" Transparent
4.) place a Bitmap "inside"

\HMG\3.4.4\SAMPLES\Miscellaneous\ScreenSplash
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CreateEllipticRgn / CreateRectRgn

Post by AUGE_OHR »

hi,
andyglezl wrote: Thu Oct 31, 2019 4:30 pm \HMG\3.4.4\SAMPLES\Miscellaneous\ScreenSplash
Yes the Splash Sample is nice and i learn

Code: Select all

   NOSYSMENU;
   NOSIZE;
   NOMINIMIZE;
   NOMAXIMIZE; 
   NOCAPTION;
   TOPMOST;
so i get a Windows without anything ... but i need a Windows Handle for API Function

i found out that i get Handle "when" it i have a TITLE

Code: Select all

   hWnd := GetFormHandle(cWindow)
but if i have NOCAPTION ... how to get Handle :?:
have fun
Jimmy
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: CreateEllipticRgn / CreateRectRgn

Post by andyglezl »

You try with ? [ TITLE <cTitle> ]
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: CreateEllipticRgn / CreateRectRgn

Post by bpd2000 »

Replace line no 58 of \HMG\3.4.4\SAMPLES\Miscellaneous\ScreenSplash
with following code

@ 0, 0 IMAGE Image_1 PICTURE cFileName ON CLICK (MsgInfo ("Splash Image"),MsgInfo (ThisWindow.Handle,"Form_Handle"))
BPD
Convert Dream into Reality through HMG
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CreateEllipticRgn / CreateRectRgn

Post by AUGE_OHR »

hi,

thx for Answer.

i got it ... so far
SetRegion_1.zip
(101.93 KiB) Downloaded 178 times

Code: Select all

   IF HMG_GetImageInfo (cFileName, @Image_Width, @Image_Height, @Image_BackColor) == .F.
i have look into c:\hmg.3.4.4\SOURCE\h_image.prg
it get Information but than close all.

Code: Select all

      @ 0, 0 IMAGE Image_1 PICTURE cFileName ON CLICK MsgInfo ("Splash Image")
does it "load" Image in this line :?:

my Problem : i need to "resize" Image .

now Image must be same Size as Form_Splash else my Array does not work correct.

---

i try to "Print Screen" but it did not show in Clipboard, why :o
got it ... focus was not on desktop
HMG_Region.jpg
HMG_Region.jpg (22.27 KiB) Viewed 3641 times
Last edited by AUGE_OHR on Fri Nov 01, 2019 6:23 am, edited 1 time in total.
have fun
Jimmy
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: CreateEllipticRgn / CreateRectRgn

Post by bpd2000 »

Refer examples at you will get Image related solution
C:\hmg\SAMPLES\BosTaurus
BPD
Convert Dream into Reality through HMG
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CreateEllipticRgn / CreateRectRgn

Post by AUGE_OHR »

bpd2000 wrote: Fri Nov 01, 2019 5:35 am Refer examples at you will get Image related solution
C:\hmg\SAMPLES\BosTaurus
WOW ...

Demo 2,4 amd 6 are resize able so i will have a look at it.

Demo2 : Gradiant is "painting"
Demo4 : ON PAINT Proc_ON_PAINT ();
Demo6 : ON PAINT Proc_ON_PAINT ()

Code: Select all

   BT_CreateDC (...)
   BT_DrawBitmap (hDC, 20, 20, Width, Height, BT_SCALE, hBitmap)
but this "paint" it "only" into hDC of "Win1"

i like to have a empty Second Bitmap at start and "paint" Original Bitmap into it

Code: Select all

  hdcSource = CreateCompatibleDC(hdc);
  hBitmap1 = LoadImage(GetModuleHandle(NULL), BmpRes, IMAGE_BITMAP, nWidth, nHeight, LR_DEFAULTCOLOR);
  SelectObject(hdcSource, hBitmap1);

  hdcTarget = CreateCompatibleDC(hdc);
  hBitmap2 = CreateCompatibleBitmap(hdcSource, iExpWidth, iExpHeight);
  SelectObject(hdcTarget, hBitmap2);

  bResult = StretchBlt( hdcTarget, 0, 0, iExpWidth, iExpHeight, hdcSource, 0, 0, iWidth, iHeight, SRCCOPY );

  return hBitmap2;
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CreateEllipticRgn / CreateRectRgn

Post by AUGE_OHR »

hi,

i found this Code

Code: Select all

#pragma BEGINDUMP
#include <mgdefs.h>

HB_FUNC( CREATERECTRGN )
{
   HRGN hRgn = CreateRectRgn( hb_parni( 1 ), hb_parni( 2 ),
                              hb_parni( 4 ), hb_parni( 3 ) );

//   RegisterResource( hRgn, "REGION" );

   #ifndef _WIN64
      hb_retnl( ( LONG ) hRgn );
   #else
      hb_retnll( ( LONGLONG ) hRgn );
   #endif
}

//----------------------------------------------------------------------------//

HB_FUNC( COMBINERGN )
{
   #ifndef _WIN64
      HRGN hrgnDest = ( HRGN ) hb_parnl( 1 );
      HRGN hrgnSrc1 = ( HRGN ) hb_parnl( 2 );
      HRGN hrgnSrc2 = ( HRGN ) hb_parnl( 3 );
   #else
      HRGN hrgnDest = ( HRGN ) hb_parnll( 1 );
      HRGN hrgnSrc1 = ( HRGN ) hb_parnll( 2 );
      HRGN hrgnSrc2 = ( HRGN ) hb_parnll( 3 );
   #endif
   int fnCombineMode = hb_parni( 4 ) ;

   hb_retni( CombineRgn( hrgnDest, hrgnSrc1, hrgnSrc2, fnCombineMode ) );
}

#pragma ENDDUMP
it seems to compile and run but Result ... it seems me not the same like i got with DllCall() :?:

my Problem : i can't activate HbXpp with Extended Version so DllCall() does not work. :(
so i try HB_FUNC but i'm not happy with Result.

what i want a "7-Segment LCD" like this
7_Segment.jpg
7_Segment.jpg (12.41 KiB) Viewed 3525 times
here data for aRegion

Code: Select all

// aSize := {100,300}
FUNCTION MaskItemArray()
LOCAL aRegion := {}
   // 1
   AADD( aRegion, { 5, 160, 20 + 9, 250 } )                 //      Balken links Oben
   AADD( aRegion, { 5 + 8, 251, 21, 259 } )                 // Nase Balken links Oben   oben
   AADD( aRegion, { 5 + 8, 151, 21, 159 } )                 // Nase Balken links Oben   unten
   // 4
   AADD( aRegion, { 5, 39, 20 + 9, 128 } )                  //      Balken links unten
   AADD( aRegion, { 5 + 8, 129, 21, 137 } )                 // Nase Balken links unten  oben
   AADD( aRegion, { 5 + 8, 30, 21, 38 } )                   // Nase Balken links unten  unten
   // 7
   AADD( aRegion, { 21 + 9, 252, 70 + 9, 280 } )            //      Balken Mitte Oben
   AADD( aRegion, { 21, 260, 29, 272 } )                    // Nase Balken Mitte Oben   links
   AADD( aRegion, { 80, 260, 88, 272 } )                    // Nase Balken Mitte Oben   rechts
   // 10
   AADD( aRegion, { 21 + 9, 130, 70 + 9, 158 } )            //      Balken Mitte Mitte
   AADD( aRegion, { 21, 138, 29, 150 } )                    // Nase Balken Mitte Mitte  links
   AADD( aRegion, { 80, 138, 88, 150 } )                    // Nase Balken Mitte Mitte  rechts
   // 13
   AADD( aRegion, { 21 + 9, 9, 70 + 9, 37 } )               //      Balken Mitte Unten
   AADD( aRegion, { 21, 17, 29, 29 } )                      // Nase Balken Mitte Unten  links
   AADD( aRegion, { 80, 17, 88, 29 } )                      // Nase Balken Mitte Unten  rechts
   // 16
   AADD( aRegion, { 81, 160, 96 + 9, 250 } )                //      Balken Rechts oben
   AADD( aRegion, { 81 + 8, 251, 97, 259 } )                // Nase Balken Rechts oben  oben
   AADD( aRegion, { 81 + 8, 151, 97, 159 } )                // Nase Balken Rechts oben  unten
   // 19
   AADD( aRegion, { 81, 39, 96 + 9, 128 } )                 //      Balken Rechts unten
   AADD( aRegion, { 81 + 8, 129, 97, 137 } )                // Nase Balken Rechts unten oben
   AADD( aRegion, { 81 + 8, 30, 97, 38 } )                  // Nase Balken Rechts unten unten
   // 22
   AADD( aRegion, { 40, 70, 60, 100 } )
   AADD( aRegion, { 40, 200, 60, 230 } )

#IFDEF __XPP__
   // 0,0 is Bottom left 
#ELSE
   AEVAL(aRegion, {|x| x[4] := ABS(300-x[4]) }  )
   AEVAL(aRegion, {|x| x[2] := ABS(300-x[2]) }  )
#ENDIF

RETURN aRegion
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CreateEllipticRgn / CreateRectRgn

Post by AUGE_OHR »

hi,

now i got it with DllCall working so far ... only Bitmap / Color still is not what i want
HMG_UHR01.jpg
HMG_UHR01.jpg (117.59 KiB) Viewed 3512 times
upper ist HMG Version and lower is my Xbase++ App

here hole HMG Project
HMG_UHR1.zip
(31.86 KiB) Downloaded 161 times
have fun

---

i like to have 8 "Parts" of Bitmap while i use 8 x Form and all together are what i want.
this is my Xbase++ Code to split Bitmap

Code: Select all

STATIC FUNCTION BMPsplit( oBMP, aXbpSize, nAnzahl, lSave )
LOCAL oHuge,oTiny,oPS,oRet,nBits,nPlanes,nSizeX,nSizeY,nSteps, i
LOCAL aBMP    := {}
   DEFAULT lSave TO .F.
   IF aXbpSize[ 2 ] > 0
      oHuge := oBMP
      nBits := oBMP:bits
      nPlanes := oBMP:planes
  // create with this size
      nSizeX := oBMP:xSize
      nSizeY := oBMP:ySize
      nSteps := INT( nSizeX / nAnzahl )

      FOR i := 1 TO nAnzahl
  // create a empty Bitmap
         oTiny := XBPBITMAP() :New() :Create()
         oTiny:Make( aXbpSize[ 1 ], aXbpSize[ 2 ], nPlanes, nBits )
         oPS := XBPPRESSPACE() :new()
         oTiny:presSpace( oPS )
   // draw Part of Original Bitmap to new Bitmap
         oHuge:Draw( oPS, { 0, 0, aXbpSize[ 1 ], aXbpSize[ 2 ] }, ;
                            { nSteps * ( i - 1 ), 0, nSteps * ( i ), nSizeY }, ;
                            ,, GRA_BLT_BBO_IGNORE )
    // add Object to Array
         AADD( aBMP, oTiny )
         
         IF lSave
            oTiny:saveFile( "TEST" + STRZERO( i, 2 ) + ".JPG", XBPBMP_FORMAT_JPG )
         ENDIF
         Sleep( 1 )
         oPS := NIL
      NEXT
   ENDIF
RETURN aBMP
so i need to learn how to "draw" Part of a Bitmap into new empty Bitmap in harbour / HMG

---

this is at Create Sub-Form

Code: Select all

         @ 0,0 IMAGE &cImage ;
            PICTURE aLights[i][1] ;
            WIDTH aSubSize[ 1 ] HEIGHT aSubSize[ 2 ] ;
            STRETCH
now i want to change PICTURE
i found this Code

Code: Select all

   cIdx := STRZERO(nIDig,2)
   cForm := "Form_" + cIdx   // Form_01
   cImage := "Image_"+cIdx   // Image_01
   SetProperty( "Form_" + cIdx, "Image_" + cIdx, 'Picture', a_Digit[nNr+1] )
but it does not change PICTURE :(

who can help me please.
have fun
Jimmy
Post Reply