Page 1 of 3

Dialog controls are flickering when resized..

Posted: Fri Jun 04, 2010 7:22 am
by fraxzi
Dear All,

As with the above..

When I resize Dialog controls are flickering with backround gradient..

Code: Select all

   DEFINE DIALOG oDlg TRANSPARENT

      
          ...standard controls here..  say, get, folder, xbrowse...

          oDlg:SetBrush( TBrush():New()  )


   ACTIVATE DIALOG oDlg NOWAIT;
            ON PAINT uDialogGradient( hDC, oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } }, .F. )

....


FUNCTION uDialogGradient( hDC, oDlg, aGrad, lPos )

 GradientFill( hDC,  0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, lPos )
 ReleaseDC( hDC )

RETURN NIL
 

Any thoughts?

Regards,
Frances

Re: Dialog controls are flickering when resized..

Posted: Sat Jun 05, 2010 12:56 am
by fraxzi
Anyone with controls in dialog not flickering when resized?


Mr. Antonio?


regards,
Frances

Re: Dialog controls are flickering when resized..

Posted: Sat Jun 05, 2010 1:29 am
by Daniel Garcia-Gil
Frances...


please post a simple test here

Re: Dialog controls are flickering when resized..

Posted: Sat Jun 05, 2010 2:19 am
by fraxzi
Dear Daniel,

Here's a full working sample (scratch works)

.PRG

Code: Select all

#Include 'FiveWin.ch'
#include 'Ribbon.ch'

GLOBAL oRibbon,;
       oBtn_RR, oBtn_SR,;
       oBtn_RE, oBtn_CH, oBtn_CO,;
       oBtn_RP

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

PROCEDURE uMain()
 Local aScreen := { GetSysMetrics( 4 ) +  GetSysMetrics( 17 ),;  //height of caption and screen }
                    GetSysMetrics( 16 ),;                        //width of client area
                    GetSysMetrics( 0 ),;                         //width of screen
                    GetSysMetrics( 1 ) }                         //height of screen


 DEFINE WINDOW oMDIFrame TITLE "Ribbon flicker" MDI;
        From 0, 0 To aScreen[1],aScreen[2] PIXEL;  //fullscreen desktop screen       \
        MENU uBuildMenu()


        DEFINE RIBBONBAR oRibbon WINDOW oMDIFrame;
               PROMPT 'ONE', 'TWO', 'THREE';
               HEIGHT 112 TOPMARGIN 26


               ADD GROUP oGrp_PUR_N3 RIBBON oRIBBON TO OPTION 1;
                   PROMPT "one.1" width 120

                   @ 05, 10 ADD BUTTON GROUP oGrp_PUR_N3;
                            SIZE 50, 58 PROMPT '&1';
                            SPLITPOPUP ROUND;
                            ACTION msginfo('1.1')

                   @ 05, 62 ADD BUTTON GROUP oGrp_PUR_N3;
                            SIZE 50, 58 PROMPT '&2';
                            SPLITPOPUP ROUND ;
                            ACTION msginfo('1.2')

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

               ADD GROUP oGrp_INV_N3 RIBBON oRIBBON TO OPTION 2;
                   PROMPT "two.1" width 120


                   @ 05, 10 ADD BUTTON oBtn_RR GROUP oGrp_INV_N3;
                            SIZE 50, 58 PROMPT "&Here";
                            SPLITPOPUP ROUND;
                            ACTION uDlgOnMDIChild()


                   @ 05, 62 ADD BUTTON oBtn_SR GROUP oGrp_INV_N3;
                            SIZE 50, 58 PROMPT "&2";
                            SPLITPOPUP ROUND ;
                            ACTION msginfo('2.1')


               ADD GROUP oGrp_COS_N3 RIBBON oRIBBON TO OPTION 2;
                   PROMPT "two.2" width 210


                   @ 05,  10 ADD BUTTON oBtn_RE GROUP oGrp_COS_N3;
                             SIZE 50, 58 PROMPT "&1";
                             SPLITPOPUP ROUND;
                             ACTION msginfo('2.1')

                   @ 05,  62 ADD BUTTON oBtn_CH GROUP oGrp_COS_N3;
                             SIZE 70, 58 PROMPT "&2";
                             SPLITPOPUP ROUND ;
                             ACTION msginfo('2.2')

                   @ 05, 133 ADD BUTTON oBtn_CO GROUP oGrp_COS_N3;
                             SIZE 70, 58 PROMPT "&3";
                             SPLITPOPUP ROUND ;
                             ACTION msginfo('2.3')

               ADD GROUP oGrp_INV_RE RIBBON oRIBBON TO OPTION 2;
                   PROMPT "three.3" width 210 BITMAP 'ribbontip'


                   @ 05,  10 ADD BUTTON oBtn_RP GROUP oGrp_INV_RE;
                             SIZE 70, 58 PROMPT "&1";
                             SPLITPOPUP ROUND ;
                             ACTION msginfo('3.1')

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



 ACTIVATE WINDOW oMDIFrame Maximized;
          ON INIT ( oRibbon:SetOption( 2 ),;
                    oMDIFrame:aMinMaxInfo := {,,,,,,oMDIFrame:nWidth,oMDIFrame:nHeight} )


