PROMT on button

User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

PROMT on button

Post by Rick Lipkin »

To All

Sorry for asking a dumb question .. never had to do this before .. based on a logical condition to change the text on the button .. here is the code :

DO CASE
CASE cISCHARTER = .T. // found a charter document
cCHPROMPT := " This Projects CHARTER [read me]"
OTHERWISE
cCHPROMPT := " This Projects CHARTER"
ENDCASE

REDEFINE BUTTON oBTN5 ID 138 PROMPT cCHPROMPT of oWORK ; // charter
ACTION ( _Chimport( oRsProj, cPROJECTEID, cMODE, oWork ))


Application
===========
Path and name: C:\FOX\PMOSQL\PmoW32.Exe (32 bits)
Size: 1,717,248 bytes
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 05/21/2008, 14:31:54
Error description: Error BASE/1004 Message not found: TBUTTON:DEFCONTROL

Stack Calls
===========
Called from: => TBUTTON:ERROR(179)
Called from: tobject.prg => (b)HBOBJECT:HBOBJECT(105)
Called from: => TBUTTON:MSGNOTFOUND(0)
Called from: BUTTON.PRG => TBUTTON:DEFCONTROL(167)
Called from: BUTTON.PRG => TBUTTON:REDEFINE(0)
Called from: PROJVIEW.PRG => _PROJVIEW(350)
Called from: PROJBROW.PRG => (b)_PBROW(200)
Called from: CONTROL.PRG => TCONTROL:LDBLCLICK(0)
Called from: WBROWSE.PRG => TWBROWSE:LDBLCLICK(0)
Called from: WINDOW.PRG => TWINDOW:HANDLEEVENT(0)
Called from: CONTROL.PRG => TWBROWSE:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: WINDOW.PRG => TMDIFRAME:ACTIVATE(0)
Called from: MAIN.PRG => MAIN(234)


Any clues ?? using a rather old version or FiveWin .. fwh27 ..

Rick Lipkin
SC Dept of Health, USA
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: PROMT on button

Post by Enrico Maria Giordano »

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oBtn

    DEFINE DIALOG oDlg

    @ 3, 1 BUTTON oBtn;
           PROMPT "&Original";
           ACTION oBtn:SetText( "Changed" )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
EMG
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Enrico

Trying to do this on a redefine .. looking at FiveWin.ch .. 'prompt' is a parameter on the Redefine Button :cry:

I just re-newed my FTDN .. perhaps my old fwh27 has a few 'moths' in it ..

Thanks
Rick Lipkin
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rick,

We have just processed your order, thanks!

Try it this way:
REDEFINE BUTTON oBTN5 PROMPT cCHPROMPT ID 138 of oWORK ;
ACTION ( _Chimport( oRsProj, cPROJECTEID, cMODE, oWork ))

It looks as a preprocessor issue with the compiler version that you are using. Check the resulting PPO file
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Antonio

HMMMM .. that worked .. just had the PROMPT in the wrong place .. Another question .. I would like to turn the PROMPT ( text ) RED if the logical is .f. .. did not see a COLOR clause Button option .. is this doable ??

Thanks
Rick Lipkin
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rick,

Try this:
oButton:SetColor( "R+/W" ) // or use a pair of RGB colors

You may be able to change the text color only
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Antonio

Must be doing something wrong .. getting an error that setcolor is NIL

DO CASE
CASE cISCHARTER = .T. // found a charter document
cCHPROMPT := "This Projects CHARTER [read me]"
oBtn5:SetColor( "G+/W" )
OTHERWISE
cCHPROMPT := "This Projects CHARTER"
oBtn5:SetColor( "R+/W" )
ENDCASE

REDEFINE BUTTON oBTN5 PROMPT cCHPROMPT ID 138 of oWORK ;
ACTION ( _Chimport( oRsProj, cPROJECTEID, cMODE, oWork ))

Application
===========
Path and name: C:\FOX\PMOSQL\PmoW32.Exe (32 bits)
Size: 1,718,272 bytes
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 05/21/2008, 17:30:08
Error description: Error BASE/1004 Class: 'NIL' has no exported method: SETCOLOR
Args:
[ 1] = C G+/W

