首页 > REDM基础教程 > REDM基础教程15-增加托盘功能
2016十一月29

REDM基础教程15-增加托盘功能

[隐藏]

 MyRes资源包和MyTest+qq.ico下载–>(方便起见,继续使用以前的工程和资源演示,不使用单exe工程)

MyTest1.zip

qqico.zip

  修改后的MyTest下载–>

MyTest.zip

 

  

   这一节我们来为我们的QQ登陆框增加一个托盘功能,下一节我们来为托盘增加一个菜单弹出框

   

1.托盘功能

   

托盘功能其实和UI是没有什么关系的,但DM还是在QQDemo中加了个简单的封装类TrayIconWndMgr,把

Samples\QQDemo\inc\TrayIconWndMgr.h
Samples\QQDemo\src\TrayIconWndMgr.cpp

分别放在Test\incTest\src中,运行编译

1>TrayIconWndMgr.cpp
1>..\..\MyTest\Test\src\TrayIconWndMgr.cpp(1) : warning C4627: '#include "QQDemoAfx.h"': skipped when looking for precompiled header use

还是老规则,把QQDemoAfx.h替换成StdAfx.h,编译通过! 

    

我们先给它增加一个ICO图标吧:

1.把qq.ico放在Test\inc目录下

  

2.在VS工程中的资源中加入qq.ico文件,名字就叫IDI_ICON1

  

3.把自动生成的Build2008\Test\resource.h以及Build2008\Test\Test.rc转移到MyTest\Test\inc\中

  

4.修改MyTest\Test\CMakeLists.txt,把