RETURN

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

STATIC FUNCTION uBuildMenu()
 LOCAL oMenu
 MENU oMenu
 ENDMENU
RETURN( oMenu )


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

PROCEDURE uDlgOnMDIChild()
 LOCAL oWnd, oDlg

 LOCAL oGrp,;
       oSay,;
       oGet

 LOCAL oFont

 LOCAL cGet := 'themed apps'

      DEFINE FONT oFont NAME "Verdana" SIZE 0, -16

      DEFINE WINDOW oWnd TITLE "xBrowse" MDICHILD;
             FROM 0,0 TO 0, 0;
             OF oMDIFrame PIXEL


             DEFINE DIALOG oDlg RESOURCE 'DLG_CONTENT';
                    OF oWnd PIXEL;
                    FONT oFont

                    REDEFINE GROUP ID 1001;
                             OF oDlg TRANSPARENT

                    REDEFINE SAY ID 1003;
                             OF oDlg TRANSPARENT

                    REDEFINE GET oGet VAR cGet;
                             ID 1002 OF oDlg UPDATE


             ACTIVATE DIALOG oDlg NOWAIT;
                      ON PAINT uDialogGradient( hDC, oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } }, .F. );
                      ON INIT oDlg:SetBrush( TBrush():New()  );
                      VALID .F.   //no esc-key

             //oWnd:oClient := oDlg

             oWnd:bResized := {|| oDlg:SetSize( oWnd:oWndClient:nWidth-3,;
                                                oWnd:oWndClient:nHeight-3)  }


      ACTIVATE WINDOW oWnd;
               ON PAINT uDialogGradient( hDC, oWnd, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } }, .F. );
               ON INIT ( oWnd:nHeight := Min(oMDIFrame:oWndClient:nHeight,800),;
                         oWnd:nWidth  := Max(oMDIFrame:oWndClient:nWidth, 1280),;
                         oWnd:SetBrush( TBrush():New() )   )


RETURN


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


FUNCTION uDialogGradient( hDC, oDlg, aGrad, lPos )

 GradientFill( hDC,  0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, lPos )
 ReleaseDC( hDC )

RETURN NIL
 
The .RC

Code: Select all

1 MANIFEST "WindowsXP.Manifest"

DLG_CONTENT DIALOGEX 0,0,273,122
FONT 18,"Verdana",400,0
STYLE WS_CHILDWINDOW|WS_VISIBLE
BEGIN
  CONTROL "Transparent Say...",1004,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_CENTER,48,5,192,16
  CONTROL "GroupBox",1001,"Button",WS_CHILDWINDOW|WS_VISIBLE|BS_GROUPBOX,13,48,128,39
  CONTROL "Test Say",1003,"Static",WS_CHILDWINDOW|WS_VISIBLE,19,71,31,10
  CONTROL "",1002,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,53,69,83,13,WS_EX_CLIENTEDGE
END

Re: Dialog controls are flickering when resized..

Posted: Sat Jun 05, 2010 8:28 am
by Antonio Linares
Frances,

In order to avoid the flickering of a dialog, double buffer painting technique has to be used.

FWH currently does not implement double buffer painting in dialogboxes, though we could easily implement it. Basically all is needed is to redefine the Method Paint()

Re: Dialog controls are flickering when resized..

Posted: Sat Jun 05, 2010 8:34 am
by Antonio Linares
Here there is a recent implementation of double buffer painting that we have done for the Class TUrlLink (used from the new Class TExplorerBar):

Code: Select all

   METHOD Paint()
   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
 

Code: Select all

METHOD Paint() CLASS TURLLink

   local aInfo := ::DispBegin()   

   CallWindowProc( ::nOldProc, ::hWnd, WM_PAINT, ::hDC, 0 )

   if ValType( ::bPainted ) == "B"
      Eval( ::bPainted, ::hDC, ::cPS, Self )
   endif
   
   ::DispEnd( aInfo )

return nil
 
To avoid the flickering, the Method EraseBackground is made dummy:

Code: Select all

   METHOD EraseBkGnd( hDC ) INLINE 1
 
So erase and paint are no longer two separated process. Whatever work has to do EraseBackground is performed from the Method Paint (using calling FillRect), this way there is no flickering.

FWH Methods DispBegin() and DispEnd() perform the real work to build a "double buffer" in memory.

Re: Dialog controls are flickering when resized..

Posted: Sat Jun 05, 2010 9:05 am
by fraxzi
Mr. Antonio,

How can I [re]Define method of class without breaking original class method or modifying dialog.prg?


I also tried to modify dialog.prg and add to my test but when I open the dialog.. system exits without any runtime error/messages.. any idea?

Regards,
Frances

Re: Dialog controls are flickering when resized..

Posted: Sat Jun 05, 2010 2:32 pm
by James Bott
Frances,

>How can I [re]Define method of class without breaking original class method or modifying dialog.prg?

Create a subclass of TDialog.

Code: Select all

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

CLASS TMydialog from TDialog
   METHOD Paint()
   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
   METHOD EraseBkGnd( hDC ) INLINE 1
ENDCLASS 

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

METHOD Paint() CLASS TMydialog

   local aInfo := ::DispBegin()   

   CallWindowProc( ::nOldProc, ::hWnd, WM_PAINT, ::hDC, 0 )

   if ValType( ::bPainted ) == "B"
      Eval( ::bPainted, ::hDC, ::cPS, Self )
   endif
   
   ::DispEnd( aInfo )

return nil
 
//---------------------------------------------------------------------------//
Then you can modify the include syntax for your new class. Just give it a new name and call the new class. You can either put this at the top of the PRG containing your new dialog, or create a new include file.

Code: Select all

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

#xcommand DEFINE MYDIALOG <oDlg> ;
             [ <resource: NAME, RESNAME, RESOURCE> <cResName> ] ;
             [ TITLE <cTitle> ] ;
             [ FROM <nTop>, <nLeft> TO <nBottom>, <nRight> ] ;
             [ SIZE <nWidth>, <nHeight> ] ;
             [ <lib: LIBRARY, DLL> <hResources> ] ;
             [ <vbx: VBX> ] ;
             [ STYLE <nStyle> ] ;
             [ <color: COLOR, COLORS> <nClrText> [,<nClrBack> ] ] ;
             [ BRUSH <oBrush> ] ;
             [ <of: WINDOW, DIALOG, OF> <oWnd> ] ;
             [ <pixel: PIXEL> ] ;
             [ ICON <oIco> ] ;
             [ FONT <oFont> ] ;
             [ <help: HELP, HELPID> <nHelpId> ] ;
             [ <transparent: TRANSPARENT> ] ;
       => ;
          <oDlg> = TMyDialog():New( <nTop>, <nLeft>, <nBottom>, <nRight>,;
                 <cTitle>, <cResName>, <hResources>, <.vbx.>, <nStyle>,;
                 <nClrText>, <nClrBack>, <oBrush>, <oWnd>, <.pixel.>,;
                 <oIco>, <oFont>, <nHelpId>, <nWidth>, <nHeight>, <.transparent.> )


//----------------------------------------------------------------------------//
Now create your dialog:

Code: Select all

   define Mydialog oDlg ...

   activate dialog oDlg
You may want to read my articles on OOP. www.gointellitech.com/program.htm

Regards,
James

Re: Dialog controls are flickering when resized..

Posted: Sun Jun 06, 2010 1:17 am
by fraxzi
Dear James,

You're a great help! Thank you for making the article..


I will follow your lead.


Regards,
Frances

Re: Dialog controls are flickering when resized..

Posted: Sun Jun 06, 2010 1:51 am
by fraxzi
Dear Mr. Antonio/Mr. James,

As follows:

Code: Select all

#include "FiveWin.ch"
#include "Constant.ch"


CLASS TMydialog from TDialog
      METHOD Paint()
      METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
      METHOD EraseBkGnd( hDC ) INLINE 1
ENDCLASS


