#Define mutiline

#Define mutiline

Postby Otto » Wed May 06, 2020 7:25 am

Hello,
Can we insert multiple lines at the same time with #define?

Thank you in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: #Define mutiline

Postby nageswaragunupudi » Wed May 06, 2020 11:05 am

If you mean in one #define, can we create multiple definitions, then it is not possible.
Each define has to be separate.
I am not sure if I understood you correctly.
Regards

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

Re: #Define mutiline

Postby Otto » Wed May 06, 2020 12:13 pm

Dear Mr. Rao,
Yes, that's exactly what I want. Because of the better readability of the source code, it would be fine.
Even when checking the source code, you only need to look at this one #define.
For example:
@ ( oDlg:nHeight - 30 )/2.05, 5 BUTTON "MoveUp" SIZE 35,12 PIXEL OF oDlg ACTION SwapRow( oBrw, .f. )
@ ( oDlg:nHeight - 30 )/2.05, 50 BUTTON "MoveDn" SIZE 35,12 PIXEL OF oDlg ACTION SwapRow( oBrw, .t. )

#DEFINE COLOFFSETBTN nOffset += 5 + oBtn:nwidth
#define MYBTN @ ( oDlg:nHeight - 30 )/2.05, nOffset BUTTON oBtn PROMPT

COLOFFSETBTN
MYBTN "MoveDn" PIXEL OF oDlg ACTION SwapRow( oBrw, .t. )
COLOFFSETBTN
MYBTN "HideSel" PIXEL OF oDlg msginfo("test")
COLOFFSETBTN
MYBTN "Show Select" PIXEL OF msginfo("test")
COLOFFSETBTN
MYBTN "Artikeldatei aktualisieren" ACTION f_verteilen(aData) OF oDlg PIXEL


With Harbourino preprocessor I do it like this.

$-> MYBTN : Caption=MoveUp; Action= msginfo("test")
$-> MYBTN : Caption=MoveDn; Action= SwapRow( oBrw, .t. )
$-> MYBTN : Caption=HideSel; Action= msginfo("test")
$-> MYBTN : Caption=Show Select; Action= msginfo("test")
$-> MYBTN : Caption=Artikeldatei aktualisieren; Action=f_verteilen(aData)

Image

I replace for example
@ ( oDlg:nHeight - 30 )/2.05, 5 BUTTON "MoveUp" SIZE 35,12 PIXEL OF oDlg ACTION SwapRow( oBrw, .f. )
@ ( oDlg:nHeight - 30 )/2.05, 50 BUTTON "MoveDn" SIZE 35,12 PIXEL OF oDlg ACTION SwapRow( oBrw, .t. )

( Calculation of vertical positioning is all automaically. )
with
$-> MYBTN : Caption=MoveUp; Action= SwapRow( oBrw, .f. )
$-> MYBTN : Caption=MoveDn; Action= SwapRow( oBrw, .t. )

I thought maybe it is also possible with #define.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: #Define mutiline

Postby nageswaragunupudi » Wed May 06, 2020 2:10 pm

Code: Select all  Expand view

#xtranslate NEXTBTN <prompt> ACTION <uaction> => ;
   nOffset += 5 + oBtn:nwidth ;;
   @ ( oDlg:nHeight - 30 )/2.05, nOffset BUTTON oBtn PROMPT <prompt> OF oDlg PIXEL ACTION <uaction>

// ....

   NEXTBTN "myprompt" ACTION MsgInfo( "ok" )

 


is preprocessed by Harbour as:

Code: Select all  Expand view
  nOffset += 5 + oBtn:nwidth ; oBtn := TButton():New( ( oDlg:nHeight - 30 )/2.05, nOffset, "myprompt", oDlg, {|| MsgInfo( "ok" )},,,,, .F., .T., .F.,, .F.,,, .F., "oBtn", .F. )
 
Regards

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

Re: #Define mutiline

Postby nageswaragunupudi » Wed May 06, 2020 2:17 pm

With define
Code: Select all  Expand view
#define NEXTBTN nOffset += 5 + oBtn:nwidth; @ ( oDlg:nHeight - 30 )/2.05, nOffset BUTTON oBtn PROMPT
 


With the above definition, this works
Code: Select all  Expand view
  NEXTBTN "MoveDn" PIXEL OF oDlg ACTION SwapRow( oBrw, .t. )
 
Regards

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

Re: #Define mutiline

Postby Otto » Wed May 06, 2020 4:10 pm

Dear Mr. Rao,
thank you so much. I think this offers much power to build his own toolbox.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: #Define mutiline

Postby Otto » Wed May 06, 2020 5:42 pm

Dear Mr. Rao,

I can't find out a way for the first button to define.
I tried this but with no success.
iif( VALTYPE( oBtn) = "C", ( nOffset += 5 + oBtn:nwidth ), nOffset )

So I ended up using 2 xTranslate.

Code: Select all  Expand view
#xtranslate NEXTBTN <prompt> ACTION <uaction> => ;
  nOffset += 5 + oBtn:nwidth ;;
   @ ( oDlg:nHeight - 30 )/2.05, nOffset BUTTON oBtn PROMPT <prompt> SIZE NIL, 25 OF oDlg PIXEL ACTION <uaction>
   
   
   #xtranslate NEXTBTN1 <prompt> ACTION <uaction> => ;
   @ ( oDlg:nHeight - 30 )/2.05, nOffset BUTTON oBtn PROMPT <prompt> SIZE NIL, 25 OF oDlg PIXEL ACTION <uaction>




Code: Select all  Expand view

     #include "nextbtn.ch"
 
    NEXTBTN1 "MoveDn"     ACTION SwapRow( oBrw, .t. )

   NEXTBTN "MoveUp"      ACTION SwapRow( oBrw, .f. )
   
   NEXTBTN "MoveDn"      ACTION SwapRow( oBrw, .t. )

 


Sure, you have a solution for this.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: #Define mutiline

Postby nageswaragunupudi » Thu May 07, 2020 4:45 am

Code: Select all  Expand view

#xtranslate MYBTN <prompt> ACTION <uaction> => ;
   nOffSet := If( oBtn == nil, 5, nOffSet + 5 + oBtn:nWidth );;
   @ oDlg:nHeight - 30, nOffset BUTTON oBtn PROMPT <prompt> SIZE 80, 25 OF oDlg PIXEL ACTION <uaction>

func test

   local oDlg, nOffset, oBtn

   DEFINE DIALOG oDlg SIZE 600,100 PIXEL TRUEPIXEL

   MYBTN "ONE" ACTION MsgInfo( "One" )
   MYBTN "TWO" ACTION MsgInfo( "Two" )
   MYBTN "TEN" ACTION MsgInfo( "ten" )

   ACTIVATE DIALOG oDlg CENTERED

return nil
 


Image
Regards

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

Re: #Define mutiline

Postby Otto » Thu May 07, 2020 7:14 am

Dear Mr. Rao,
thank you. Now it is working fine.
---------------------------------------
May I ask you something else please.
If I use OOP code, how can I pass the parameters.


Code: Select all  Expand view
#xtranslate NEXTBTN <prompt> ACTION <uaction> => ;
    nOffSet := If( oBtn == nil, 5, nOffSet + 5 + oBtn:nWidth );;
   oBtn := TButton():New( ( oDlg:nHeight - 30 )/2.05, nOffset, , oDlg, ,      ,   30      ,,, .F., .T., .F.,, .F.,,, .F., , .F. )


With my code all buttons have caption "Button".

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: #Define mutiline

Postby nageswaragunupudi » Thu May 07, 2020 10:06 am

Code: Select all  Expand view
#xtranslate NEXTBTN <prompt> ACTION <uAction> => ;
   nOffSet := If( oBtn == nil, 5, nOffSet + 5 + oBtn:nWidth );;
   oBtn := TButton():New( oDlg:nHeight - 50, nOffset, <prompt>, oDlg, ;
   [\{||<uAction>\}], 80, 25,,, .F., .T., .F.,, .F.,,, .F., "oBtn", .F. )

 

This works.
But I do not advise preprocessing BUTTON command.
Anyway, that is your choice.
Regards

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

Re: #Define mutiline

Postby Otto » Thu May 07, 2020 12:49 pm

Dear Mr. Rao,

It works perfectly.
I think you can tremendously simplify the source code of your programs.
Comments can be inserted in the #xtranslate files, and the reading flow in the actual program is not disturbed.

I want to show how easy it is to rearrange the switch.
You swap the lines and don't have to worry about anything.
I think even in preparation for the change of the own programs to mod Harbour this can bring something.
Maybe we find a way to exchange the #xTranslate files.

Thanks again.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: #Define mutiline

Postby Otto » Thu May 07, 2020 4:15 pm

Dear Mr. Rao,
Can you help me again, please? I would now like to assign a background color.
But the Button color of oBtn does not change.
Best regards,
Otto

Code: Select all  Expand view

#xtranslate NEXTBTN <prompt> ACTION <uAction> => ;
   nOffSet := If( oBtn == nil, 5, nOffSet + 5 + oBtn:nWidth );;
   oBtn := TButton():New( oDlg:nHeight/2.05 - 50, nOffset, <prompt>, oDlg, ;
   [\{||<uAction>\}], , 25,,, .F., .T., .F.,, .F.,,, .F., "oBtn", .F. );;
   oBtn:nClrPane := CLR_GREEN
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: #Define mutiline

Postby nageswaragunupudi » Thu May 07, 2020 5:56 pm

TButton and TButtonBmp are Windows controls. We can not set colors.

It is possible to set colors for TBtnBmp only.
Regards

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

Re: #Define mutiline

Postby Otto » Thu May 07, 2020 6:33 pm

Dear Mr. Rao,
I have seen that TButton inherit from TControl.
But I have not checked whether the paint method takes into account all the data. I will test with ButtonBmp.

I think we should extend AUTOCODE in this direction. :D

Thank you for your help and best regard
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: #Define mutiline

Postby nageswaragunupudi » Fri May 08, 2020 2:31 am

Yes. TButton and all other FWH controls are derived from TControl.

TButton class creates a Windows "BUTTON" control and the button is painted by Windows only. TButton does not have its own paint method.

TButtonBmp is derived from TButton class. So this control also creates a Windows "BUTTON" control. This class has its own Paint() method. The Paint() method uses Windows to paint the button and then paints the bitmap over the button.

Therefore, in both the above cases, button is actually painted by Windows.

In contrast, TBtnBmp and TFlatBtn do not depend on any Windows control and paint the entire button themselves.
Regards

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

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