Question Label Name in the button

Abbashatim

New Member
The label in the button widget is displayed in one line.
I want to display the label in multiple lines. The height of the button is big, but the width is not long enough to show the label of the button. I want to show the label in multiple lines. Is this possible.
If so can some one please guide me.

thanks
abbas
 

TheMadDBA

Active Member
Not with a standard 4GL/ABL button.

You can use an image for the label or use a .NET/OCX button that supports word wrap.
 

Abbashatim

New Member
Thanks for your reply. Is there anyway you can guide me to use .Net/OCX button.
The label is a variable I need to display based on the record selected.
 

Osborne

Active Member
There are some basic examples in the GUI for .NET Programming manual - dvngp.pdf. I have copied one of these examples and added the .NET button workings:
Code:
DEFINE VARIABLE b2 AS System.Windows.Forms.Button NO-UNDO.
DEFINE VARIABLE b2Label AS CHAR INITIAL ".NET Button Label 2 Lines" NO-UNDO.
DEFINE VARIABLE hWin AS HANDLE NO-UNDO.
DEFINE VARIABLE MainForm AS Progress.Windows.Form NO-UNDO.
DEFINE VARIABLE WinContainer AS Progress.Windows.WindowContainer NO-UNDO.

DEFINE BUTTON b1 LABEL "Progress Button" SIZE 20 BY 1.14.
DEFINE FRAME f1 b1 AT ROW 2 COL 21 WITH SIDE-LABELS THREE-D SIZE 60 BY 6.

CREATE WINDOW hWin ASSIGN
   WIDTH = 60
   HEIGHT = 6.
FRAME f1:PARENT = hWin.

ON CHOOSE OF b1 DO:
   MESSAGE "Click of Progress Button." VIEW-AS ALERT-BOX.
END.

/* Create the .NET form. */
MainForm = NEW Progress.Windows.Form( ).
MainForm:Text = "Embedded Window Sample".
MainForm:ClientSize = NEW System.Drawing.Size(hwin:WIDTH-PIXELS, hwin:HEIGHT-PIXELS).
MainForm:FormClosed:Subscribe( "Window_FormClosed" ).
MainForm:Show( ).

/* Create the .NET button. */
b2 = NEW System.Windows.Forms.Button().
b2:Location = NEW System.Drawing.Point(100, 60).
b2:Name = "b2".
b2:Size = NEW System.Drawing.Size(102, 39).
b2:Text = b2Label.
b2:Click:Subscribe("b2Clicked").
MainForm:Controls:Add(b2).

/* Create the WindowContainer, embedding the window into it. */
WinContainer = NEW Progress.Windows.WindowContainer( ).
WinContainer:Size = NEW System.Drawing.Size( hWin:WIDTH-PIXELS, hWin:HEIGHT-PIXELS ).
WinContainer:EmbeddedWindow = hWin.
WinContainer:Parent = MainForm.
WinContainer:Show( ).

/* Now make the window visible.
It will be realized inside the WindowContainer. */
hWin:VISIBLE = YES.
ENABLE ALL WITH FRAME f1.

WAIT-FOR System.Windows.Forms.Application:Run(MainForm).

/* Delete the embedded window after the main form closes. */
PROCEDURE Window_FormClosed:
   DEFINE INPUT PARAMETER sender AS System.Object.
   DEFINE INPUT PARAMETER e AS System.EventArgs.

   DELETE WIDGET hWin.
END PROCEDURE.

PROCEDURE b2Clicked:
   DEFINE INPUT PARAMETER sender AS CLASS System.Object NO-UNDO.
   DEFINE INPUT PARAMETER e AS CLASS System.EventArgs NO-UNDO.

   MESSAGE "Click of .NET Button." VIEW-AS ALERT-BOX.
END PROCEDURE.
 
I do not know what your exact requirements are, but there are two strategies I generally use for my coding:
1) Give concise name for your button and add ToolTip for the complete description
2) If the text to be shown on the button is "fixed" you can create your button using images. I do it from AppBuilder > Add Button> Property Sheet

PS: I tried Osbornes solution and it worked perfectly for me.
 

nborshukov

New Member
You can use Windos API functions to get multiline button label.
To use attached procedure:
1. Set label of your button using any delimiter, for eaxample comma, to specify lines.
2. Call attached procedure, passing button handle and delimiter as input parameters.
NOTE: You may call procedure once per button!
 

Attachments

  • set-multiline-button.p
    789 bytes · Views: 2

nborshukov

New Member
Code:
define input parameter b-h as handle no-undo.
define input parameter lbl-delim as character no-undo.


define variable iStyle as integer no-undo.
define variable oldStyle as integer no-undo.


    run GetWindowLongA(b-h:hwnd,-16,output iStyle).
    run SetWindowLongA(b-h:hwnd,-16,iStyle + 8192,output oldStyle).
    b-h:label = replace(b-h:label,lbl-delim,chr(10)).


procedure  GetWindowLongA external "user32":U:
   define input parameter hWnd as long.
   define input parameter iIdx as long.
   define return parameter iValue as long.
end.

procedure  SetWindowLongA external "user32":U:
   define input parameter hWnd as long.
   define input parameter iIdx as long.
   define input parameter iValue as long.
   define return parameter oldValue as long.
end.
 

Abbashatim

New Member
Dear nborshukov
Thanks for your help. How do I pass the button detail to b-h handle.
I tried assign b-h = button-1 (where button-1 is the object name of the button).
It gives me error 'Incompitable data types in expression or assignment, (223)
Please help.
thank you
 

RealHeavyDude

Well-Known Member
You are confusing the handle ( pointer to the object in memory ) with the reference ( name of the widget ) of the button widget.

In order to get the handle of the button you need to execute code similar to this:
Code:
define variable buttonHandle as handle  no-undo.
do with frame {&frame-name}:
     assign buttonHandle =  myButton:handle.
end.

You could also use a widget-walk on the frame to access the handle to the button - but, when you know the reference then it is very easy to access the handle just by accessing the handle attribute of the button widget.

Heavy Regards, RealHeavyDude.
 
Top