Drawing on a groupbox

Drawing on a groupbox

Postby Enrico Maria Giordano » Tue May 08, 2012 9:04 am

Is there any chances I can see the result of WndBox() call in the following sample as it is?

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    oDlg:nStyle = NOR( oDlg:nStyle, WS_CLIPCHILDREN, WS_THICKFRAME )

    @ 1, 1 GROUP TO 15, 30;
           PROMPT "This is a test";
//           TRANSPARENT

    ACTIVATE DIALOG oDlg;
             ON PAINT TEST( hDC );
             CENTER

    RETURN NIL


STATIC FUNCTION TEST( hDC )

    WNDBOX( hDC, 50, 50, 100, 100 )

    RETURN NIL


Thank you.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a groupbox

Postby nageswaragunupudi » Tue May 08, 2012 6:33 pm

We can see the result of WndBox() if
1) WS_CLIPCHILDREN style is NOT set
and
2) Group control is assigned Transparent property.

In my opinion,

1) When WS_CLIPCHILDREN style is specified, area occupied by the child windows is excluded while painting the parent window. WndBox() falls in the excluded area and is therefore not painted.

2) Because controls are painted after the parent window's background is painted, the Group box masks the WndBox(), unless its transparent property is set to true.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Drawing on a groupbox

Postby Enrico Maria Giordano » Tue May 08, 2012 9:35 pm

nageswaragunupudi wrote:We can see the result of WndBox() if
1) WS_CLIPCHILDREN style is NOT set
and
2) Group control is assigned Transparent property.

In my opinion,

1) When WS_CLIPCHILDREN style is specified, area occupied by the child windows is excluded while painting the parent window. WndBox() falls in the excluded area and is therefore not painted.


Please try this sample. As you can see, the GET is visible. How can I get the rectangle visible too?

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 35 )

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    oDlg:nStyle = NOR( oDlg:nStyle, WS_CLIPCHILDREN, WS_THICKFRAME )

    @ 1, 1 GROUP TO 15, 30;
           PROMPT "This is a test";
//           TRANSPARENT

    @ 3, 3 GET cVar

    ACTIVATE DIALOG oDlg;
             ON PAINT TEST( hDC );
             CENTER

    RETURN NIL


STATIC FUNCTION TEST( hDC )

    WNDBOX( hDC, 50, 50, 100, 100 )

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a groupbox

Postby ukoenig » Tue May 08, 2012 11:30 pm

Enrico,

A visible Group and Box :

Image

Image

Image

Image

Code: Select all  Expand view

#include "FiveWin.ch"
#include "Image.ch"

STATIC hDC, oFont, nDStyle

// ------- DIALOG from Code ---------------

FUNCTION Main()
LOCAL nSWidth := GetSysMetrics(0), nSHeight := GetSysMetrics(1)
local oDlg1, oGrp1, oGet
LOCAL cVar := SPACE( 35 )

oFont := TFont():New("Arial",0,-14,.F.,.T.,0,0,0,.T. )
SET _3DLOOK ON
SetBalloon( .T. )
c_path := GETCURDIR()
nDStyle := 2

DEFINE DIALOG oDlg1 FROM 30, 30 TO 380, 500  PIXEL ;
FONT  oFont TITLE "DIALOG from Code" TRANSPARENT

D_BACKGRD( oDlg1, nDStyle, 16642248, 15714367, .F., 0.2, "BluStone.Bmp", "PICTURE16.jpg" )

@ 3, 3 GET cVar

@ 20, 20 GROUP oGrp1 TO 150, 200 PIXEL ;
PROMPT "Group" OF oDlg1
oGrp1:oFont := oFont
oGrp1:SetColor( 0, )
oGrp1:lTransparent := .T.

ACTIVATE DIALOG oDlg1 ;
ON PAINT TEST( hDC ) ;
ON INIT ( oDlg1:Move( 60, 30, oDlg1:nWidth, oDlg1:nHeight, .f. ) )

oFont:End()

