Ribbon Bar

Ribbon Bar

Postby anserkk » Mon Mar 15, 2010 9:01 am

Hi,

I found a peculiar painting problem on windows when functions are called from a ribbon bar control. I do not know whether this is a bug or something wrong the way I am doing.


I have a function named MyTest(). To demonstrate the problem, I'll try to call the function MyTest() from a ButtonBar button as well as from a RibbonBar.

* I found that when this function is called by clicking the button on a ButtonBar, everything is working as expected.
* But if you try to call the same function from a Button on RibbonBar control, then the window is not painted properly as expected. If I try to resize this window using a mouse, then the painting is done as expected.

Screen Snapshot taken when I invoked the function MyTest() from a ButtonBar
Image


Screen Snapshot taken when I invoked the function MyTest() from a RibbonBar
Image

Here is a self contained sample to reproduce the above said problem.

Code: Select all  Expand view
#include "FiveWin.Ch"
#include "Ribbon.ch"

*-------------------------------------*
Function Main()
*-------------------------------------*
    Local oWnd, lRibbon
   
    lRibbon:=.F.  // Change this to .F. or .T. to see the difference
   
    DEFINE WINDOW oWnd TITLE "Test Ribbon" MDI
   
        lRibbon:=MsgYesNo("Do you want to use Ribbon Bar")
        if lRibbon
            CreateRibbon(oWnd)
        else
            CreateBar(oWnd)
        Endif
   
    ACTIVATE WINDOW oWnd MAXIMIZED

Return NIL
 
*-----------------------------------------*
Function CreateBar(oWnd)  // Creates a ButtonBar
*-----------------------------------------*
    Local oBar
   
    DEFINE BUTTONBAR oBar OF oWnd SIZE 80, 80 2007
       
    DEFINE BUTTON OF oBar PROMPT "Test" ;
           ACTION  MyTest()
Return NIL

*-----------------------------------------*
Function CreateRibbon(oWnd)  // Create a RibbonBar
*-----------------------------------------*
    Local oRBar, oGrpTest, oBtnTest
         
    DEFINE RIBBONBAR oRBar OF oWnd PROMPT "My Test",  "Help"  HEIGHT 133 TOPMARGIN 25
   
      ADD GROUP oGrpTest RIBBON oRBar TO  OPTION 1 PROMPT "Test Group"  WIDTH 130
         @ 2,35 ADD BUTTON  oBtnTest PROMPT "Test" GROUP oGrpTest ;
             ACTION MyTest() ;
             ROUND SIZE 60, 83

Return NIL

*---------------------------------------------*
Function MyTest() // This fuction demonstrates the problem
*---------------------------------------------*
    Local oWnd, oGetPhone, oSrchBtn
    Local cPhoneNo:=Space(15), nTextClr, nBkgClr
   
    nTextClr:=nRGB(  0,  0,  0)  // Text Color (ForeGround Colour) Black
    nBkgClr:=nRGB(213,228,242)  // BackGround Colour, SkyBlue
   
    DEFINE WINDOW oWnd MDICHILD OF WndMain() FROM 1,2 to 29,79 ;
           TITLE "A Window to demonstrate the problem" ;
           COLOR nTextClr, nBkgClr
         
        @00,01 to 4.7,40  
                         
        @01,03 SAY "Phone No :" COLOR nTextClr, nBkgClr
        @03,03 SAY "Your Name :" COLOR nTextClr, nBkgClr
       
        @01,11 GET oGetPhone VAR cPhoneNo OF oWnd PICTURE "@!"  SIZE 130,20                    
       
        @03,310 BTNBMP oSrchBtn OF oWnd PROMPT "Search" 2007 SIZE 75,70
   
    ACTIVATE WINDOW oWnd ;
             ON INIT ( oGetPhone:SetFocus())

Return NIL



Regards
Anser
Last edited by anserkk on Mon Mar 15, 2010 9:15 am, edited 1 time in total.
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Ribbon Bar

Postby anserkk » Mon Mar 15, 2010 9:14 am

Hi,

For the time being Calling oWnd:Refresh() during the window On Init solves the problem.

Code: Select all  Expand view
    ACTIVATE WINDOW oWnd ;
             ON INIT ( oGetPhone:SetFocus(),oWnd:Refresh())
 

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Ribbon Bar

Postby Carles » Mon Mar 15, 2010 11:01 am

Anse,

The solution i propose is in the TMdiChild() class, ::New() method, after creating the handle of the window put a ::Refresh()

Code: Select all  Expand view

   ::hWnd = ::oWndClient:SendMsg( WM_MDICREATE, 0,;
        cMdiStruct( "TMDICHILD", cTitle,;
                    ::nTop, ::nLeft, ::nBottom, ::nRight,;
                    ::nStyle ) )

   ::Refresh() // CAF
 


Regards
C.
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Ribbon Bar

Postby anserkk » Mon Mar 15, 2010 12:19 pm

Dear Mr.Carles,

Thank you for the solution :-) Your soultion is working :-)
I wonder why the refresh problem occurs only when the function is called from a RibbonBar and the problem does not appear when the same function is called from a ButtonBar.

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

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