tag:blogger.com,1999:blog-12524441168137256932024-02-20T20:26:45.157-08:00Code DreamerAnonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-1252444116813725693.post-17119938781128692732014-03-20T05:54:00.002-07:002014-03-20T05:58:24.270-07:00Build yajl in windowsI've used <a href="http://lloyd.github.io/yajl/" target="_blank">yajl</a>, which is very attractive library for json in C.<br />
Although, in package including a doc, '<a href="https://github.com/lloyd/yajl/blob/master/BUILDING.win32">BUILDING.win32</a>', when I followed the guide, I've got some error.<br />
<br />
First of all, I have no experience about CMake, and 'CMakeLists.txt' for window build, seems to have a little mistake.<br />
<br />
For solving, let's say the path of 'yajl' package is 'D:\yajl_2_0_4_test'.<br />
<span style="background-color: white;">(My environment is CMake 2.6 and VS2010 for visual studio command prompt.)</span><br />
<span style="background-color: white;">In '</span>D:\yajl_2_0_4_test\<a href="https://github.com/lloyd/yajl/blob/master/src/CMakeLists.txt">CMakeLists.txt</a>', <span style="background-color: white;">below code have to append on line 14,</span><br />
<pre class="c++" name="code">cmake_minimum_required(VERSION 2.6)
SET (YAJL_MAJOR 2)
SET (YAJL_MINOR 0)
SET (YAJL_MICRO 4)
</pre>
<div style="font-size: 10pt; margin: 0in;">
<span style="font-family: inherit;">By adding above code, I could acquire such a nice build log!</span></div>
<div style="font-size: 10pt; margin: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinsJgxfc6O8dOjSYdzL4EDhQPNHwnWQhPEzu_PfF-Rzdo4EGUQkdkhJ_GuXYvGC8gA-mkNRNtkHd9lwY3REPTI3T8oPF-GGnA7jLXOR2LQz1tebEqD-1kmZSDgC2up1YWor2HUOZ-_i9w/s1600/log.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinsJgxfc6O8dOjSYdzL4EDhQPNHwnWQhPEzu_PfF-Rzdo4EGUQkdkhJ_GuXYvGC8gA-mkNRNtkHd9lwY3REPTI3T8oPF-GGnA7jLXOR2LQz1tebEqD-1kmZSDgC2up1YWor2HUOZ-_i9w/s1600/log.png" height="640" width="509" /></a></div>
<div style="font-size: 10pt; margin: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div style="font-family: "Malgun Gothic"; font-size: 10.0pt; margin: 0in;">
<br /></div>
<div style="font-family: "Malgun Gothic"; font-size: 10.0pt; margin: 0in;">
<br /></div>
<br />
<span style="background-color: white;"><br /></span>
<span style="background-color: white;"><br /></span>
<span style="background-color: white;"><br /></span>Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-12775321660517626312014-03-14T18:53:00.003-07:002014-03-14T18:53:47.918-07:00Build time speed-up in VC++ projectThere are some ways to improve VC++ project compile time.<br />
<br />
Firstly, through using #pragma once directive and #ifdef guard.
Although, #pragma once is not standard, it can be recognized in MS VC++ compiler. Furthermore, it does not try to open itself, whereas #ifdef guard opens header file once, and then, if the symbol is defined, not load.<br />
However, when I apply #pragma once in my project, I couldn't find distinct different result.
Before applying #pragma once, I was using #ifdef guard only, the build time was approximately 3 minute more.
After applying that, although the build time was shortened about several seconds, I'm not sure if there was any chance.<br />
<br />
Second method is forwarding declaration. It means, if you just use pointer or reference of class as a class member in your header file, you don't need to include the header file which is declared the class.<br />
<br />
And using 'impl' pattern is another well-known method, but if goal is just decreasing compile time, it may be cumbersome work in terms of additional writing code.<br />
<br />
First of all, to turn of <a href="http://msdn.microsoft.com/en-us/library/bb385193.aspx" target="_blank">'/MP' switch</a> is the most fastest and simplest method to improve build speed. '/MP' means 'build with multiple processes. In vs2010, the MP switch is turn off in default because it conflicts /Gm(Enable Minimum Rebuild).<br />
When I turned on /MP switch, my project's compile time was shortened over 3 minutes to under one minute.
Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-2639212396345622052013-12-09T07:16:00.001-08:002013-12-10T05:24:44.346-08:00Another method substitute for Initializer lists<br />
Although, <a href="http://herbsutter.com/elements-of-modern-c-style/" target="_blank">Initializer Lists</a> was introduced in C++ 11, it was not applied to Visual Studio 2010.<br />
So, I can't write below code, in VS2010.(and, may be same in VS2012)<br />
<pre class="c++" name="code">vector<int> v = { 1, 2, 3, 4 };</pre>
So, I often used array rather than vector and non-member std::begin()/std::end(), since I prefer to use for_each, lambda, like below,<br />
<span style="color: magenta;"></span>
<span style="color: magenta;"></span>
<pre class="c++" name="code">
struct Actor<br />{<br /> string name;<br /> unsigned int age;<br />} actors[] = { {"joe", 19}, {"bach",24} };<br /><br />for_each (std::begin(actors), std::end(actors), [](const Actor& a)<br />{<br /> //do something<br /> cout << ' ' << a.name;<br /> cout << ' ' << a.age;<br />});</pre>
Today, I read below article in StackOverFlow, <br />
<a href="http://stackoverflow.com/questions/2236197/c-easiest-way-to-initialize-an-stl-vector-with-hardcoded-elements?rq=1">http://stackoverflow.com/questions/2236197/c-easiest-way-to-initialize-an-stl-vector-with-hardcoded-elements?rq=1</a><br />
<br />
If I have to use only vector, this method will better solution, however, it will run for only primitive data type such as, int.<br />
For user defined type, other method will be required.<br />
Ref 1. <a href="http://en.cppreference.com/w/cpp/utility/initializer_list">http://en.cppreference.com/w/cpp/utility/initializer_list</a><br />
Ref 2. <a href="http://oopscenities.net/2011/05/09/c0x-initializer-lists/">http://oopscenities.net/2011/05/09/c0x-initializer-lists/</a><br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-31601023909175832052013-08-31T01:59:00.001-07:002013-12-10T05:23:29.490-08:00Precautions in luainterface 2.0.3<br />
<span class="EOP SCX258477573" style="font-family: Malgun Gothic,Sans-Serif; font-size: 10pt; line-height: 18px;">For In visual studio 2010, below section should be added in app.config. Since luainterface was compiled as clr version 2.0, 'useLegacyV2RuntimeActivationPlicy' is must be set to true.</span><br />
<pre class="xml" name="code">
<startup useLegacyV2RuntimeActivationPolicy="true"><br /> <supportedRuntime version="v4.0"/> <br /></startup></pre><br />
<br />
<div class="Paragraph SCX258477573" style="font-size: 6pt; text-align: left;">
<span class="EOP SCX258477573" style="font-family: Malgun Gothic,Sans-Serif; font-size: 10pt; line-height: 18px;">For reference a C# object in luainterface, the namespace of the reference object should be different with program main interface. For example, if I address the name of project as 'DrwaDesk', the main namespsce will be 'DrawDesk'. If I want to reference 'Book' class in luainterface, the 'Book' class should have different </span></div>
<div class="Paragraph SCX258477573" style="font-size: 6pt; text-align: left;">
<span class="EOP SCX258477573" style="font-family: Malgun Gothic,Sans-Serif; font-size: 10pt; line-height: 18px;">namespace with 'DrawDesk'. </span></div>
<pre class="c#" name="code">
namespace DrawDesk<br />{<br /> static class Program<br /> {<br /> /// <summary><br /> /// The main entry point for the application.<br /> /// </summary><br /> [STAThread]<br /> static void Main()<br /> {<br /> }<br /> }<br />}<br />
namespace ShredTypes<br />{<br /> class Book<br /> {<br />
}<br />}</pre>
<br />
<div class="Paragraph SCX258477573" style="font-size: 6pt; text-align: left;">
<span class="EOP SCX258477573" style="font-family: Malgun Gothic,Sans-Serif; font-size: 10pt; line-height: 18px;">Lastly, there is no sleep function in lua. So using os.time() or os.clock(), we normaly make sleep function. However, if the function call in several processes, it will throw exception. A possible solution for this, just wrap function which use the sleep function of C# and call this wrap function in Luainterface. </span></div>
<div class="Paragraph SCX258477573" style="font-size: 6pt; text-align: left;">
<span class="EOP SCX258477573" style="font-family: Malgun Gothic,Sans-Serif; font-size: 10pt; line-height: 18px;"></span> </div>
<div class="Paragraph SCX258477573" style="font-size: 6pt; text-align: left;">
<span class="EOP SCX258477573" style="font-family: Malgun Gothic,Sans-Serif; font-size: 10pt; line-height: 18px;"></span> </div>
<div class="Paragraph SCX258477573" style="font-size: 6pt; text-align: left;">
<span class="EOP SCX258477573" style="font-family: Malgun Gothic,Sans-Serif; font-size: 10pt; line-height: 18px;"></span> </div>
<div class="Paragraph SCX258477573" style="font-size: 6pt; text-align: left;">
<span class="EOP SCX258477573" style="font-family: Malgun Gothic,Sans-Serif; font-size: 10pt; line-height: 18px;"></span> </div>
Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-45937748522290397782013-07-17T07:02:00.000-07:002013-07-17T07:14:23.764-07:00Using Google C++ Style Guide<br />
Probably, when many people write C++ code for their own project at home, they don't seem like to follow specific guide line. So they write code according to habit or experience. However, as the length of the code is getting longer, various styles are appeared.This is why many developers try to follow <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml" target="_blank">Google C++ Style Guide</a> consiciously.<br />
<br />
<a href="http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py" target="_blank">cpplint.py</a> is a python file for identifying whether follow Google C++ Style Guide. For using, just install Python 2.7(2013-07-17 currently, it doesn't work in higher version.)<br />
<br />
The direction is simple.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCQzYsb0l52HA1a67BNIrHB0ZhB4UrWJwszsM3FaptlS-w5-ksXzn_ZHHHRDkt8edHorfuhWhbGyvl13ejifi4uD828zL2EOGhS6SZPkZaIkyn7u6cIrvRHbRDoK4XdDCau1y4zUcFEg0/s1600/u1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCQzYsb0l52HA1a67BNIrHB0ZhB4UrWJwszsM3FaptlS-w5-ksXzn_ZHHHRDkt8edHorfuhWhbGyvl13ejifi4uD828zL2EOGhS6SZPkZaIkyn7u6cIrvRHbRDoK4XdDCau1y4zUcFEg0/s1600/u1.png" /></a></div>
<br />
Also, you can use filter option for reducing unimportant style checking. <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_Azo_leZ48nw7kMY9_0RRPTl8Wr_ML5FitDrsvbvvnvUab0TOHXg3nua5o5vqRx1f7PKS6AhnneK61K5yubYiylNgjL8_Et5mIYGERD-7yWTZkl2sM5ZPrO5OXITksrPUaOZngb7hpIA/s1600/u2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_Azo_leZ48nw7kMY9_0RRPTl8Wr_ML5FitDrsvbvvnvUab0TOHXg3nua5o5vqRx1f7PKS6AhnneK61K5yubYiylNgjL8_Et5mIYGERD-7yWTZkl2sM5ZPrO5OXITksrPUaOZngb7hpIA/s1600/u2.png" /></a></div>
<br />
Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-5421572212346205262013-07-07T22:42:00.002-07:002013-07-07T22:50:13.899-07:00Factory method patternThis pattern is used with polymorphism and template which are representative feature of C++ language. The main advantage of factory method is that when making new object or extending previous object, define new sublayer class and then just overriding member function which is defined as a factory method. Therefore, we don't need to analyze existing source code detaily.<br />
<br />
Here is a sample class diagram using Factory method pattern.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYkI5i3QFFGd9E2oqYqIYut3HSg1x7YdtYhW4UqO7FvXoFR67vVzWDeLFz_7xfTl2y_TX8jIjaaxgyvgsiPtq2MNH0YD0mY85pMBRrPlfQLwUTFvpooEQamMz0CIPf2Hn04G4rxUKLUUU/s1600/Untitled1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYkI5i3QFFGd9E2oqYqIYut3HSg1x7YdtYhW4UqO7FvXoFR67vVzWDeLFz_7xfTl2y_TX8jIjaaxgyvgsiPtq2MNH0YD0mY85pMBRrPlfQLwUTFvpooEQamMz0CIPf2Hn04G4rxUKLUUU/s400/Untitled1.png" width="400" /></a></div>
<br />
Implementation code is below.<br />
sample.h<br />
<div class="cpp" style="background: rgb(245, 245, 245); font-size-adjust: none; font-stretch: normal; font: 12px/1.6 Consolas, 나눔고딕코딩, monospace, Arial;">
<div class="cpp" style="background: rgb(245, 245, 245); font-size-adjust: none; font-stretch: normal; font: 12px/1.6 Consolas, 나눔고딕코딩, monospace, Arial;">
<span style="color: #339900;">#include <map></span><br />
<br />
<span style="color: blue;">using</span> <span style="color: blue;">namespace</span> std<span style="color: teal;">;</span><br />
<br />
<span style="color: magenta;">typedef</span> <span style="color: magenta;">struct</span> _controlInfo<br />
<span style="color: maroon;">{</span><br />
<span style="color: magenta;">unsigned</span> <span style="color: magenta;">int</span> ctrlId<span style="color: teal;">;</span><br />
<span style="color: magenta;">struct</span> _positionInfo<br />
<span style="color: maroon;">{</span><br />
<span style="color: magenta;">unsigned</span> <span style="color: magenta;">int</span> x<span style="color: teal;">;</span><br />
<span style="color: magenta;">unsigned</span> <span style="color: magenta;">int</span> y<span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span>Position<span style="color: teal;">;</span><br />
<span style="color: magenta;">struct</span> _sizeInfo<br />
<span style="color: maroon;">{</span><br />
<span style="color: magenta;">unsigned</span> <span style="color: magenta;">int</span> width<span style="color: teal;">;</span><br />
<span style="color: magenta;">unsigned</span> <span style="color: magenta;">int</span> height<span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span>Size<span style="color: teal;">;</span><br />
<br />
<span style="color: maroon;">}</span>ControlInfo<span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">class</span> CControlBase<br />
<span style="color: maroon;">{</span><br />
<span style="color: blue;">public</span><span style="color: teal;">:</span><br />
<span style="color: blue;">virtual</span> <span style="color: magenta;">bool</span> Create<span style="color: maroon;">(</span><span style="color: magenta;">const</span> ControlInfo<span style="color: #000040;">*</span> info<span style="color: maroon;">)</span> <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span><span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">class</span> CButton <span style="color: teal;">:</span> <span style="color: blue;">public</span> CControlBase<br />
<span style="color: maroon;">{</span><br />
<span style="color: blue;">public</span> <span style="color: teal;">:</span><br />
<span style="color: magenta;">bool</span> Create<span style="color: maroon;">(</span><span style="color: magenta;">const</span> ControlInfo<span style="color: #000040;">*</span> info<span style="color: maroon;">)</span><br />
<span style="color: maroon;">{</span><br />
<span style="color: #ff7837;">//Make Button</span><br />
<span style="color: #ff7837;">//...</span><br />
<span style="color: #ff7837;">//...</span><br />
<br />
<span style="color: darkblue;">return</span> <span style="color: blue;">true</span><span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span><br />
<span style="color: maroon;">}</span><span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">class</span> ControlMaker <br />
<span style="color: maroon;">{</span><br />
<span style="color: blue;">public</span> <span style="color: teal;">:</span><br />
<span style="color: magenta;">void</span> Make<span style="color: maroon;">(</span><span style="color: magenta;">const</span> ControlInfo<span style="color: #000040;">*</span> info<span style="color: maroon;">)</span><br />
<span style="color: maroon;">{</span><br />
CControlBase <span style="color: #000040;">*</span>base <span style="color: navy;">=</span> CreateControl<span style="color: maroon;">(</span><span style="color: maroon;">)</span><span style="color: teal;">;</span><br />
base<span style="color: #000040;">-</span><span style="color: navy;">></span>Create<span style="color: maroon;">(</span>info<span style="color: maroon;">)</span><span style="color: teal;">;</span><br />
ctrlMap<span style="color: maroon;">[</span>info<span style="color: #000040;">-</span><span style="color: navy;">></span>ctrlId<span style="color: maroon;">]</span> <span style="color: navy;">=</span> base<span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span><br />
<br />
<span style="color: blue;">protected</span> <span style="color: teal;">:</span><br />
<span style="color: blue;">virtual</span> CControlBase<span style="color: #000040;">*</span> CreateControl<span style="color: maroon;">(</span><span style="color: maroon;">)</span> <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">private</span> <span style="color: teal;">:</span><br />
map<span style="color: navy;"><</span><span style="color: magenta;">unsigned</span> <span style="color: magenta;">int</span>, CControlBase <span style="color: #000040;">*</span><span style="color: navy;">></span>ctrlMap<span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span><span style="color: teal;">;</span><br />
<br />
<span style="color: blue;">template</span> <span style="color: navy;"><</span><span style="color: blue;">class</span> ctrlType<span style="color: navy;">></span><br />
<span style="color: blue;">class</span> ConcreteControlMaker <span style="color: teal;">:</span> <span style="color: blue;">public</span> ControlMaker<br />
<span style="color: maroon;">{</span><br />
<span style="color: blue;">protected</span> <span style="color: teal;">:</span><br />
CControlBase<span style="color: #000040;">*</span> CreateControl<span style="color: maroon;">(</span><span style="color: maroon;">)</span> <span style="color: maroon;">{</span> <span style="color: darkblue;">return</span> <span style="color: red;">new</span> ctrlType<span style="color: teal;">;</span> <span style="color: maroon;">}</span><br />
<span style="color: maroon;">}</span><span style="color: teal;">;</span><br />
</div>
<br />
sample.cpp<br />
<div class="cpp" style="background: rgb(245, 245, 245); font-size-adjust: none; font-stretch: normal; font: 12px/1.6 Consolas, 나눔고딕코딩, monospace, Arial;">
<span style="color: #ff7837;">//</span><br />
<span style="color: #339900;">#include "stdafx.h"</span><br />
<span style="color: #339900;">#include "Sample.h"</span><br />
<br />
<span style="color: magenta;">int</span> _tmain<span style="color: maroon;">(</span><span style="color: magenta;">int</span> argc, _TCHAR<span style="color: #000040;">*</span> argv<span style="color: maroon;">[</span><span style="color: maroon;">]</span><span style="color: maroon;">)</span><br />
<span style="color: maroon;">{</span> <br />
<span style="color: #ff7837;">//get contrl info by using xml or ini</span><br />
ControlInfo<span style="color: #000040;">*</span> info <span style="color: navy;">=</span> <span style="color: blue;">NULL</span><span style="color: teal;">;</span><br />
GetControlInfo<span style="color: maroon;">(</span>info<span style="color: maroon;">)</span><span style="color: teal;">;</span><br />
<br />
<span style="color: #ff7837;">//if need to make a button</span><br />
ConcreteControlMaker<span style="color: navy;"><</span>CButton<span style="color: navy;">></span> btn<span style="color: teal;">;</span><br />
btn.<span style="color: #007788;">Make</span><span style="color: maroon;">(</span>info<span style="color: maroon;">)</span><span style="color: teal;">;</span><br />
<br />
<span style="color: darkblue;">return</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span><br />
</div>
</div>
Because this pattern delegates sublayer classes to create object, therefore, factory method pattern has advantages when need to divide the responsibility of object creation.
Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-11689947053955518442013-07-06T23:06:00.001-07:002013-07-06T23:07:24.687-07:00[VC++]How can I expand or collapse when click item in tree control?The simplest way is to set 'single expand' style on tree ctrl. Without 'single expand', if you just use Expand() function, you will not receive notify such as TVN_ITEMEXPANDED, TVN_ITEMEXPANDING.<br />
<br />
However, setting 'single expand' style has also a drawback. It is that expanded item once will be collapsed again when it is unselected. This behaviour is different with usual applications' behaviour. Therefore, if remaining unselected item, you should write code like below.<br />
<br />
<div class="cpp" style="background: rgb(245, 245, 245); font-size-adjust: none; font-stretch: normal; font: 12px/1.6 Consolas, 나눔고딕코딩, monospace, Arial;">
<span style="color: magenta;">void</span> CExpandTestDlg<span style="color: teal;">::</span><span style="color: #007788;">OnItemexpandingTree</span><span style="color: maroon;">(</span>NMHDR<span style="color: #000040;">*</span> pNMHDR, LRESULT<span style="color: #000040;">*</span> pResult<span style="color: maroon;">)</span> <br />
<span style="color: maroon;">{</span><br />
NM_TREEVIEW<span style="color: #000040;">*</span> pNMTreeView <span style="color: navy;">=</span> <span style="color: maroon;">(</span>NM_TREEVIEW<span style="color: #000040;">*</span><span style="color: maroon;">)</span>pNMHDR<span style="color: teal;">;</span><br />
<span style="color: #ff7837;">// TODO: Add your control notification handler code here</span><br />
<br />
<span style="color: #ff7837;">//Getting a current item</span><br />
HTREEITEM hCurItem <span style="color: navy;">=</span> m_Tree.<span style="color: #007788;">GetSelectedItem</span><span style="color: maroon;">(</span><span style="color: maroon;">)</span><span style="color: teal;">;</span> <br />
<br />
<span style="color: #ff7837;">//Comparing to a received item and then, </span><br />
<span style="color: #ff7837;">//if the received item is not same, </span><br />
<span style="color: #ff7837;">//just return for protecting notify TVN_ITEMEXPANDED</span><br />
<span style="color: darkblue;">if</span><span style="color: maroon;">(</span>hCurItem <span style="color: #000040;">!</span><span style="color: navy;">=</span> pNMTreeView<span style="color: #000040;">-</span><span style="color: navy;">></span>itemNew.<span style="color: #007788;">hItem</span><span style="color: maroon;">)</span> <br />
<span style="color: maroon;">{</span><br />
<span style="color: #000040;">*</span>pResult <span style="color: navy;">=</span> <span style="color: #0000dd;">1</span><span style="color: teal;">;</span><br />
<span style="color: darkblue;">return</span><span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span><br />
<br />
<span style="color: #000040;">*</span>pResult <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span><br />
<span style="color: maroon;">}</span><br />
</div>
<br />
reference from <a href="http://msdn.microsoft.com/en-us/library/vstudio/b17bescz(v=vs.100).aspx">MSDN</a><br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-42007266234302377332013-06-18T17:41:00.000-07:002013-06-18T17:41:47.088-07:00Catch the boomerang(for attending 'Intel perceptual computing challenge')Recently, I'm preparing to enter <a href="https://perceptualchallenge.intel.com/">Intel perceptual computing challenge</a>. One of my ideas is a simple gesture game. It's called 'Catch The Boomerang'. Some brief sketches are below.<br />
<br />
Users can throw the boomerang by rotating their wrist. Distance of flying, speed and the count of caught boomerang are displayed on the game screen.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwQCBY0KZlxVn5ghfIzGLRnM3Mflwn-MKNcuu5ruGe8_UrLkTHh0KcVheqrNuYz-dvRAQA078GeZ1s56VCrPJx_eqRtR7N5E_g3ZD3mmX61ZDg0fqYybH9G9oAFWGHEhzY-Gr-emI2L-w/s1600/boo1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwQCBY0KZlxVn5ghfIzGLRnM3Mflwn-MKNcuu5ruGe8_UrLkTHh0KcVheqrNuYz-dvRAQA078GeZ1s56VCrPJx_eqRtR7N5E_g3ZD3mmX61ZDg0fqYybH9G9oAFWGHEhzY-Gr-emI2L-w/s400/boo1.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhagou0ihiLKLu1iMLMtXN-il6keLgOITd-jzdy5wyq1SY7m8IBnWBUhnsV0d-y_AnURfM3d3hlT3z_GPGJnAyiDRmOPySm8MQkkJNi6rLmVb-pBS9qxvPmZZb0XlsnBJCaG9F40oX4KeU/s1600/boo2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="293" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhagou0ihiLKLu1iMLMtXN-il6keLgOITd-jzdy5wyq1SY7m8IBnWBUhnsV0d-y_AnURfM3d3hlT3z_GPGJnAyiDRmOPySm8MQkkJNi6rLmVb-pBS9qxvPmZZb0XlsnBJCaG9F40oX4KeU/s400/boo2.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
Of course, the thrown boomerang will be returned, so that users should catch the returning boomerang by grasping gesture.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfwhqqwQ_ScPaLoVyfs8SBIk850r5zcUnG3d_0-7ZlA7augE9EGjvIA_nlpmsGE7JrTeLH7i5ZQ5FM2FVOm1slXbk0f-ZfeJggg8uXo49RATJSsbs-Sa4zFZ89ROjhTrYpYhboQ87358I/s1600/boo3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfwhqqwQ_ScPaLoVyfs8SBIk850r5zcUnG3d_0-7ZlA7augE9EGjvIA_nlpmsGE7JrTeLH7i5ZQ5FM2FVOm1slXbk0f-ZfeJggg8uXo49RATJSsbs-Sa4zFZ89ROjhTrYpYhboQ87358I/s400/boo3.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdyLRse7Co6-gMw70UuUDK7wjG9Tk7Vvmf6ARbuwakkN3rLLH36EU0wIPMB3ncPwnsjzTUYFK3z49Dh4zN9Ywv0CNv1yHKIhOnYJFmgEEUkEe9PsyziFdVv9C_kO8mqAAKHrZuU1ypu0k/s1600/boo4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdyLRse7Co6-gMw70UuUDK7wjG9Tk7Vvmf6ARbuwakkN3rLLH36EU0wIPMB3ncPwnsjzTUYFK3z49Dh4zN9Ywv0CNv1yHKIhOnYJFmgEEUkEe9PsyziFdVv9C_kO8mqAAKHrZuU1ypu0k/s400/boo4.png" width="400" /></a></div>
<div>
I hope to get an opportunity which can attend next stage.</div>
<br />Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-74873072154723960072013-06-02T15:51:00.000-07:002013-06-02T15:56:46.216-07:00When computer is locked in XP, proceeding redrawing.During the time that computer is locked in XP, if application's size is altered or do other drawing work, these works will not reflect after the computer is unlocked. Although, it will be changed in Vista or Win 7.<br />
<br />
In normal case, it will be solved by managing WM_ACTIVEAPP, but during the time, through executing other program + altering size + redrawing, if z-order is changed, unfortunately other program will be received WM_ACTIVEAPP.<br />
<br />
Therefore, the most effective soluting is to manage WM_WCSSESSION_CHANGE.<br />
After checking the WPARAM value of the message is WTS_SESSION_UNLOCK, doing redraw will be solved this issue.<br />
<br />
<div style="font-family: "Malgun Gothic"; font-size: 10pt; margin: 0in;">
<a href="http://support.microsoft.com/kb/310153/en-us">http://support.microsoft.com/kb/310153/en-us</a></div>
<div style="font-family: "Malgun Gothic"; font-size: 10pt; margin: 0in;">
<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa383828(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/windows/desktop/aa383828(v=vs.85).aspx</a><br />
<div class="autosourcing-stub">
<strong><span style="font-family: Dotum;"></span></strong> </div>
</div>
Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-66030327498926129032013-05-07T19:07:00.000-07:002013-05-07T19:15:02.101-07:00Rule for using c++ 0x auto?'auto' is one of popular keywords in c++ 0x. Now, one of envy lists, which we feel when we see c# or such as script languages, can be reduced.
The most typical example of using is when declare 'iterator' in STL.
<br />
<pre class="cpp" name="code">//when declared typical iter
for (map&ltstring, int>::const_iterator iter = MapScores.begin(); iter != MapScores.end(); ++iter)
{
cout << "Name = " << iter->first << ", Score = " << iter->second << endl;
}
//when used auto
for (auto iter = MapScores.begin(); iter != MapScores.end(); ++iter)
{
cout << "Name = " << iter->first << ", Score = " << iter->second << endl;
}
</pre>
(In first one, instead of 'const_iterator', using of cbegin(), cend() is also fine for const appliance. cbegin(), cend() are also added containers of c++ 0x.)
<br />
<br />
The problem is that lots of c++ developers are already used for one rule, which type of variables always have to be declared. Therefore, inordinate using of 'auto' might bring about confusing and annoying.
Furthermore, because of operation through misunderstanding, proportion of debugging time may be longer.
<br />
<br />
So, I make a rule for me.
<br />
<br />
<ol>
<li>when immediately know 'return type' like above code and such as 'for', 'while' loop, when use local variable which available in short scope only.</li>
<li>As much as possible, use 'const auto'. So that, if possible, it uses for 'read only'. I think it can aid to protect wrong operation by means of misunderstanding.
</li>
</ol>
<br />
Below link is a stackoverflow thread which discussed for 'guideline using auto'.
<br />
<br />
<a href="http://stackoverflow.com/questions/6434971/how-much-is-too-much-with-c0x-auto-keyword">http://stackoverflow.com/questions/6434971/how-much-is-too-much-with-c0x-auto-keyword</a>
<br />
Personally, I believe that the use of at least is better way.<br />
<br />
Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-67249450791335131282013-05-06T02:02:00.000-07:002013-05-06T02:03:39.001-07:00The best way to appear dialog invisibly when dialog is createdFor this, 'WM_WINDOWPOSCHANGING' is used.<br />
<br />
If we use WM_CREATE or WM_INITDIALOG and then, call ShowWindow(SW_HIDE),<br />
we will firstly see a dialog, after that, it will be disappear.<br />
<br />
Below code shows how to use WM_WINDOWPOSCHANGING in WTL.<br />
<br />
<pre class="c++" name="code">LRESULT CHideDialog::OnWindowPosChanging(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
LPWINDOWPOS lpwndpos = (LPWINDOWPOS)lParam;
if (FALSE == m_isVisible)
{
lpwndpos->flags &= ~SWP_SHOWWINDOW;
}
else
{
lpwndpos->flags |= SWP_SHOWWINDOW;
}
return 0;
}</pre>
<br />
As we see, the value of m_isVisible decides on whether dialog is visible.<br />
So, if we call below function, after setting the value of m_isVisible to TRUE, <br />
the dialog will be appear again.<br />
<br />
<pre class="c++" name="code">
::SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);<br />
</pre>
<br />Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-88991059513794633032013-05-02T04:39:00.000-07:002013-05-06T18:42:24.138-07:00How can I make a transparent window in WPF?We will make a transparent window, which can be adjusted the opicity by slider control, llike below picture.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2TMGyQdk47YzZFRbK8ou1V3K8daUSaQnMn1q2mhEhE1Z_Wdk1SM1snaPbrOSa3AXb_aXpa0-saZIeka9QIstPu_Mzhie0cwhI93usMslmgkVfsoYKLKRmgdAb_KdsJmVmt3CtVrsObz0/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2TMGyQdk47YzZFRbK8ou1V3K8daUSaQnMn1q2mhEhE1Z_Wdk1SM1snaPbrOSa3AXb_aXpa0-saZIeka9QIstPu_Mzhie0cwhI93usMslmgkVfsoYKLKRmgdAb_KdsJmVmt3CtVrsObz0/s1600/1.png" height="315" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaonKUL4XJMYbzhLL7xh1HCme0fICic64ZhMAgNqACR5YrR0x_r29l0LmmvuFuo476ZiqbMEqXF1Kq2Mc1Yk_FO2VVd4mqggdJ5acQkIp3gSvHLXagwbGBR3iUJs0JwBUl-vMCUpFzNNs/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaonKUL4XJMYbzhLL7xh1HCme0fICic64ZhMAgNqACR5YrR0x_r29l0LmmvuFuo476ZiqbMEqXF1Kq2Mc1Yk_FO2VVd4mqggdJ5acQkIp3gSvHLXagwbGBR3iUJs0JwBUl-vMCUpFzNNs/s1600/2.png" height="297" width="320" /></a></div>
<br />
<br />
To begin with, it is required to adjust 3 of properties. They are 'AllowsTransparency', 'Background' and 'WindowStyle'.<br />
<pre class="xml" name="code"><Window x:class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
AllowsTransparency="True" Background="Transparent"
WindowStyle="None" ></pre>
<br />
<br />
And then, the opacity of window bind to slider control, like this,<br />
<pre class="xml" name="code"><Window x:class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
AllowsTransparency="True" Background="Transparent"
WindowStyle="None"
Height="550" Width="400" Opacity="{Binding Value, ElementName=slider}" ></pre>
<br />
Here is all xaml code.<br />
<pre class="xml" name="code"><Window x:Class="WpfApplication1.MainWindow"
xmlns="<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>"
xmlns:x="<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>"
Title="MainWindow"
AllowsTransparency="True" Background="Transparent"
WindowStyle="None"
Height="550" Width="400" Opacity="{Binding Value, ElementName=slider}" >
<Border BorderBrush="Gray" BorderThickness="1" CornerRadius="6" Background="Gray">
<Border BorderBrush="White" BorderThickness="1" CornerRadius="6">
<DockPanel Background="#303030" Margin="2,2,2,2" >
<Border Height="100" MouseMove="Header_MouseMove" DockPanel.Dock="Top" VerticalAlignment="Top">
<Button Click="Button_Close" HorizontalAlignment="Right" Margin="0,0,0,80" Width="15" Height="20" VerticalAlignment="Bottom" BorderThickness="1">X</Button>
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,2">
<GradientStop Color="#C0C0C0" Offset="0." />
<GradientStop Color="#303030" Offset="0.1" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Slider x:Name="slider" Height="20" DockPanel.Dock="Bottom" Maximum="1" Minimum="0.5" TickFrequency="0.2" Value="0.9"/>
<Border Height="100" MouseMove="Header_MouseMove" DockPanel.Dock="Bottom" VerticalAlignment="Bottom">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,18">
<GradientStop Color="#303030" Offset="0." />
<GradientStop Color="#C0C0C0" Offset="0.1" />
</LinearGradientBrush>
</Border.Background>
</Border>
</DockPanel>
</Border>
</Border>
</Window></pre>
<br />
<div class="separator" style="clear: both; text-align: left;">
</div>
Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-6764035192494222042013-04-30T03:35:00.000-07:002013-04-30T03:35:53.747-07:00A problem of link error in release mode of WTLAlthough, it is well compiled in debug mode without any link error, we will see below link error in release mode of WTL.<br />
<br />
<span style="font-size: x-small;">LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in atlmincrt.lib(atlinit.obj)<br />LIBCMT.lib(tidtable.obj) : error LNK2005: __encoded_null already defined in atlmincrt.lib(atlinit.obj)<br />LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in atlmincrt.lib(atlinit.obj)<br />LIBCMT.lib(crt0dat.obj) : error LNK2005: __get_osplatform already defined in atlmincrt.lib(atlinit.obj)</span><br />
<br />
Some typical solution to tackle for this,<br />
1)Set 'Minimize CRT in Use in ATL' to 'NO' in project setting.<br />
In this case, the size of file will be slightly increased.<br />
<br />
2)Or Set 'ignore', the item of 'atlmincrt.lib' in linker option.<br />
<br />
<br />
Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-54180049423232873582013-04-29T02:00:00.000-07:002013-04-29T17:12:04.693-07:00How can we reduce the repetitive style declaration in WPF?Xaml is also needed refactoring. Especially for the style, there is a 'BasedOn' property.<br />
It seems like enum or #define of c++.<br />
<br />
Let's look below xaml code,<br />
<pre class="xml" name="code"> <Style TargetType="{x:Type Label}">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontSize" Value="10" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Margin" Value="4" />
</Style></pre>
<br />
<br />
In the above code, line 2, 3 and line 9, 10 are exactly the same. In case, by means of 'BasedOn' property, the duplicate can be removed.<br />
<pre class="xml" name="code"> <Style x:Key="defaultControlStyle"
TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontSize" Value="10" />
</Style>
<Style TargetType="{x:Type Label}"
BasedOn="{StaticResource defaultControlStyle}">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style TargetType="{x:Type Button}"
BasedOn="{StaticResource defaultControlStyle}">
<Setter Property="Margin" Value="2" />
</Style></pre>
<div class="xml" name="code">
</div>
<div class="xml" name="code">
To begin with, 'defaultControlStyle' is declared as a common style, and then each control style are using by 'BasedOn' property.</div>
<div class="xml" name="code">
</div>
The use of repetitive code is a stairway to overwork in all IT fields. Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0tag:blogger.com,1999:blog-1252444116813725693.post-88232937675183838532013-04-28T05:24:00.000-07:002013-04-29T18:16:04.452-07:00Why does WPF have strong points in UI programming, when comparing with WINFORM, MFC, WTL ?<ul>
<li><h3>
The feature of declarable UI</h3>
</li>
</ul>
<span style="font-family: Verdana, sans-serif;">First of all, the power of WPF is that it can aid to develop impressive user interface faster and easily. We are able to construct the ui of application using a markup language called XAML. The XAML is similar with HTML or XML. So that, if you already have some experience for them, learning XAML will just take a day! Here is an sample short code.</span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="font-family: Verdana, sans-serif; font-size: x-small;"></span></span><br />
<span style="font-family: Verdana; font-size: x-small;"></span><br />
<pre class="xml" name="code"><Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hello, there" Height="240" Width="300">
<DockPanel>
<Border DockPanel.Dock="Top" BorderThickness="3"
BorderBrush="White" CornerRadius="5"
Padding="5" Background="Gray">
<TextBlock FontSize="10" TextWrapping="Wrap"
Foreground="White">
Hello! There.
</TextBlock>
</Border>
<Button Background="LightGray" Width="80"
Height="40" Content="Click"/>
</DockPanel>
</Window></pre>
<br />
<span style="font-family: Verdana;"></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;">Even if you haven't never meet XAML code before, you could estmate what above code is doing.</span><br />
<span style="font-family: Verdana, sans-serif;">'DockPanel' and 'Border' are one of a number of rich controls which are provided by WPF. This sample code will make a window like a below picture.</span><br />
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_A5JBnHsuwohWBmB-2_A8OcKBg52QATWwH28lLsZNi46ks4PN-54cIBysnozfzydvX9fc4jm_1UL4tP40Kt_v-UByUmtGoVibnG5B9YOtpiwH8a79obTT4Da3bt8_HOmo6dKpikcKMU/s1600/Untitled1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_A5JBnHsuwohWBmB-2_A8OcKBg52QATWwH28lLsZNi46ks4PN-54cIBysnozfzydvX9fc4jm_1UL4tP40Kt_v-UByUmtGoVibnG5B9YOtpiwH8a79obTT4Da3bt8_HOmo6dKpikcKMU/s1600/Untitled1.jpg" /></a></div>
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"></span><br />
<br />
<span style="font-family: Verdana, sans-serif;">Although, WinForm, MFC, WTL are supporting design tools for constructing UI easily, the quality of default controls of them is not relevant for using real workplace. Actually, the quality of WPF's default controls is also unattractive, but this point can be weighed out by using mark up language, because the use of markup language means that it can be available to bring the feature of web development such as CSS.</span><br />
</span><br />
<ul>
<li><h3>
The power of Style</h3>
</li>
</ul>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">For a long time, one of distinct trends in UI programming is to provide the skin function. It allows to change the appearance of the application during the running time. The use of information file such as ini or xml is frequently used as a common method. Here is a drawback.</span><br />
<span style="font-family: Verdana, sans-serif;">a typical example is below.</span><br />
</span></span><br />
<pre class="xml" name="code"><Skin name="Gloomy">
<Edit name="Input" position="10,40" size="100,40" color="128,128,128" />
<Button name="Commit" position="115,40" size="70,40" color="128,128,128" /></Skin></pre>
<br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<span style="font-family: Verdana, sans-serif;">Above approach requires some extra processes. For example, indicated color value have to be translated relevant value for using in application code. So that, altering skin process usually follows the following sequence.First loading XML, next finding selected skin name, and then by means of iterating, changing the look of all controls. Furthermore, C++ requires extra library for parsing xml, such as tinyXML.</span><br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<span style="font-family: Verdana, sans-serif;">On the other hand, all approaches for skin function change dramatically in WPF.</span><br />
<span style="font-family: Verdana, sans-serif;">To begin with, we can declare some skin set like below,</span><br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<span style="font-family: Verdana;">-DefaultStyle.xaml</span><br />
<pre class="xml" name="code"><Style x:Key="groupBoxHeader"
TargetType="{x:Type Borders}">
<Setter Property="CornerRadius"
Value="4" />
<Setter Property="TextBlock.Foreground"
Value="White" />
</Style></pre>
<br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<span style="font-family: Verdana, sans-serif;">After that, above style set can be used like below code.</span><br />
<pre class="xml" name="code"><GroupBox.Header>
<Border Background="{StaticResource brownBrush}"
Style="{StaticResource gropBoxHeader}">
<TextBlock Text="Phone" />
</Border>
</GroupBox.Header></pre>
<br />
For changing style during the running time, <br />
1)<br />
After making several style xaml files, when it is needed, load that.<br />
2)<br />
Or, adopt resources to style as a 'DynamicResource'. And then, make each control's syle property to connect this 'DynamicResource'.<br />
<br />
When comparing to other measures, unnecessary works be reduced surprisingly. Now, we can just concentrate to other valuable work.<br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"></span><br />Anonymoushttp://www.blogger.com/profile/08802763216302329668noreply@blogger.com0