如何在 Delphi 5 中从 TDBGrid 获取选定的单元格
我在表单上有一个 DBGrid,并且我做了多个选择,我现在需要将选定的单元格(它们是电子邮件地址)发送到 Outlook 的“收件人框”,我该怎么做,我将不胜感激任何帮助(Delphi5) 提前致谢
I have a DBGrid on a form and I have made multiple selections, I now need to send the selected cells (they are email addresses) to the "TO Box" of Outlook how can I do this, I will appreciate any help ( Delphi5)
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要获取所选电子邮件的列表,您可以使用此过程。 对于 Outlook,您可能需要使用 shellexec 和 mailto: 或使用 API(如果有)。
To get list of selected E-Mails you can use this procedure. For outlook you might want to use shellexec and mailto: or use API if there's any.
smok1:您检查过您的解决方案是否真正有效吗? 尝试单击“发送”按钮。 OE 说虽然在文本框中没有输入地址。 或者单击文本框左侧的图标。 OE 看不到使用 WM_SETTEXT 输入的地址。 您必须手动输入它。
smok1: have you checked if your solution is actually working? Try to click Send button. OE says there is no address antered although it is in text box. Or click the icon on the left of text box. OE doesn't see address enterered using WM_SETTEXT. You have to manually type it.
Windows 中的每个(几乎)控件本身就是一个窗口。 它有它的类和实例名称。 由于每个邮件客户端中每个 MailTo 窗口的构造保持相同,因此在了解如何找到适当的控件后,可以构建解决方案。
这就是 Visual Studio 中的 Spy++ 派上用场的地方(如果您没有它,请尝试找到一些类似的工具,有一个免费软件版本 http://msdn.microsoft.com/pl-pl/magazine/cc163617(en-us).aspx 但它缺乏酷搜索工具)。
因此,启动 Spy++ 和邮件程序后,我们点击“新邮件”,就会出现邮件窗口。 在 Spy++ 中刷新,然后使用“查找窗口”工具 - 单击您的 TO 列表,您将看到它是如何构建的。
我从 Outlook Express 开始。 邮件窗口是ATH_Note类,然后地址区域内是一个OE_Envelope类的窗口,该窗口内有几个窗口,其中一些是RichEdit20W类的窗口。 “收件人”字段是第一个字段。
注意:当第二个参数为 0 时,FindWindowEx 将始终搜索行中的第一个 - 所以,但如果您执行以下操作:
文本将被放入第二个编辑字段中。 请参阅 FindWindowEx 的 msdn。
因此,这对于 OE (XP SP3 IE7) 有好处。 但是 MS Outlook 又如何呢? 我在工作中用 Spy++ 检查了它,“To”字段是连续第二个“RichEdit20WPT”类(末尾注意 T),父类是“#32770(对话框)”,其父类是“AfxWndW”,并且一次同样,父类是“AfxWndW”(这是 TPanel 中的某种 MS 风格的 TPanel)和 – tadam! – 邮件窗口属于“rctrl_renwnd32”类。 所以伪代码是:
也许您会想要使用 WM_GETTEXT 来提取当前文本并相应地更新新文本,但这超出了进入编辑字段的范围。
顺便说一句:此代码强烈依赖于 Outlook 版本,因此请先尝试使用 Spy++ 检查您的版本)。
Every (almost) control in Windows is a window itself. It has got its class and instance name. Since the construction of every MailTo window in each mail client remains the same, after gaining knowledge how to find appropriate control a solution can be built.
This is where Spy++ from Visual Studio comes in handy (if you do not have it, try to find some similar tool, there is a freeware version at http://msdn.microsoft.com/pl-pl/magazine/cc163617(en-us).aspx but it lacks cool searching tool).
So, After starting Spy++ and mail program, we hit “New mail” and mailing window will appear. Refresh in Spy++, and use “Find window” tool – click on your TO list, and you will se how it is built.
I started with Outlook Express. The mail window is of class ATH_Note, then inside address area is a window of class OE_Envelope and inside this window there are several windows, some of them are of class RichEdit20W. The “To” field is the first one.
Note: FindWindowEx when second param is 0 will always search for FIRST in the row – so, but if you will do sth like this:
The text will be put in a SECOND edit field. See msdn for FindWindowEx.
So, this is good for OE (XP SP3 IE7). But what with MS Outlook? I checked it with Spy++ at work and “To” Field is a second in a row “RichEdit20WPT” class (note T on the end), parent class is “#32770 (Dialog)”, parent of this is “AfxWndW” and once again parent class is “AfxWndW” (this is some kind MS-style TPanel in TPanel) and – tadam! – mail window is of a class “rctrl_renwnd32”. So the pseudocode for this will be:
Probably you will want to use WM_GETTEXT to extract current text and update new text accordingly, but this is beyond the scope of getting into edit field.
BTW: This code strongly depends of outlook version, so try to check your version with Spy++ before).