RETURN NIL

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

STATIC FUNCTION TEST( hDC )

WNDBOX( hDC, 120, 100, 180, 200 )

RETURN NIL

// --------  DIALOG - Background ---------------

FUNCTION D_BACKGRD( oDlg, nStyle, nColor1, nColor2, lDirect, nMove, cBrush, cImage)
Local oBrush

IF nStyle = 1
    DEFINE BRUSH oBrush COLOR nColor1
ENDIF
IF nStyle = 2
    aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
    hDC = CreateCompatibleDC( oDlg:GetDC() )
    // Get Width and Height from INIT !!!
    hBmp = CreateCompatibleBitMap( oDlg:hDC, 470, 350 )
    hBmpOld = SelectObject( hDC, hBmp )
    GradientFill( hDC, 0, 0, 350, 470, aGrad, lDirect )
    DeleteObject( oDlg:oBrush:hBrush )
    oBrush := TBrush():New( ,,,, hBmp )
    oBrush:Cargo  := aGrad
    SelectObject( hDC, hBmpOld )
    ReleaseDC(hDC)
ENDIF
IF nStyle = 3
    DEFINE BRUSH oBrush FILE c_path + "\Images\" + cBrush
ENDIF
IF nStyle = 4
    DEFINE IMAGE oImage FILE c_path + "
\Images\" + cImage
    // Get Width and Height from INIT !!!
    oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, 470, 350, .T. ) )
    oImage:End()
ENDIF

oDlg:SetBrush( oBrush )
oBrush:End()

RETURN( NIL )


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Drawing on a groupbox

Postby Enrico Maria Giordano » Wed May 09, 2012 8:09 am

Thank you, but I need to use WS_CLIPCHILDREN.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a groupbox

Postby ukoenig » Wed May 09, 2012 9:35 am

Enrico,

got it working.
I defined a overlapped box, to show that it is painted on group and dialog

oDlg1:nStyle = NOR( oDlg1:nStyle, WS_CLIPCHILDREN, WS_THICKFRAME )

Image

Code: Select all  Expand view

#include "FiveWin.ch"
#include "Image.ch"

STATIC hDC, oFont, nDStyle

// ------- DIALOG from Code ---------------

FUNCTION Main()
LOCAL nSWidth := GetSysMetrics(0), nSHeight := GetSysMetrics(1)
local oDlg1, oGrp1, oGet
LOCAL cVar := SPACE( 30 )

oFont := TFont():New("Arial",0,-14,.F.,.T.,0,0,0,.T. )
SET _3DLOOK ON
SetBalloon( .T. )
c_path := GETCURDIR()
nDStyle := 1

DEFINE DIALOG oDlg1 FROM 30, 30 TO 380, 500  PIXEL ;
FONT  oFont TITLE "DIALOG from Code" TRANSPARENT
 oDlg1:nStyle = NOR( oDlg1:nStyle, WS_CLIPCHILDREN, WS_THICKFRAME )

@ 3, 3 GET cVar

D_BACKGRD( oDlg1, nDStyle, 16642248, 15714367, .F., 0.2, "BluStone.Bmp", "PICTURE9.jpg" )

ACTIVATE DIALOG oDlg1 ;
ON INIT ( oDlg1:Move( 60, 30, oDlg1:nWidth, oDlg1:nHeight, .f. ) ) ;
ON PAINT (  SHOW_GROUP( oDlg1 ) )

oFont:End()

RETURN NIL

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

FUNCTION SHOW_GROUP( oDlg1 )
LOCAL oGrp1

@ 20, 20 GROUP oGrp1 TO 210, 350 PIXEL ;
PROMPT "Group" OF oDlg1
oGrp1:oFont := oFont
oGrp1:SetColor( 0, )
oGrp1:lTransparent := .T.

TEST( oGrp1:GETDC() )

RETURN( NIL )

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

STATIC FUNCTION TEST( hDC )

WNDBOX( hDC, 150, 220, 300, 400 )

RETURN NIL

