how to put a private-data of a button in to a browse

afm

New Member
Hi All.
Could anyone tell me how to solve this problem ?
I have a movable button and i want to drop that buton in to a cell browse and put the private-data of the button in to the cell that i choose to drop.

can anyone tell me how i can do that ?

many thanks

Martins
 

Casper

ProgressTalk.com Moderator
Staff member
To my knowledge you cannot get the handle to a browser cell after an endmove trigger. So I tried to hack around a bit and I came up with this.
It kinda works, provided you have a row selected in the browse. If you drag the button to the column with label "Drop" then the private-data is copied to the calculated field of the selected row in the browser. A bit of quick and dirty happy hacking ;)

Code:
define variable name-hdl as handle.
define variable num-hdl as handle.
define variable calc-col-hdl as handle.
define variable browse-hdl as handle.
define button btn-quit label "&Quit"  auto-endkey.
DEFINE VARIABLE hQuery AS HANDLE      NO-UNDO.
define variable j as integer.
DEFINE VARIABLE btnDrop AS HANDLE      NO-UNDO.
define frame MyFrame skip(10)
             btn-quit
       with size 80 by 22.
 
create button btnDrop
       assign label = 'dropPrivateData'
              frame = frame MyFrame:HANDLE
              width = 30
              x = 34
              y = 211
              visible = yes
              sensitive = yes
              movable = yes
              selectable = yes
              private-data = 'some data'
    triggers:
       on end-move persistent run movetrig.
    end triggers.
create query hQuery.
hQuery:add-buffer(buffer customer:handle).
hQuery:query-prepare('For each customer no-lock').
hQuery:query-open().
 
create browse browse-hdl
    assign title = "Dynamic Browse"
           frame = frame MyFrame:HANDLE
           query  = hQuery
           x = 2
           y = 2
           width = 74
           down = 6
           read-only=no
           VISIBLE = yes
           SENSITIVE = true
            . 
num-hdl = browse-hdl:ADD-LIKE-COLUMN("customer.custnum").
name-hdl = browse-hdl:ADD-LIKE-COLUMN("customer.name").
calc-col-hdl = browse-hdl:ADD-CALC-COLUMN("CHARACTER","X(15)","","Drop").
 
browse-hdl:refresh().
browse-hdl:expandable = yes.
on choose of btn-quit do:
    quit.
end.
enable all with frame MyFrame.
wait-for close of current-window. 
procedure movetrig:
    do j = 1 to browse-hdl:num-columns:
        if browse-hdl:num-selected-rows <> 0
        then do:
            if browse-hdl:get-browse-column(j):label= 'drop' and
               browse-hdl:get-browse-column(j):x <= self:x and
               self:y >= browse-hdl:get-browse-column(3):height-pixels and
               self:y <= browse-hdl:height-pixels
            then assign calc-col-hdl:screen-value = btnDrop:private-data.
        end.
        else if browse-hdl:get-browse-column(j):label= 'drop' and
             browse-hdl:get-browse-column(j):x <= self:x and
             self:y >= browse-hdl:get-browse-column(3):height-pixels and
             self:y <= browse-hdl:height-pixels
        then message 'please select row first' view-as alert-box information.
    end.
    assign btnDrop:x = 34
           btnDrop:y = 211.
end procedure.

HTH,

Casper.
 
Top