首页 > REDM设计器教程 > REDM设计器教程11-显示自定义控件
2016十一月14

REDM设计器教程11-显示自定义控件

[隐藏]

  MyRes+Test下载–>

Test.zip

MyRes.zip

  修改后的Plugin_Designer+DMAttr.xml+DMCls.xml下载–>

Plugin_Designer.zip

xml.zip

 

       

1.让设计器识别自定义控件

   

前面两节我们尝试了怎么手工加一个皮肤和comboxex控件,但是设计器无法显示出comboxex,因为这是我们自行注册的控件,设计器没有comboxex的代码,当然无法识别,这就有点尴尬了,尤其是位置,得调多久才能调到适合的位置,所以DM设计器提供了个临时解决方案:

既然设计器没有comboxex的代码,我们就加入它,为了不和设计器自身代码冲突,我们放在设计器的插件Plugin_Designer里,原始的插件Plugin_Designer是没有注册代码的,只是个空壳

1.把ComboboxEx.h+ListBoxEx.h拷贝到\PlugIns\Plugin_Designer\inc\目录下,把ComboboxEx.cpp+ListBoxEx.cpp拷贝到\PlugIns\Plugin_Designer\src\目录下

   

2.点击DM库的CMake工具的Generate按钮,新加的代码文件会自动加载到Plugin_Designer工程中

    

3.编译Plugin_Designer

\..\..\PlugIns\Plugin_Designer\src\ListBoxEx.cpp(1) : warning C4627: '#include "StdAfx.h"': skipped when looking for precompiled header use
1>        Add directive to 'Plugin_DesignerAfx.h' or rebuild precompiled header
1>..\..\..\PlugIns\Plugin_Designer\src\ListBoxEx.cpp(2) : warning C4627: '#include "ListBoxEx.h"': skipped when looking for precompiled header use
1>        Add directive to 'Plugin_DesignerAfx.h' or rebuild precompiled header
1>..\..\..\PlugIns\Plugin_Designer\src\ListBoxEx.cpp(1062) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "Plugin_DesignerAfx.h"' to your source?
1>ComboboxEx.cpp
1>..\..\..\PlugIns\Plugin_Designer\src\ComboboxEx.cpp(1) : warning C4627: '#include "StdAfx.h"': skipped when looking for precompiled header use
1>        Add directive to 'Plugin_DesignerAfx.h' or rebuild precompiled header
1>..\..\..\PlugIns\Plugin_Designer\src\ComboboxEx.cpp(2) : warning C4627: '#include "ComboboxEx.h"': skipped when looking for precompiled header use
1>        Add directive to 'Plugin_DesignerAfx.h' or rebuild precompiled header
1>..\..\..\PlugIns\Plugin_Designer\src\ComboboxEx.cpp(236) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "Plugin_DesignerAfx.h"' to your source?
1>Generating Code...

  

4.这个错误和之前一样,因为预编译头的名字不一样,Plugin_Designer的预编译头为Plugin_DesignerAfx.h,把ComboboxEx.cpp+ListBoxEx.cppStdAfx.h替换成Plugin_DesignerAfx.h即可

    

5.在Plugin_Designer.cpp中注册和反注册这两个类

#include "ListBoxEx.h"
#include "ComboboxEx.h"
...
void Plugin_Designer::Install()
{
	g_pDMApp->Register(DMRegHelperT<ListBoxEx>(),true);
	g_pDMApp->Register(DMRegHelperT<ComboboxEx>(),true);
}

void Plugin_Designer::Uninstall()
{
	g_pDMApp->UnRegister(ListBoxEx::GetClassName(),ListBoxEx::GetClassType());
	g_pDMApp->UnRegister(ComboboxEx::GetClassName(),ComboboxEx::GetClassType());
}

   

6.编译通过,运行,这时设计器就可以显示它们了,我们也可以很方便的使用设计器来调整它的坐标了

21.gif

    

  

2.增加控件属性列表

  