// --------  DIALOG - Background ---------------

FUNCTION D_BACKGRD( oDlg, nStyle, nColor1, nColor2, lDirect, nMove, cBrush, cImage)
Local oBrush

IF nStyle = 1
    DEFINE BRUSH oBrush COLOR nColor1
ENDIF
IF nStyle = 2
    aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
    hDC = CreateCompatibleDC( oDlg:GetDC() )
    // Get Width and Height from INIT !!!
    hBmp = CreateCompatibleBitMap( oDlg:hDC, 470, 350 )
    hBmpOld = SelectObject( hDC, hBmp )
    GradientFill( hDC, 0, 0, 350, 470, aGrad, lDirect )
    DeleteObject( oDlg:oBrush:hBrush )
    oBrush := TBrush():New( ,,,, hBmp )
    oBrush:Cargo  := aGrad
    SelectObject( hDC, hBmpOld )
    ReleaseDC(hDC)
ENDIF
IF nStyle = 3
    DEFINE BRUSH oBrush FILE c_path + "\Images\" + cBrush
ENDIF
IF nStyle = 4
    DEFINE IMAGE oImage FILE c_path + "
\Images\" + cImage
    // Get Width and Height from INIT !!!
    oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, 470, 350, .T. ) )
    oImage:End()
ENDIF

oDlg:SetBrush( oBrush )
oBrush:End()

RETURN( NIL )


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Drawing on a groupbox

Postby Enrico Maria Giordano » Wed May 09, 2012 9:49 am

Sorry, it's not fine. You are going to create a new groupbox on each WM_PAINT message. :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a groupbox

Postby Enrico Maria Giordano » Wed May 16, 2012 1:22 pm

A new sample. Please compile it with the manifest resource. Why the SAY and the COMBOBOX are visible while the GET is not?

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 35 )

    LOCAL cItem := ""

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    oDlg:nStyle = NOR( oDlg:nStyle, WS_CLIPCHILDREN, WS_THICKFRAME )

    @ 1, 1 GROUP TO 15, 30;
           PROMPT "This is a test"

    @ 3, 3 GET cVar

    @ 5, 3 SAY "This is a test"

    @ 7, 3 COMBOBOX cItem ITEMS { "", "This is a test" }

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a groupbox

Postby carlos vargas » Wed May 16, 2012 8:33 pm

here, with fwh 12.01
the combo, say and get is show.
but the get at beging no have border, if press tab and jump to other control the border is show.

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

Re: Drawing on a groupbox

Postby ukoenig » Wed May 16, 2012 9:06 pm

The same result :

Image

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Re: Drawing on a groupbox

Postby ukoenig » Wed May 16, 2012 10:29 pm

Enrico,

again a group-problem.
With these changes it works, but only with ON PAINT !!!

DEFINE DIALOG oDlg1 SIZE 800, 600
oDlg1:nStyle = NOR( oDlg1:nStyle, WS_CLIPCHILDREN, WS_THICKFRAME )

@ 3, 3 GET cVar OF oDlg1 UPDATE

@ 5, 3 SAY oSay1 VAR "This is a test" OF oDlg1
oSay1:lTransparent := .T.

@ 7, 3 COMBOBOX cItem ITEMS { "", "This is a test" } OF oDlg1

ACTIVATE DIALOG oDlg1 CENTER ;
ON PAINT GRP_PAINT( oDlg1 )

RETURN NIL

// ---------

FUNCTION GRP_PAINT( oDlg1 )

@ 20, 20 GROUP oGrp1 TO 300, 400 PROMPT "This is a test" OF oDlg1 PIXEL
oGrp1:lTransparent := .T.

RETURN NIL
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Drawing on a groupbox

Postby Enrico Maria Giordano » Thu May 17, 2012 8:35 am

As I already said, unfortunately you are going to create a new groupbox on each WM_PAINT message. Maybe I could end the existing groupbox each time. I will see, thank you. Anyway, I'm looking forward for a real solution.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 104 guests