Thread: EM_GETLINE And Unicode?

  1. #16
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You need to use SendMessageTimeout and not SendMessage if you want to obtain line counts etc from a multi-line edit/richedit that belongs to another application. Also, but not related to your original problem, if you're going to use SetTimer then make sure you kill it off with KillTimer.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  2. #17
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    thanks for the reply, i tried this and had the same effect as before.

  3. #18
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    UNICODE is not the problem, the window handle you're using probably is. Try using an explicit handle for a known, open and active richedit/edit control (use spy++ or, if you don't have it, get a free variation from here; use the tool to get the handle of an active edit/richedit control). When you compare that with whatever handle you're trapping in code you'll probably find they're different.

    Other test code you might consider implementing include
    • Testing the handle you are attempting to use to ensure it actually belongs to an edit/richedit control ( use GetWindowLong/GetWindowLongPtr to test the style bits for ES_MULTILINE (if this style is absent from the window under scrutiny then messages such as EM_GETLINE and EM_GETLINECOUNT will always fail); popup a messagebox if the ES_MULTILINE style is absent).
    • Testing the return value from SendMessageTimeOut

    If, after taking some or all of these steps, you still have problems then post/attach your amended code.
    Last edited by Ken Fitlike; 08-01-2004 at 06:05 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed