WM_PASTE weirdness

This is a discussion on WM_PASTE weirdness within the Windows Programming forums, part of the Platform Specific Boards category; I'm writing a WordPad clone with wxWidget. The text control should be a native Windows control. A strange thing appeared ...

  1. #1
    The larch
    Join Date
    May 2006
    Posts
    3,573

    WM_PASTE weirdness

    I'm writing a WordPad clone with wxWidget. The text control should be a native Windows control.

    A strange thing appeared when trying to copy rather large amount of text (around 80000 characters) both with the wxTextCtrl::Paste function and with SendMessage and WM_PASTE: at first attempt only about 30000 characters are pasted, at second attempt more but still not all and only at third attempt is everything pasted successfully. It looks as if some sort of internal buffer is incrementally enlarged and if it cannot be made large enough with one step, only as much as pasted as currently possible (and at next attempt the buffer is enlarged by the same step).

    Has anyone else experienced this and is there a solution?

    I also discovered the same behaviour in an older no-rich-text Notepad clone of mine (also coded with wxWidgets), so I doubt it is just some undefined behaviour on my part.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    The same behaviour can be observed for example with this code (add WS_VSCROLL to the rich edit controls and try to paste an enormous lot of text into it).

    It appears that indeed text controls have a default size how much text can be typed or pasted into them (and wxWidgets apparently tries to increase that internally but doesn't for some reason get the size right and instead increases the max limit in fixed steps?).

    Currently I just put this in the text editors constructor, so it would let me at least paste up to around 1000000 characters:
    Code:
        //increase text limit to allow larger documents to be pasted
        SendMessage((HWND)GetHandle(), EM_EXLIMITTEXT, 0, 1 << 20);
    However, since it is a tabbed program and can have many text controls open, is it a good idea to set that kind of max size to any text control the program might have?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pass-by-value weirdness
    By sillyfofilly in forum C Programming
    Replies: 8
    Last Post: 02-16-2009, 09:08 AM
  2. rand() weirdness
    By Mostly Harmless in forum C++ Programming
    Replies: 3
    Last Post: 08-26-2006, 12:41 AM
  3. weirdness
    By newbieneedzhelp in forum C Programming
    Replies: 2
    Last Post: 07-02-2005, 03:38 PM
  4. allegro weirdness, <fstream> errors
    By ichijoji in forum Game Programming
    Replies: 2
    Last Post: 02-16-2003, 09:46 PM
  5. while loop weirdness (does not accept compound statements?)
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 03-01-2002, 12:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21