METHOD Paint() CLASS TMydialog

   local aInfo := ::DispBegin()  

   CallWindowProc( ::nOldProc, ::hWnd, WM_PAINT, ::hDC, 0 )

   if ValType( ::bPainted ) == "B"
      Eval( ::bPainted, ::hDC, ::cPS, Self )
   endif
   
   ::DispEnd( aInfo )

return nil
 

This causes to hang:
CallWindowProc( ::nOldProc, ::hWnd, WM_PAINT, ::hDC, 0 )

What am I missing?


Regards,
Frances

Re: Dialog controls are flickering when resized..

Posted: Sun Jun 06, 2010 7:43 am
by Antonio Linares
Frances,

My mistake, I missed to remember that dialogboxes are not (Windows) subclassed so there is no a valid ::nOldProc.

We may need to subclass the dialog calling Method ::Link(). But we need to find the right place to call it.

Re: Dialog controls are flickering when resized..

Posted: Mon Jun 07, 2010 3:48 am
by fraxzi
Dear Mr. Antonio,

Following the sample testmdir.prg.. Controls still flickering when resizing MDI Child Window

Code: Select all

PROCEDURE uMain()
 Local aScreen := { GetSysMetrics( 4 ) +  GetSysMetrics( 17 ),;  //height of caption and screen }
                    GetSysMetrics( 16 ),;                        //width of client area
                    GetSysMetrics( 0 ),;                         //width of screen
                    GetSysMetrics( 1 ) }                         //height of screen

 LOCAL oIcon

 DEFINE ICON oIcon ;
        RESOURCE 'aaa'

 DEFINE WINDOW oMDIFrame TITLE "Ribbon flicker" MDI;
        From 0, 0 To aScreen[1],aScreen[2] PIXEL;  //fullscreen desktop screen       \
        ICON oIcon;
        MENU uBuildMenu()


        DEFINE RIBBONBAR oRibbon WINDOW oMDIFrame;
               PROMPT 'ONE', 'TWO', 'THREE';
               HEIGHT 112 TOPMARGIN 26


               ADD GROUP oGrp_PUR_N3 RIBBON oRIBBON TO OPTION 1;
                   PROMPT "one.1" width 120

                   @ 05, 10 ADD BUTTON GROUP oGrp_PUR_N3;
                            SIZE 50, 58 PROMPT '&1';
                            SPLITPOPUP ROUND;
                            ACTION msginfo('1.1')

                   @ 05, 62 ADD BUTTON GROUP oGrp_PUR_N3;
                            SIZE 50, 58 PROMPT '&2';
                            SPLITPOPUP ROUND ;
                            ACTION msginfo('1.2')

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

               ADD GROUP oGrp_INV_N3 RIBBON oRIBBON TO OPTION 2;
                   PROMPT "two.1" width 120


                   @ 05, 10 ADD BUTTON oBtn_RR GROUP oGrp_INV_N3;
                            SIZE 50, 58 PROMPT "&Here";
                            SPLITPOPUP ROUND;
                            ACTION uDlgOnMDIChild()


                   @ 05, 62 ADD BUTTON oBtn_SR GROUP oGrp_INV_N3;
                            SIZE 50, 58 PROMPT "&2";
                            SPLITPOPUP ROUND ;
                            ACTION Nil


               ADD GROUP oGrp_COS_N3 RIBBON oRIBBON TO OPTION 2;
                   PROMPT "two.2" width 210


                   @ 05,  10 ADD BUTTON oBtn_RE GROUP oGrp_COS_N3;
                             SIZE 50, 58 PROMPT "&1";
                             SPLITPOPUP ROUND;
                             ACTION msginfo('2.1')

                   @ 05,  62 ADD BUTTON oBtn_CH GROUP oGrp_COS_N3;
                             SIZE 70, 58 PROMPT "&2";
                             SPLITPOPUP ROUND ;
                             ACTION msginfo('2.2')

                   @ 05, 133 ADD BUTTON oBtn_CO GROUP oGrp_COS_N3;
                             SIZE 70, 58 PROMPT "&3";
                             SPLITPOPUP ROUND ;
                             ACTION msginfo('2.3')

               ADD GROUP oGrp_INV_RE RIBBON oRIBBON TO OPTION 2;
                   PROMPT "three.3" width 210 BITMAP 'ribbontip'


                   @ 05,  10 ADD BUTTON oBtn_RP GROUP oGrp_INV_RE;
                             SIZE 70, 58 PROMPT "&1";
                             SPLITPOPUP ROUND ;
                             ACTION msginfo('3.1')

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



 ACTIVATE WINDOW oMDIFrame Maximized;
          ON INIT ( oRibbon:SetOption( 2 ),;
                    oMDIFrame:aMinMaxInfo := {,,,,,,oMDIFrame:nWidth,oMDIFrame:nHeight} )


