Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

PB/WIN 7, RichEdit fonthandling/popup menu sample

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PB/WIN 7, RichEdit fonthandling/popup menu sample

    improved/updated version of: http://www.powerbasic.com/support/pb...ad.php?t=23176
    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' richedit demo - public domain by borje hagsten, october 2002
    ' shows how to change font settings in selection and update controls
    ' when caret moves around, etc. even handles wingdings font properly.
    '
    ' basically the same as a sample i posted a year ago, but updated
    ' for pbwin 7.0 (can now use plain charformat structure), plus i
    ' added a working right-click popup edit menu. also implemented
    ' %scf_word to enable settings on non-selected word at caret's place.
    ' note: no sub-classing needed or used for right-click popup menu.
    ' %em_seteventmask enables us to get the notifications we need anyway.
    '
    ' tip: can combine this sample with don dickinson's excellent rtf routines
    ' (see: [url="http://dickinson.basicguru.com/code_other.htm"]http://dickinson.basicguru.com/code_other.htm[/url]  add ways to set bulleted
    ' paragraphs, etc. via em_setparaformat, mix it all up in notepad sample
    ' and you have made yourself an almost complete word processor. also, lots
    ' of other richedit samples here with code that can be fun to add..    [img]http://www.powerbasic.com/support/forums/smile.gif[/img]
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #compile exe
    #include "win32api.inc"
    #include "richedit.inc"
     
    %idbtn_bold     = %wm_user + 110
    %idbtn_italic   = %wm_user + 111
    %idbtn_uline    = %wm_user + 112
    %idbtn_strike   = %wm_user + 113
    %idchk_color    = %wm_user + 120
    %idcb_fontnames = %wm_user + 130
    %idcb_fontsizes = %wm_user + 131
    %id_richedit    = %wm_user + 150
    %idm_undo       = %wm_user + 220
    %idm_cut        = %wm_user + 222
    %idm_copy       = %wm_user + 223
    %idm_paste      = %wm_user + 224
    %idm_delete     = %wm_user + 225
    %idm_selall     = %wm_user + 226
     
    global hdlg as long, hedit as long, hlib as long, glf as logfont
     
    declare callback function dlgproc() as long
    declare function getrfname() as string
    declare function getrfsize() as long
    declare function getrfeffect() as long
    declare function getrfcolor() as long
    declare function enumfontfamproc(lf as logfont, tm as textmetric, _
                                     byval fonttype as long, lret as long) as long
    declare sub setrfname(byval fontname as string)
    declare sub setrfsize(byval fontsize as long)
    declare sub setrfeffect(byval fonteffect as long)
    declare sub setrfcolor(byval fontcolor as long)
    declare sub updatecontrols
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' create dialog and controls, etc
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    function pbmain () as long
     
      hlib = loadlibrary("riched32.dll")
      if hlib = 0 then exit function
     
      dialog new 0, "tinyword - richedit sample for pbwin 7.0",,, 300, 242, _
                    %ws_border or %ws_sysmenu, 0 to hdlg
     
      control add "richedit", hdlg, %id_richedit, "here is some text to start with..", 4, 24, 289, 200, _
                  %ws_child or %ws_visible or %es_multiline or %ws_hscroll or %ws_vscroll or _
                  %es_autovscroll or %es_nohidesel or %es_wantreturn, %ws_ex_clientedge
      control send hdlg, %id_richedit, %em_setoptions, %ecoop_or, %eco_selectionbar
      control handle hdlg, %id_richedit to hedit
     
      control add combobox, hdlg, %idcb_fontnames, ,   4, 4, 100, 120, _
                            %cbs_dropdownlist or %cbs_sort or %ws_vscroll
     
     'should enumerate, but lazy - with truetype font one can simply list desired sizes..
      redim fs(15) as string
      fs(0)  = "8"  : fs(1)  = "9"  : fs(2)  = "10" : fs(3)  = "11"
      fs(4)  = "12" : fs(5)  = "14" : fs(6)  = "16" : fs(7)  = "18"
      fs(8)  = "20" : fs(9)  = "22" : fs(10) = "24" : fs(11) = "26"
      fs(12) = "28" : fs(13) = "36" : fs(14) = "48" : fs(15) = "72"
      control add combobox, hdlg, %idcb_fontsizes, fs(), 110, 4, 30, 120, _
                            %cbs_dropdownlist or %ws_vscroll
     
      control add button, hdlg, %idbtn_bold,     "&b",    150, 4, 14,  14, %bs_autocheckbox or %bs_pushlike
      control add button, hdlg, %idbtn_italic,   "&i",    164, 4, 14,  14, %bs_autocheckbox or %bs_pushlike
      control add button, hdlg, %idbtn_uline ,   "&u",    178, 4, 14,  14, %bs_autocheckbox or %bs_pushlike
      control add button, hdlg, %idbtn_strike ,  "&s",    192, 4, 14,  14, %bs_autocheckbox or %bs_pushlike
      control add checkbox, hdlg, %idchk_color , "&red ", 210, 4, 30, 14
      control add button, hdlg, %idcancel,       "e&xit", 242, 4, 50, 14
     
      dialog show modal hdlg call dlgproc
    end function
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' main callback
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    callback function dlgproc() as long
     
      select case cbmsg
         case %wm_initdialog 'first message - initiate
            local hdc as long, lret as long, txt as string, cr as charrange
     
            lret = 1 'enumerate all fonts and fill font name combobox
            hdc = getdc(%hwnd_desktop)
            enumfontfamilies hdc, byval %null, codeptr(enumfontfamproc), byval varptr(lret)
            releasedc %hwnd_desktop, hdc
     
            'set event mask so we'll get en_selchange and %enm_mouseevents notifications
            control send hdlg, %id_richedit, %em_seteventmask, 0, %enm_selchange or %enm_mouseevents
     
            'start out with this font
            call sendmessage(hedit, %em_setsel, 0, -1)
            setrfname "times new roman"
            setrfsize 12
            call sendmessage(hedit, %em_setsel, 200, 200)
            call sendmessage(hedit, %em_emptyundobuffer, 0, 0)
            setfocus hedit
     
            'uncomment next line to test with another background color
            'sendmessage hedit, %em_setbkgndcolor, 0, rgb(0,255,255)
     
         case %wm_destroy
            if hlib then freelibrary hlib
     
         case %wm_command
            select case cbctl
               case %idcancel 'exit (also via escape key)
                  if cbctlmsg = %bn_clicked then dialog end cbhndl
     
               'edit menu commands
               case %idm_undo
                  if cbctlmsg = %bn_clicked then
                     sendmessage hedit, %em_undo, 0, 0
                     updatecontrols
                  end if
     
               case %idm_cut
                  if cbctlmsg = %bn_clicked then
                     sendmessage hedit, %wm_cut, 0, 0
                     updatecontrols
                  end if
     
               case %idm_copy   : 
                  if cbctlmsg = %bn_clicked then
                     sendmessage hedit, %wm_copy, 0, 0
                     updatecontrols
                  end if
     
               case %idm_paste  : 
                  if cbctlmsg = %bn_clicked then
                     sendmessage hedit, %wm_paste, 0, 0
                     updatecontrols
                  end if
     
               case %idm_delete : 
                  if cbctlmsg = %bn_clicked then
                     sendmessage hedit, %wm_clear, 0, 0
                     updatecontrols
                  end if
     
               case %idm_selall
                  if cbctlmsg = %bn_clicked then
                     cr.cpmin = 0 : cr.cpmax = -1
                     sendmessage hedit, %em_exsetsel, 0, varptr(cr) 'get selstart and selend
                  end if
     
               'format controls commands
               case %idcb_fontnames
                  if cbctlmsg = %cbn_selendok then
                     combobox get text cbhndl, %idcb_fontnames to txt
                     setrfname txt
                  end if
     
               case %idcb_fontsizes
                  if cbctlmsg = %cbn_selendok then
                     combobox get text cbhndl, %idcb_fontsizes to txt
                     setrfsize val(txt)
                  end if
     
               case %idbtn_bold
                  if cbctlmsg <> %bn_clicked then exit function
                  if sendmessage(cblparam, %bm_getcheck, 0, 0) then
                     setrfeffect byval (getrfeffect or %cfe_bold)
                  else
                     setrfeffect byval (getrfeffect and not %cfe_bold)
                  end if
     
               case %idbtn_italic
                  if cbctlmsg <> %bn_clicked then exit function
                  if sendmessage(cblparam, %bm_getcheck, 0, 0) then
                     setrfeffect byval (getrfeffect or %cfe_italic)
                  else
                     setrfeffect byval (getrfeffect and not %cfe_italic)
                  end if
     
               case %idbtn_uline
                  if cbctlmsg <> %bn_clicked then exit function
                  if sendmessage(cblparam, %bm_getcheck, 0, 0) then
                     setrfeffect byval (getrfeffect or %cfe_underline)
                  else
                     setrfeffect byval (getrfeffect and not %cfe_underline)
                  end if
     
               case %idbtn_strike
                  if cbctlmsg <> %bn_clicked then exit function
                  if sendmessage(cblparam, %bm_getcheck, 0, 0) then
                     setrfeffect byval (getrfeffect or %cfe_strikeout)
                  else
                     setrfeffect byval (getrfeffect and not %cfe_strikeout)
                  end if
     
               case %idchk_color
                  if cbctlmsg <> %bn_clicked then exit function
                  if sendmessage(cblparam, %bm_getcheck, 0, 0) then
                     setrfcolor %red
                  else
                     setrfcolor %black
                  end if
     
            end select
     
         case %wm_notify
            local hmenuedit as long, pnmh as nmhdr ptr, mf as msgfilter ptr, pt as pointapi
            pnmh = cblparam
     
            if @pnmh.hwndfrom = hedit then
               if @pnmh.code = %en_selchange then 'update comboboxes and effect buttons..
                  updatecontrols
               elseif @pnmh.code = %en_msgfilter then 'see if user right-clicked for popup menu
                  mf = cblparam
                  if @mf.msg = %wm_rbuttondown then 'ok, so build and show popup menu
                     sendmessage hedit, %em_exgetsel, 0, varptr(cr) 'get selstart and selend
     
                     menu new popup to hmenuedit
                       menu add string, hmenuedit, "&undo"  & $tab & "ctrl + z", %idm_undo, _
                                iif&(sendmessage(hedit, %em_canundo, 0, 0), %mf_enabled, %mf_grayed)
                       menu add string, hmenuedit, "-", 0, 0
                       menu add string, hmenuedit, "cu&t"   & $tab & "ctrl + x", %idm_cut, _
                                iif&(cr.cpmin <> cr.cpmax, %mf_enabled, %mf_grayed)
                       menu add string, hmenuedit, "&copy"  & $tab & "ctrl + c", %idm_copy, _
                                iif&(cr.cpmin <> cr.cpmax, %mf_enabled, %mf_grayed)
                       menu add string, hmenuedit, "&paste" & $tab & "ctrl + v", %idm_paste, _
                                iif&(sendmessage(hedit, %em_canpaste, 0, 0), %mf_enabled, %mf_grayed)
                       menu add string, hmenuedit, "&delete" & $tab & "del", %idm_delete, _
                                iif&(cr.cpmin <> cr.cpmax, %mf_enabled, %mf_grayed)
                       menu add string, hmenuedit, "-", 0, 0
                       menu add string, hmenuedit, "&select all" & $tab & "ctrl + a", %idm_selall, _
                                iif&(sendmessage(hedit, %wm_gettextlength, 0, 0), %mf_enabled, %mf_grayed)
     
                     pt.x = lowrd(@mf.lparam)
                     pt.y = hiwrd(@mf.lparam)
                     clienttoscreen hedit, pt 'convert mouse position
                     trackpopupmenu hmenuedit, 0, pt.x, pt.y, 0, cbhndl, byval %null
                  end if
               end if
            end if
     
      end select
    end function
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' set font name at caret's place/selection
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    sub setrfname(byval fontname as string)
      local hdc as long, lret as long, cf as charformat
     
      cf.cbsize = len(cf)
      cf.dwmask = %cfm_face or %cfm_charset
     
      hdc = getdc(%hwnd_desktop) 'important: get proper bcharset and bpitchandfamily via enumeration
      enumfontfamilies hdc, byval strptr(fontname), codeptr(enumfontfamproc), byval varptr(lret)
      releasedc %hwnd_desktop, hdc
     
      cf.szfacename      = glf.lffacename
      cf.bcharset        = glf.lfcharset
      cf.bpitchandfamily = glf.lfpitchandfamily
     
      call sendmessage(hedit, %em_setcharformat, %scf_word or %scf_selection, varptr(cf))
      updatecontrols
     
    end sub
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' set font size at caret's place/selection
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    sub setrfsize(byval fontsize as long)
      local cf as charformat
     
      cf.cbsize = len(cf)
      cf.dwmask = %cfm_size
      cf.yheight = fontsize * 20
     
      call sendmessage(hedit, %em_setcharformat, %scf_word or %scf_selection, varptr(cf))
      updatecontrols
     
    end sub
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' set font effect at caret's place/selection
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    sub setrfeffect(byval fonteffect as long)
      local cf as charformat
     
      cf.cbsize    = len(cf)
      cf.dwmask    = %cfm_bold or %cfm_italic or %cfm_underline or %cfm_strikeout
      cf.dweffects = fonteffect
     
      call sendmessage(hedit, %em_setcharformat, %scf_word or %scf_selection, varptr(cf))
      updatecontrols
     
    end sub
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' set text color at caret's place/selection
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    sub setrfcolor(byval fontcolor as long)
      local cf as charformat
     
      cf.cbsize = len(cf)
      cf.dwmask = %cfm_color
      cf.crtextcolor = fontcolor
     
      call sendmessage(hedit, %em_setcharformat, %scf_word or %scf_selection, varptr(cf))
      updatecontrols
     
    end sub
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' enumerate fonts
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    function enumfontfamproc(lf as logfont, tm as textmetric, _
                             byval fonttype as long, lret as long) as long
      if lret = 0 then
         glf = lf
      else
         if (fonttype and %truetype_fonttype) then
            combobox add hdlg, %idcb_fontnames, lf.lffacename
         end if
      end if
      function = lret  'lret decides: 0 stops enumeration, <> 0 makes sure it continues
    end function
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' return font name at caret's place
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    function getrfname() as string
      local cf as charformat
     
      cf.cbsize = len(cf)
      cf.dwmask = %cfm_face
     
      call sendmessage(hedit, %em_getcharformat, %scf_selection, varptr(cf))
     
      function = cf.szfacename
    end function
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' return font size at caret's place
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    function getrfsize() as long
      local cf as charformat
     
      cf.cbsize = len(cf)
      cf.dwmask = %cfm_size
     
      call sendmessage(hedit, %em_getcharformat, %scf_selection, varptr(cf))
     
      function = cf.yheight / 20
    end function
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' return font effects at caret's place
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    function getrfeffect() as long
      local cf as charformat
     
      cf.cbsize = len(cf)
      cf.dwmask = %cfm_bold or %cfm_italic or %cfm_underline or %cfm_strikeout
     
      call sendmessage(hedit, %em_getcharformat, %scf_selection, varptr(cf))
     
      function = cf.dweffects
    end function
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' return text color at caret's place
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    function getrfcolor() as long
      local cf as charformat
     
      cf.cbsize = len(cf)
      cf.dwmask = %cfm_color
     
      call sendmessage(hedit, %em_getcharformat, %scf_selection, varptr(cf))
     
      function = cf.crtextcolor
    end function
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' update comboboxes and font effect buttons
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    sub updatecontrols
      local lret as long, txt as string
     
      txt = getrfname
      sendmessage getdlgitem(hdlg, %idcb_fontnames), %cb_selectstring, -1, byval strptr(txt)
     
      txt = format$(getrfsize)
      sendmessage getdlgitem(hdlg, %idcb_fontsizes), %cb_selectstring, -1, byval strptr(txt)
     
      lret = getrfeffect
      control send hdlg, %idbtn_bold, %bm_setcheck, _
                   iif&((lret and %cfe_bold), %bst_checked, %bst_unchecked), 0
     
      control send hdlg, %idbtn_italic, %bm_setcheck, _
                   iif&((lret and %cfe_italic), %bst_checked, %bst_unchecked), 0
     
      control send hdlg, %idbtn_uline, %bm_setcheck, _
                   iif&((lret and %cfe_underline), %bst_checked, %bst_unchecked), 0
     
      control send hdlg, %idbtn_strike, %bm_setcheck, _
                   iif&((lret and %cfe_strikeout), %bst_checked, %bst_unchecked), 0
     
      lret = getrfcolor
      control send hdlg, %idchk_color, %bm_setcheck, _
                   iif&(lret = %red, %bst_checked, %bst_unchecked), 0
     
      setfocus hedit
     
    end sub
    ------------------




    [this message has been edited by borje hagsten (edited october 07, 2002).]
Working...
X