'RichEdit20W' class is blank

  Load "Outlook Express version 6.0" and open an email.
   There are four items above the email body: "From:", "Date:", "To:", "Subject:".

   Using "Spy++" each of these fields were identified as a 'RichEdit20W' class.

   However, using the API call GetWindowText() only the "Date:" and "Subject:" fields return any information.  The "From:" and "To:" fields are blank.

   Any idea where Outlook Express hides the "From:" and "To:" information?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richie_SimonettiIT OperationsCommented:
don't use that API, try with SendMessage API WM_GETTEXT parameter.
Richie_SimonettiIT OperationsCommented:
if i remember well:

dim buff as string * 255
SendMessage hwnd,WM_GETTEXT,255,byval buff
Buff should contains the captured text
Richie_SimonettiIT OperationsCommented:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_GETTEXT = &HD

sub test
Dim buff As String * 255
'hwnd is the handle to 'RichEdit20W' window
SendMessage hwnd, WM_GETTEXT, 255, ByVal buff
'Buff should contains the captured text
msgbox Left$(buff, InStr(1, buff, Chr$(0), vbTextCompare) - 1)
end sub
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

EasyAimAuthor Commented:
Good answer but that isn't it either.  I went back through my code and I was already using your suggested "SendMessage(hWnd, WM_GETTEXT, ....)" to no avail.

What's interesting is that using

iNumLines = SendMessage(hWnd, EM_GETLINECOUNT, 0&, 0&)

 I get "1" returned.  But I can't seem to extract the text that shows up in the Outlook Express "From:" field.
Richie_SimonettiIT OperationsCommented:
OK. As you said, those fields are diffrent from the others:
Use Spy++ and see Style value ;)
Maybe changing the style of that fields we could use those other API.
EasyAimAuthor Commented:
I'm not sure how "Style" would help.
Here's another hint:  When the "To:" field has multiple email addresses, the only thing that shows up in the 'RichEdit20W' extracted text is a row of semi-colons.  The actual email addresses are missing.
Richie_SimonettiIT OperationsCommented:
well, not the best approach but:

Option Explicit

Private Const EM_SETSEL = &HB1
Private Const WM_COPY = &H301

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Dim h As Long
Private Sub Form_Click()
Dim ret As Long
SendMessage h, EM_SETSEL, 0&, 0&
SendMessage h, WM_COPY, 0&, 0&
Dim v as boolean
v = Clipboard.Getformat(vbCFText)
if v then
   msgbox Clipboard.GetText(vbCFText)

end if
End Sub

Private Sub Form_Load()
h = 460092
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EasyAimAuthor Commented:
   Another good idea but unfortunately, it didn't work either.   Again, it has very strange behavior in that it shows up as a "RichEdit20W" and it is readable on the form but the 'WM_GETTEXT' command returns nothing and attempts at 'EM_SETSEL' fail also (the SendMessage function is returning a zero).

   Also:  When you go to the "To:" field and select the name there (say "John Doe") and 'Copy' it to the clipboard and then paste it to Notepad it returns  "John Doe  <jdoe@trash.com>"

Richie_SimonettiIT OperationsCommented:
But i tested and it works! I did the same test as yours and everything works fine. Did you change the hwnd number from my example, didn't you?
I tested with "To:" field from a message.
EasyAimAuthor Commented:
oops, I stand corrected.... you're right it does work.  My first attempt failed for some reason.   The cut/paste method is clunky but I'm happy to get it any way I can.  I'll continue researching a more graceful method.

Thanks Richie!
Richie_SimonettiIT OperationsCommented:
Thanks to you.
As i said, "well, not the best approach but:" ...it works.
I got several GPF (in VB and in OE but, strange, not in both at same time :D) before got this way.
If your want continue crashing your pc, check a list of this Riched constants for sendmessage:

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.