FILE(GLOB ROOT_HEADER 		${CMAKE_CURRENT_SOURCE_DIR}/inc/*.h)

更改为(自动在VS工程的inc这个filter中加载rc后缀的文件)

FILE(GLOB ROOT_HEADER 		${CMAKE_CURRENT_SOURCE_DIR}/inc/*.h;${CMAKE_CURRENT_SOURCE_DIR}/inc/*.rc)

  

5.重新生成一次CMAKE,这时应该显示成这样:

7.png

  

6.在\MyTest\Test\inc\MainWnd.h中增加构造函数和析构函数:

CMainWnd();
~CMainWnd();

在\MyTest\Test\src\MainWnd.cpp的头部增加

#include "resource.h"
#include "TrayIconWndMgr.h"

在构造函数和析构函数中增加托盘消息类对象的new和delete,在OnInitDialog增加托盘提示和汽泡提示

CMainWnd::CMainWnd()
{
	new CTrayIconWndMgr;
}

CMainWnd::~CMainWnd()
{
	CTrayIconWndMgr::getSingletonPtr()->SetBalloonDetails(L"DM托盘提示",L"MyTest已退出");
	delete CTrayIconWndMgr::getSingletonPtr();
}

BOOL CMainWnd::OnInitDialog(HWND wndFocus, LPARAM lInitParam)
{
	// todo
	// 增加一个托盘图标
	HICON hIcon = ::LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON1));
	CTrayIconWndMgr::getSingleton().InstallTrayIcon(L"托盘提示:MyTest",m_hWnd,hIcon,IDI_ICON1);
	// 增加一个汽泡提示
	CTrayIconWndMgr::getSingletonPtr()->SetBalloonDetails(L"汽泡提示",L"MyTest");

	return TRUE;
}

这时,运行,我们看到的效果应该如下:

21.gif

  

7.最后介绍下接收消息的地方:CTrayIconWndMgr::OnTrayIcon

LRESULT CTrayIconWndMgr::OnTrayIcon(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	UINT Msg = (UINT)LOWORD(lParam);
	switch (Msg)
	{
	case WM_RBUTTONUP:
		{
			::PostMessage(m_hParentWnd, WM_SHOWTRAYMENU, 0 ,NULL);
		}
		break;

比如我们的右键弹出菜单消息,我们是在这里Post了WM_SHOWTRAYMENU这个消息到窗口m_hParentWnd中,m_hParentWnd就是前面代码中InstallTrayIcon传入的m_hWnd

  

   

  下一节教程:REDM基础教程16-为托盘消息增加弹出菜单       

     

文章作者:hgy413
本文地址:http://hgy413.com/3844.html
版权所有 © 转载时必须以链接形式注明作者和原始出处!

41 Responses to “REDM基础教程15-增加托盘功能”

  1. #1 minecraft 回复 | 引用 Post:2018-10-03 20:42

    I read this article fully regarding the difference of newest
    and previous technologies, it’s awesome article.

  2. #2 minecraft 回复 | 引用 Post:2018-10-05 20:39

    Hi, There’s no doubt that your website could possibly be having internet browser compatibility issues.
    When I take a look at your site in Safari, it looks fine however, if
    opening in IE, it has some overlapping issues. I merely wanted to provide you with a quick heads up!
    Aside from that, wonderful site!

  3. #3 minecraft 回复 | 引用 Post:2018-10-06 19:56

    It’s hard to come by knowledgeable people about this subject,
    however, you seem like you know what you’re talking about!

    Thanks

  4. Wow, that’s what I was searching for, what a stuff! present here at this website,
    thanks admin of this site.

  5. It’s remarkable in favor of me to have a website, which is useful in favor of my know-how.
    thanks admin

  6. Valuable info. Lucky me I found your site by chance,
    and I am surprised why this accident did not came about in advance!
    I bookmarked it.

  7. I am genuinely glad to glance at this weblog posts which carries lots of valuable facts, thanks for providing these kinds of data.

  8. #8 Benefits of Coconut Oil 回复 | 引用 Post:2018-10-19 13:15

    Helpful information. Lucky me I found your web site by accident, and I am
    stunned why this accident didn’t came about in advance! I bookmarked it.

  9. #9 Benefits of Coconut Oil 回复 | 引用 Post:2018-10-27 02:48

    Every weekend i used to pay a quick visit this website, for the
    reason that i wish for enjoyment, as this this web
    page conations genuinely good funny material too.

  10. I have read so many articles or reviews on the topic of the blogger
    lovers however this post is truly a fastidious article,
    keep it up.

  11. Hey I know this is off topic but I was wondering if you knew of any widgets I could
    add to my blog that automatically tweet my newest twitter updates.

    I’ve been looking for a plug-in like this for quite some time
    and was hoping maybe you would have some experience with something like this.

    Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your new updates.

  12. #12 Sling TV 回复 | 引用 Post:2018-11-11 12:31

    This post is priceless. When can I find out more?

  13. #13 Sling TV 回复 | 引用 Post:2018-11-11 21:35

    Fantastic blog you have here but I was curious if you knew of any discussion boards that cover the same topics talked about here?
    I’d really love to be a part of community where I can get feed-back from other knowledgeable people that share
    the same interest. If you have any recommendations, please let
    me know. Cheers!

  14. #14 descargar facebook 回复 | 引用 Post:2018-11-21 01:03

    Fantastic site you have here but I was curious about if you knew of any user discussion forums that cover the same topics talked
    about in this article? I’d really love to be a part
    of online community where I can get feedback from other experienced people that share the same interest.
    If you have any suggestions, please let me know. Cheers!

  15. #15 http://goo.gl/8r1Yuu 回复 | 引用 Post:2019-03-30 09:35

    When I initially commented I seem to have clicked on the -Notify me when new comments are
    added- checkbox and now every time a comment is added I receive four emails with the exact same comment.

    Perhaps there is an easy method you are able to remove me from that service?
    Kudos!

  16. #16 minecraft 回复 | 引用 Post:2019-03-31 21:25

    I like the valuable information you provide to your articles.
    I will bookmark your weblog and check again right here regularly.
    I’m moderately sure I will be informed many new stuff right
    here! Best of luck for the next!

  17. #17 minecraft 回复 | 引用 Post:2019-04-09 11:27

    Great post. I was checking continuously this blog and I’m impressed!
    Extremely helpful information specially the
    ultimate part :) I deal with such information much.
    I was looking for this particular information for a long time.
    Thank you and best of luck.

  18. #18 tinyurl.com 回复 | 引用 Post:2019-04-10 03:37

    Hey! Do you know if they make any plugins to help with SEO?

    I’m trying to get my blog to rank for some
    targeted keywords but I’m not seeing very good gains.
    If you know of any please share. Kudos!

  19. #19 http://tinyurl.com/ 回复 | 引用 Post:2019-04-20 09:34

    Hi there, You’ve done an incredible job. I’ll definitely digg it and personally suggest to my friends.

    I am confident they will be benefited from this
    site.

  20. #20 minecraft 回复 | 引用 Post:2019-04-21 22:39

    Quality content is the important to invite the visitors to visit the web page, that’s what this
    site is providing.

  21. Actually when someone doesn’t be aware of afterward its up to
    other users that they will assist, so here it takes place.

  22. #22 minecraft 回复 | 引用 Post:2019-04-29 01:07

    What’s up, I read your blog regularly. Your story-telling style is awesome, keep it up!

  23. #23 gamefly free trial 回复 | 引用 Post:2019-05-02 00:49

    What’s up, yeah this article is truly good and I have learned lot of things from
    it on the topic of blogging. thanks.

  24. Asking questions are actually fastidious thing if you
    are not understanding something entirely, however this post provides good understanding
    yet.

  25. #25 minecraft free download 回复 | 引用 Post:2019-05-10 05:33

    It’s very easy to find out any matter on web as compared to textbooks, as I found this piece of writing
    at this web page.

  26. #26 nail salon 回复 | 引用 Post:2019-05-10 20:20

    Hi Dear, are you in fact visiting this site regularly, if
    so after that you will without doubt take fastidious know-how.

  27. #27 Best Online Dating 回复 | 引用 Post:2019-05-11 10:39

    WOW just what I was searching for. Came here by searching for Best Online Dating

  28. #28 google mesh review 回复 | 引用 Post:2019-05-17 08:38

    It’s no wonder: There are just so many things we can’t know about a voice-controlled tabletop assistant based solely on marketing descriptions and closely controlled
    demos. How well will the device actually work in a normal and noisy household environment?
    What will it be like to interact with the Google Assistant without
    being able to see anything on a screen (especially when the software returns web
    results as an answer)? And how will the gadget handle incoming commands from multiple people with multiple Google accounts?

  29. Hi i am kavin, its my first occasion to commenting anyplace, when i read this piece of writing
    i thought i could also make comment due to this brilliant paragraph.

  30. #30 Puffy Nipples 回复 | 引用 Post:2019-05-19 14:55

    When I originally commented I seem to have clicked the -Notify
    me when new comments are added- checkbox and now every time a comment is added I recieve four
    emails with the exact same comment. Is there a way you
    can remove me from that service? Appreciate it!

  31. It’s amazing in support of me to have a website, which is good in support
    of my know-how. thanks admin

  32. #32 gamefly free trial 回复 | 引用 Post:2019-06-01 02:51

    Hi are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started and set up
    my own. Do you need any coding knowledge to make your own blog?
    Any help would be greatly appreciated!

  33. #33 gamefly free trial 回复 | 引用 Post:2019-06-03 18:27

    My spouse and I absolutely love your blog and find a lot of your
    post’s to be just what I’m looking for. Would you offer guest writers to write content available for you?
    I wouldn’t mind creating a post or elaborating on a number of the subjects you write with regards to here.
    Again, awesome blog!

  34. #34 gamefly free trial 回复 | 引用 Post:2019-06-05 04:22

    Nice replies in return of this query with firm arguments and
    explaining everything on the topic of that.

  35. #35 gamefly free trial 回复 | 引用 Post:2019-06-05 20:06

    Wow! At last I got a blog from where I know how to genuinely obtain useful information regarding my study and knowledge.

  36. #36 gamefly free trial 回复 | 引用 Post:2019-06-06 19:41

    Hello there, I found your site by means of Google whilst looking
    for a comparable subject, your website came up, it looks great.
    I’ve bookmarked it in my google bookmarks.

    Hi there, just was alert to your weblog through Google, and located that it is really informative.
    I’m gonna be careful for brussels. I will appreciate in case you continue this in future.
    Lots of other people will probably be benefited from
    your writing. Cheers!

  37. Nice weblog right here! Also your website loads up fast!
    What web host are you the usage of? Can I get your affiliate hyperlink for your host?
    I wish my website loaded up as fast as yours
    lol

  38. It’s a shame you don’t have a donate button! I’d definitely donate to this
    fantastic blog! I guess for now i’ll settle for
    bookmarking and adding your RSS feed to my Google account.

    I look forward to brand new updates and will share this site with my
    Facebook group. Chat soon!

  39. #39 quest bars 回复 | 引用 Post:2019-06-16 02:17

    This is a topic that’s near to my heart… Cheers!
    Exactly where are your contact details though?

  40. Amazing things here. I’m very happy to see
    your post. Thanks so much and I’m looking forward to contact you.
    Will you kindly drop me a e-mail?

  41. #41 http://tinyurl.com 回复 | 引用 Post:2019-06-17 06:02

    Excellent post. I certainly appreciate this site. Keep writing!

发表评论