'RichEdit20W' class is blank

Posted on 2003-03-30
Medium Priority
Last Modified: 2007-12-19
  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?

Question by:EasyAim
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
LVL 16

Expert Comment

ID: 8236802
don't use that API, try with SendMessage API WM_GETTEXT parameter.
LVL 16

Expert Comment

ID: 8236818
if i remember well:

dim buff as string * 255
SendMessage hwnd,WM_GETTEXT,255,byval buff
Buff should contains the captured text
LVL 16

Expert Comment

ID: 8236832
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8242363
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.
LVL 16

Expert Comment

ID: 8246372
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.

Author Comment

ID: 8246676
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.
LVL 16

Accepted Solution

Richie_Simonetti earned 1200 total points
ID: 8247403
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

Author Comment

ID: 8247679
   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>"

LVL 16

Expert Comment

ID: 8247703
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.

Author Comment

ID: 8248725
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!
LVL 16

Expert Comment

ID: 8248815
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:


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question