BUTTON question?

Post Reply
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

BUTTON question?

Post by dutch »

Dear Antonio,

1. BUTTON class does still support CRLF for seperate line?
2. BUTTON Caption can define left alignment?

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

Post by Antonio Linares »

Dutch,

> 1. BUTTON class does still support CRLF for seperate line?

Only if you use it from resource and you use this style:
#define BS_MULTILINE 1024

> 2. BUTTON Caption can define left alignment?

Same as above but using BS_LEFTTEXT
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Even from code:

Code: Select all

#include "Fivewin.ch"


#define CR CHR( 13 )

#define BS_MULTILINE 8192


FUNCTION MAIN()

    LOCAL oDlg, oBtn

    DEFINE DIALOG oDlg

    @ 1, 1 BUTTON oBtn PROMPT "&Close" + CHR( 13 ) + "the dialog";
           SIZE 50, 30;
           ACTION oDlg:End()

    oBtn:nStyle = NOR( oBtn:nStyle, BS_MULTILINE )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
EMG
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Ops, sorry, I wasn't aware that this is the FWPCC forum. But maybe it could still work.

EMG
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

It works with DIALOGs but not with WINDOWs and I don't know why:

Code: Select all

#include "Fwce.ch"


#define BS_MULTILINE 8192


FUNCTION MAIN()

    LOCAL oDlg, oBtn

    DEFINE DIALOG oDlg

    @ 1, 1 BUTTON oBtn PROMPT "&Close" + CHR( 13 ) + "the dialog";
           SIZE 50, 30;
           ACTION oDlg:End()

    oBtn:nStyle = NOR( oBtn:nStyle, BS_MULTILINE )

    ACTIVATE DIALOG oDlg

    RETURN NIL
EMG
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

It works perfect.

Post by dutch »

Dear Antonio&Enrico,

It works perfect now.

#define BS_MULTILINE 8192 and CR CHR(13)

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

Post by Antonio Linares »

Enrico,

> It works with DIALOGs but not with WINDOWs and I don't know why:

Because in dialogs, the control style is used when building the dialog.

In a window, the window already exists and the control is created later on.
regards, saludos

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

Post by Antonio Linares »

Enrico,

