[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2901.0. "Customer with a listbox problem" by KETJE::DIERICK (Have Telescopes, Will Travel) Fri Jun 08 1990 05:59


A customer has a problem with the listbox. He is using VMS 5.3.
This is the situation :

He has a listbox where he allows single and extended select.
When he has made an extended selection using Shift-MB1 and then
he tries to do a single select on the LAST item he has selected using
extended select, the single select does not work and he gets a callback
for extended select ( the extended select remains visible in the list
box too).
This does not show whenever he single selects another item then the
last one of his previously extended selected list of items.

Any clues ?

Dominique
T.RTitleUserPersonal
Name
DateLines
2901.1Pascal Example that allows mixed single or extended callbacksCSC32::B_KEMPI just answer the phoneFri Jun 08 1990 16:42198
     Try this and see if it will work for your customer.  It is written
in Pascal and does not really do anything, but it seems to solve your 
customer's problem.  

     BTW, you have to hack on the cda$def.pas file to get it into a 
format that will compile to form the .pen file.  Otherwise just define
the necessary constants that it contains in your program and don't inherit
it.

     Hope this helps...

Bill


(*  PROGRAM LIST_BOX.PAS:                                         *)
(*  Example of creating a List_Box Widget in Pascal with a single *)
(*  Callback routine and one item selected.                       *) 

[Inherit( 'sys$library:decw$dwtwidgetdef',  (* DECwindows Toolkit *)
          'sys$library:pascal$lib_routines',(* RTL's definitions  *)
          'sys$library:cda$def',            (* Charset definitions*)
          'sys$library:starlet' )]          (* System definitions *)

Program list_box(output);

 Var
  toplevel,
  listbox,
  workbox         : dwt$widget;             (* Widget ID's        *)
  arglist         : array[0..7] of dwt$arg; (* Array of Arg's     *)
  argc            : dwt$cardinal := 0;      (* Null argc          *)
  i,status        : integer;                (* Control varibles   *)
  visible_count   : integer;                (* Visible in list    *)
  items_count     : integer;                (* Total in list      *)
  sel_items_count : integer;                (* Selected items     *)
  position        : boolean := false;       (* Default postion    *)
  charset         : unsigned := cda$k_iso_latin1;  (* CharSet     *)
  rend            : dwt$rend_mask := NIL;   (* Null redtion mask  *)
  cancel_label    : packed array [1..15] of char; (* Button label *)
  excallback      : array [1..2] of dwt$callback; (* Callback     *)
  callback        : array [1..2] of dwt$callback; (* Callback     *)
  strings         : array [1..4] of packed array [1..12] of char;
  cs_cancel_label : dwt$comp_string;        (* Compound strings   *)
  sel_items       : array [1..1] of dwt$comp_string;
  items           : array [1..4] of dwt$comp_string;
  sel_bool        : boolean:=FALSE;    
    
 (*  Callback routine for the listbox widget.  It manages the   *)
 (*  workbox and displays the selected item in the workbox.     *)
 (*  Tag is the widget id of the unmanaged workbox widget.      *)

 Procedure ListboxCallback(    widget : dwt$widget;
                           VAR tag    : dwt$widget;
                           VAR list   : dwt$listbox_cb_st);
  Var
    arglist            : array[0..1] of dwt$arg;

  Begin (* ListboxCallback *)

    if list.dwt$l_listbox_item_number = 4 then
     $EXIT(1);

    Dwt$VMS_Set_Arg(list.dwt$a_listbox_item, 
                    arglist, 0, Dwt$C_Nlabel);
    Xt$Set_Values( tag, arglist, 1 );
    
    Xt$Manage_Child( tag );

  End; (* ListboxCallback *)
 (*  Callback routine for the listbox widget.  It manages the   *)
 (*  workbox and displays the selected item in the workbox.     *)
 (*  Tag is the widget id of the unmanaged workbox widget.      *)


 Procedure ListboxExCallback(    widget : dwt$widget;
                           VAR tag    : dwt$widget;
                           VAR list   : dwt$listbox_cb_st);
  Var
    arglist            : array[0..1] of dwt$arg;

  Begin (* ListboxExCallback *)

    WriteLn('This is the extended callback');

    if list.dwt$l_listbox_item_number = 4 then
     $EXIT(1);

    Dwt$VMS_Set_Arg(list.dwt$a_listbox_item, 
                    arglist, 0, Dwt$C_Nlabel);
    Xt$Set_Values( tag, arglist, 1 );
    
    Xt$Manage_Child( tag );

  End; (* ListboxExCallback *)


  Begin (* Main program *)

  (*  Initialize the Toolkit.  *)

    toplevel:= Xt$Initialize( 'List',       (* application name *)
                              'listclass',  (* application class *)
                              0, 0, argc);

    Dwt$VMS_Set_Arg(400, arglist, 0, Dwt$C_Nx);
    Dwt$VMS_Set_Arg(200, arglist, 1, Dwt$C_Ny);
    Xt$Set_Values( toplevel, arglist, 2 );

    (* Cancel label for cancel button in the workbox.  *)

    cancel_label := 'Acknowledged';

    status := Dwt$CS_String(cancel_label,charset,
                            dwt$c_language_not_specified,
                            0,rend,
                            cs_cancel_label);
    if (not odd(status)) then lib$stop(status);

    (*  Set up the arg list for the workbox.  *)

    Dwt$VMS_Set_Arg(Dwt$C_Modal, arglist, 0, Dwt$C_Nstyle);
    Dwt$VMS_Set_Arg( position, arglist, 1, Dwt$C_Ndefault_Position);
    Dwt$VMS_Set_Arg(200, arglist,2, Dwt$C_Nx);
    Dwt$VMS_Set_Arg(200, arglist, 3, Dwt$C_Ny);
    Dwt$VMS_Set_Arg(cs_cancel_label, arglist, 4, Dwt$C_Ncancel_label);

    (*  Create a modal workbox, but do not manage it.  It will  *)
    (*  be managed in the callback routine.                     *)

    workbox := Dwt$Work_Box_Create(toplevel, 'WorkBox', arglist,5);


  
    (*  Set up the items to be displayed as the list in the list  *)
    (*  box widget.                                               *)

    strings[1] := 'Begin';
    strings[2] := 'Continue';
    strings[3] := 'Finish';
    strings[4] := 'Stop';

    (*  Convert the list to a list of compound strings.  *)

    for i := 1 to 4 do
     begin
      status := Dwt$CS_String(strings[i],charset,
                              dwt$c_language_not_specified,
                              0,rend,
                              items[i]);
      if (not odd(status)) then lib$stop(status);
     end;


    (*  Listbox attributes *)

    items_count := 4;
    sel_items_count := 1;
    visible_count := 4;
    sel_items[1] := items[1];
    
    (*  Initialize a callback routine data structure with the  *)
    (*  listbox's callback routine's address.                  *)

    callback[1].dwt$a_callback_proc::integer := iaddress(ListboxCallback);
    callback[1].dwt$l_callback_tag::integer := iaddress(workbox);
    callback[2].dwt$a_callback_proc::integer := 0;

    excallback[1].dwt$a_callback_proc::integer := iaddress(ListboxExCallback);
    excallback[1].dwt$l_callback_tag::integer := iaddress(workbox);
    excallback[2].dwt$a_callback_proc::integer := 0;

    (*  Set up an arg list for the listbox.  *)

    Dwt$VMS_Set_Arg( iaddress(items), arglist, 0, Dwt$C_Nitems );
    Dwt$VMS_Set_Arg( items_count, arglist, 1, Dwt$C_Nitems_Count );
    Dwt$VMS_Set_Arg( iaddress(sel_items), arglist, 2, Dwt$C_Nselected_Items);
    Dwt$VMS_Set_Arg( sel_items_count, arglist, 3, 
                          Dwt$C_NSelected_items_count);
    Dwt$VMS_Set_Arg( visible_count, arglist, 4, Dwt$C_Nvisible_Items_Count);
    Dwt$VMS_Set_Arg( sel_bool, arglist, 5, Dwt$C_Nsingle_Selection);
    Dwt$VMS_Set_Callback_Arg( callback, arglist, 6, Dwt$C_Nsingle_Callback);
    Dwt$VMS_Set_Callback_Arg( excallback, arglist, 7, Dwt$C_Nextend_Callback);

    (*  Create and Manage the listbox widget.  *)

    listbox := Dwt$List_Box_Create(toplevel,'l_box',arglist,8);
    Xt$Manage_Child( listbox );


    (*  Realize the toplevel widget  *)

    Xt$Realize_Widget( toplevel );

   
    (*  Enter the Main Loop.  *)
 
    Xt$Main_Loop
  End (* listbox *).