1. Re: copy in win32lib?

On Fri, 11 Aug 2000 14:00:10 -0400, John Coonrod wrote:

>I find that the copy(object) to clipboard procedure in win32lib doesn't
>seem to work, at least in my Windows 2000 machine. Is there some trick to
>it I don't know about? Thanks.

Yes, the trick is that your text must be selected in order to copy it.
Below is a demo that selects all text in an MleText box then copys it to
the clipboard when you click on a button:

include win32lib.ew

constant
  Win = create( Window, "Copy demo", 0, Default, Default, 300, 200, 0 ),
  Box = create( MleText, "Hello World...", Win, 5, 5, 285, 120, 0 ),
  Btn = create( PushButton, "Copy to clipboard", Win, 5,135,100,30, 0 )

procedure onClick_Btn()
  atom result
  -- you must select text to copy...
  -- this is how you can select all text in a text box
  result = sendMessage( Box, EM_SETSEL, 0, -1 )
  -- note: this message does not return anything but since sendMessage
  --       is a function, we must assign it's value to something
  -- we could just say "if sendMessage( Box, EM_SETSEL, 0, -1 ) then end if"

  -- now we can copy to clipboard
  copy( Box )
end procedure
onClick[Btn] = routine_id( "onClick_Btn" )

----------------------
WinMain( Win, Normal )
----------------------

-- Hope this helps...
-- Brian

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu