如何在桌面上创建苍蝇 [英] How to Create Flies on Desktop

查看:117
本文介绍了如何在桌面上创建苍蝇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友



我在互联网上看到一个允许在桌面上创建多个苍蝇的应用程序。



每个Fly都可以轻松地在桌面上走动。



现在从编程方面来说,我们可以使用Win 32 API甚至是MFC创建相同的想法吗?



关于

解决方案

您可以使用普通的Win32 API或MFC来创建一个透明窗口,它可能还需要实现点击到下面的任何窗口,设置 always-on-top 标志并处理自己的非客户端绘图以及普通的 WM_PAINT 消息,这样您就可以取消框架和标题。

从Win32或MFC的角度来看,有许多示例代码项目文章涵盖了这些内容,透明度,非客户端绘制和始终在线



另一种方法是使用 Microsoft Agent 基于COM的API,让自己成为一个新角色。基本上这是臭名昭着的Clippy背后的技术,但你对它的使用并不一定是丑陋或烦人的。



可能还有其他更多侵入性或棘手的技术,如挂钩桌面本身的重绘,但是这种方法越狡猾,通常越难以使其在不同的Windows版本中可靠地工作。

<无论哪种方式,你都需要成为一个合理的艺术家,掌握动画如何运作才能获得真实或有趣的东西。


使用SHGetFolderPath()函数Win32 / MFC获取用户桌面的路径。

然后使用CreateDirectory()函数创建文件夹。

使用CreateFile()函数或CFile类对象创建文件夹路径。

Hello Friends

I saw an application on internet which allows to create multiple flies on desktop.

Each Fly walks around Desktop easily.

Now Programmatically speaking, any idea we can create the same using Win 32 API or even MFC ?

Regards

解决方案

You could use plain Win32 API or MFC to make a transparent window which would probably also need to implement click-through to any window underneath, have always-on-top flags set and handle is own Non-Client paint as well as ordinary WM_PAINT messages so you can do away with the frame and caption.
There are numerous sample Code Project articles covering these things, transparency, non-client painting and always-on-top from a Win32 or MFC perspective.

An alternative would be to use the Microsoft Agent COM based API and make your self a new character. Essentially this is the technology behind the infamous ''Clippy'' but your usage of it doesn''t have to be hideous or annoying.

There may be other more intrusive or tricky techniques like hooking the redraw of the Desktop itself but the more sneaky the approach then generally the harder it is to make it work reliably across different Windows versions.

Either way you''ll need to be a reasonable artist with a grasp of how animation works to get something realistic or fun.


Use SHGetFolderPath() function in Win32 / MFC to get path to user desktop.
Then use CreateDirectory() fucntion to create folders.
Use CreateFile() function or CFile class object to create file in the path.


这篇关于如何在桌面上创建苍蝇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