<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-123239008466022371</id><updated>2011-11-28T02:40:35.113+02:00</updated><category term='Menu'/><category term='Visual Studio'/><category term='DataGridView'/><category term='QT'/><category term='contract'/><category term='XSD'/><category term='QSTRING'/><category term='JPEG'/><category term='NET'/><category term='Dialog'/><category term='QPushButton'/><category term='XML'/><category term='settings'/><category term='netTcpBinding'/><category term='USB'/><category term='string'/><category term='C#'/><category term='Endpoint'/><category term='RGB'/><category term='MFC'/><category term='WCF'/><category term='Lingo'/><category term='Hex'/><category term='CButton'/><category term='Singleton'/><category term='vs10'/><category term='Design Pattern'/><category term='Debugging'/><category term='std'/><category term='Recrusive'/><category term='Handle'/><category term='User Control'/><category term='CString'/><category term='file'/><category term='c++'/><category term='WPF'/><category term='bitmap'/><title type='text'>Code SOS - your essential code blog</title><subtitle type='html'>C++ C# Lingo Mojo and WebOS and QT assistance for those who hate reading manuals.

Featuring the amzing Diet Control Application for Palm Pre</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>32</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-5093684519961839452</id><published>2011-05-29T11:50:00.000+03:00</published><updated>2011-05-29T11:50:09.177+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>WCF Service failing with “The server has rejected the client credentials”.</title><content type='html'>Great &lt;a href="http://brianseekford.com/index.php/2009/11/25/wcf-service-failing-with-the-server-has-rejected-the-client-credentials-why-doesnt-the-server-like-me/"&gt;article&lt;/a&gt; regarding an issue that happens a lot&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-5093684519961839452?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://brianseekford.com/index.php/2009/11/25/wcf-service-failing-with-the-server-has-rejected-the-client-credentials-why-doesnt-the-server-like-me/' title='WCF Service failing with “The server has rejected the client credentials”.'/><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/5093684519961839452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2011/05/wcf-service-failing-with-server-has.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/5093684519961839452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/5093684519961839452'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2011/05/wcf-service-failing-with-server-has.html' title='WCF Service failing with “The server has rejected the client credentials”.'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-3313204653228249855</id><published>2011-04-12T14:48:00.000+03:00</published><updated>2011-04-12T14:48:48.870+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='User Control'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Step By Step Creating WPF User Control</title><content type='html'>&lt;div class="MsoListParagraphCxSpFirst" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;1.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;Create WPF User control library. It will create such class &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;partial class MySuperTextBox : UserControl&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpLast" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;2.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;Create DependencyProperty via propdp&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="background: yellow; color: blue; mso-highlight: yellow;"&gt;int&lt;/span&gt; &lt;span style="background: yellow; mso-highlight: yellow;"&gt;MyProperty&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)GetValue(MyPropertyProperty); }&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt; { SetValue(MyPropertyProperty, &lt;span style="color: blue;"&gt;value&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green;"&gt;// Using a DependencyProperty as the backing store for MyProperty.&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;This enables animation, styling, binding, etc...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;readonly&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DependencyProperty&lt;/span&gt; MyPropertyProperty =&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af;"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="color: #a31515;"&gt;"MyProperty"&lt;/span&gt;, &lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue;"&gt;int&lt;/span&gt;), &lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="background: yellow; mso-highlight: yellow;"&gt;ownerclass&lt;/span&gt;), &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;UIPropertyMetadata&lt;/span&gt;(0));&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraph" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;3.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;No you can change the dp to the type you need&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; Text&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; (&lt;span style="color: blue;"&gt;string&lt;/span&gt;)GetValue(TextProperty); }&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt; { SetValue(TextProperty, &lt;span style="color: blue;"&gt;value&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green;"&gt;// Using a DependencyProperty as the backing store for Text.&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;This enables animation, styling, binding, etc...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;readonly&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DependencyProperty&lt;/span&gt; TextProperty =&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af;"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="color: #a31515;"&gt;"Text"&lt;/span&gt;, &lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue;"&gt;string&lt;/span&gt;), &lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af;"&gt;MySuperTextBox&lt;/span&gt;), &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;FrameworkPropertyMetadata&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"red"&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;PropertyChangedCallback&lt;/span&gt;(qwe)));&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraph" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;4.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;The difference between &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;UIPropertyMetadata to FrameworkPropertyMetadata&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt; is that &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;UIPropertyMetadata&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt; does only initialize the dp , &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;FrameworkPropertyMetadata can also fire events.&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 18pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpFirst" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-fareast-font-family: Consolas;"&gt;&lt;span style="mso-list: Ignore;"&gt;5.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt; &lt;span style="color: #2b91af;"&gt;FrameworkPropertyMetadata&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"red"&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;PropertyChangedCallback&lt;/span&gt;(qwe)));&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;qwe is a function with this signature (need to do that manually).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpLast" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;private&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; qwe(&lt;span style="color: #2b91af;"&gt;DependencyObject&lt;/span&gt; obj,&lt;span style="color: #2b91af;"&gt;DependencyPropertyChangedEventArgs&lt;/span&gt; args)&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af;"&gt;MySuperTextBox&lt;/span&gt; mstb = obj &lt;span style="color: blue;"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MySuperTextBox&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;mstb.txt.Text = args.NewValue.ToString();&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpFirst" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;6.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;That closed the User Control.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;7.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;If you want to use this control in a WPF application.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;8.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;Create WPF application&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;9.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;You can see the user control in the toolbox &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-mE-7fh3zBAg/TaQ7mi6-hXI/AAAAAAAAAE0/BYmKKg0ysHw/s1600/untitled.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" r6="true" src="http://2.bp.blogspot.com/-mE-7fh3zBAg/TaQ7mi6-hXI/AAAAAAAAAE0/BYmKKg0ysHw/s1600/untitled.PNG" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;10.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;Drag it to your XAML&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;11.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;This will &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;a.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;Add reference &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;b.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Add xmlns :&lt;/span&gt; &lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;xmlns:my="clr-namespace:MyControl;assembly=MyControl"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;c.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;Add the control to the XAML &amp;lt;my:MySuperTextBox Name="mySuperTextBox2" /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpLast" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri;"&gt;d.&lt;/span&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt;You can bind the dp in the user control to other data (&lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;textBox1&lt;/span&gt;&lt;span style="mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-family: Calibri;"&gt; is a TextBox Control):&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: white; direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;my&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;:&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;MySuperTextBox&lt;/span&gt;&lt;span style="color: red; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt; Name&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;="mySuperTextBox1"&lt;/span&gt;&lt;span style="color: red; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt; Text&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;Binding&lt;/span&gt;&lt;span style="color: red; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt; ElementName&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;=textBox1,&lt;/span&gt;&lt;span style="color: red; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt; Path&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;=Text}"&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-align: left; unicode-bidi: embed;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraph" style="direction: ltr; line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; text-align: left; text-indent: -18pt; unicode-bidi: embed;"&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-fareast-font-family: Consolas;"&gt;&lt;span style="mso-list: Ignore;"&gt;12.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;"&gt;That’s it.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-3313204653228249855?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/3313204653228249855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2011/04/step-by-step-creating-wpf-user-control.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3313204653228249855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3313204653228249855'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2011/04/step-by-step-creating-wpf-user-control.html' title='Step By Step Creating WPF User Control'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-mE-7fh3zBAg/TaQ7mi6-hXI/AAAAAAAAAE0/BYmKKg0ysHw/s72-c/untitled.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-255433155108096034</id><published>2011-03-09T11:37:00.000+02:00</published><updated>2011-03-09T11:37:36.465+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NET'/><category scheme='http://www.blogger.com/atom/ns#' term='settings'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><category scheme='http://www.blogger.com/atom/ns#' term='vs10'/><title type='text'>changing VC++ include setting for all projects in 1 solution</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://i.imgur.com/V9pYd.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="185" q6="true" src="http://i.imgur.com/V9pYd.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Here are the steps to change the settings file through UI:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Open up property manager by clicking on View.Property Manager.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Expand the project node and then the Configuration|Platform nodes, you will see "Microsoft.cpp..users" file for each Configuration|Platform. These are the files for the global settings, similar to the old tools/Options/VC++ Directories.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Multi-Select "Microsoft.cpp..users", right click and bring up the property page window&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;In the property page window, click on "VC++ Directories" (for example) in the left pane, add new paths for the directories such as "Include Directories". separated by semicolons&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Make sure to save the settings before shutting down Visual Studio.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Re-launch Visual Studio and the new settings will be in effect.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;If you would like to only change the settings for a specific project, you can right click on the project and bring up the property page. Change the settings for “VC++ Directories”, these settings will be persisted to the project file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-255433155108096034?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/255433155108096034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2011/03/changing-vc-include-setting-for-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/255433155108096034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/255433155108096034'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2011/03/changing-vc-include-setting-for-all.html' title='changing VC++ include setting for all projects in 1 solution'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-262786944486501298</id><published>2011-02-20T10:41:00.001+02:00</published><updated>2011-02-20T11:06:04.954+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='contract'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>WCF Contract - Overloading Methods</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.indiastudychannel.com/pictures/gallery/earnmoney__operatoroverloading.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="400" width="388" src="http://www.indiastudychannel.com/pictures/gallery/earnmoney__operatoroverloading.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;If you need to overload a funtion in WCF contract , you've probably encountered in :&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Cannot have two operations in the same contract with the same name, methods ***** and ****** in type ******* violate this rule. You can change the name of one of the operations by changing the method name or by using the Name property of OperationContractAttribute&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's how to fix this issue (second option)&lt;br /&gt;&lt;br /&gt;http://www.switchonthecode.com/snippet-tutorials/wcf-snippet-tutorial-overloading-methods&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-262786944486501298?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.switchonthecode.com/snippet-tutorials/wcf-snippet-tutorial-overloading-methods' title='WCF Contract - Overloading Methods'/><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/262786944486501298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2011/02/wcf-contract-overloading-methods.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/262786944486501298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/262786944486501298'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2011/02/wcf-contract-overloading-methods.html' title='WCF Contract - Overloading Methods'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-8081809723774885177</id><published>2011-02-13T10:47:00.003+02:00</published><updated>2011-02-13T10:59:54.366+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netTcpBinding'/><category scheme='http://www.blogger.com/atom/ns#' term='Endpoint'/><category scheme='http://www.blogger.com/atom/ns#' term='contract'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>2 Endpoints for netTcpBinding with different contracts</title><content type='html'>Need to use same netTcpBinding binding but need additional endpoint for different contract? here's how:&lt;br /&gt;&lt;br /&gt;1. It's very good to read this &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163412.aspx"&gt;article&lt;/a&gt;&lt;br /&gt;2. If you have current netTcpBinding it should look like this:&lt;br /&gt;&lt;br /&gt;&lt;textarea style="width: 420px;height: 150px" onfocus="this.select();" name="textarea"&gt; &lt;service name="[name]"&gt;&lt;br /&gt;&lt;endpoint address="" binding="netTcpBinding" contract="[contract]"&gt;&lt;br /&gt;&lt;identity&gt;&lt;br /&gt;&lt;dns value="localhost"&gt;&lt;br /&gt;&lt;/identity&gt;&lt;br /&gt;&lt;/endpoint&gt;&lt;br /&gt;&lt;endpoint address="mex" binding="mexTcpBinding" bindingconfiguration="" contract="IMetadataExchange" name="MexTcpBidingEndpoint"&gt;&lt;br /&gt;&lt;host&gt;&lt;br /&gt;&lt;baseaddresses&gt;&lt;br /&gt;&lt;add baseaddress="[some base address]"&gt;&lt;br /&gt;&lt;/baseaddresses&gt;&lt;br /&gt;&lt;/host&gt;&lt;br /&gt;&lt;/service&gt;&lt;/textarea&gt;  &lt;br /&gt;&lt;br /&gt;3. what you have here is a TCP type of WCF with base address. Thats a deafult implementation of netTcpBinding.&lt;br /&gt;4. I suggest you to use the VS20010 tool "Edit WCF Configuration" to edit the App.config file instead of manually edition it.&lt;br /&gt;5. Add additional end point same values as the 1'st netTcpBinding binding (leave the MexTcpBidingEndpoint alone)&lt;br /&gt;6. Change the folowing :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;give each endpoint a name (the default implementation keeps them empty , it's good to give them some name to know on which one you are working on&lt;/li&gt;&lt;li&gt;for each give a unique name in the address section , &lt;u&gt;thats the magic here&lt;/u&gt; , giving the base address (see host baseaddress section) allownig wach binding to "sit" in a unique position within the service , leaving this section empty will cause assertion such as "When multiple endpoints on a service share the same ListenUri, those endpoints must all have the same Identity in their EndpointAddress."&lt;/li&gt;&lt;li&gt;For each binding state the contract.&lt;/li&gt;&lt;/ul&gt;7. the app.config script should look like this:&lt;br /&gt;&lt;br /&gt;&lt;textarea style="width: 420px;height: 150px" onfocus="this.select();" name="textarea"&gt;&lt;service name="[name]"&gt;&lt;br /&gt;&lt;endpoint address="[relative address1]" binding="netTcpBinding" contract="[contract]" name="[unique name1]"&gt;&lt;br /&gt;&lt;identity&gt;&lt;br /&gt;&lt;dns value="localhost"&gt;&lt;br /&gt;&lt;/identity&gt;&lt;br /&gt;&lt;/endpoint&gt;&lt;br /&gt;&lt;endpoint address="mex" binding="mexTcpBinding" bindingconfiguration="" contract="IMetadataExchange" name="MexTcpBidingEndpoint"&gt;&lt;br /&gt;&lt;endpoint address="[relative address 2]" binding="netTcpBinding" bindingconfiguration="" contract="[contract]" name="[unique name2]"&gt;&lt;br /&gt;&lt;host&gt;&lt;br /&gt;&lt;baseaddresses&gt;&lt;br /&gt;&lt;add baseaddress="[base address]"&gt;&lt;br /&gt;&lt;/baseaddresses&gt;&lt;br /&gt;&lt;/host&gt;&lt;br /&gt;&lt;/service&gt;&lt;/textarea&gt;  &lt;br /&gt;8. Thats it , Cool , no?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-8081809723774885177?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/8081809723774885177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2011/02/2-endpoints-for-nettcpbinding-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8081809723774885177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8081809723774885177'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2011/02/2-endpoints-for-nettcpbinding-with.html' title='2 Endpoints for netTcpBinding with different contracts'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-817858895305954663</id><published>2011-01-30T10:07:00.000+02:00</published><updated>2011-01-30T10:07:44.307+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XSD'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>XSD to byte array and vice versa</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.xsd.ca/XSDSeminarLinks/XSD.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="154" s5="true" src="http://www.xsd.ca/XSDSeminarLinks/XSD.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;need to construct your own byte array from a defiined XSD ? heres how&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;first construct the class from XSD (or XML)&lt;br /&gt;&lt;br /&gt;&lt;div&gt;we use &lt;a href="http://msdn.microsoft.com/en-us/library/x6c1kb0s(v=vs.71).aspx"&gt;XSD tool &lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;go to Visual studio command prompt&lt;/li&gt;&lt;li&gt;Go to path of xsd file(I.E c:\xsd)&lt;/li&gt;&lt;li&gt;xsd [file name].xsd /c /n:[namespace]&lt;/li&gt;&lt;li&gt;where &lt;/li&gt;&lt;ul&gt;&lt;li&gt;/c – generate classes&lt;/li&gt;&lt;li&gt;/n - namespace&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;Now you have created the class representation of the XML (or XSD) file.&lt;br /&gt;you can now use this 2 functions to serialize and deserialize the objects , to byte array and from byte array&lt;br /&gt;&lt;blockquote&gt;public static byte[] ObjectToXmlBytes(object o) &lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;MemoryStream memoryStream = new MemoryStream();&lt;br /&gt;&lt;br /&gt;XmlSerializer serializer = new XmlSerializer(o.GetType());&lt;br /&gt;&lt;br /&gt;serializer.Serialize(memoryStream, o);&lt;br /&gt;&lt;br /&gt;return memoryStream.ToArray();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public static object XmlBytesToObject(byte[] bytes, Type t)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;MemoryStream memoryStream = new MemoryStream(bytes);&lt;br /&gt;&lt;br /&gt;memoryStream.Position = 0;&lt;br /&gt;&lt;br /&gt;XmlSerializer serializer = new XmlSerializer(t);&lt;br /&gt;&lt;br /&gt;return serializer.Deserialize(memoryStream);&lt;br /&gt;&lt;br /&gt;}&lt;/blockquote&gt;enjoy&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-817858895305954663?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/817858895305954663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2011/01/xsd-to-byte-array-and-vice-versa.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/817858895305954663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/817858895305954663'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2011/01/xsd-to-byte-array-and-vice-versa.html' title='XSD to byte array and vice versa'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-110693313238506624</id><published>2009-07-21T11:20:00.001+03:00</published><updated>2009-07-21T11:32:38.637+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='Menu'/><title type='text'>MFC - Route Menu commands ElseWhere</title><content type='html'>&lt;B&gt;Want to Handle Menu command where ever you want? - Use this code&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.biobase-international.com/pages/uploads/pics/route1.gif" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;void CUtilities::CmdRouteMenu(CWnd* pWnd, CMenu* pPopupMenu)&lt;br /&gt;{&lt;br /&gt; CCmdUI state;&lt;br /&gt; state.m_pMenu = pPopupMenu;&lt;br /&gt; state.m_pParentMenu = pPopupMenu;&lt;br /&gt; state.m_nIndexMax = pPopupMenu-&gt;GetMenuItemCount();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class='hidepost'&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; for (state.m_nIndex = 0; &lt;br /&gt;      state.m_nIndex &lt; state.m_nIndexMax; &lt;br /&gt;      state.m_nIndex++) &lt;br /&gt; {&lt;br /&gt;  state.m_nID = pPopupMenu-&gt;GetMenuItemID(state.m_nIndex);&lt;br /&gt;&lt;br /&gt;  // menu separator or invalid cmd - ignore it&lt;br /&gt;  if (state.m_nID == 0) continue; &lt;br /&gt;&lt;br /&gt;  if (state.m_nID == (UINT)-1)&lt;br /&gt;  {&lt;br /&gt;   // possibly a popup menu, route to child menu if so&lt;br /&gt;   CMenu* pSub=pPopupMenu-&gt;GetSubMenu(state.m_nIndex);&lt;br /&gt;   if(pSub) CmdRouteMenu(pWnd,pSub);&lt;br /&gt;  }&lt;br /&gt;  else &lt;br /&gt;  {&lt;br /&gt;   // normal menu item, Auto disable if command is _not_ a system command.&lt;br /&gt;   state.m_pSubMenu = NULL;&lt;br /&gt;   state.DoUpdate(pWnd, FALSE);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Usage:&lt;br /&gt;&lt;br /&gt;CMenu menu;&lt;br /&gt;if  ( menu.LoadMenu(uMenuID) )&lt;br /&gt;{&lt;br /&gt; CMenu * pMenu = (CMenu*)menu.GetSubMenu(0);&lt;br /&gt; CUtilities::CmdRouteMenu(&amp;m_pParent, pMenu); // Make sure commands get to parent window&lt;br /&gt; // Route commands to parent window:&lt;br /&gt; POINT pt;&lt;br /&gt; GetCursorPos(&amp;pt);&lt;br /&gt; pMenu-&gt;TrackPopupMenu(TPM_RIGHTBUTTON|TPM_LEFTALIGN, pt.x, pt.y, &amp;m_pParent);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-110693313238506624?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/110693313238506624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/07/mfc-route-menu-commands-elsewhere.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/110693313238506624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/110693313238506624'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/07/mfc-route-menu-commands-elsewhere.html' title='&lt;U&gt;MFC - Route Menu commands ElseWhere&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-1098817308865836303</id><published>2009-07-14T09:32:00.002+03:00</published><updated>2009-07-14T11:22:57.279+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CString'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><title type='text'>MFC - Find if a given string is numeric</title><content type='html'>&lt;B&gt;Find if a given string is numeric&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.toyvault.com/gamesupplies/6%20sided%20dice%20numeric%20-%20Large.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;bool IsNumeric(const CString&amp; str, bool bIsInt)&lt;br /&gt;{&lt;br /&gt; int nSize = str.GetLength();&lt;br /&gt; int ReturnValue = 0;&lt;br /&gt; int DotCounter = 0;&lt;br /&gt; bool bContiue = true;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class='hidepost'&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; //-------Case of integer--------------------------&lt;br /&gt; if ( bIsInt )&lt;br /&gt; {&lt;br /&gt;  // Goes over the string characters&lt;br /&gt;  for ( int i=0; i &lt; nSize; i++ )&lt;br /&gt;  {&lt;br /&gt;   ReturnValue = isdigit( str.GetAt(i) );&lt;br /&gt;   if ( !ReturnValue )&lt;br /&gt;   {&lt;br /&gt;    CString strChar = str.GetAt(i);&lt;br /&gt;    if ( (i == 0) &amp;&amp; (strChar=="-") )&lt;br /&gt;     bContiue = true;&lt;br /&gt;    else&lt;br /&gt;     bContiue = false;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   if ( !bContiue )&lt;br /&gt;    return false;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  return true;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; //-------Case of double----------------------&lt;br /&gt; // Goes over the string characters&lt;br /&gt; for ( int i=0; i &lt; nSize; i++ )&lt;br /&gt; {&lt;br /&gt;  ReturnValue = isdigit( str.GetAt(i) );&lt;br /&gt;  if ( !ReturnValue )&lt;br /&gt;  {&lt;br /&gt;   CString strChar = str.GetAt(i);&lt;br /&gt;   if ((i == 0) &amp;&amp; (strChar=="-") )&lt;br /&gt;    bContiue = true;&lt;br /&gt;   else if ( (i!=0) &amp;&amp; (strChar== ".") &amp;&amp; (DotCounter==0) )&lt;br /&gt;   {&lt;br /&gt;    DotCounter = 1;&lt;br /&gt;    bContiue = true;&lt;br /&gt;   }&lt;br /&gt;   else&lt;br /&gt;    bContiue = false;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  if ( !bContiue )&lt;br /&gt;   return false;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return true;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-1098817308865836303?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/1098817308865836303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/07/mfc-find-if-given-string-is-numeric.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1098817308865836303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1098817308865836303'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/07/mfc-find-if-given-string-is-numeric.html' title='&lt;U&gt;MFC - Find if a given string is numeric&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-4068579107538188488</id><published>2009-07-14T09:25:00.002+03:00</published><updated>2009-07-14T11:24:31.842+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><title type='text'>MFC - Wait until a file or path does or not not exist</title><content type='html'>&lt;B&gt;useful code to wait till a file path does or not exists&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/commons/4/48/Julia_Margaret_Cameron-I_wait.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;BOOL FileExist( LPTSTR pszFilePath )&lt;br /&gt;{&lt;br /&gt; BOOL bRetVal;&lt;br /&gt;&lt;br /&gt; if( _taccess( pszFilePath , 0 ) == 0 )&lt;br /&gt; {&lt;br /&gt;  bRetVal = TRUE;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt;  bRetVal = FALSE;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; return bRetVal;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class='hidepost'&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;BOOL WaitForFileNotExist( LPTSTR pszPath , DWORD dwTimeout )&lt;br /&gt;{&lt;br /&gt; int nCount = dwTimeout/100;&lt;br /&gt; int nCounter = 0;&lt;br /&gt;&lt;br /&gt; if( nCount &lt; 1 )&lt;br /&gt; {&lt;br /&gt;  // timeout must be more or equal to 1 !!&lt;br /&gt;  return FALSE;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; // only exit the loop when the file is present or timeout occurs&lt;br /&gt; while( !FileExist(pszPath) &amp;&amp; nCounter  &lt; nCount )&lt;br /&gt; {&lt;br /&gt;  Sleep(100);&lt;br /&gt;  nCounter++;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; if( nCounter &gt;= nCount )&lt;br /&gt; {&lt;br /&gt;  return FALSE;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return TRUE;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;BOOL WaitForFileExist( LPTSTR pszPath , DWORD dwTimeout )&lt;br /&gt;{&lt;br /&gt; int nCount = dwTimeout/100;&lt;br /&gt; int nCounter = 0;&lt;br /&gt;&lt;br /&gt; if( nCount &lt; 1 )&lt;br /&gt; {&lt;br /&gt;  // timeout must be more or equal to 1 !!&lt;br /&gt;  return FALSE;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; // only exit the loop when the file is present or timeout occurs&lt;br /&gt; while( !FileExist(pszPath) &amp;&amp; nCounter  &lt; nCount )&lt;br /&gt; {&lt;br /&gt;  ::Sleep(100);&lt;br /&gt;  nCounter++;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; if( nCounter &gt;= nCount )&lt;br /&gt; {&lt;br /&gt;  return FALSE;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return TRUE;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-4068579107538188488?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/4068579107538188488/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/07/wait-until-file-or-path-does-or-not-not.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/4068579107538188488'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/4068579107538188488'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/07/wait-until-file-or-path-does-or-not-not.html' title='&lt;U&gt;MFC - Wait until a file or path does or not not exist&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-2176198436273216006</id><published>2009-07-14T09:22:00.003+03:00</published><updated>2009-07-14T11:49:08.670+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Recrusive'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><title type='text'>MFC - Delete Path Recursive</title><content type='html'>&lt;B&gt;Want to Delete entire path? Use this&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.wishlist.nu/wp-content/uploads/2008/06/delete.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;void CMyFileManager::DeletePathRecursive( LPTSTR pszPathToDelete )&lt;br /&gt;{&lt;br /&gt; CString  strCurPathToDelete;&lt;br /&gt; CString  strCurFileFound;&lt;br /&gt; CFileFind FileFinder;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class='hidepost'&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; strCurPathToDelete.Format( _T("%s\\*.*") ,  pszPathToDelete );&lt;br /&gt;&lt;br /&gt; BOOL bWorking = FileFinder.FindFile( strCurPathToDelete );&lt;br /&gt; while ( bWorking )&lt;br /&gt; {&lt;br /&gt;  bWorking = FileFinder.FindNextFile();&lt;br /&gt;  &lt;br /&gt;  if ( FileFinder.IsDots() ) continue;&lt;br /&gt;&lt;br /&gt;  strCurFileFound = FileFinder.GetFilePath();&lt;br /&gt;  &lt;br /&gt;  if ( FileFinder.IsDirectory() )&lt;br /&gt;  {&lt;br /&gt;   // Found a sub-directory - delete it recursivly:&lt;br /&gt;   DeletePathRecursive( strCurFileFound.GetBuffer(0) );&lt;br /&gt;  &lt;br /&gt;   // Delete the sub-directory itself:&lt;br /&gt;   TRACE( _T("\nDeleting sub-directory %s") , strCurFileFound );&lt;br /&gt;   RemoveDirectory( strCurFileFound.GetBuffer(0) );&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;  {&lt;br /&gt;   // Found a file - delete it:&lt;br /&gt;   TRACE( _T("\nDeleting file %s") , strCurFileFound );&lt;br /&gt;   DeleteFile( strCurFileFound );&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-2176198436273216006?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/2176198436273216006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/07/mfc-delete-path-recursive.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/2176198436273216006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/2176198436273216006'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/07/mfc-delete-path-recursive.html' title='&lt;U&gt;MFC - Delete Path Recursive&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-8598095218858346465</id><published>2009-06-18T11:58:00.001+03:00</published><updated>2009-06-18T12:04:01.137+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='Debugging'/><title type='text'>"funny" memory values</title><content type='html'>&lt;img src="http://media.bigoo.ws/content/image/funny/funny_407.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;A href="http://bimba.blogli.co.il/"&gt;Thanks to bimba&lt;/A&gt;. &lt;br /&gt;&lt;br /&gt;&lt;B&gt;0xcccccccc&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;When the code is compiled with the /GZ option, uninitialized variables are automatically assigned to this value (at byte level). - you define a variable - this is its default value&lt;br /&gt;&lt;br /&gt;&lt;B&gt;0xdddddddd&lt;/B&gt;&lt;br /&gt;After you delete an object - Memory that has been released with delete or free. It is used to detect writing through dangling pointers. &lt;br /&gt;&lt;br /&gt;&lt;B&gt;0xcdcdcdcd&lt;/B&gt;&lt;br /&gt;Allocated memory via malloc or new but never written by the application. &lt;br /&gt;&lt;br /&gt;&lt;B&gt;0xfdfdfdfd&lt;/B&gt;&lt;br /&gt;Also known as "no mans land." This is used to wrap the allocated memory (like surrounding it with fences) and is used to detect indexing arrays out of bounds. &lt;br /&gt;&lt;br /&gt;&lt;B&gt;0xBAADFOOD(bad food)&lt;/B&gt; &lt;br /&gt;Memory allocated by LocalAlloc() with LMEM_FIXED, but not yet written to. &lt;br /&gt;&lt;br /&gt;&lt;B&gt;0xabababab&lt;/B&gt;&lt;br /&gt;Memory allocated by LocalAlloc()&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-8598095218858346465?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/8598095218858346465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/06/funny-memory-values.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8598095218858346465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8598095218858346465'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/06/funny-memory-values.html' title='&lt;U&gt;&quot;funny&quot; memory values&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-2986146692927932103</id><published>2009-06-18T11:10:00.005+03:00</published><updated>2009-07-14T11:27:23.131+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>Watch Window Tips for Visual Studio 2003</title><content type='html'>&lt;img src="http://tbn3.google.com/images?q=tbn:fjajHNy0FmUW-M:http://leonmeijer.nl/images/leonmeijer_nl/WindowsLiveWriter/TestdrivendevelopmentUni.NETwhatsallthis_D86E/sw_testing.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;Edit autoexp.dat Which is located in C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\Debugger&lt;br /&gt;&lt;br /&gt;Show Vecor Size&lt;br /&gt;Add this line : &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;std::vector &lt;*&gt; = size = &lt;size(), i&gt;, capacity = &lt;capacity() , i&gt;&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.vcode.no/resource.nsf/GSWNAPI/404.htm"&gt;List of additional Object that can be better "Watched" &lt;/A&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-2986146692927932103?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/2986146692927932103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/06/watch-window-tips-for-visual-studio.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/2986146692927932103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/2986146692927932103'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/06/watch-window-tips-for-visual-studio.html' title='&lt;U&gt;Watch Window Tips for Visual Studio 2003&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-4819104695644316560</id><published>2009-06-18T10:08:00.002+03:00</published><updated>2009-06-18T10:12:52.251+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>Call GetLastError in the Watch Tab in Debugger</title><content type='html'>&lt;B&gt;Want to see GetLastError messsage on run time?&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.belshe.com/wp-content/uploads/2006/12/WindowsLiveWriter/HowtocallGetLastErrorintheDebuggerVisual_8430/watcherr%5B14%5D.png" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;just add “@err” or “@err,hr” to your debug watch window.  Now it’s more like looking at errno.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-4819104695644316560?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/4819104695644316560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/06/call-getlasterror-in-watch-tab-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/4819104695644316560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/4819104695644316560'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/06/call-getlasterror-in-watch-tab-in.html' title='&lt;U&gt;Call GetLastError in the Watch Tab in Debugger&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-7535795286676443734</id><published>2009-06-02T16:46:00.003+03:00</published><updated>2009-06-02T17:15:05.772+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='Dialog'/><title type='text'>move a dialog without a caption</title><content type='html'>&lt;B&gt;how can you move a dialog without a caption (title)?&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;A href="http://bimba.blogli.co.il/"&gt;Thanks to bimba&lt;/A&gt;. &lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.winternet.com/~mikelr/assets/move.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;Pre&gt;&lt;br /&gt;&lt;br /&gt;simply add this code:&lt;br /&gt;&lt;br /&gt;UINT CClientRectDlg:: OnNcHitTest(CPoint point) &lt;br /&gt;{ &lt;br /&gt;   UINT ret = CDialog:: OnNcHitTest(point); &lt;br /&gt;   if(ret == HTCLIENT) &lt;br /&gt;     return HTCAPTION; &lt;br /&gt;   else return ret; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;you have to add this to the message_map ON_WM_NCHITTEST()&lt;br /&gt;&lt;br /&gt;Nice ah?&lt;br /&gt;&lt;br /&gt;&lt;/Pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-7535795286676443734?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/7535795286676443734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/06/move-dialog-without-caption.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/7535795286676443734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/7535795286676443734'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/06/move-dialog-without-caption.html' title='&lt;U&gt;move a dialog without a caption&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-8151132498679737651</id><published>2009-06-02T09:28:00.002+03:00</published><updated>2009-07-14T11:29:23.154+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lingo'/><category scheme='http://www.blogger.com/atom/ns#' term='RGB'/><category scheme='http://www.blogger.com/atom/ns#' term='Hex'/><title type='text'>Lingo - Translate hex to rgb format</title><content type='html'>&lt;B&gt;Ever wanted to transform Hex to RGB? Use this useful utility&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.technovelgy.com/graphics/content08/nokia-shoot-to-translate.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;on HexToRGB hex&lt;br /&gt;  ---------------------------------------------------------------&lt;br /&gt;  -- Name:HexToRGB&lt;br /&gt;  -- Input:hex string&lt;br /&gt;  -- Description:Translate hex to rgb format&lt;br /&gt;  --&lt;br /&gt;  --&lt;br /&gt;  -- Output:rgb value&lt;br /&gt;  ---------------------------------------------------------------&lt;br /&gt;  &lt;br /&gt;  num1=0&lt;br /&gt;  num2=0&lt;br /&gt;  num3=0&lt;br /&gt;&lt;/pre&gt;  &lt;br /&gt;&lt;span class='hidepost'&gt;&lt;br /&gt;&lt;pre&gt;  &lt;br /&gt;  str1=hex.char[2]&amp;hex.char[1]&lt;br /&gt;  str2=hex.char[4]&amp;hex.char[3]&lt;br /&gt;  str3=hex.char[6]&amp;hex.char[5]&lt;br /&gt;  &lt;br /&gt;  repeat with i=1 to 2&lt;br /&gt;    case (str1.char[i]) of&lt;br /&gt;      "A":num1=num1+power(i,4)*10&lt;br /&gt;      "B":num1=num1+power(i,4)*11&lt;br /&gt;      "C":num1=num1+power(i,4)*12&lt;br /&gt;      "D":num1=num1+power(i,4)*13&lt;br /&gt;      "E":num1=num1+power(i,4)*14&lt;br /&gt;      "F":num1=num1+power(i,4)*15&lt;br /&gt;      otherwise:  num1=num1+power(i,4)*integer(str1.char[i])&lt;br /&gt;    end case&lt;br /&gt;    &lt;br /&gt;  end repeat&lt;br /&gt;  repeat with i=1 to 2&lt;br /&gt;    case (str2.char[i]) of&lt;br /&gt;      "A":num2=num2+power(i,4)*10&lt;br /&gt;      "B":num2=num2+power(i,4)*11&lt;br /&gt;      "C":num2=num2+power(i,4)*12&lt;br /&gt;      "D":num2=num2+power(i,4)*13&lt;br /&gt;      "E":num2=num2+power(i,4)*14&lt;br /&gt;      "F":num2=num2+power(i,4)*15&lt;br /&gt;      otherwise:  num=num+power(i,4)*integer(str2.char[i])&lt;br /&gt;    end case&lt;br /&gt;  end repeat&lt;br /&gt;  repeat with i=1 to 2&lt;br /&gt;    case (str3.char[i]) of&lt;br /&gt;      "A":num3=num3+power(i,4)*10&lt;br /&gt;      "B":num3=num3+power(i,4)*11&lt;br /&gt;      "C":num3=num3+power(i,4)*12&lt;br /&gt;      "D":num3=num3+power(i,4)*13&lt;br /&gt;      "E":num3=num3+power(i,4)*14&lt;br /&gt;      "F":num3=num3+power(i,4)*15&lt;br /&gt;      otherwise:  num3=num3+power(i,4)*integer(str3.char[i])&lt;br /&gt;    end case&lt;br /&gt;    --i=i-1&lt;br /&gt;  end repeat&lt;br /&gt;  return (rgb(num1,num2,num3))&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-8151132498679737651?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/8151132498679737651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/06/lingo-translate-hex-to-rgb-format.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8151132498679737651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8151132498679737651'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/06/lingo-translate-hex-to-rgb-format.html' title='&lt;U&gt;Lingo - Translate hex to rgb format&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-8723569250936190781</id><published>2009-05-27T08:40:00.003+03:00</published><updated>2009-07-14T11:30:58.743+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lingo'/><category scheme='http://www.blogger.com/atom/ns#' term='string'/><title type='text'>Lingo - "CString" like operation on strings</title><content type='html'>&lt;B&gt; Coding in Lingo? (Macromedia and shockwave) here are some useful string utilities to help you &lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.rogerwang.net/pics/No%20Strings%20Attached%20Cover.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;on new me&lt;br /&gt;  return me&lt;br /&gt;end new&lt;br /&gt;&lt;br /&gt;on trimLeadingWhiteSpace str&lt;br /&gt;  FuncName="trimLeadingWhiteSpace"      &lt;br /&gt;  ---------------------------------------------------------------&lt;br /&gt;  -- Name:trimLeadingWhiteSpace&lt;br /&gt;  -- Input:String&lt;br /&gt;  -- delete whitespace on the beginning of the string&lt;br /&gt;  --&lt;br /&gt;  --&lt;br /&gt;  -- Output:String&lt;br /&gt;  ---------------------------------------------------------------&lt;br /&gt;  &lt;br /&gt;  theCount = str.char.count&lt;br /&gt;  whiteSpace = " "&lt;br /&gt;  repeat with i = 1 to theCount&lt;br /&gt;    if whiteSpace contains str.char[i]then&lt;br /&gt;      next repeat&lt;br /&gt;    else&lt;br /&gt;      outStr = str.char[i..theCount]&lt;br /&gt;      exit repeat&lt;br /&gt;    end if&lt;br /&gt;  end repeat&lt;br /&gt;  return outStr&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class='hidepost'&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;On TrimLeft me,str,subStr&lt;br /&gt;  FuncName="TrimLeft"  &lt;br /&gt;  if(voidp(subStr)) then -- trim leading spaces&lt;br /&gt;    retStr= word 1 to the number of words in str of str&lt;br /&gt;  else&lt;br /&gt;    offsetNum=length(subStr)&lt;br /&gt;    retStr=chars (str, offsetNum+1, length(str))&lt;br /&gt;  end if&lt;br /&gt;  return retStr&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;on strReplace me,input, stringToFind, stringToInsert&lt;br /&gt;  FuncName="strReplace"      &lt;br /&gt;  -- search and replace char in a string&lt;br /&gt;  output = ""&lt;br /&gt;  findLen = stringToFind.length - 1&lt;br /&gt;  repeat while input contains stringToFind&lt;br /&gt;    currOffset = offset(stringToFind, input)&lt;br /&gt;    output = output &amp; input.char [1..currOffset]&lt;br /&gt;    delete the last char of output&lt;br /&gt;    output = output &amp; stringToInsert&lt;br /&gt;    delete input.char [1.. (currOffset + findLen)] &lt;br /&gt;  end repeat&lt;br /&gt;  set output = output &amp; input&lt;br /&gt;  return output&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;on GetFileTitle me,str,pref&lt;br /&gt;  offs=offset(pref,str)&lt;br /&gt;  repeat with i=offs down to 1&lt;br /&gt;    if(str.char[i..i]="\" or str.char[i..i]="/" ) then&lt;br /&gt;      posOfSlesh=i&lt;br /&gt;      i=1&lt;br /&gt;    end if&lt;br /&gt;  end repeat&lt;br /&gt;  substring=chars (str, 0, posOfSlesh)&lt;br /&gt;  ret=me.TrimLeft(str,substring)&lt;br /&gt;  ret=me.TrimRight(ret,pref)&lt;br /&gt;  return ret&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;on trimspaces me, t&lt;br /&gt;  FuncName="trimspaces"      &lt;br /&gt;  return word 1 to the number of words in t of t&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;on SetLocalPath me, str&lt;br /&gt;  FuncName="SetLocalPath"      &lt;br /&gt;  -- set the local path for local play&lt;br /&gt;  retStr=me.strReplace(str,"file://","")&lt;br /&gt;  if(retStr.char[1]="/") then&lt;br /&gt;    retStr=chars (retStr, 2,length(retStr))&lt;br /&gt;    retStr=me.strReplace(retStr,"/","\")&lt;br /&gt;    retstr=me.strReplace(retstr,"|",":")&lt;br /&gt;  else --local web path&lt;br /&gt;    retStr=me.strReplace(retStr,"/","\")&lt;br /&gt;    retstr=me.strReplace(retstr,"|",":")&lt;br /&gt;    retstr="\\"&amp;retstr&lt;br /&gt;  end if&lt;br /&gt;  return retStr&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;on GetContent me, _url,str&lt;br /&gt;  FuncName="GetContent"      &lt;br /&gt;  --Get the content of a known path (I.E. http://Test/league.htm -&gt; http://Test/DswMedia)&lt;br /&gt;  EndOffset=offset(str,_url)&lt;br /&gt;  retStr=chars (_url, 0,EndOffset-1)&lt;br /&gt;  retstr=retstr&amp;"DswMedia"&lt;br /&gt;  return retStr&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;on TrimRight me,_source,str  &lt;br /&gt;  FuncName="TrimRight"      &lt;br /&gt;  -- trim the right string from source&lt;br /&gt;  offsetNum=length(str)&lt;br /&gt;  retStr=chars (_source, 0, length(_source)-offsetNum)&lt;br /&gt;  retStr=me.trimspaces(retStr)  &lt;br /&gt;  return retStr&lt;br /&gt;end TrimRight&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;on String2List me,str&lt;br /&gt;  _list=[]&lt;br /&gt;  repeat with i=1 to str.length&lt;br /&gt;    if(str.char[i..i]&lt;&gt;",") then&lt;br /&gt;      _list.append(str.char[i..i])&lt;br /&gt;    end if&lt;br /&gt;  end repeat&lt;br /&gt;  return _list&lt;br /&gt;end  &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-8723569250936190781?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/8723569250936190781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/lingo-cstring-like-operation-on-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8723569250936190781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8723569250936190781'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/lingo-cstring-like-operation-on-strings.html' title='&lt;U&gt;Lingo - &quot;CString&quot; like operation on strings&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-453637888870963743</id><published>2009-05-26T09:45:00.006+03:00</published><updated>2009-07-14T11:49:37.510+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='Recrusive'/><title type='text'>C++ - Build Recrusive Folder presentation from current location</title><content type='html'>&lt;B&gt;This code demonstrates how to print out a recursive folder presentation from any where in the drive the output file "Tree.txt" contains the "level" number of folder in the hierarchy and it's name You can also contain the files in the folder by changing if( c_file.attrib&amp;_A_SUBDIR &amp;&amp; strchr(c_file.name,'.')==0) to if(strchr(c_file.name,'.')==0)&lt;br /&gt;&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.johntopley.com/oldblog/archive/2004/07/17/project_structure.gif" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &lt;direct.h&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;io.h&gt;&lt;br /&gt;#include &lt;string.h&gt;&lt;br /&gt;&lt;br /&gt;#define _MAX_PATH 255&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class='hidepost'&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;int FindLevel(char *s)&lt;br /&gt;{&lt;br /&gt; int result=0;&lt;br /&gt; for(int i=1;i&lt;strlen(s);i++)&lt;br /&gt; {&lt;br /&gt;  if(s[i]=='\\') result++;&lt;br /&gt; }&lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void BuildTree(char *path,FILE *fp,int nTreeLevel)&lt;br /&gt;{&lt;br /&gt; struct _finddata_t c_file;&lt;br /&gt;    long hFile; &lt;br /&gt; char tmp[_MAX_PATH];&lt;br /&gt; strcpy(tmp,path);&lt;br /&gt; strcat(tmp,"\\*.*\0");&lt;br /&gt; &lt;br /&gt; if( (hFile = _findfirst( tmp, &amp;c_file )) == -1L )&lt;br /&gt;       printf( "No *.* files in current directory!\n" );&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;            while( _findnext( hFile, &amp;c_file ) == 0 )&lt;br /&gt;            {&lt;br /&gt;                if( c_file.attrib&amp;_A_SUBDIR &amp;&amp; strchr(c_file.name,'.')==0)&lt;br /&gt;    {&lt;br /&gt;     int NewLevel=0;&lt;br /&gt;     strcpy(tmp,path);&lt;br /&gt;     strcat(tmp,"\\");&lt;br /&gt;     strcat(tmp,c_file.name);&lt;br /&gt;     int i=FindLevel(path);&lt;br /&gt;     if(i&gt;nTreeLevel)  NewLevel=i-nTreeLevel;&lt;br /&gt;     fprintf(fp,"%d %s\n",NewLevel,c_file.name); &lt;br /&gt;     BuildTree(tmp,fp,nTreeLevel);&lt;br /&gt;    }&lt;br /&gt;            }&lt;br /&gt;    _findclose( hFile );&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char* argv[])&lt;br /&gt;{&lt;br /&gt; FILE *fp;&lt;br /&gt; char buffer[_MAX_PATH];&lt;br /&gt;   /* Get the current working directory: */&lt;br /&gt;   if( _getcwd( buffer, _MAX_PATH ) == NULL )&lt;br /&gt;      perror( "_getcwd error" );&lt;br /&gt;   else&lt;br /&gt;   {&lt;br /&gt;    if((fp=fopen("c:\\Tree.txt","w"))==NULL)&lt;br /&gt;  {&lt;br /&gt;   printf( "Error opening file" );&lt;br /&gt;   return -1;&lt;br /&gt;  }&lt;br /&gt;  /* Find first *.* file in current directory */&lt;br /&gt;  BuildTree(buffer,fp,FindLevel(buffer));&lt;br /&gt;  fclose(fp);&lt;br /&gt;   }&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-453637888870963743?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/453637888870963743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/c-build-recrusive-folder-presentation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/453637888870963743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/453637888870963743'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/c-build-recrusive-folder-presentation.html' title='&lt;U&gt;C++ - Build Recrusive Folder presentation from current location&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-1954685362569482590</id><published>2009-05-26T08:59:00.001+03:00</published><updated>2009-06-03T13:20:28.456+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><title type='text'>C++  - HowTo printf on release version</title><content type='html'>&lt;B&gt;Ever wanted to know where you are in your code when running a release version? use this&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;AllocConsole();&lt;br /&gt;freopen("conin$", "r", stdin);&lt;br /&gt;freopen("conout$", "w", stdout);&lt;br /&gt;freopen("conout$", "w", stderr); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;and now you can use "printf" to output debug on a simple console.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-1954685362569482590?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/1954685362569482590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/c-howto-printf-on-release-version.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1954685362569482590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1954685362569482590'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/c-howto-printf-on-release-version.html' title='&lt;U&gt;C++  - HowTo printf on release version&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-1948230964189783462</id><published>2009-05-14T09:04:00.003+03:00</published><updated>2009-05-14T10:02:33.493+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='CButton'/><title type='text'>MFC - Vertical button with text</title><content type='html'>&lt;B&gt;Ever wanted to place a vertical button on your application? use this code&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://static.zooomr.com/images/7447043_39abdfc1e0_o.jpg" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;1. You will have to Subclass CButton&lt;br /&gt;2. change the fon't lfEscapement ,lfOrientation  to 2700&lt;br /&gt;        GetFont(&amp;tLogFont);&lt;br /&gt; tLogFont.lfEscapement = tLogFont.lfOrientation = 2700;&lt;br /&gt; m_bRotation = bRotation;&lt;br /&gt; SetFont(&amp;tLogFont);&lt;br /&gt;&lt;br /&gt;3. overide the ::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) &lt;br /&gt;   function&lt;br /&gt;&lt;br /&gt;4. Draw the caption&lt;br /&gt;&lt;br /&gt; int nAlign = _pDC-&gt;SetTextAlign (TA_BASELINE);&lt;br /&gt; CRect rc;&lt;br /&gt; GetClientRect(rc);&lt;br /&gt; CPoint pt;&lt;br /&gt; CSize sSizeExt = _pDC-&gt;GetTextExtent(sCaption);&lt;br /&gt; GetViewportOrgEx (_pDC-&gt;m_hDC,&amp;pt) ;&lt;br /&gt; SetViewportOrgEx (_pDC-&gt;m_hDC,rc.Width() / 2, &lt;br /&gt;                                      rc.Height() / 2, NULL) ;&lt;br /&gt; int nPosOfStart =(rc.Height()/2)+(rc.Height()-sSizeExt.cx)/2;&lt;br /&gt; if(sSizeExt.cx&gt;rc.Height()) nPosOfStart = rc.Height()/2;&lt;br /&gt; int nPosX = min(0,(sSizeExt.cy-rc.Width())/2);&lt;br /&gt; _pDC-&gt;TextOut (nPosX, ((nState-1) *rc.Height()) + &lt;br /&gt;                                       nPosOfStart, sCaption) ;&lt;br /&gt; SetViewportOrgEx (_pDC-&gt;m_hDC,pt.x / 2, pt.y / 2, NULL) ;&lt;br /&gt; _pDC-&gt;SetTextAlign (nAlign);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/Pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-1948230964189783462?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/1948230964189783462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/mfc-vertical-button-with-text.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1948230964189783462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1948230964189783462'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/mfc-vertical-button-with-text.html' title='&lt;U&gt;MFC - Vertical button with text&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-8472727866565163010</id><published>2009-05-13T09:11:00.005+03:00</published><updated>2009-06-03T13:18:08.110+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><title type='text'>C++ , MFC  - get COLORREF value from string</title><content type='html'>&lt;B&gt; Ever wanted to get COLORREF value from string? use this&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.allthesky.com/icons/rgbcircles.gif" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;COLORREF CClassName::GetColorFromStr(char * str)&lt;br /&gt;{&lt;br /&gt; int r = 255,g = 255,b = 255;&lt;br /&gt; if(str &amp;&amp; strlen(str)&gt;=5)  // minimum size&lt;br /&gt; {&lt;br /&gt;  CString sStr(str);&lt;br /&gt;  int curPos= 0;&lt;br /&gt;  CString resToken= sStr.Tokenize(",",curPos);&lt;br /&gt;  int nIndex=0;&lt;br /&gt;  while (resToken != "")&lt;br /&gt;  {&lt;br /&gt;   if(nIndex == 0)&lt;br /&gt;    r = atoi(resToken);&lt;br /&gt;   else if (nIndex == 1)&lt;br /&gt;    g = atoi(resToken);&lt;br /&gt;   else&lt;br /&gt;    b= atoi(resToken);&lt;br /&gt;   nIndex++;&lt;br /&gt;   resToken= sStr.Tokenize(",",curPos);&lt;br /&gt;  };&lt;br /&gt; }&lt;br /&gt; return RGB(r,g,b);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-8472727866565163010?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/8472727866565163010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/c-mfc-get-colorref-value-from-string.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8472727866565163010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8472727866565163010'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/c-mfc-get-colorref-value-from-string.html' title='&lt;U&gt;C++ , MFC  - get COLORREF value from string&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-3321051051416277520</id><published>2009-05-13T09:02:00.002+03:00</published><updated>2009-05-14T08:56:54.346+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='CString'/><category scheme='http://www.blogger.com/atom/ns#' term='std'/><title type='text'>C++ - How to convert between 'CString' and 'std::string'?</title><content type='html'>&lt;B&gt;Simple But Still Annoying&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.matraxis.co.uk/ACRMarketingCycle/a_Matraxis_convert_Logo02.gif" alt="" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;U&gt;'CString' to 'std::string'&lt;/U&gt;&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;CString cs("Hello");&lt;br /&gt;std::string s((LPCTSTR)cs);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;U&gt;'std::string' to 'CString':&lt;/U&gt;&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;std::string s("Hello");&lt;br /&gt;CString cs(s.c_str());&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-3321051051416277520?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/3321051051416277520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/c-how-to-convert-between-cstring-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3321051051416277520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3321051051416277520'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/c-how-to-convert-between-cstring-and.html' title='&lt;U&gt;C++ - How to convert between &apos;CString&apos; and &apos;std::string&apos;?&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-3204719186535682176</id><published>2009-05-10T09:59:00.002+03:00</published><updated>2009-05-10T10:14:12.287+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QPushButton'/><category scheme='http://www.blogger.com/atom/ns#' term='QT'/><title type='text'>QT - Resize QPushButton to fit it's text </title><content type='html'>&lt;B&gt;Maybe there are better ways but this is how i did it&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;1. subclass QPushButton.&lt;br /&gt;2. overwrite the virtual sizeHint() function&lt;br /&gt;3. In this function return the prefered sizeHint (QPushButton sizeHint().width=80)&lt;br /&gt;4. call adjustSize() on your subclassed QPushButton.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;U&gt;Header&lt;/U&gt;&lt;br /&gt;&lt;br /&gt;class QModifiedQPushButton : public QPushButton&lt;br /&gt;{&lt;br /&gt;    Q_OBJECT&lt;br /&gt;public:&lt;br /&gt;    QModifiedQPushButton(const QString &amp;text ,QWidget * parent = 0, const char * name = 0 ); &lt;br /&gt;    virtual ~QModifiedQPushButton();&lt;br /&gt;    QSize sizeHint() const;&lt;br /&gt;};&lt;br /&gt; &lt;br /&gt;&lt;U&gt;CPP&lt;/U&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;QModifiedQPushButton::QModifiedQPushButton(const QString &amp;text ,QWidget * parent,const char * name) : QPushButton(text,parent,name)&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;QModifiedQPushButton::~QModifiedQPushButton()&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;QSize QModifiedQPushButton::sizeHint() const&lt;br /&gt;{&lt;br /&gt;    return QSize(40,28); // you can return whatever size here&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-3204719186535682176?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/3204719186535682176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/qt-resize-qpushbutton-to-fit-its-text.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3204719186535682176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3204719186535682176'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/qt-resize-qpushbutton-to-fit-its-text.html' title='&lt;U&gt;QT - Resize QPushButton to fit it&apos;s text &lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-3376710463705017011</id><published>2009-05-09T08:35:00.004+03:00</published><updated>2009-05-09T22:27:18.731+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='Design Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='Singleton'/><title type='text'>Singleton Design Pattern in c++</title><content type='html'>if you want a class that has only one representation in the proccess&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;declaration&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;class Singleton&lt;br /&gt;{&lt;br /&gt;public: static Singleton* Instance();&lt;br /&gt;protected: Singleton();&lt;br /&gt;Singleton(const Singleton&amp;amp;);&lt;br /&gt;Singleton&amp;amp; operator= (const Singleton&amp;amp;);&lt;br /&gt;private:&lt;br /&gt;static Singleton* pinstance;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;em&gt;implementation&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Singleton* Singleton::pinstance = 0;// initialize pointer&lt;br /&gt;&lt;br /&gt;Singleton* Singleton::Instance ()&lt;br /&gt;{&lt;br /&gt;if (pinstance == 0) // is it the first call?&lt;br /&gt;{&lt;br /&gt;pinstance = new Singleton; // create sole instance&lt;br /&gt;}&lt;br /&gt;return pinstance; // address of sole instance&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Singleton::Singleton()&lt;br /&gt;{ //... perform necessary instance initializations&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;em&gt;usage&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;Singleton *p1 = Singleton::Instance();&lt;br /&gt;Singleton *p2 = p1-&gt;Instance();&lt;br /&gt;Singleton &amp;amp; ref = * Singleton::Instance();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-3376710463705017011?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/3376710463705017011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/singleton-design-pattern-in-c.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3376710463705017011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3376710463705017011'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/singleton-design-pattern-in-c.html' title='&lt;U&gt;Singleton Design Pattern in c++&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-3173395808708560809</id><published>2009-05-07T09:00:00.002+03:00</published><updated>2009-06-03T13:18:48.615+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# - Why a mdi form does not produce a click event?</title><content type='html'>It doesn't fire the click event because you are not clicking on the actual &lt;br /&gt;form you are clicking on an MDIClient.  &lt;br /&gt;This is the last control in the control's collection of the form.  &lt;br /&gt;Attach the click event to this. &lt;br /&gt;this.Controls[this.Controls.Count -1].Click += new EventHandler(Form1_Click);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-3173395808708560809?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/3173395808708560809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/c-why-mdi-form-does-not-produce-click.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3173395808708560809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3173395808708560809'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/c-why-mdi-form-does-not-produce-click.html' title='&lt;U&gt;C# - Why a mdi form does not produce a click event?&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-3937336114530725939</id><published>2009-05-07T08:57:00.002+03:00</published><updated>2009-05-10T08:34:33.968+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataGridView'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Get location of CurrentCell in DataGridView</title><content type='html'>&lt;strong&gt;want to manipulate the colors of DataGridViewCell's rectangle?&lt;br /&gt;use this code to getthe rectangle&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;DataGridViewCell cc = this.dataGridView1.CurrentCell;&lt;br /&gt;Rectangle rect = this.dataGridView1.GetCellDisplayRectangle(cc.ColumnIndex,&lt;br /&gt;cc.RowIndex, true);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-3937336114530725939?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/3937336114530725939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/get-location-of-currentcell-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3937336114530725939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3937336114530725939'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/get-location-of-currentcell-in.html' title='&lt;U&gt;Get location of CurrentCell in DataGridView&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-1277901488560049065</id><published>2009-05-07T08:50:00.004+03:00</published><updated>2009-06-03T13:19:49.123+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='bitmap'/><title type='text'>Embeding String as overlay on a bitmap</title><content type='html'>&lt;strong&gt;want to write your own string as an overlay of a given bitmap?&lt;br /&gt;Use this code&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CFont* pFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));&lt;br /&gt;CFont* pOldFont = dc.SelectObject(pFont);&lt;br /&gt;dc.SetTextColor(RGB(255,255,255));&lt;br /&gt;dc.SetBkMode(TRANSPARENT);&lt;br /&gt;dc.TextOut(500,397,"String");&lt;br /&gt;dc.SelectObject(pOldFont);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-1277901488560049065?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/1277901488560049065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/embeding-string-as-overlay-on-bitmap.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1277901488560049065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1277901488560049065'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/embeding-string-as-overlay-on-bitmap.html' title='&lt;U&gt;Embeding String as overlay on a bitmap&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-8369587966292454624</id><published>2009-05-05T08:46:00.002+03:00</published><updated>2009-06-03T13:17:23.180+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='bitmap'/><category scheme='http://www.blogger.com/atom/ns#' term='JPEG'/><title type='text'>save rectangle to JPEG</title><content type='html'>&lt;strong&gt;When you need to save a rectangle in your program to a file&lt;br /&gt;the im.Save( "c:\\image.jpg", ImageFormatJPEG); line determines the file format&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &lt;atlimage.h &gt; //For Image&lt;br /&gt;using namespace Gdiplus; //For Image&lt;br /&gt;&lt;br /&gt;void BitmapUtils::SaveBitmapToFile(HDC hdc,CRect rect)&lt;br /&gt;{&lt;br /&gt; HDC hMemDC = CreateCompatibleDC(hdc);&lt;br /&gt; HBITMAP hBitmap = CreateCompatibleBitmap(hdc,rect.right, rect.Height() + rect.bottom);&lt;br /&gt; if (hBitmap)&lt;br /&gt; {&lt;br /&gt;  HBITMAP hOld = (HBITMAP) SelectObject(hMemDC, hBitmap);&lt;br /&gt;  BitBlt(hMemDC, 0, 0, rect.right, rect.Height() + rect.bottom, hdc, 0, 0, SRCCOPY);&lt;br /&gt;  SelectObject(hMemDC, hOld);&lt;br /&gt;  DeleteDC(hMemDC);&lt;br /&gt;  ::ReleaseDC(NULL, hdc);&lt;br /&gt; }&lt;br /&gt; CImage im;&lt;br /&gt; im.Attach(hBitmap); &lt;br /&gt; im.Save( "c:\\image.jpg", ImageFormatJPEG);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-8369587966292454624?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/8369587966292454624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/save-rectangle-to-jpeg.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8369587966292454624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/8369587966292454624'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/save-rectangle-to-jpeg.html' title='&lt;U&gt;save rectangle to JPEG&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-3399803697873864483</id><published>2009-05-04T11:05:00.002+03:00</published><updated>2009-05-10T08:42:47.209+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='file'/><category scheme='http://www.blogger.com/atom/ns#' term='Handle'/><title type='text'>Obtaining a File Name From a File Handle</title><content type='html'>&lt;strong&gt;Got a file handle and you want to get the file name?&lt;br /&gt;Use this code&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#include "windows.h"&lt;br /&gt;#include "stdio.h"&lt;br /&gt;#include "tchar.h"&lt;br /&gt;#include "string.h"&lt;br /&gt;#include "psapi.h"&lt;br /&gt;#include "strsafe.h"&lt;br /&gt;&lt;br /&gt;#define BUFSIZE 512&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;BOOL GetFileNameFromHandle(HANDLE hFile) &lt;br /&gt;{&lt;br /&gt;  BOOL bSuccess = FALSE;&lt;br /&gt;  TCHAR pszFilename[MAX_PATH+1];&lt;br /&gt;  HANDLE hFileMap;&lt;br /&gt;&lt;br /&gt;  // Get the file size.&lt;br /&gt;  DWORD dwFileSizeHi = 0;&lt;br /&gt;  DWORD dwFileSizeLo = GetFileSize(hFile, &amp;dwFileSizeHi); &lt;br /&gt;&lt;br /&gt;  if( dwFileSizeLo == 0 &amp;&amp; dwFileSizeHi == 0 )&lt;br /&gt;  {&lt;br /&gt;     printf("Cannot map a file with a length of zero.\n");&lt;br /&gt;     return FALSE;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  // Create a file mapping object.&lt;br /&gt;  hFileMap = CreateFileMapping(hFile, &lt;br /&gt;                    NULL, &lt;br /&gt;                    PAGE_READONLY,&lt;br /&gt;                    0, &lt;br /&gt;                    1,&lt;br /&gt;                    NULL);&lt;br /&gt;&lt;br /&gt;  if (hFileMap) &lt;br /&gt;  {&lt;br /&gt;    // Create a file mapping to get the file name.&lt;br /&gt;    void* pMem = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 1);&lt;br /&gt;&lt;br /&gt;    if (pMem) &lt;br /&gt;    {&lt;br /&gt;      if (GetMappedFileName (GetCurrentProcess(), &lt;br /&gt;                             pMem, &lt;br /&gt;                             pszFilename,&lt;br /&gt;                             MAX_PATH)) &lt;br /&gt;      {&lt;br /&gt;&lt;br /&gt;        // Translate path with device name to drive letters.&lt;br /&gt;        TCHAR szTemp[BUFSIZE];&lt;br /&gt;        szTemp[0] = '\0';&lt;br /&gt;&lt;br /&gt;        if (GetLogicalDriveStrings(BUFSIZE-1, szTemp)) &lt;br /&gt;        {&lt;br /&gt;          TCHAR szName[MAX_PATH];&lt;br /&gt;          TCHAR szDrive[3] = TEXT(" :");&lt;br /&gt;          BOOL bFound = FALSE;&lt;br /&gt;          TCHAR* p = szTemp;&lt;br /&gt;&lt;br /&gt;          do &lt;br /&gt;          {&lt;br /&gt;            // Copy the drive letter to the template string&lt;br /&gt;            *szDrive = *p;&lt;br /&gt;&lt;br /&gt;            // Look up each device name&lt;br /&gt;            if (QueryDosDevice(szDrive, szName, MAX_PATH))&lt;br /&gt;            {&lt;br /&gt;              UINT uNameLen = _tcslen(szName);&lt;br /&gt;&lt;br /&gt;              if (uNameLen &lt; MAX_PATH) &lt;br /&gt;              {&lt;br /&gt;                bFound = _tcsnicmp(pszFilename, szName, &lt;br /&gt;                    uNameLen) == 0;&lt;br /&gt;&lt;br /&gt;                if (bFound) &lt;br /&gt;                {&lt;br /&gt;                  // Reconstruct pszFilename using szTempFile&lt;br /&gt;                  // Replace device path with DOS path&lt;br /&gt;                  TCHAR szTempFile[MAX_PATH];&lt;br /&gt;                  StringCchPrintf(szTempFile,&lt;br /&gt;                            MAX_PATH,&lt;br /&gt;                            TEXT("%s%s"),&lt;br /&gt;                            szDrive,&lt;br /&gt;                            pszFilename+uNameLen);&lt;br /&gt;                  StringCchCopyN(pszFilename, MAX_PATH+1, szTempFile, _tcslen(szTempFile));&lt;br /&gt;                }&lt;br /&gt;              }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // Go to the next NULL character.&lt;br /&gt;            while (*p++);&lt;br /&gt;          } while (!bFound &amp;&amp; *p); // end of string&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;      bSuccess = TRUE;&lt;br /&gt;      UnmapViewOfFile(pMem);&lt;br /&gt;    } &lt;br /&gt;&lt;br /&gt;    CloseHandle(hFileMap);&lt;br /&gt;  }&lt;br /&gt;  _tprintf(TEXT("File name is %s\n"), pszFilename);&lt;br /&gt;  return(bSuccess);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int _tmain(int argc, TCHAR *argv[])&lt;br /&gt;{&lt;br /&gt;    HANDLE hFile;&lt;br /&gt;&lt;br /&gt;    if( argc != 2 )&lt;br /&gt;    {&lt;br /&gt;        printf("This sample takes a file name as a parameter.\n");&lt;br /&gt;        return 0;&lt;br /&gt;    }&lt;br /&gt;    hFile = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL,&lt;br /&gt;        OPEN_EXISTING, 0, NULL);&lt;br /&gt;&lt;br /&gt;    if(hFile == INVALID_HANDLE_VALUE)&lt;br /&gt;    {&lt;br /&gt;        printf("CreateFile failed with %d\n", GetLastError());&lt;br /&gt;        return 0;&lt;br /&gt;    }&lt;br /&gt;    GetFileNameFromHandle( hFile );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-3399803697873864483?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/3399803697873864483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/obtaining-file-name-from-file-handle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3399803697873864483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3399803697873864483'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/obtaining-file-name-from-file-handle.html' title='&lt;U&gt;Obtaining a File Name From a File Handle&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-1027088572718441261</id><published>2009-05-04T09:07:00.003+03:00</published><updated>2009-06-03T13:21:35.522+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='bitmap'/><title type='text'>Writing a bitmap to a BMP file</title><content type='html'>Great function to save a bitmap structure to a file&lt;br /&gt;&lt;br /&gt;// WriteDIB  - Writes a DIB to file&lt;br /&gt;// Returns  - TRUE on success&lt;br /&gt;// szFile  - Name of file to write to&lt;br /&gt;// hDIB   - Handle of the DIB&lt;br /&gt;BOOL WriteDIB( LPTSTR szFile, HANDLE hDIB)&lt;br /&gt;{&lt;br /&gt; BITMAPFILEHEADER hdr;&lt;br /&gt; LPBITMAPINFOHEADER lpbi;&lt;br /&gt;&lt;br /&gt; if (!hDIB)&lt;br /&gt;  return FALSE;&lt;br /&gt;&lt;br /&gt; CFile file;&lt;br /&gt; if( !file.Open( szFile, CFile::modeWrite|CFile::modeCreate) )&lt;br /&gt;  return FALSE;&lt;br /&gt;&lt;br /&gt; lpbi = (LPBITMAPINFOHEADER)hDIB;&lt;br /&gt;&lt;br /&gt; int nColors = 1 &lt;&lt; lpbi-&gt;biBitCount;&lt;br /&gt;&lt;br /&gt; // Fill in the fields of the file header &lt;br /&gt; hdr.bfType  = ((WORD) ('M' &lt;&lt; 8) | 'B'); // is always "BM"&lt;br /&gt; hdr.bfSize  = GlobalSize (hDIB) + sizeof( hdr );&lt;br /&gt; hdr.bfReserved1  = 0;&lt;br /&gt; hdr.bfReserved2  = 0;&lt;br /&gt; hdr.bfOffBits  = (DWORD) (sizeof( hdr ) + lpbi-&gt;biSize +&lt;br /&gt;      nColors * sizeof(RGBQUAD));&lt;br /&gt;&lt;br /&gt; // Write the file header &lt;br /&gt; file.Write( &amp;hdr, sizeof(hdr) );&lt;br /&gt;&lt;br /&gt; // Write the DIB header and the bits &lt;br /&gt; file.Write( lpbi, GlobalSize(hDIB) );&lt;br /&gt;&lt;br /&gt; return TRUE;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-1027088572718441261?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/1027088572718441261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/writing-bitmap-to-bmp-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1027088572718441261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1027088572718441261'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/writing-bitmap-to-bmp-file.html' title='&lt;U&gt;Writing a bitmap to a BMP file&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-2260141970010280611</id><published>2009-05-03T14:46:00.016+03:00</published><updated>2009-06-11T00:11:33.640+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='USB'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><title type='text'>USB handling in MFC - discovering , Ejecting</title><content type='html'>&lt;strong&gt;inserted a usb and need to knowe which drive it occupies? want to eject a USB?&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Use this:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;the "*****" stand for the class you are using&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=http://groups.google.com/group/codesos/web/USBFixedDiskSafeRemoval.rar&gt;Force USB Removal Project&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;U&gt;Header file&lt;/U&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;static const GUID GUID_DEVCLASS_COMPUTER = &lt;br /&gt;{ 0x4D36E966, 0xE325, 0x11CE, { 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18} };&lt;br /&gt;&lt;br /&gt;// Copy from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses&lt;br /&gt;static const GUID GUID_DEVINTERFACE_LIST[] = &lt;br /&gt;{&lt;br /&gt; // GUID_DEVINTERFACE_USB_DEVICE&lt;br /&gt; { 0xA5DCBF10, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } },&lt;br /&gt;&lt;br /&gt;  // GUID_DEVINTERFACE_DISK&lt;br /&gt; { 0x53f56307, 0xb6bf, 0x11d0, { 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b } },&lt;br /&gt;&lt;br /&gt; // GUID_DEVINTERFACE_HID, &lt;br /&gt; { 0x4D1E55B2, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } },&lt;br /&gt;&lt;br /&gt; // GUID_NDIS_LAN_CLASS&lt;br /&gt; { 0xad498944, 0x762f, 0x11d0, { 0x8d, 0xcb, 0x00, 0xc0, 0x4f, 0xc3, 0x35, 0x8c } }&lt;br /&gt;&lt;br /&gt; };&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;private members:&lt;br /&gt;SP_CLASSIMAGELIST_DATA m_imgList;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;U&gt;Link: Setupapi.lib&lt;/U&gt;&lt;br /&gt;&lt;br /&gt;&lt;U&gt;Source:&lt;/U&gt;&lt;br /&gt;&lt;br /&gt;#include "winioctl.h"&lt;br /&gt;#define MAX_DRIVES 26&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;BEGIN_MESSAGE_MAP(*****, CDialog)&lt;br /&gt;//{{AFX_MSG_MAP(CRSDCDlg)&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;ON_MESSAGE(WM_DEVICECHANGE, OnMyDeviceChange)&lt;br /&gt;ON_MESSAGE(WM_STATUS_MESAGE, OnStatusMessage)&lt;br /&gt;//}}AFX_MSG_MAP&lt;br /&gt;END_MESSAGE_MAP()&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;*****::OnInitDialog()&lt;br /&gt;{&lt;br /&gt;     .&lt;br /&gt;     .&lt;br /&gt;&lt;br /&gt; ZeroMemory(&amp;m_imgList, sizeof(SP_CLASSIMAGELIST_DATA));&lt;br /&gt; m_imgList.cbSize = sizeof(SP_CLASSIMAGELIST_DATA);&lt;br /&gt; BOOL b = SetupDiGetClassImageList(&amp;m_imgList);&lt;br /&gt; ASSERT(b);&lt;br /&gt; int nRootImg;&lt;br /&gt; b = SetupDiGetClassImageIndex(&amp;m_imgList, &amp;GUID_DEVCLASS_COMPUTER, &amp;nRootImg);&lt;br /&gt; ASSERT(b);&lt;br /&gt;&lt;br /&gt; HDEVNOTIFY hDevNotify;&lt;br /&gt; DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;&lt;br /&gt; ZeroMemory( &amp;NotificationFilter, sizeof(NotificationFilter) );&lt;br /&gt; NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);&lt;br /&gt; NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;&lt;br /&gt; for(int i=0; i&lt;sizeof(GUID_DEVINTERFACE_LIST)/sizeof(GUID); i++) &lt;br /&gt; {&lt;br /&gt;  NotificationFilter.dbcc_classguid = GUID_DEVINTERFACE_LIST[i];&lt;br /&gt;  hDevNotify = RegisterDeviceNotification(this-&gt;GetSafeHwnd(), &amp;NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);&lt;br /&gt;  if( !hDevNotify ) {&lt;br /&gt;   AfxMessageBox(CString("Can't register device notification: ") &lt;br /&gt;    + _com_error(GetLastError()).ErrorMessage(), MB_ICONEXCLAMATION);&lt;br /&gt;   return FALSE;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;      .&lt;br /&gt;      .&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;//handle windows message regurding USB insertion&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;LRESULT *****::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)&lt;br /&gt;{&lt;br /&gt; if ( DBT_DEVICEARRIVAL == wParam || DBT_DEVICEREMOVECOMPLETE == wParam ) &lt;br /&gt; {&lt;br /&gt;  PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam;&lt;br /&gt;  PDEV_BROADCAST_DEVICEINTERFACE pDevInf;&lt;br /&gt;  PDEV_BROADCAST_HANDLE pDevHnd;&lt;br /&gt;  PDEV_BROADCAST_OEM pDevOem;&lt;br /&gt;  PDEV_BROADCAST_PORT pDevPort;&lt;br /&gt;  PDEV_BROADCAST_VOLUME pDevVolume;&lt;br /&gt;  switch( pHdr-&gt;dbch_devicetype ) &lt;br /&gt;  {&lt;br /&gt;   case DBT_DEVTYP_DEVICEINTERFACE:&lt;br /&gt;    pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr;&lt;br /&gt;    UpdateDevice(pDevInf, wParam);&lt;br /&gt;    break;&lt;br /&gt;&lt;br /&gt;   case DBT_DEVTYP_HANDLE:&lt;br /&gt;    pDevHnd = (PDEV_BROADCAST_HANDLE)pHdr;&lt;br /&gt;    break;&lt;br /&gt;&lt;br /&gt;   case DBT_DEVTYP_OEM:&lt;br /&gt;    pDevOem = (PDEV_BROADCAST_OEM)pHdr;&lt;br /&gt;    break;&lt;br /&gt;&lt;br /&gt;   case DBT_DEVTYP_PORT:&lt;br /&gt;    pDevPort = (PDEV_BROADCAST_PORT)pHdr;&lt;br /&gt;    break;&lt;br /&gt;&lt;br /&gt;   case DBT_DEVTYP_VOLUME:&lt;br /&gt;    pDevVolume = (PDEV_BROADCAST_VOLUME)pHdr;&lt;br /&gt;    HandleDrive(pDevVolume-&gt;dbcv_unitmask);&lt;br /&gt;    break;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// &lt;br /&gt;&lt;br /&gt;void *****::UpdateDevice(PDEV_BROADCAST_DEVICEINTERFACE pDevInf, WPARAM wParam)&lt;br /&gt;{&lt;br /&gt; // pDevInf-&gt;dbcc_name: &lt;br /&gt; // \\?\USB#Vid_04e8&amp;Pid_503b#0002F9A9828E0F06#{a5dcbf10-6530-11d2-901f-00c04fb951ed}&lt;br /&gt; // szDevId: USB\Vid_04e8&amp;Pid_503b\0002F9A9828E0F06&lt;br /&gt; // szClass: USB&lt;br /&gt;&lt;br /&gt; ASSERT(lstrlen(pDevInf-&gt;dbcc_name) &gt; 4);&lt;br /&gt; CString szDevId = pDevInf-&gt;dbcc_name+4;&lt;br /&gt; int idx = szDevId.ReverseFind(_T('#'));&lt;br /&gt; ASSERT( -1 != idx );&lt;br /&gt; szDevId.Truncate(idx);&lt;br /&gt; szDevId.Replace(_T('#'), _T('\\'));&lt;br /&gt; szDevId.MakeUpper();&lt;br /&gt;&lt;br /&gt; CString szClass;&lt;br /&gt; idx = szDevId.Find(_T('\\'));&lt;br /&gt; ASSERT(-1 != idx );&lt;br /&gt; szClass = szDevId.Left(idx);&lt;br /&gt; if ( DBT_DEVICEARRIVAL == wParam ) &lt;br /&gt; {&lt;br /&gt;  //szTmp.Format(_T("Adding %s\r\n"), szDevId.GetBuffer());&lt;br /&gt;  m_bAdding = true;&lt;br /&gt;   printf("Adding %s\n", szDevId.GetBuffer());&lt;br /&gt; } else &lt;br /&gt; {&lt;br /&gt;  //szTmp.Format(_T("Removing %s\r\n"), szDevId.GetBuffer());&lt;br /&gt;  m_bAdding =false;&lt;br /&gt;   printf("Removing %s\n", szDevId.GetBuffer());&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; // seems we should ignore "ROOT" type....&lt;br /&gt; if ( _T("ROOT") == szClass ) &lt;br /&gt; {&lt;br /&gt;  return;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; DWORD dwFlag = DBT_DEVICEARRIVAL != wParam ? &lt;br /&gt;DIGCF_ALLCLASSES : (DIGCF_ALLCLASSES | DIGCF_PRESENT);&lt;br /&gt; HDEVINFO hDevInfo = SetupDiGetClassDevs(NULL,szClass,NULL,dwFlag);&lt;br /&gt; if( INVALID_HANDLE_VALUE == hDevInfo ) &lt;br /&gt; {&lt;br /&gt;  AfxMessageBox(CString("SetupDiGetClassDevs(): ") &lt;br /&gt;   + _com_error(GetLastError()).ErrorMessage(), MB_ICONEXCLAMATION);&lt;br /&gt;  return;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; SP_DEVINFO_DATA spDevInfoData;&lt;br /&gt; if ( FindDevice(hDevInfo, szDevId, spDevInfoData) ) &lt;br /&gt; {&lt;br /&gt;  // OK, device found&lt;br /&gt;  DWORD DataT ;&lt;br /&gt;  TCHAR buf[MAX_PATH];&lt;br /&gt;  DWORD nSize = 0;&lt;br /&gt;&lt;br /&gt;  // get Friendly Name or Device Description&lt;br /&gt;  if ( SetupDiGetDeviceRegistryProperty(hDevInfo, &amp;spDevInfoData, &lt;br /&gt;   SPDRP_FRIENDLYNAME, &amp;DataT, (PBYTE)buf, sizeof(buf), &amp;nSize) ) &lt;br /&gt;  {&lt;br /&gt;   printf("%s\n",GetClassDesc(&amp;(spDevInfoData.ClassGuid)));&lt;br /&gt;   &lt;br /&gt;  } &lt;br /&gt;  else if ( SetupDiGetDeviceRegistryProperty(hDevInfo, &amp;spDevInfoData, &lt;br /&gt;    SPDRP_DEVICEDESC, &amp;DataT, (PBYTE)buf, sizeof(buf), &amp;nSize) ) &lt;br /&gt;   {&lt;br /&gt;    printf("%s\n",GetClassDesc(&amp;(spDevInfoData.ClassGuid)));&lt;br /&gt;   }&lt;br /&gt;  else &lt;br /&gt;   {&lt;br /&gt;     lstrcpy(buf, _T("Unknown"));&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   if(m_bAdding &amp;&amp; GetClassDesc(&amp;(spDevInfoData.ClassGuid)) == "Disk drives")&lt;br /&gt;   {&lt;br /&gt;     // drive was added handle this!!&lt;br /&gt;     &lt;br /&gt;   }&lt;br /&gt;   else if(!m_bAdding) //remove&lt;br /&gt;   {&lt;br /&gt;     removeDevice(szDevId);&lt;br /&gt;   }&lt;br /&gt;   &lt;br /&gt; }&lt;br /&gt; SetupDiDestroyDeviceInfoList(hDevInfo);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;BOOL *****::FindDevice(HDEVINFO&amp; hDevInfo, &lt;br /&gt;         CString&amp; szDevId, &lt;br /&gt;         SP_DEVINFO_DATA&amp; spDevInfoData)&lt;br /&gt;{&lt;br /&gt; spDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);&lt;br /&gt; for(int i=0; SetupDiEnumDeviceInfo(hDevInfo, i, &amp;spDevInfoData); i++) &lt;br /&gt; {&lt;br /&gt;  DWORD nSize=0 ;&lt;br /&gt;  TCHAR buf[MAX_PATH];&lt;br /&gt;&lt;br /&gt;  if ( !SetupDiGetDeviceInstanceId(hDevInfo, &amp;spDevInfoData, buf, sizeof(buf), &amp;nSize) ) &lt;br /&gt;  {&lt;br /&gt;   printf(CString("SetupDiGetDeviceInstanceId(): ") &lt;br /&gt;    + _com_error(GetLastError()).ErrorMessage());&lt;br /&gt;   return FALSE;&lt;br /&gt;  } &lt;br /&gt;  if ( szDevId == buf ) {&lt;br /&gt;   // OK, device found&lt;br /&gt;   return TRUE;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; return FALSE;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CString *****::GetClassDesc(const GUID* pGuid)&lt;br /&gt;{&lt;br /&gt; TCHAR buf[MAX_PATH];&lt;br /&gt; DWORD size;&lt;br /&gt; if ( SetupDiGetClassDescription(pGuid, buf, sizeof(buf), &amp;size) ) {&lt;br /&gt;  return CString(buf);&lt;br /&gt; } else {&lt;br /&gt;  printf("Can't get class description: %s", _com_error(GetLastError()).ErrorMessage());&lt;br /&gt;  return _T("");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//disable the popup made via windows&lt;br /&gt;&lt;br /&gt;void *****::UsbPopupDisable(CString sUSB)&lt;br /&gt;{&lt;br /&gt;  &lt;br /&gt;  HDEVINFO hDevInfo = SetupDiGetClassDevs(NULL,NULL,NULL,DIGCF_ALLCLASSES);&lt;br /&gt;  if( INVALID_HANDLE_VALUE == hDevInfo ) {&lt;br /&gt;   AfxMessageBox(CString("SetupDiGetClassDevs(): ") &lt;br /&gt;    + _com_error(GetLastError()).ErrorMessage(), MB_ICONEXCLAMATION);&lt;br /&gt;   return;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  SP_PROPCHANGE_PARAMS spPropChangeParams;&lt;br /&gt;  spPropChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);&lt;br /&gt;  spPropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;&lt;br /&gt;  spPropChangeParams.Scope = DICS_FLAG_GLOBAL;&lt;br /&gt;  spPropChangeParams.StateChange = DICS_DISABLE;&lt;br /&gt;  spPropChangeParams.HwProfile = 0;&lt;br /&gt;&lt;br /&gt;  SP_DEVINFO_DATA spDevInfoData;&lt;br /&gt;  if ( FindDevice(hDevInfo, sUSB, spDevInfoData) ) &lt;br /&gt;  {&lt;br /&gt;   if ( !SetupDiSetClassInstallParams(hDevInfo, &amp;spDevInfoData, &lt;br /&gt;    (SP_CLASSINSTALL_HEADER*)&amp;spPropChangeParams, sizeof(spPropChangeParams)) ) &lt;br /&gt;   {&lt;br /&gt;     AfxMessageBox(CString("SetupDiSetClassInstallParams(): ") &lt;br /&gt;      + _com_error(GetLastError()).ErrorMessage(), MB_ICONEXCLAMATION);&lt;br /&gt;    } else if ( !SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hDevInfo, &amp;spDevInfoData) ) &lt;br /&gt;   {&lt;br /&gt;     AfxMessageBox(CString("SetupDiClassInstaller(): ") &lt;br /&gt;      + _com_error(GetLastError()).ErrorMessage(), MB_ICONEXCLAMATION);&lt;br /&gt;    } else {&lt;br /&gt;     AfxMessageBox(_T("Dislabe OK"), MB_OK);&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  SetupDiDestroyDeviceInfoList(hDevInfo);&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//Description  &lt;br /&gt;//&lt;br /&gt;//Finds the first valid drive letter from a mask of drive letters.  &lt;br /&gt;//&lt;br /&gt;//The mask must be in the format bit 0 = A, bit 1 = B, bit 3 = C,  &lt;br /&gt;//&lt;br /&gt;//etc. A valid drive letter is defined when the corresponding bit  &lt;br /&gt;//&lt;br /&gt;//is set to 1.  &lt;br /&gt;//&lt;br /&gt;//Returns the first drive letter that was found.  &lt;br /&gt;&lt;br /&gt;char *****::FirstDriveFromMask (ULONG unitmask)  &lt;br /&gt;{  &lt;br /&gt; char i;  &lt;br /&gt; for (i = 0; i &lt; 26; ++i)  &lt;br /&gt; {  &lt;br /&gt;  if (unitmask &amp; 0x1)  &lt;br /&gt;   break;  &lt;br /&gt;  unitmask = unitmask &gt;&gt; 1;  &lt;br /&gt; }  &lt;br /&gt; return (i + 'A');  &lt;br /&gt;}  &lt;br /&gt;&lt;br /&gt;void *****::HandleDrive(ULONG unitmask)&lt;br /&gt;{&lt;br /&gt; CFile   systemNameFile;&lt;br /&gt; CFileException fileError;&lt;br /&gt; CString sDrive;&lt;br /&gt; CString strFilePath;&lt;br /&gt; int  nSystemNameSize;&lt;br /&gt; CString strSystemName;&lt;br /&gt;&lt;br /&gt; char cSystemName[ MAX_SYSTEM_NAME ];&lt;br /&gt; sDrive.Format("%c:",FirstDriveFromMask(unitmask));&lt;br /&gt; printf("HandleDrive -%s\n",sDrive);&lt;br /&gt;&lt;br /&gt; bool bExisted =false;&lt;br /&gt; if(IsDriveAlreadyExist(sDrive,bExisted))&lt;br /&gt; {&lt;br /&gt;  if(!bExisted)&lt;br /&gt;  {&lt;br /&gt;   printf("HandleDrive - %s already exist assuming removed\n",sDrive);&lt;br /&gt;   return; //probably device is detaching&lt;br /&gt;  }&lt;br /&gt;  else // drive was there before the application started&lt;br /&gt;  {&lt;br /&gt;   removeDevice(sDrive,true);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; RSDC_Status * currentAvailableSlot;&lt;br /&gt; currentAvailableSlot = GetFirstAvailableSlot(true);&lt;br /&gt; if(!currentAvailableSlot)&lt;br /&gt;  return;&lt;br /&gt; currentAvailableSlot-&gt;eStatus = USB_CONNECTED;&lt;br /&gt; currentAvailableSlot-&gt;strDriveName=sDrive;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt; strFilePath =sDrive + BK_SLASH + SYSTEM_NAME_FILE;&lt;br /&gt; if ( systemNameFile.Open( strFilePath , CFile::modeRead , &amp;fileError ) )&lt;br /&gt; {&lt;br /&gt;  printf("HandleDrive - Read file %s\n",strFilePath);&lt;br /&gt;  nSystemNameSize = systemNameFile.Read( cSystemName , MAX_SYSTEM_NAME );&lt;br /&gt;  cSystemName[ nSystemNameSize ] = '\0'; // puts NULL at the end of the name&lt;br /&gt;  strSystemName = A2T( cSystemName );&lt;br /&gt; &lt;br /&gt;  // If it's new then it is still idle:&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt;  printf("Found drive but no System file - Read file %s\n",strFilePath);&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Search for all of Hard drive devices in the system , and filter the USB's type &lt;br /&gt;&lt;br /&gt;void ******::SearchForAllDevices()&lt;br /&gt;{&lt;br /&gt; HANDLE hHardDrive = INVALID_HANDLE_VALUE;  &lt;br /&gt; for(int i = 0; i&lt; MAX_DRIVES; i++) &lt;br /&gt; {&lt;br /&gt;  CString sFormat;&lt;br /&gt;  sFormat.Format("\\\\.\\%c:",'a'+i);&lt;br /&gt;  if ((hHardDrive= CreateFile(sFormat,GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL)) == INVALID_HANDLE_VALUE)   &lt;br /&gt;  {    &lt;br /&gt;   CloseHandle(hHardDrive);&lt;br /&gt;   continue;&lt;br /&gt;  }     &lt;br /&gt;  else   &lt;br /&gt;  {    &lt;br /&gt;   DISK_GEOMETRY geo;   &lt;br /&gt;   STORAGE_HOTPLUG_INFO inf;&lt;br /&gt;   //GET_MEDIA_TYPES media_types;&lt;br /&gt;   DWORD dwSize = 0;    &lt;br /&gt;   ZeroMemory(&amp;geo,sizeof(geo));&lt;br /&gt;   BOOL bRes = DeviceIoControl( hHardDrive, IOCTL_STORAGE_GET_HOTPLUG_INFO , NULL, 0, &amp;inf, sizeof(STORAGE_HOTPLUG_INFO),&amp;dwSize, NULL);      // the type of hard disk    //geo.MediaType  &lt;br /&gt;   //bRes = DeviceIoControl(hHardDrive,IOCTL_STORAGE_GET_MEDIA_TYPES_EX,NULL,0,&amp;media_types, sizeof(GET_MEDIA_TYPES),&amp;dwSize, NULL);      // the type of hard disk    //geo.MediaType  &lt;br /&gt;   bRes = DeviceIoControl( hHardDrive, IOCTL_DISK_GET_DRIVE_GEOMETRY , NULL, 0, &amp;geo, sizeof(DISK_GEOMETRY),&amp;dwSize, NULL);      // the type of hard disk    //geo.MediaType  &lt;br /&gt;   CloseHandle(hHardDrive);&lt;br /&gt;   if(bRes &amp;&amp; (geo.MediaType == RemovableMedia ||  geo.MediaType == FixedMedia) &amp;&amp; inf.DeviceHotplug )&lt;br /&gt;&lt;br /&gt;   {&lt;br /&gt;    printf("USB found on :%c:\n",'a'+i);&lt;br /&gt;    &lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;     printf("Found drive but no System file - Read file %s\n",strFilePath);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;HANDLE ******::OpenVolume(TCHAR cDriveLetter,BOOL &amp;bIsFixedMedia)&lt;br /&gt;{&lt;br /&gt; HANDLE hVolume;&lt;br /&gt; UINT uDriveType;&lt;br /&gt; TCHAR szVolumeName[8];&lt;br /&gt; TCHAR szRootName[5];&lt;br /&gt; DWORD dwAccessFlags;&lt;br /&gt; LPTSTR szVolumeFormat = TEXT("\\\\.\\%c:");&lt;br /&gt; LPTSTR szRootFormat = TEXT("%c:\\");&lt;br /&gt;&lt;br /&gt; wsprintf(szRootName, szRootFormat, cDriveLetter);&lt;br /&gt;&lt;br /&gt; uDriveType = GetDriveType(szRootName);&lt;br /&gt; bIsFixedMedia = DRIVE_FIXED == uDriveType;&lt;br /&gt; switch(uDriveType) {&lt;br /&gt;    case DRIVE_REMOVABLE:&lt;br /&gt;    case DRIVE_FIXED:&lt;br /&gt;     dwAccessFlags = GENERIC_READ | GENERIC_WRITE;&lt;br /&gt;     break;&lt;br /&gt;    case DRIVE_CDROM:&lt;br /&gt;     dwAccessFlags = GENERIC_READ;&lt;br /&gt;     break;&lt;br /&gt;    default:&lt;br /&gt;     _tprintf(TEXT("Cannot eject.  Drive type is incorrect.\n"));&lt;br /&gt;     return INVALID_HANDLE_VALUE;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; wsprintf(szVolumeName, szVolumeFormat, cDriveLetter);&lt;br /&gt;&lt;br /&gt; hVolume = CreateFile(   szVolumeName,&lt;br /&gt;  dwAccessFlags,&lt;br /&gt;  FILE_SHARE_READ | FILE_SHARE_WRITE,&lt;br /&gt;  NULL,&lt;br /&gt;  OPEN_EXISTING,&lt;br /&gt;  0,&lt;br /&gt;  NULL );&lt;br /&gt; if (hVolume == INVALID_HANDLE_VALUE)&lt;br /&gt; {&lt;br /&gt;  printf("Error Opening %s\n",szVolumeFormat);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return hVolume;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;BOOL *******::CloseVolume(HANDLE hVolume)&lt;br /&gt;{&lt;br /&gt; return CloseHandle(hVolume);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#define LOCK_TIMEOUT        10000       // 10 Seconds&lt;br /&gt;#define LOCK_RETRIES        20&lt;br /&gt;&lt;br /&gt;BOOL *******::LockVolume(HANDLE hVolume)&lt;br /&gt;{&lt;br /&gt; DWORD dwBytesReturned;&lt;br /&gt; DWORD dwSleepAmount;&lt;br /&gt; int nTryCount;&lt;br /&gt;&lt;br /&gt; dwSleepAmount = LOCK_TIMEOUT / LOCK_RETRIES;&lt;br /&gt;&lt;br /&gt; // Do this in a loop until a timeout period has expired&lt;br /&gt; for (nTryCount = 0; nTryCount &lt; LOCK_RETRIES; nTryCount++) {&lt;br /&gt;  if (DeviceIoControl(hVolume,&lt;br /&gt;   FSCTL_LOCK_VOLUME,&lt;br /&gt;   NULL, 0,&lt;br /&gt;   NULL, 0,&lt;br /&gt;   &amp;dwBytesReturned,&lt;br /&gt;   NULL))&lt;br /&gt;   return TRUE;&lt;br /&gt;&lt;br /&gt;  Sleep(dwSleepAmount);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return FALSE;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;BOOL *******::DismountVolume(HANDLE hVolume)&lt;br /&gt;{&lt;br /&gt; DWORD dwBytesReturned;&lt;br /&gt;&lt;br /&gt; return DeviceIoControl( hVolume,&lt;br /&gt;  FSCTL_DISMOUNT_VOLUME,&lt;br /&gt;  NULL, 0,&lt;br /&gt;  NULL, 0,&lt;br /&gt;  &amp;dwBytesReturned,&lt;br /&gt;  NULL);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;BOOL ********::PreventRemovalOfVolume(HANDLE hVolume, BOOL fPreventRemoval)&lt;br /&gt;{&lt;br /&gt; DWORD dwBytesReturned;&lt;br /&gt; PREVENT_MEDIA_REMOVAL PMRBuffer;&lt;br /&gt;&lt;br /&gt; PMRBuffer.PreventMediaRemoval = fPreventRemoval;&lt;br /&gt;&lt;br /&gt; return DeviceIoControl( hVolume,&lt;br /&gt;  IOCTL_STORAGE_MEDIA_REMOVAL,&lt;br /&gt;  &amp;PMRBuffer, sizeof(PREVENT_MEDIA_REMOVAL),&lt;br /&gt;  NULL, 0,&lt;br /&gt;  &amp;dwBytesReturned,&lt;br /&gt;  NULL);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;BOOL *******::AutoEjectVolume(HANDLE hVolume)&lt;br /&gt;{&lt;br /&gt; DWORD dwBytesReturned;&lt;br /&gt;&lt;br /&gt; return DeviceIoControl( hVolume,&lt;br /&gt;  IOCTL_STORAGE_EJECT_MEDIA,&lt;br /&gt;  NULL, 0,&lt;br /&gt;  NULL, 0,&lt;br /&gt;  &amp;dwBytesReturned,&lt;br /&gt;  NULL);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//************************************&lt;br /&gt;// Description : Eject the USB device&lt;br /&gt;//************************************&lt;br /&gt;BOOL ******::EjectVolume(TCHAR cDriveLetter)&lt;br /&gt;{&lt;br /&gt; HANDLE hVolume;&lt;br /&gt;&lt;br /&gt; BOOL fRemoveSafely = FALSE;&lt;br /&gt; BOOL fAutoEject = FALSE;&lt;br /&gt; BOOL bIsFixedMedia = FALSE;&lt;br /&gt; // Open the volume.&lt;br /&gt; hVolume = OpenVolume(cDriveLetter,bIsFixedMedia);&lt;br /&gt;&lt;br /&gt; if(bIsFixedMedia = TRUE)&lt;br /&gt; {&lt;br /&gt;  if (hVolume == INVALID_HANDLE_VALUE)&lt;br /&gt;   return FALSE;&lt;br /&gt;  if (!CloseVolume(hVolume))&lt;br /&gt;   return FALSE;&lt;br /&gt;&lt;br /&gt;  //Eject the fixed drive&lt;br /&gt;  HINSTANCE hDll;&lt;br /&gt;  hDll = LoadLibrary("USBFixedDiskSafeRemoval");&lt;br /&gt;  if(hDll == NULL)&lt;br /&gt;  {&lt;br /&gt;   return FALSE;&lt;br /&gt;  }&lt;br /&gt;  eject = (EJECT)GetProcAddress(hDll,"fnUSBFixedDiskSafeRemoval");&lt;br /&gt;  int result;&lt;br /&gt;  if(eject != NULL)&lt;br /&gt;   result = (eject)(cDriveLetter);&lt;br /&gt;  else&lt;br /&gt;  {&lt;br /&gt;   FreeLibrary(hDll);&lt;br /&gt;   return FALSE;&lt;br /&gt;  }&lt;br /&gt;   FreeLibrary(hDll);&lt;br /&gt;   return TRUE;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; if (hVolume == INVALID_HANDLE_VALUE)&lt;br /&gt;  return FALSE;&lt;br /&gt;&lt;br /&gt; // Lock and dismount the volume.&lt;br /&gt; if (LockVolume(hVolume) &amp;&amp; DismountVolume(hVolume)) {&lt;br /&gt;  fRemoveSafely = TRUE;&lt;br /&gt;&lt;br /&gt;  // Set prevent removal to false and eject the volume.&lt;br /&gt;  if (PreventRemovalOfVolume(hVolume, FALSE) &amp;&amp;&lt;br /&gt;   AutoEjectVolume(hVolume))&lt;br /&gt;   fAutoEject = TRUE;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; // Close the volume so other processes can use the drive.&lt;br /&gt; if (!CloseVolume(hVolume))&lt;br /&gt;  return FALSE;&lt;br /&gt;&lt;br /&gt; if (fAutoEject)&lt;br /&gt;  printf("Media in Drive %c has been ejected safely.\n",&lt;br /&gt;  cDriveLetter);&lt;br /&gt; else {&lt;br /&gt;  if (fRemoveSafely)&lt;br /&gt;   printf("Media in Drive %c can be safely removed.\n",&lt;br /&gt;   cDriveLetter);&lt;br /&gt; }&lt;br /&gt; return TRUE;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-2260141970010280611?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/2260141970010280611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/how-to-match-between-physical-usb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/2260141970010280611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/2260141970010280611'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/how-to-match-between-physical-usb.html' title='&lt;U&gt;USB handling in MFC - discovering , Ejecting&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-1717963659334403591</id><published>2009-05-03T14:17:00.003+03:00</published><updated>2009-06-03T09:23:54.824+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Ensuring that only a single instance of a .NET application is running</title><content type='html'>&lt;strong&gt;If you want to activate only one instance(.exe) of your application use this code in C#&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;&lt;br /&gt;public static Process PriorProcess()&lt;br /&gt;// Returns a System.Diagnostics.Process pointing to&lt;br /&gt;// a pre-existing process with the same name as the&lt;br /&gt;// current one, if any; or null if the current process&lt;br /&gt;// is unique.&lt;br /&gt;{&lt;br /&gt;Process curr = Process.GetCurrentProcess();&lt;br /&gt;Process[] procs = Process.GetProcessesByName(curr.ProcessName);&lt;br /&gt;foreach (Process p in procs)&lt;br /&gt;{&lt;br /&gt;if ((p.Id != curr.Id) &amp;amp;&amp;amp;&lt;br /&gt;(p.MainModule.FileName == curr.MainModule.FileName))&lt;br /&gt;return p;&lt;br /&gt;}&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;[STAThread]&lt;br /&gt;static void Main() // args are OK here, of course&lt;br /&gt;{&lt;br /&gt;if (PriorProcess() != null)&lt;br /&gt;{&lt;br /&gt;MessageBox("Another instance is already running.");&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;Application.Run(new Form1()); // or whatever was here&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-1717963659334403591?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/1717963659334403591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/ensuring-that-only-single-instance-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1717963659334403591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/1717963659334403591'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/ensuring-that-only-single-instance-of.html' title='&lt;U&gt;Ensuring that only a single instance of a .NET application is running&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-123239008466022371.post-3448371546354340389</id><published>2009-05-03T14:04:00.003+03:00</published><updated>2009-06-03T09:23:19.014+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QSTRING'/><category scheme='http://www.blogger.com/atom/ns#' term='QT'/><title type='text'>find out the size in pixels (width, height) of a QString</title><content type='html'>&lt;strong&gt;Very useful when trying to determine the width or height of a string in case of control position.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;QFontMetrics fm( someFont);&lt;br /&gt;int w = fm.width( "String");&lt;br /&gt;int h = fm.height();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/123239008466022371-3448371546354340389?l=codesos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codesos.blogspot.com/feeds/3448371546354340389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codesos.blogspot.com/2009/05/find-out-size-in-pixels-width-height-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3448371546354340389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/123239008466022371/posts/default/3448371546354340389'/><link rel='alternate' type='text/html' href='http://codesos.blogspot.com/2009/05/find-out-size-in-pixels-width-height-of.html' title='&lt;U&gt;find out the size in pixels (width, height) of a QString&lt;/U&gt;'/><author><name>codesos</name><uri>http://www.blogger.com/profile/12186005909566638723</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_4c_Zso1HOAE/Sf3au8-HCzI/AAAAAAAAADI/3860HtRwqdU/S220/omer111.JPG'/></author><thr:total>0</thr:total></entry></feed>
