copy text from a label?

maesn

New Member
Is it possible to make a label in a browser that you can copy the text from, I don't want to be able to alter the text just copy it... /maesn
 
Is it possible to make a label in a browser that you can copy the text from, I don't want to be able to alter the text just copy it... /maesn


On windows you can use the clipboard. Here is a sample procedure.

Code:
DEFINE VARIABLE C-Win   AS WIDGET-HANDLE    NO-UNDO.
DEFINE VARIABLE cLabel  AS CHARACTER        NO-UNDO.
/* Button to copy the label */
DEFINE BUTTON Copylabel 
     LABEL "COPY LABEL" 
     SIZE 15 BY 1.14.
/* Query definitions                                                    */
DEFINE QUERY BROWSE-2 FOR 
      Customer SCROLLING.
/* Browse definitions                                                   */
DEFINE BROWSE BROWSE-2
  QUERY BROWSE-2 NO-LOCK DISPLAY
      Customer.CustNum FORMAT ">>>>9":U
      Customer.Name FORMAT "x(30)":U
    WITH NO-ROW-MARKERS SEPARATORS SIZE 129 BY 14.76 FIT-LAST-COLUMN.

/* ************************  Frame Definitions  *********************** */
DEFINE FRAME DEFAULT-FRAME
     BROWSE-2 AT ROW 1.24 COL 3 WIDGET-ID 200
     Copylabel AT ROW 15.05 COL 133 WIDGET-ID 2
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
         SIDE-LABELS NO-UNDERLINE THREE-D 
         AT COL 1 ROW 1
         SIZE 156.4 BY 16 WIDGET-ID 100.
/* Window definition */
CREATE WINDOW C-Win ASSIGN
         HIDDEN             = YES
         TITLE              = "<insert window title>"
         HEIGHT             = 16
         WIDTH              = 156.4
         MAX-HEIGHT         = 16
         MAX-WIDTH          = 156.4
         VIRTUAL-HEIGHT     = 16
         VIRTUAL-WIDTH      = 156.4
         RESIZE             = yes
         SCROLL-BARS        = no
         STATUS-AREA        = no
         BGCOLOR            = ?
         FGCOLOR            = ?
         KEEP-FRAME-Z-ORDER = yes
         THREE-D            = yes
         MESSAGE-AREA       = no
         SENSITIVE          = yes.
/* Triggers */
ON 'WINDOW-CLOSE':U OF c-Win
DO:
    APPLY "CLOSE" TO THIS-PROCEDURE.
END.
/* When user presses a label in the browse the name of the label will be assigned to a variable */
ON START-SEARCH OF BROWSE-2 IN FRAME DEFAULT-FRAME /* Browse 1 */
DO:
  cLabel = SELF:CURRENT-COLUMN:LABEL.
END.
ON CHOOSE OF Copylabel IN FRAME DEFAULT-FRAME /* Copy */
DO:
    CLIPBOARD:VALUE = cLabel.    /* Copy the label to the windows clipboard. */
END.
/* This will enable the columns of the browse so you can click on it */
ASSIGN 
       BROWSE-2:ALLOW-COLUMN-SEARCHING IN FRAME DEFAULT-FRAME = TRUE.
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
THEN C-Win:HIDDEN = no.
ENABLE ALL WITH FRAME default-frame IN WINDOW C-Win.
OPEN QUERY browse-2 FOR EACH Customer.
WAIT-FOR "CLOSE" OF THIS-PROCEDURE.
 
Back
Top