RETURN

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

STATIC FUNCTION uBuildMenu()
 LOCAL oMenu
 MENU oMenu 2007
 ENDMENU
RETURN( oMenu )


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

PROCEDURE uDlgOnMDIChild()
 LOCAL oWnd


      DEFINE WINDOW oWnd TITLE "Test Controls" MDICHILD;
             FROM 0,0 TO 0, 0;
             OF oMDIFrame PIXEL;
             COLOR 0, GetSysColor(15)


      ACTIVATE WINDOW oWnd;
               ON INIT ( oWnd:nHeight := oMDIFrame:oWndClient:nHeight,;
                         oWnd:nWidth  := oMDIFrame:oWndClient:nWidth,;
                         uBuildChildDlg( oWnd ) )


RETURN


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

FUNCTION uBuildChildDlg( oWnd )
 LOCAL oDlg
 LOCAL oFont
 LOCAL oGrp,;
       oSay,;
       oGet

 LOCAL cGet := 'themed apps'

      DEFINE FONT oFont NAME "Verdana" SIZE 0, -16


             DEFINE DIALOG oDlg RESOURCE 'DLG_CONTENT';
                    OF oWnd PIXEL;
                    FONT oFont TRANSPARENT

                    REDEFINE GROUP ID 1001;
                             OF oDlg TRANSPARENT

                    REDEFINE SAY ID 1003;
                             OF oDlg TRANSPARENT

                    REDEFINE GET oGet VAR cGet;
                             ID 1002 OF oDlg UPDATE


             ACTIVATE DIALOG oDlg NOWAIT;
                      ON INIT uChangeParent( oDlg, oWnd );
                      VALID .F.   //no esc-key

            oDlg:End()

RETURN


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


FUNCTION  uChangeParent( oDlg, oChild )

   LOCAL n

   FOR EACH n IN oDlg:aControls
       SetParent( n:hWnd, oChild:hWnd )
       AAdd( oChild:aControls, n )
       n:oWnd := oChild
   NEXT

RETURN

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

RC:

Code: Select all

1 MANIFEST "WindowsXP.Manifest"

aaa ICON DISCARDABLE "lab.ico"

DLG_CONTENT DIALOGEX 0,0,273,122
FONT 18,"Verdana",400,0
STYLE WS_CHILDWINDOW|WS_VISIBLE
BEGIN
  CONTROL "Transparent Say...",1004,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_CENTER,48,5,192,16
  CONTROL "GroupBox",1001,"Button",WS_CHILDWINDOW|WS_VISIBLE|BS_GROUPBOX,13,48,128,39
  CONTROL "Test Say",1003,"Static",WS_CHILDWINDOW|WS_VISIBLE,19,71,31,10,WS_EX_TRANSPARENT
  CONTROL "",1002,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,53,69,83,13,WS_EX_CLIENTEDGE
END
 
Regards,
Frances

Re: Dialog controls are flickering when resized..

Posted: Mon Jun 07, 2010 6:55 am
by Antonio Linares
Frances,

Besides the mdichild, the child controls must also have double buffer painting implemented.

Please try to place a xbrowse on the mdichild and test if it flickers, thanks

Re: Dialog controls are flickering when resized..

Posted: Mon Jun 07, 2010 7:35 am
by fraxzi
Antonio Linares wrote:Frances,

Besides the mdichild, the child controls must also have double buffer painting implemented.

Please try to place a xbrowse on the mdichild and test if it flickers, thanks

No It does not flicker at all..


I hope fivetechsoft implement double-buffering on all controls.. this way, apps would have a more professional look and feel..
most appealing to customers/client..

Can it be possible to adopt xBrowse's double-buffering to other common controls like say, get, folder...

I thinks this is very very important. 2Cents!


Best regards,
Frances

Re: Dialog controls are flickering when resized..

Posted: Mon Jun 07, 2010 8:16 am
by Antonio Linares
Frances,

What child controls are you using in such mdichild ?

SAYs, GETs, GROUPBOX, BUTTONs...

Are SAYs flickering too ?