Page 1 of 1

BTNGET vs GET..ACTION..BITMAP

Posted: Mon Mar 02, 2009 6:17 pm
by Ugo
Antonio Linares wrote:FWH supports this syntax now:

@ ..., .. GET ... ACTION ... BITMAP ...

There is no need to keep using TBtnGet.
Dear Antonio,

I use the redefine, work, but not well, the button position is not on the right!
Image

and next, how to support RESOURCE clause?

In the image the second is btnget :-(

Many thanks for your reponse.

Re: BTNGET vs GET..ACTION..BITMAP

Posted: Tue Mar 03, 2009 8:07 am
by dutch
Dear Ugo,

I think Antonio will include RESIZE16 clause fixed for GET..ACTION. If not now you can fix as following. I've changed all BTNGET to original GET..ACTION and working without problem

Code: Select all

METHOD CreateButton() CLASS TGet
   local oThis := Self
   if ValType( ::bAction ) == "B" .and. Upper( ::ClassName() ) == "TGET" 
      if Empty( ::cBmpName )
         @ 0, ::nWidth - ::nHeight BUTTONBMP ::oBtn OF Self ;
         ACTION ( Eval( oThis:bAction, oThis ) ) ;   // , oThis:LostFocus() ) ;  
         SIZE ::nHeight - 4, ::nHeight - 4 PIXEL
         if Empty( ::oBtn:hBitmap )
            ::oBtn:SetText( "..." )
         endif      
      else   
         @ 0, ::nWidth - ::nHeight BUTTONBMP ::oBtn OF Self ; 
         ACTION ( Eval( oThis:bAction, oThis ) ) ;  //  oThis:SetFocus() ) ;
         SIZE ::nHeight - 4, ::nHeight - 4 PIXEL BITMAP ::cBmpName
      endif
//  add this 3 lines.
      if Upper( ::oWnd:ClassName() ) == "TDIALOG" .and. ::oWnd:lResize16
         ::oBtn:nLeft   = ( ::nWidth * 1.167 ) - ::nHeight
      end
// add above 3 lines
      ::oBtn:lCancel = .T. // so the GET VALID is not fired when the button is focused

      /*
      // We force a WM_NCCALCSIZE msg to be sent to the GET      
      SetWindowPos( ::hWnd, 0, 0, 0, 0, 0,;
                    nOr( SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, SWP_FRAMECHANGED ) )
      */              
   endif   
   
return nil   
 

Re: BTNGET vs GET..ACTION..BITMAP

Posted: Tue Mar 03, 2009 10:29 am
by Ugo
Dear Dutch,

the position work well,
thank you.

> I've changed all BTNGET to original GET..ACTION and working without problem
I have a problem, test this (with BTNGET work well):

Code: Select all

FUNCTION Main()

   LOCAL o := MyClass():New()

   RETURN Nil

CLASS MyClass
   DATA dData
   METHOD New() CONSTRUCTOR

   ENDCLASS

METHOD New() CLASS MyClass

   LOCAL oGet4, lWhen := .T., oDlg

   ::dData := Date()

   DEFINE DIALOG oDlg

   @ 1, 1 GET oGet4 VAR ::dData OF oDlg PICTURE "@D";  // RESOURCE "B_Cld"
            SIZE 50, 12 ;
            ACTION (::dData:=Date()-10)

   ACTIVATE DIALOG oDlg
   RETURN Self
return an error when i click button. :-(

This is the error:
Descrizione: Warning BASE/1005 Message not found: TGET:_DDATA
Args:

Stack Calls
===========
Called from: source\rtl\tobject.prg => TGET:ERROR(172)
Called from: source\rtl\tobject.prg => TGET:MSGNOTFOUND(205)
Called from: source\rtl\tobject.prg => TGET:_DDATA(0)
Called from: SRC-WIN\TEst\Source\Test.prg => (b)MYCLASS:NEW(82)
Called from: prg\TGET.prg => (b)TGET:CREATEBUTTON(465)
Called from: prg\BUTTON.prg => TBUTTONBMP:CLICK(177)
Called from: prg\CONTROL.prg => TBUTTON:HANDLEEVENT(1412)
Called from: prg\BUTTONB.prg => TBUTTONBMP:HANDLEEVENT(168)
Called from: prg\WINDOW.prg => _FWH(3345)
Called from: => SENDMESSAGE(0)
Called from: prg\WINDOW.prg => TGET:COMMAND(1014)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: prg\CONTROL.prg => TCONTROL:HANDLEEVENT(1454)
Called from: prg\TGET.prg => TGET:HANDLEEVENT(561)
Called from: prg\WINDOW.prg => _FWH(3345)
Called from: => DIALOGBOXINDIRECT(0)
Called from: prg\DIALOG.prg => TDIALOG:ACTIVATE(273)
Called from: SRC-WIN\TEst\Source\Test.prg => MYCLASS:NEW(84)
Called from: SRC-WIN\TEst\Source\Test.prg => MAIN(60)
There is a workaround?

Is possible to insert also the resources?

Many thanks in advance.

Re: BTNGET vs GET..ACTION..BITMAP

Posted: Tue Mar 03, 2009 6:38 pm
by Enrico Maria Giordano

Code: Select all

#include "Fivewin.ch"


FUNCTION Main()

   LOCAL o := MyClass():New()

   RETURN Nil

CLASS MyClass
   DATA dData
   METHOD New() CONSTRUCTOR

   ENDCLASS

METHOD New() CLASS MyClass

   LOCAL oGet4, lWhen := .T., oDlg, oSelf := Self

   ::dData := Date()

   DEFINE DIALOG oDlg

   @ 1, 1 GET oGet4 VAR ::dData OF oDlg PICTURE "@D";  // RESOURCE "B_Cld"
            SIZE 50, 12 ;
            ACTION (oSelf:dData:=Date()-10)

   ACTIVATE DIALOG oDlg
   RETURN Self
EMG

Re: BTNGET vs GET..ACTION..BITMAP

Posted: Tue Mar 03, 2009 11:43 pm
by Ugo
Dear Enrico,

work well, of course! :wink:
thank you.

This is a bug?
The other clauses (valid,spinner,when etc.) work well using directly the class variable.

There is also the RESOURCE
How to use the resource instead bitmap image?

Re: BTNGET vs GET..ACTION..BITMAP

Posted: Wed Mar 04, 2009 8:05 am
by Enrico Maria Giordano
Ugo wrote:This is a bug?
It seems not. Look inside tget.prg, method CreateButton() and you will see that the same technique is used there. I tried it under Harbour with the same result (the local variable is still required).
Ugo wrote:There is also the RESOURCE
How to use the resource instead bitmap image?
It is not supported yet. You have to modify CreateButton() method for this. Antonio?

EMG

Re: BTNGET vs GET..ACTION..BITMAP

Posted: Wed Mar 04, 2009 8:32 am
by Ugo
Enrico Maria Giordano wrote:
Ugo wrote:This is a bug?
It seems not. Look inside tget.prg, method CreateButton() and you will see that the same technique is used there. I tried it under Harbour with the same result (the local variable is still required).
Ugo wrote:The other clauses (valid,spinner,when etc.) work well using directly the class variable
Dear Enrico,
Test it:

Code: Select all

FUNCTION Main()
   LOCAL o

   Set century on
   SET EPOCH TO 2000

   o := MyClass():New()

   RETURN Nil

CLASS MyClass
   DATA dData
   DATA lTest INIT .T.

   METHOD New() CONSTRUCTOR

   ENDCLASS

METHOD New() CLASS MyClass

   LOCAL oGet4, lWhen := .T., oDlg, oSelf := Self, cTxt := Space( 10 ), oGet5

   ::dData := Date()

   DEFINE DIALOG oDlg

   @ 1, 1 GET oGet4 VAR ::dData OF oDlg PICTURE "@D";  // RESOURCE "B_Cld"
            SIZE 50, 12 ;
            WHEN ::lTest;
            VALID IF( ::lTest,;
                      IF( MyTest( ::dData ),;
                        ( MsgInfo( "Test OK", ::dData ), .T. ),;
                        ( MsgInfo( "Test KO", ::dData ), .F. ) ),;
                        .T. );
            ACTION (oSelf:dData:=Date()-10)

   @ 3, 1 GET oGet5 VAR cTxt OF oDlg

   ACTIVATE DIALOG oDlg
   RETURN Self

STATIC FUNCTION MyTest( dData )

   MsgInfo( "Test in corso" + CRLF + ;
            DToS( dData ) + " < " + DToS( Date() ) + CRLF + ;
            cValToChar( dData < Date() ) , dData )

   RETURN dData < Date()
as you can see, both the variable ::lTest that the same ::dData work well in the When and Valid clauses, only Action required oSelf.

Re: BTNGET vs GET..ACTION..BITMAP

Posted: Wed Mar 04, 2009 8:34 am
by Ugo
Enrico Maria Giordano wrote:
Ugo wrote:There is also the RESOURCE
How to use the resource instead bitmap image?
It is not supported yet. You have to modify CreateButton() method for this. Antonio?
Antonio,
can you help me?

Re: BTNGET vs GET..ACTION..BITMAP

Posted: Wed Mar 04, 2009 9:47 am
by Enrico Maria Giordano
Ugo wrote:Dear Enrico,
Test it:
Interesting... It seems I was wrong. If I change the last line of @ row, col GET ... ACTION command in fivewin.ch:

Code: Select all

<.pass.>, [<.lNoBorder.>], <nHelpId>,,,,,, <{uAction}>, <cBmpName>, <"uVar"> )
then it works fine.

Antonio?

EMG