home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / LOADTB.E < prev    next >
Text File  |  1995-10-09  |  2KB  |  59 lines

  1. ; Command to load a previously-saved toolbar, by Larry Margolis
  2.  
  3. compile if not defined(EPMINFO_EDITFRAME)
  4.    include 'stdconst.e'
  5. compile endif
  6.  
  7. compile if not EPM32
  8.    *** Error:  EPM 6 or above required for Toolbar support.
  9. compile endif
  10.  
  11. compile if not defined(ERROR__MSG)
  12.    include 'english.e'
  13. compile endif
  14.  
  15. const
  16.    NO_TOOLBARS__MSG =     'No saved toolbars from which to select.'
  17.    LOAD_TOOLBAR__MSG =    'Load Toolbar'  -- Dialog box title
  18.    SELECT_TOOLBAR__MSG =  'Select a Toolbar menu set'
  19.    TOOLBAR_UNKNOWN__MSG = 'Toolbar unknown:  '
  20.  
  21. defc load_toolbar
  22.    universal app_hini, toolbar_loaded
  23.    TB_name = arg(1)
  24.    if TB_name='' then  -- List all toolbars
  25.       inidata = queryprofile(app_hini, INI_UCMENU_APP, '')
  26.       if not length(inidata) then sayerror NO_TOOLBARS__MSG; return; endif
  27.       getfileid startfid
  28.       'xcom e /c /q tempfile'
  29.       if rc<>-282 then  -- sayerror('New file')
  30.          sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  31.          return
  32.       endif
  33.       .autosave = 0
  34.       browse_mode = browse()     -- query current state
  35.       if browse_mode then call browse(0); endif
  36.       do while inidata<>''
  37.          parse value inidata with menuname \0 inidata
  38.          insertline menuname, .last+1
  39.       enddo
  40.       if browse_mode then call browse(1); endif  -- restore browse state
  41.       if listbox_buffer_from_file(startfid, bufhndl, noflines, usedsize) then return; endif
  42.       parse value listbox(LOAD_TOOLBAR__MSG, \0 || atol(usedsize) || atoi(32) || atoi(bufhndl),
  43.                           '/'OK__MSG'/'Cancel__MSG'/'Help__MSG,1,5,min(noflines,12),0,
  44.                           gethwndc(APP_HANDLE) || atoi(1) || atoi(1) || atoi(7000) ||
  45.                           SELECT_TOOLBAR__MSG) with button 2 TB_name \0
  46.       call buffer(FREEBUF, bufhndl)
  47.       if button<>\1 then return; endif
  48.    else
  49.       inidata = queryprofile(app_hini, INI_UCMENU_APP, TB_name)
  50.       if inidata = '' then
  51.          sayerror TOOLBAR_UNKNOWN__MSG || TB_name
  52.          return
  53.       endif
  54.    endif
  55.    call windowmessage(0, getpminfo(EPMINFO_EDITFRAME), 5916, app_hini, put_in_buffer(TB_name))
  56.    toolbar_loaded = menuname
  57.  
  58.  
  59.