In a window it may work using SetWindowLong( oButton:hWnd, GWL_STYLE, nOr( GetWindowLong( oButton:hWnd, GWL_STYLE ), BS_... ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Confirmed!

Code: Select all

#include "Fwce.ch"


#define GWL_STYLE -16
#define BS_MULTILINE 8192


FUNCTION MAIN()

    LOCAL oWnd, oBtn

    DEFINE WINDOW oWnd

    @ 1, 1 BUTTON oBtn PROMPT "&Close" + CHR( 13 ) + "the window";
           SIZE 60, 50;
           ACTION oWnd:End()

    ACTIVATE WINDOW oWnd;
             ON INIT SETWINDOWLONG( oBtn:hWnd, GWL_STYLE, NOR( GETWINDOWLONG( oBtn:hWnd, GWL_STYLE ), BS_MULTILINE ) )

    RETURN NIL
EMG
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

#DefineBS_LEFTTET 32 is not working?

Post by dutch »

Dear Antonio&Enrico,

This code does not work.

oBtn:nStyle := NOR( oBtn:nStyle, BS_LEFTTEXT )

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

Post by Antonio Linares »

Dutch,

Please try it as Enrico's sample code.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

BUTTON question again?

Post by dutch »

Dear Antonio,

Can I change oBtn:cCaption that create from source code in FWPPC. In FW/Clipper I do it from Resource and change :cCaption and :Refresh(). It works ok but I try with FWPPC. It doesn't change.

oBtn:cCaption := 'Next Caption"
oBtn:Show()
oBtn:Refresh()

Example
======

Code: Select all

DEFINE DIALOG oDlg FROM  0, 0.2 TO  nHeight,nWidth ;   
           PIXEL 
            
     for n := 1 to 21
          MakeBtn( n, oDlg, nRow, nCol, aPost )
          if nRow >= 72
              nRow := 0
              nCol += 36	   
           else
              nRow += 12
           end
    next      
    	   @  96.8,85  BTNBMP FILENAME (cPath+"ARRUP.BMP") ;
       			   SIZE   23,13 ;
       			   WHEN (nPage>1) ;
       			   ACTION KeyPage( oDlg, aPost, .T. , .F. )

	   @ 110,85    BTNBMP FILENAME (cPath+"ARRDN.BMP") ;
       			   SIZE   23,12 ;
       			   WHEN (nEndPage=0) ;
       			   ACTION KeyPage( oDlg, aPost, .F. , .T. )
 
Return

*------------------*
Static Procedure MakeBtn(n,oDlg,nRow,nCol,aPost)
if empty(ACT->ACCT_CODE)
   MadeBtn( n, oDlg, nRow, nCol, ACT->ACCT_CODE, rtrim(ACT- >ACCT_EDESC ), ACT->ACCT_TYPE, aPost )
end
ACT->(DbSkip())
*----------------------------*
Procedure MaeBtn( n, oDlg, nRow, nCol, cTrn, cDesc, cType, aPost )

if !empty(cTrn)
   @ (nRow), (nCol) BUTTON oBtns[n] ;
                PROMPT left(cDesc,14) ;
                FONT oFnts ;   
                SIZE 35, 12 ;
                PIXEL ;
                ACTION ( aadd( aPost,{ str(len(aPost)+1,2), cDesc, str(iif  (empty(cQty),1,val(cQty)),7,2), cTrn } ), (cQty := '') )
                
   oBtns[n]:nStyle := NOR( oBtns[n]:nStyle, BS_MULTILINE )
   
else
   @ (nRow), (nCol) BUTTON oBtns[n] ;
   				FONT oFnts ;
   				SIZE 35, 12 ;
   				PIXEL 
end

return      

*------------------*
Function KeyPage( oDlg, aPost, lPrev, lNext )
local n, nRow, nCol
local lChk := .F.
local nMultiple := 2
local cCap, aMenuItems := {}

if (nPage > 1 .and. lPrev) .or. (nEndPage=0.and.lNext)
   if lNext
      nPage += 1
   elseif lPrev
   	  nPage -= 1
      ACT->(DbGoTop())
      if nPage > 1
  	     ACT->(DbSkip((nPage-1)*21))
      end
   end
   for n := 1 to 21
       if !empty(ACT->ACCT_CODE)  
          aadd( aMenuItems, { ACT->ACCT_CODE , rtrim(ACT->ACCT_EDESC) } )
       else
          oBtns[n]:Hide()
          oBtns[n]:Refresh()
       end
       if !empty(ACT->ACCT_CODE)
          ACT->(DbSkip())          
       end
   next
   
end	  
// Last page checking
if !empty(ACT->ACCT_CODE)
   if nEndPage > 0
      nEndPage -= nEndPage
   end
end

for n := 1 to len(aMenuItems)
    ShowMenu( aMenuItems, n )
next

return 

*--------------------------------*
Function ShowMenu( aMenuItems, n )
local cCap, cTrn

cTrn := aMenuItems[n][1]
cCap := left( aMenuItems[n][2], 28 )
     
oBtns[n]:cCaption := cCap
oBtns[n]:bAction  := {|| ( aadd( aPost,{ str(len(aPost)+1,2), cCap , str(iif(empty(cQty),1,val(cQty)),7,2),  } ), (cQty := '') ) }
oBtns[n]:Show()
oBtns[n]:Refresh()
         
return
Best regards,
Dutch
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Dutch,

Try this:

oBtn:SetText( "Next Caption" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

It works ok now.

Post by dutch »

Dear Antonio,

It works perfect now.

Thanks&Regards,
Dutch
Post Reply