0

0

Windows 10 Notifications from a VCL app with the WinRT API

絕刀狂花

絕刀狂花

发布时间:2025-08-31 08:40:01

|

655人浏览过

|

来源于php中文网

原创

the winrt api headers for delphi are now available on getit, and you can explore a demo showcasing the use of windows 10 notifications in a vcl win32 application.


The WinRT API headers for Delphi are now accessible on GetIt, providing you with a demo to explore the use of Windows 10 notifications within a VCL Win32 application.

We recently conducted a Windows 10 focused webinar, featuring a Microsoft guest alongside a few of us (myself, David I, Jim McKeeth, and JT) discussing Windows 10 and the capabilities RAD Studio XE8 offers for upcoming Windows versions. If you missed the event, the replay will be available soon. During the webinar, apart from classic demos, I demonstrated a VCL application utilizing Windows 10 notifications, a feature not supported by traditional Win32 APIs but accessible through the new WinRT APIs.

Interested in obtaining the headers for this API and running a working demo? Continue reading to find out how...

The WinRT API headers for Windows 10 are now available on GetIt for all developers using Delphi or RAD Studio XE8 (note that there is currently no direct support for C++). Simply access GetIt in XE8 and select the relevant entry as shown below.

Windows 10 Notifications from a VCL app with the WinRT APIPlease be aware that this code targets the Windows 10 preview, and both the APIs and our header translations may evolve in the coming months. You may need to adjust or clean up your code later, but it's advantageous to start working with WinRT classes in XE8 now.

The WinRT Notification Demo offers an example of a unique feature available only through WinRT: "toast" notifications. While the API is accessible, it isn't encapsulated in ready-to-use components, making the code somewhat complex. I'll highlight the core elements rather than listing the entire code. Our goal is to achieve this:

萝卜简历
萝卜简历

免费在线AI简历制作工具,帮助求职者轻松完成简历制作。

下载

Windows 10 Notifications from a VCL app with the WinRT APIHere's a snippet of the code used to create a notification. As you can see, WinRT classes function similarly to COM objects, sharing a common architecture. Object creation is more intricate than using a CoClass (or class factory):

if Succeeded(RoGetActivationFactory(LString, TGUID.Create('{50AC103F-D235-4598-BBEF-98FE4D1A3AD4}'), LCreated)) then    begin      LINotificationManagerStatics := LCreated as IToastNotificationManagerStatics;      if Succeeded(WindowsCreateString(PWideChar(Edit1.Text), Length(Edit1.Text), LString2)) then      begin        LToastNotifier := LINotificationManagerStatics.CreateToastNotifier(LString2);        LXMLTemplate := LINotificationManagerStatics.GetTemplateContent(ToastTemplateType.ToastText02);        if Succeeded(WindowsCreateString(PWideChar(SToastNotification), Length(SToastNotification), LString)) then        begin          if Succeeded(RoGetActivationFactory(LString, TGUID.Create('{04124124B20-82C6-4229-B109-FD9ED4662B53}'), LCreated)) then          LToastFactory := LCreated as IToastNotificationFactory;          LToast := LToastFactory.CreateToastNotification(LXMLTemplate);          LAccepted := TAcceptedEventHandler.Create;          LToast.add_Activated(LAccepted);          LToastNotifier.Show(LToast);        end;

The TAcceptedEventHandler class includes an invoke callback method that logs the acceptance of the notification in the memo. Here's the code:

procedure TAcceptedEventHandler.Invoke(sender: IToastNotification; args: IInspectable);begin  Form51.Memo1.Lines.Add ('You clicked on the notification!');end; 

I acknowledge that referencing the global form directly might not be ideal, but the complexity of the code justifies avoiding additional indirection. Are you interested in trying this out? You can download the full demo at dl.dropboxusercontent.com/u/133855/WinRTCheck.zip. I plan to update it and potentially create more examples covering other new WinRT features.

Windows 10 is on the horizon, promising to be a significant release. Start exploring the Windows 10 Preview now, and use XE8 to experiment with integrating your VCL (and FireMonkey) applications with it.

相关专题

更多
if什么意思
if什么意思

if的意思是“如果”的条件。它是一个用于引导条件语句的关键词,用于根据特定条件的真假情况来执行不同的代码块。本专题提供if什么意思的相关文章,供大家免费阅读。

755

2023.08.22

while的用法
while的用法

while的用法是“while 条件: 代码块”,条件是一个表达式,当条件为真时,执行代码块,然后再次判断条件是否为真,如果为真则继续执行代码块,直到条件为假为止。本专题为大家提供while相关的文章、下载、课程内容,供大家免费下载体验。

91

2023.09.25

java break和continue
java break和continue

本专题整合了java break和continue的区别相关内容,阅读专题下面的文章了解更多详细内容。

256

2025.10.24

class在c语言中的意思
class在c语言中的意思

在C语言中,"class" 是一个关键字,用于定义一个类。想了解更多class的相关内容,可以阅读本专题下面的文章。

465

2024.01.03

python中class的含义
python中class的含义

本专题整合了python中class的相关内容,阅读专题下面的文章了解更多详细内容。

13

2025.12.06

function是什么
function是什么

function是函数的意思,是一段具有特定功能的可重复使用的代码块,是程序的基本组成单元之一,可以接受输入参数,执行特定的操作,并返回结果。本专题为大家提供function是什么的相关的文章、下载、课程内容,供大家免费下载体验。

479

2023.08.04

js函数function用法
js函数function用法

js函数function用法有:1、声明函数;2、调用函数;3、函数参数;4、函数返回值;5、匿名函数;6、函数作为参数;7、函数作用域;8、递归函数。本专题提供js函数function用法的相关文章内容,大家可以免费阅读。

163

2023.10.07

windows查看端口占用情况
windows查看端口占用情况

Windows端口可以认为是计算机与外界通讯交流的出入口。逻辑意义上的端口一般是指TCP/IP协议中的端口,端口号的范围从0到65535,比如用于浏览网页服务的80端口,用于FTP服务的21端口等等。怎么查看windows端口占用情况呢?php中文网给大家带来了相关的教程以及文章,欢迎大家前来阅读学习。

621

2023.07.26

Java编译相关教程合集
Java编译相关教程合集

本专题整合了Java编译相关教程,阅读专题下面的文章了解更多详细内容。

0

2026.01.21

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
PostgreSQL 教程
PostgreSQL 教程

共48课时 | 7.5万人学习

Excel 教程
Excel 教程

共162课时 | 12.7万人学习

PHP基础入门课程
PHP基础入门课程

共33课时 | 2万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号