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
Screen Snapshot taken when I invoked the function MyTest() from a RibbonBar
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