细心的我们可能发现,点击设计器的控件属性列表为空,打开DesignerRes\DMCls.xml,bin目录下的DMCls.xml是由\Docs\TestData\DesignerRes\DMCls.xml拷贝过来的,所以最好是改动TestData中的那份,再随便在DMDesigner工程代码中敲一个空格,使VS重新编译拷贝一次,反正最终目的是改变bin目录下的DMCls.xml增加如下XML结点(做为root结点的子节点),加入的规则可以看下面的注释:

	<comboxex>// 控件的xml名字
		<DUIComboBoxExAttr/>// 控件的Attr类
		<DUIComboBoxBaseAttr/>// 控件的基类的Attr类
		<DUIWindowAttr/>// 控件的基类的基类的Attr类
		<DUIStyleAttr/>	// 每个控件都必备的Attr类
	</comboxex>
	class DUIComboBoxExAttr:public DUIComboBoxBaseAttr
	class DUIComboBoxBaseAttr:public DUIWindowAttr
	DUIWindowAttr-->DUIStyleAttr

再次使用设计器加载,属性终于出来了,而且可调

22.gif

    

  

3.增加控件属性初值和注释

  

因为comboxex比较特殊,没有自己的特定属性,如果要帮这个控件的两个sub属性加个描述呢,如果我想再为这个控件加个int_temp属性呢,它的初值为123456呢

打开DesignerRes\DMAttr.xml,bin目录下的DMCls.xml是由\Docs\TestData\DesignerRes\DMAttr.xml拷贝过来的,所以最好是改动TestData中的那份,再随便在DMDesigner工程代码中敲一个空格,使VS重新编译拷贝一次,反正最终目的是改变bin目录下的DMAttr.xml增加如下XML结点(做为root结点的子节点)

<DUIComboBoxExAttr
	ITEM_subshow = "初始显示的XML标识"
	ITEM_sublistboxex = "子控件listbox的XML标识"
	INT_temp= "{123456} 尝试新加的属性"
	>

OK,我们来重新运行看下效果:

23.gif

  

更多细节可以参看\Docs\DMDesign详细文档\DMDesign详细文档.docx中的手动增加控件、属性列表这一节

   

使用设计器打开MyRes,再使用编辑工具(如:notepad++)编辑,再在设计器上按下F5重新加载,同样可以快速调整XML

     

    下一节教程:REDM基础教程14-单EXE方式

 

     

    

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

