Radio and GTF problem

Radio and GTF problem

Postby byte-one » Tue Mar 28, 2017 9:29 am

It seems, that the codeblock ::bchange on radios evaluated twice when changing the radiooption!
Please try oRadio:bchange := {||msginfo("Changed")}

In the meanwhile i found, that this only appears, if in the function of the codeblock a call to another dialog are present. (msginfo(),..).
A bPainted-call of the parent-window??

I have removed Eval( ::bChange, Self ) in method refresh() from TRadmenu-class. But this is only a hack.
Antonio?


Another problem with GTF!
Without commenting out the 2 lines in the following code-snippet from METHOD SetFormat( oFont, nColor ) CLASS TFGet the current font are destroyed!

Code: Select all  Expand view  RUN
     if lIsFont
//         DeleteObject( oFont:hFont )
//         oFont:hFont := oOldFont:hFont
         ::hFont := oOldFont:hFont
      else
         AAdd( ::aFonts, oFont )
         ::hFont := oFont:hFont
      endif
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Radio and GTF problem

Postby byte-one » Fri Apr 07, 2017 12:59 pm

Antonio, please take a look at this!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Radio and GTF problem

Postby Antonio Linares » Fri Apr 07, 2017 4:07 pm

Günther,

Thanks for the reminder, as I missed this post from you

> In the meanwhile i found, that this only appears, if in the function of the codeblock a call to another dialog are present. (msginfo(),..).
A bPainted-call of the parent-window??

Surely it is related to the focus. Those functions change the focus

Could you provide a small and self contained example PRG to reproduce it ? many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Radio and GTF problem

Postby Antonio Linares » Fri Apr 07, 2017 4:11 pm

I have modified samples\testrad.prg with this:

REDEFINE RADIO oRadMenu VAR nOption ID 110, 120, 130, 140, 150 OF oDlg ;
ON CHANGE MsgInfo( nOption )

and it only appears once
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Radio and GTF problem

Postby byte-one » Fri Apr 07, 2017 6:17 pm

Antonio, i have made inside my program a simple dialog with only a radio with 5 items and a button. ON CHANGE of the radio call a msginfo(). This msginfo are showing a second one if i close the first one!
WIN 10??
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Radio and GTF problem

Postby nageswaragunupudi » Sat Apr 08, 2017 5:03 am

byte-one wrote:Antonio, i have made inside my program a simple dialog with only a radio with 5 items and a button. ON CHANGE of the radio call a msginfo(). This msginfo are showing a second one if i close the first one!
WIN 10??

Can you provide a sample please?
Regards

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

Re: Radio and GTF problem

Postby byte-one » Sun Apr 09, 2017 9:04 am

Antonio, Mr Nages, there are a test!
The problem is only present if the dialog is child! The main window calls the refresh() and in this refresh() is bChange calling. Maybe other controls also affected!

Code: Select all  Expand view  RUN
function Main()
    local oWin

    DEFINE WINDOW oWin TITLE "Testrad"
    ACTIVATE WINDOW oWin ON INIT rad(oWin)

return NIL

function rad(oWin)
   local oDlg, oRadMenu, oBrush
   local nOption := 2

   DEFINE DIALOG oDlg RESOURCE "Radios" OF oWin

   REDEFINE RADIO oRadMenu VAR nOption ID 110, 120, 130, 140, 150 OF oDlg ;
      ON CHANGE Msginfo("Testrad")

   REDEFINE BUTTON ID 100 OF oDlg ACTION oRadMenu:GoNext() ;
      WHEN nOption == 3

   REDEFINE BUTTON ID 102 OF oDlg ACTION oRadMenu:GoPrev()

   ACTIVATE DIALOG oDlg ;
      ON INIT oRadMenu:aItems[ 1 ]:SetText( "Hello" )

return nil
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Radio and GTF problem

Postby Antonio Linares » Sun Apr 09, 2017 9:32 am

Günther,

Please make this change in Class TRadio:

METHOD Click() INLINE ::oRadMenu:Select( Self ), ::Super:Click() // ::oRadMenu:Refresh()

that seems to solve it

Many thanks for the example
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Radio and GTF problem

Postby byte-one » Sun Apr 09, 2017 10:27 am

Antonio, not the right way! The double call is take away but some radio-buttons stay checked if gonext() and goprev() and click on a radio-button with mouse!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Radio and GTF problem

Postby Antonio Linares » Sun Apr 09, 2017 4:47 pm

How to reproduce it ?

Please provide instructions or a video, many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Radio and GTF problem

Postby byte-one » Sun Apr 09, 2017 5:41 pm

Please change the example to this one and click on next/prev. You see, no reaction from the radio-Buttons. In some cases more then one button is checked if i click with the mouse.
Code: Select all  Expand view  RUN
function Main()
    local oWin

    DEFINE WINDOW oWin TITLE "Testrad"
    ACTIVATE WINDOW oWin ON INIT rad(oWin)

return NIL

function rad(oWin)
   local oDlg, oRadMenu, oBrush
   local nOption := 2

   DEFINE DIALOG oDlg RESOURCE "Radios" OF oWin

   REDEFINE RADIO oRadMenu VAR nOption ID 110, 120, 130, 140, 150 OF oDlg ON CHANGE Msginfo(Eval( oRadmenu:bSetGet ))

   REDEFINE BUTTON ID 100 OF oDlg ACTION oRadMenu:GoNext()

   REDEFINE BUTTON ID 102 OF oDlg ACTION oRadMenu:GoPrev()

   ACTIVATE DIALOG oDlg

return nil
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Radio and GTF problem

Postby Antonio Linares » Sun Apr 09, 2017 10:22 pm

This method has to be modified this way:

Code: Select all  Expand view  RUN
METHOD Refresh() CLASS TRadMenu

   local nOption := Eval( ::bSetGet )
   local nAt     := AScan( ::aItems, { | oRadio | If( oRadio != nil, oRadio:lIsChecked(), .f. ) } )

   DEFAULT nOption := 1

   if nAt != nOption .and. nAt <= Len( ::aItems ) .and. Len( ::aItems ) > 0
      if nAt != 0
         ::aItems[ nAt ]:SetCheck( .f. )
      endif
      if ::aItems[ nOption ] != nil
         ::aItems[ nOption ]:SetCheck( .t. )
      endif
      // if ::bChange != nil                 no needed
      //    Eval( ::bChange, Self )
      // endif
   endif

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Radio and GTF problem

Postby byte-one » Mon Apr 10, 2017 1:26 am

Antonio, thanks! To run next/prev, this change is required! Tested with my last sample.

Code: Select all  Expand view  RUN
METHOD GoPrevNext( lNext ) CLASS TRadMenu

   local nMove:= 0
   local nOption:= ::nOption

   DEFAULT lNext:= .F.

   while ! ( nMove > Len( ::aItems ) )
      nMove++

      if lNext
         nOption++
         nOption = If( nOption > Len(::aItems), 1, nOption )
      else
         nOption--
         nOption = If( nOption < 1, Len(::aItems), nOption )
      endif

      if ::aItems[ nOption ]:lWhen()
         ::nOption = nOption
     ::refresh(  )       //NEW
         exit
      endif

   enddo

//   if nOption != ::nOption
     //::SetOption( nOption )
//   endif

return Self
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria


Return to FiveWin for Harbour/xHarbour

Who is online

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