Stack Calls
===========
Called from: => SETCOLOR(0)
Called from: PROJVIEW.PRG => _PROJVIEW(342)
Called from: PROJBROW.PRG => (b)_PBROW(200)
Called from: CONTROL.PRG => TCONTROL:LDBLCLICK(0)
Called from: WBROWSE.PRG => TWBROWSE:LDBLCLICK(0)
Called from: WINDOW.PRG => TWINDOW:HANDLEEVENT(0)
Called from: CONTROL.PRG => TWBROWSE:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: WINDOW.PRG => TMDIFRAME:ACTIVATE(0)
Called from: MAIN.PRG => MAIN(234)

Must be one of my 'stupid' days .. sorry :?

Rick Lipkin
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rick,

You have to call oBtn:SetColor( ... ) after you REDEFINE it

If you do it before, then oBtn is still nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Antonio

Did not get an error .. but no change in color for the oBtn5 button ..

DO CASE
CASE cISCHARTER = .T. // found a charter document
cCHPROMPT := "This Projects CHARTER [read me]"+space(12)
OTHERWISE
cCHPROMPT := "This Projects CHARTER"+space(40)
ENDCASE

REDEFINE BUTTON oBTN5 PROMPT cCHPROMPT ID 138 of oWORK ;
ACTION ( _Chimport( oRsProj, cPROJECTEID, cMODE, oWork ))

DO CASE
CASE cISCHARTER = .T. // found a charter document
oBtn5:SetColor( "G+/W" )
oBTN5:ReFresh()
SysReFresh()
OTHERWISE
oBtn5:SetColor( "R+/W" )
oBtn5:ReFresh()
SysReFresh()
ENDCASE

Rick Lipkin
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rick,

Please try it again from the ON INIT clause of the dialog:

ACTIVATE DIALOG oDlg ;
ON INIT oBtn5:SetColor( "R+/W" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Antonio

Been one of those days .. just got Sylvia's FTDN renewal notice and I have downloaded the latest FWH .. going to wait til tomorrow to update ..

Unfortunitly .. the ON INIT clause did not change any color on oBtn5 .. did not error .. just did not change the color ..

DO CASE
CASE lISCHARTER = .T. // found a charter document
cCHPROMPT := "This Projects CHARTER [read me]"+space(10)
OTHERWISE
cCHPROMPT := "This Projects CHARTER"+space(40)
ENDCASE

REDEFINE BUTTON oBTN5 PROMPT cCHPROMPT ID 138 of oWORK ;
ACTION ( _Chimport( oRsProj, cPROJECTEID, cMODE, oWork ))

/*
DO CASE
CASE lISCHARTER = .T. // found a charter document
oBtn5:SetColor( "G+/W" )
oBTN5:ReFresh()
SysReFresh()
OTHERWISE
oBtn5:SetColor( "R+/W" )
oBtn5:ReFresh()
SysReFresh()
ENDCASE
*/

REDEFINE BUTTON oBTN6 ID 115 of oWORK // misc documents


ACTIVATE DIALOG oWORK ;
ON INIT( if( cMODE = "V", (oBTN7:Hide(), oBTN8:Hide(), oBtn9:Hide()), ),;
if( lISCHARTER = .T., oBtn5:SetColor( "G+/W" ),oBtn5:SetColor( "R+/W" ) ))
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rick,

We are going to do some tests here.

You may need to use a TBtnBmp instead of a TButton
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Antonio

Thanks a MILLION !!
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rick,

Here you have a working sample using the Class TBtnBmp:

test.prg

Code: Select all

#include "FiveWin.ch"

function Main()

   local oDlg, oBtn

   DEFINE DIALOG oDlg RESOURCE "Test"

   REDEFINE BTNBMP oBtn PROMPT "A Test" ID 100 OF oDlg ACTION MsgInfo( "Click" )
   
   oBtn:SetColor( "R+/W" )
   
   ACTIVATE DIALOG oDlg CENTERED

return nil
test.rc

Code: Select all

test DIALOG 76, 71, 194, 119
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Colors on Buttons"
FONT 8, "MS Sans Serif"
{
 CONTROL "A Test", 100, "TBtnBmp", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 70, 62, 50, 22
}
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Antonio

Worked like a CHAMP !! .. 8:00 pm here .. time for me to go home !!

Thank you VERY Much

Rick Lipkin
Post Reply