18 Responses to “REDM设计器教程11-显示自定义控件”

  1. #1 TerryMESTE 回复 | 引用 Post:2017-10-02 22:35

    Doctor Who is now considered a British Institute and has come a long way since it first aired on November 23rd 1963. The very first show saw the Doctor travel 100,00 years into the past to help some dim cavemen discover light. After 26 seasons and seven Doctors later the series came off our screens in 1989 much to the disappointment of the huge devoted fanbase. In 1996 an attempt was made to revive Doctor Who but it wasnt until June 2005 when it came back with a vengeance with Christopher Eccleston as the ninth Doctor that put the series back on the map as it were. It then went on for 5 years with David Tenant portraying the Doctor until 2010 when Matt Smith took over the role. Today it is still a great family show and has attracted many new fans.

    If youre a new or old fan of the show there are Tours and museums you can go and see some of the locations and memorabilia of this classic show. The Doctor Who Tour of London will take you on over 15 locations from the show, some from the new series and some from old sites like the location of The Invasion and Resurrection of the Darleks. The tour also takes you to the TV museum in London where you will get to see some of the cosumes worn in the show and props used. Also you can buy gifts and memorabilia from the shop.

    You will learn all about how the shows were made so the tour is also educational. If you want to take pictures of the locations thats not a problem. Remember the front door of 10 Downing Street in Aliens of London? Well you can get up and close to this and get your picture taken in front of the door. Rose Tyler fans will love the tour as you get to drop by her home in the show.

    Why not go that extra mile and actually meet a Doctor Who star. Well this is possible with private or group tours. You will get the general tour but included will be a pre-arranged meeting or lunch with a celebrity from the show. This will obviously depend on availability of the celebrity and the cost will reflect the popularity of that celebrity.

    There are tours in London and also Wales. The Wales tours take you to Cardiff where you will see lots of location which were featured in shows since 2005. You can leave from London or at Leigh Delamere services station on the M4. There is a Doctor Who exhibition in Cardiff which you get to see. At the end of the Doctor Who tour you get a souvenir group picture sent you by email which is a nice touch.

    For seriously devoted Doctor Who fans there is a 3 day tour which takes you to all the locations in both London and Cardiff. You will see locations from the past 45 years as well as recent sites from the lasted Doctor Who series. Day one is based in London where you get to see 15 sites. Day two takes you to Cardiff where you get to mean the real life owner of the to see we have an Gothic property used as the location of the school in Human Nature. The final day is partly spent in Cardiff with a walking tour at Cardiff Bay, then you head back to London but a stop at Stonehenge to see the site of the Pandoica. Then its dinner at The Cloven Hoof pub in Devils End b efore you taken back to central London.

     

  2. #2 minecraft 回复 | 引用 Post:2018-10-06 09:53

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

  3. #3 minecraft 回复 | 引用 Post:2018-10-07 02:26

    Hi there, I enjoy reading all of your article post.
    I like to write a little comment to support you.

  4. #4 minecraft 回复 | 引用 Post:2018-10-07 04:03

    Hi! I just wanted to ask if you ever have
    any problems with hackers? My last blog (wordpress) was hacked and I ended up losing months of hard work due to no data backup.
    Do you have any solutions to prevent hackers?

  5. When I initially left a comment I seem to have clicked the -Notify
    me when new comments are added- checkbox and from now on every time a comment is added I receive 4
    emails with the exact same comment. There has to be
    a way you are able to remove me from that service?

    Thank you!

  6. Definitely believe that which you stated. Your favorite justification seemed to
    be on the internet the simplest thing to be aware of.

    I say to you, I definitely get irked while people consider worries that
    they just don’t know about. You managed to hit the nail upon the top
    as well as defined out the whole thing without having side-effects ,
    people can take a signal. Will probably be back to get more.
    Thanks

  7. #7 Coconut Oil Benefits 回复 | 引用 Post:2018-10-21 05:22

    I loved as much as you’ll receive carried out right here. The sketch is tasteful,
    your authored subject matter stylish. nonetheless, you
    command get got an edginess over that you wish be delivering the following.
    unwell unquestionably come further formerly again as exactly
    the same nearly very often inside case you shield this hike.

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

    It is not my first time to go to see this website, i
    am visiting this site dailly and obtain fastidious information from
    here everyday.

  9. #9 Coconut Oil 回复 | 引用 Post:2018-10-24 04:54

    Excellent post. I was checking continuously this blog and I am impressed!
    Very useful info particularly the last part :) I care for
    such information a lot. I was looking for this particular information for a long time.
    Thank you and good luck.

  10. #10 Coconut Oil Benefits 回复 | 引用 Post:2018-10-24 16:00

    This is really interesting, You are a very skilled blogger.
    I have joined your rss feed and look forward to seeking more of your magnificent post.
    Also, I’ve shared your website in my social networks!

  11. #11 descargar facebook 回复 | 引用 Post:2018-11-02 02:18

    Thanks for one’s marvelous posting! I genuinely enjoyed reading it,
    you can be a great author.I will always bookmark your blog and
    will come back in the foreseeable future. I want to encourage yourself
    to continue your great job, have a nice weekend!

  12. #12 Quest Protein Bars 回复 | 引用 Post:2018-11-06 03:49

    Howdy! This is my first visit to your blog! We are a team of volunteers and starting a new project in a community in the same niche.
    Your blog provided us valuable information to work on.
    You have done a extraordinary job!

  13. #13 Sling TV 回复 | 引用 Post:2018-11-14 17:15

    I really like looking through a post that will make people think.
    Also, many thanks for permitting me to comment!

  14. #14 Sling TV 回复 | 引用 Post:2018-11-14 23:41

    It’s wonderful that you are getting ideas from this paragraph as well
    as from our dialogue made at this time.

  15. Sling tv coupons and promo codes for november 2018
    We’re a group of volunteers and starting a new scheme in our community.

    Your site offered us with useful info to work on. You’ve performed a formidable process
    and our entire community will be grateful to you.
    Sling tv coupons and promo codes for november 2018

  16. My spouse and I stumbled over here different web page and thought I
    might check things out. I like what I see so now i am following you.
    Look forward to checking out your web page repeatedly.

  17. of course like your website but you have to take a
    look at the spelling on quite a few of your
    posts. Many of them are rife with spelling issues and I in finding
    it very bothersome to tell the truth however I will
    certainly come again again.

  18. Thanks for sharing your thoughts. I truly appreciate your efforts and I am waiting for your next post thanks once again.

发表评论