<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rocker &#187; Programming</title>
	<atom:link href="http://www.shishirsharma.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shishirsharma.com</link>
	<description>Everything bloggable around Shishir Sharma.</description>
	<lastBuildDate>Fri, 06 Jan 2012 09:47:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Grab the net with Arduino</title>
		<link>http://www.shishirsharma.com/2011/12/29/grab-the-net-with-arduino/</link>
		<comments>http://www.shishirsharma.com/2011/12/29/grab-the-net-with-arduino/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 12:53:24 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Arduino Ethernet Shield]]></category>
		<category><![CDATA[Arduino Html Client]]></category>

		<guid isPermaLink="false">http://www.shishirsharma.com/?p=1114</guid>
		<description><![CDATA[How to access a website with multiple virtual hots from Arduino Ethernet Shield. The problem is if you have used Arduino Ethernet Shield, then you know that you can connect a IP, But if the IP has multiple virtual hosts, &#8230; <a href="http://www.shishirsharma.com/2011/12/29/grab-the-net-with-arduino/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How to access a website with multiple virtual hots from Arduino Ethernet Shield. The problem is if you have used Arduino Ethernet Shield, then you know that you can connect a IP, But if the IP has multiple virtual hosts, it will only connect to default virtual host. If it is commercial shared VPS, You wont be able to make your site default.</p>
<p>Gist is use of HTTP protocol which allows you to define host in your request on virtual host server. Here are the possible headers.</p>
<p><a href="http://en.wikipedia.org/wiki/List_of_HTTP_headers">http://en.wikipedia.org/wiki/List_of_HTTP_headers</a></p>
<p>You should also provide basic debugging info like &#8220;User-Agent&#8221; etc.</p>
<pre>#include &lt;SPI.h&gt;
#include &lt;Ethernet.h&gt;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[]            = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[]             = { 192, 168,   6,  30 };

byte server[]         = { ***, ***, 168,  16 }; // Your VPS

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 80);

String response = "";

void setup() {
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  // Give the Ethernet shield a second to initialize
  delay(1000);
  Serial.println("Connecting...");
}

void loop() {
  if (!client.available() &amp;&amp; client.connect()) {
    Serial.println("-- Connected");
    // Make a HTTP request:
    client.println("GET /bot HTTP/1.0");
    client.println("Host: example.com");
    client.println("User-Agent: Arduino/Shishir (mail.mastermind [at] gmail.com)");
    client.println();
  }
  if (client.available()) {
    char c = client.read();
    response.concat(c);
  }
  if(!client.connected()){
    process(response);
    //Serial.print(response);
  }
  if (!client.connected() &amp;&amp; reset == 1) {
    Serial.println("disconnecting.");
    client.stop();
    response = "";
    delay(1000*10);
  }
}
void process(String response) {
  Serial.println(response);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2011/12/29/grab-the-net-with-arduino/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IRB Console with history and logging</title>
		<link>http://www.shishirsharma.com/2011/12/28/irb-console-with-history-and-logging/</link>
		<comments>http://www.shishirsharma.com/2011/12/28/irb-console-with-history-and-logging/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 06:58:52 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[IRB]]></category>
		<category><![CDATA[Rails Console]]></category>

		<guid isPermaLink="false">http://www.shishirsharma.com/?p=1098</guid>
		<description><![CDATA[I spend most time with IRB or Rails/console. These are good settings on which I have settled with over the time. These will allow you to have basic logging and IRB history. Just put these in the ~/.irbrc file (If &#8230; <a href="http://www.shishirsharma.com/2011/12/28/irb-console-with-history-and-logging/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I spend most time with IRB or Rails/console. These are good settings on which I have settled with over the time. These will allow you to have basic logging and IRB history. Just put these in the ~/.irbrc file (If file doesn&#8217;t exist then create one).</p>
<pre># -*- Ruby-*-
require 'irb/completion'
require 'irb/ext/save-history'

ARGV.concat [ "--readline",
              "--prompt-mode",
              "simple" ]

# 25 entries in the list
IRB.conf[:SAVE_HISTORY] = 100

# Store results in home directory with specified file name
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"

script_console_running = ENV.include?('RAILS_ENV') &amp;&amp; IRB.conf[:LOAD_MODULES] &amp;&amp; IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
rails_running = ENV.include?('RAILS_ENV') &amp;&amp; !(IRB.conf[:LOAD_MODULES] &amp;&amp; IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
irb_standalone_running = !script_console_running &amp;&amp; !rails_running

if script_console_running
  require 'logger'
  Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2011/12/28/irb-console-with-history-and-logging/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Power Programming with Tags</title>
		<link>http://www.shishirsharma.com/2011/08/24/power-programming-with-tags/</link>
		<comments>http://www.shishirsharma.com/2011/08/24/power-programming-with-tags/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 12:10:10 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[CTags]]></category>
		<category><![CDATA[Source navigation]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://shishirsharma.com/?p=1024</guid>
		<description><![CDATA[Source tagging is very powerful source code navigation system, it beats any state of the art IDE. If you are using Emacs, Vim and TextMate then you can use source tagging for navigation. Here are the few simple steps to &#8230; <a href="http://www.shishirsharma.com/2011/08/24/power-programming-with-tags/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Source tagging is very powerful source code navigation system, it beats any state of the art IDE. If you are using Emacs, Vim and TextMate then you can use source tagging for navigation. Here are the few simple steps to do it.</p>
<p>Step 1. Install ctags in your system. For mac</p>
<pre>$ sudo port install ctags</pre>
<p>Step 2. Create A tag file</p>
<pre>$ cd /Users/username/Workspace/rails-project
$ ctags -e -a --Ruby-kinds=+f -o TAGS -R app/ lib/ config/</pre>
<p>It is best to add this in crontab for this around 11:30am</p>
<p>Step 3.1 emacs</p>
<pre>M-. Follow a tag
M-* Jump back to source.</pre>
<p>Step 3.2 vim<br />
just add this in your ~/.vimrc</p>
<pre>set tags=TAGS;/</pre>
<p>Once this is done you can navigate to source of tag by using.</p>
<pre>C-] - go to definition
C-T - Jump back from the definition.
C-W C-] - Open the definition in a horizontal split</pre>
<p>Hope you will be able to use this awesome feature.<br />
<cite>C is ctrl<br />
M is Meta/Alt/Ecs</cite></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2011/08/24/power-programming-with-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prevent Googlebot following links in Gmail</title>
		<link>http://www.shishirsharma.com/2011/08/03/prevent-googlebot-following-links-in-gmail/</link>
		<comments>http://www.shishirsharma.com/2011/08/03/prevent-googlebot-following-links-in-gmail/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 21:27:58 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Crawler]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Googlebot]]></category>

		<guid isPermaLink="false">http://shishirsharma.com/?p=1000</guid>
		<description><![CDATA[How to prevent googlebot following links in gmail messages? Well bad news is &#8220;Googlebot is following links sent to subscribers of a mailing list by email and it is causing those subscribers to receive an unsubscribe meesage or a added &#8230; <a href="http://www.shishirsharma.com/2011/08/03/prevent-googlebot-following-links-in-gmail/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How to prevent googlebot following links in gmail messages? Well bad news is &#8220;Googlebot is following links sent to subscribers of a mailing list by email and it is causing those subscribers to receive an unsubscribe meesage or a added download from the list or server&#8221;.</p>
<p>Bigger Bad news is that age old trick will <strong>NOT </strong>work here, we can not solve this simply by adding</p>
<pre>&lt;a href="signin.php" rel="nofollow"&gt;sign in&lt;/a&gt;</pre>
<p>Best way in my opinion is to reject download count based on the user agent. Which is <em>Googlebot </em>in case of Google Crawler.</p>
<p>find long answer <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=96569">here</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2011/08/03/prevent-googlebot-following-links-in-gmail/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Keep doing!</title>
		<link>http://www.shishirsharma.com/2011/07/12/keep-doing/</link>
		<comments>http://www.shishirsharma.com/2011/07/12/keep-doing/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 06:10:13 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[HackDay]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[slideshare]]></category>

		<guid isPermaLink="false">http://shishirsharma.com/?p=911</guid>
		<description><![CDATA[This is a test for the quote post. If you keep on doing what you&#8217;ve always done, you&#8217;ll keep on getting what you&#8217;ve always got. -W. L. Bateman This is really a good step to start with, I am really &#8230; <a href="http://www.shishirsharma.com/2011/07/12/keep-doing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a test for the quote post.</p>
<blockquote><p>If you keep on doing what you&#8217;ve always done, you&#8217;ll keep on getting what you&#8217;ve always got.</p></blockquote>
<p>-W. L. Bateman</p>
<p>This is really a good step to start with, I am really loving this new twenty eleven theme.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2011/07/12/keep-doing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hands on Flex</title>
		<link>http://www.shishirsharma.com/2009/07/21/hands-on-flex/</link>
		<comments>http://www.shishirsharma.com/2009/07/21/hands-on-flex/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 11:33:36 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://shishirsharma.com/?p=417</guid>
		<description><![CDATA[I&#8217;ve been very busy for last 4-5 months. But I have been hacking around with many things; Emacs, Vim, Python, Bash, Flex, Silverlight etc&#8230; No I am not trying to impress anyone here. Of course I am not master of &#8230; <a href="http://www.shishirsharma.com/2009/07/21/hands-on-flex/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been very busy for last 4-5 months. But I have been hacking around with many things; Emacs, Vim, Python, Bash, Flex, Silverlight etc&#8230; No I am not trying to impress anyone here. Of course I am not master of these things. <img src='http://www.shishirsharma.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p><a href="http://en.wikipedia.org/wiki/Adobe_Flex">Adobe Flex</a> aka Fx is a great open source tool. I happen to understand the Ajax/PHP and Curl so I can compare Flex with these.</p>
<p>In my opinion Flex is great. You can create a application with minimum ActionScript coding. Basic layout of a flex application is in MXML and ActionScript is used for more control just like we use HTML and JavaScript.</p>
<p>I have been trying the Flex charting API. I will say that they are extensive and very easy to use. Flex platform is Open Source and licensed under Mozilla Public license. </p>
<p>I will keep readers updated in Flex as soon as I get to some thing new.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2009/07/21/hands-on-flex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Desktop Calculator</title>
		<link>http://www.shishirsharma.com/2008/08/13/desktop-calculator/</link>
		<comments>http://www.shishirsharma.com/2008/08/13/desktop-calculator/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 06:38:27 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Calculator]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[GNU General Public Licence]]></category>
		<category><![CDATA[Standard C++]]></category>

		<guid isPermaLink="false">http://shishirsharma.com/?p=118</guid>
		<description><![CDATA[I always appreciate coding in standard C++. Desktop Calculator is a application coded in Standard C++. It is a application based on the example 6.1 in the book &#8220;The C++ Programming Language&#8221;, Third Edition by Bjarne Stroustrup. Desktop Calculator is &#8230; <a href="http://www.shishirsharma.com/2008/08/13/desktop-calculator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I always appreciate coding in standard C++. Desktop Calculator is a application coded in Standard C++. It is a application based on the example 6.1 in the book &#8220;The C++ Programming Language&#8221;, Third Edition by <strong>Bjarne Stroustrup</strong>. Desktop Calculator is a GPL software.</p>
<p>To download full code click here.<br />
<span id="more-118"></span><br />
<code></p>
<pre class="brush: cpp">
/*
 *    This file is part of Desktop Calculator.
 *
 *    Desktop Calculator is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    Desktop Calculator is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 * Standard
 *    You should have received a copy of the GNU General Public License
 *    along with Desktop Calculator.  If not, see < http://www.gnu.org/licenses/ >.
 *
 *	   Shishir Sharma criss < mail AT DOMAIN shishirsharma DOT com >
 */
//////////////////////////////////////////////////////////
//                                                      //
//  File name   :   dc                                  //
//  Comments    :   desk calculator                     //
//  Versions    :   Saturday, September 23, 2006        //
//  Coded by    :   Shishir Sharma 'C R I I S'          //
//                  mail.mastermind@gmail.com           //
//                                                      //
//////////////////////////////////////////////////////////

#include <iostream>
#include <string>
#include < map>
#include <cctype>
#include <cmath>

using namespace std;

enum Token_value
{
  FUNCTION, NAME, NUMBER, END,
  PLUS = '+', MINUS = '-', MUL = '*', DIV = '/',
  PRINT = ';', ASSIGIN = '=', LP = '(', RP = ')',
  EXPO = '^', MLP = '[', MRP = ']', COMMA = ','
};

Token_value curr_tok = PRINT;

double number_value;
string string_value;
int no_of_errors;

map < string, double >table;

double error (const string &#038; s);
double message (const string &#038; s);
Token_value get_token ();
double prim (bool get);
double term (bool get);
double expr (bool get);

const char help[] = "DC: Desk Calculetor\n\npress ctrl+Z to quit\n";

int
main (int argc, char *argv[])
{
  // Standard variables
  table["pi"] = 3.1415926535897932385;
  table["e"] = 2.7182818284590452354;
  // Default help message
  message (help);

  // Main loop
  while (cin) {
    get_token ();
    if (curr_tok == END)
      break;
    if (curr_tok == PRINT)
      continue;
    cout < < expr (false) << '\n';
  }

  return no_of_errors;
}

double
message (const string &#038; s)
{
  cout << s << '\n';
  return 0;
}

double
error (const string &#038; s)
{
  no_of_errors++;
  cerr << "Error:" << s << '\n';
  return 1;
}

double
expr (bool get)
{
  double left = term (get);
  for (;;)
    switch (curr_tok) {
    case PLUS:
      {
	left += term (true);
	break;
      }
    case MINUS:
      {
	left -= term (true);
	break;
      }
    default:
      return left;
    }
}

double
term (bool get)
{
  double left = prim (get);
  for (;;)
    switch (curr_tok) {
    case MUL:
      {
	left *= term (true);
	break;
      }
    case DIV:
      {
	if (double d = prim (true)) {
	  left /= d;
	  break;
	}
	return error ("divide by 0");
      }
    case EXPO:
      {
	left = pow (left, prim (true));
	break;
      }
    default:
      return left;
    }
}

double
prim (bool get)
{
  if (get)
    get_token ();

  switch (curr_tok) {
  case MINUS:
    {
      return (-expr (true));
    }
  case NUMBER:
    {
      double v = number_value;
      get_token ();
      return v;
    }
  case NAME:
    {
      //help
      if (string_value == "help" || string_value == "Help"
	  || string_value == "HELP") {
	return message (help);
      }
      else if (string_value == "clear" || string_value == "Clear"
	       || string_value == "CLEAR") {
	cout.flush ();
	return message (help);
      }
      else
	//trignometry functions
      if (string_value == "sin") {
	if (get_token () == LP)
	  return sin (expr (true));
      }
      else if (string_value == "cos") {
	if (get_token () == LP)
	  return cos (expr (true));
      }
      else if (string_value == "tan") {
	if (get_token () == LP)
	  return tan (expr (true));
      }
      else if (string_value == "asin") {
	if (get_token () == LP)
	  return asin (expr (true));
      }
      else if (string_value == "acos") {
	if (get_token () == LP)
	  return acos (expr (true));
      }
      else if (string_value == "atan") {
	if (get_token () == LP)
	  return atan (expr (true));
      }
      // exponential functions
      else if (string_value == "exp") {
	if (get_token () == LP)
	  return exp (expr (true));
      }
      else if (string_value == "log") {
	if (get_token () == LP)
	  return log (expr (true));
      }
      else if (string_value == "log10") {
	if (get_token () == LP)
	  return log10 (expr (true));
      }
      else if (string_value == "sum") {
	get_token ();
	if (curr_tok == LP) {
	  double sum = 0;
	  sum += expr (true);
	  while (curr_tok != RP) {
	    if (curr_tok == COMMA)
	      sum += expr (true);
	  }
	  return sum;
	}
      }
      // new variables
      else {
	double &#038;v = table[string_value];
	if (get_token () == ASSIGIN)
	  v = expr (true);
	return v;
      }
    }
  case LP:
    {
      double e = expr (true);
      if (curr_tok != RP)
	return error ("')' expected");
      get_token ();
      return e;
    }
  default:
    return error ("primary expected");
  }
}

Token_value
get_token ()
{
  char ch;

  do {
    if (!cin.get (ch))
      return curr_tok = END;
  } while (ch != '\n' &#038;&#038; isspace (ch));

  switch (ch) {
  case '\n':
  case ';':
    return curr_tok = PRINT;
  case '^':
  case '*':
  case '/':
  case '+':
  case '-':
  case '(':
  case ')':
  case '[':
  case ']':
  case ',':
  case '=':
    return curr_tok = Token_value (ch);
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
  case '.':
    cin.putback (ch);
    cin >> number_value;
    return curr_tok = NUMBER;
  default:
    if (isalpha (ch)) {
      string_value = ch;
      while (cin.get (ch) &#038;&#038; isalnum (ch))
	string_value.push_back (ch);
      cin.putback (ch);
      return curr_tok = NAME;
    }
    error ("bad token");
    return curr_tok = PRINT;
  }
}

/* eof */
</cmath></cctype></string></iostream></pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2008/08/13/desktop-calculator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Windows GUI example code</title>
		<link>http://www.shishirsharma.com/2008/07/31/windows-gui-example-code/</link>
		<comments>http://www.shishirsharma.com/2008/07/31/windows-gui-example-code/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 03:06:19 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[GDI]]></category>
		<category><![CDATA[windows gui]]></category>
		<category><![CDATA[windows programming]]></category>

		<guid isPermaLink="false">http://shishirsharma.com/wp/?p=39</guid>
		<description><![CDATA[Windows GUI programming code with GDI. <a href="http://www.shishirsharma.com/2008/07/31/windows-gui-example-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Windows GUI example code. To download the Full code in one file click <a href="http://shishirsharma.com/files/winexample.cpp" target="_blank">here</a>.<br />
<span id="more-39"></span></p>
<pre lang="cpp" lineno=1>#include < windows.h >

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsExApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&#038;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&#038;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&#038;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&#038;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC hDC;
    PAINTSTRUCT Ps;

    switch (message)                  /* handle the messages */
    {
        case WM_PAINT:
            hDC = BeginPaint(hwnd, &#038;Ps);
            MoveToEx(hDC, 160, 120, NULL);
            LineTo(hDC, 364, 222);
            MoveToEx(hDC, 60, 20, NULL);
            LineTo(hDC, 60, 122);
            LineTo(hDC, 264, 122);
            LineTo(hDC, 60, 20);
            EndPaint(hwnd, &#038;Ps);
            break;
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2008/07/31/windows-gui-example-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows programing with Dev-C++</title>
		<link>http://www.shishirsharma.com/2008/07/29/windows-programing-with-dev-c/</link>
		<comments>http://www.shishirsharma.com/2008/07/29/windows-programing-with-dev-c/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 07:35:13 +0000</pubDate>
		<dc:creator>Shishir Sharma 'criss'</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Dev-C++]]></category>
		<category><![CDATA[gcc gnu]]></category>
		<category><![CDATA[gnu compiler collection]]></category>
		<category><![CDATA[open source development]]></category>
		<category><![CDATA[windows program]]></category>
		<category><![CDATA[wxDev-C++]]></category>

		<guid isPermaLink="false">http://shishirsharma.com/wp/?p=14</guid>
		<description><![CDATA[Dev-C++ is good IDE for programming in C++. Considering it supports MinGW and MSVC (Rarely used with MSVC). It has syntax highlighting, debugger, profiler,  to do lists and many more. It is best for small and medium size project development. <a href="http://www.shishirsharma.com/2008/07/29/windows-programing-with-dev-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Dev-C++ is good IDE for programming in C++. Considering it supports MinGW and MSVC (Rarely used with MSVC). It has syntax highlighting, debugger, profiler,  TO DO lists and many more. It is best for small and medium size project development.</p>
<h2>Basic requirements</h2>
<h3>Personal Computer</h3>
<p><a href="http://www.google.co.in/search?hl=en&amp;client=firefox-a&amp;rls=org.mozilla%3Aen-GB%3Aofficial&amp;hs=SjO&amp;q=Personal+Computer+Download&amp;btnG=Search&amp;meta=">Download </a>( ?? )<br />
23. Just don&#8217;t talk about it.<br />
<span id="more-14"></span></p>
<h3>Microsoft Windows</h3>
<p><a href="http://www.google.co.in/search?hl=en&amp;client=firefox-a&amp;rls=org.mozilla%3Aen-GB%3Aofficial&amp;hs=JjO&amp;q=Microsoft+Windows+Xp+Download&amp;btnG=Search&amp;meta=">Download </a>(Are you nuts !!)<br />
If you have option for Operating System. Windows XP must be the last one, so stop here and turn off this tutorial and switch to any operating systems designed for humans.</p>
<h3>MinGW</h3>
<p>Download <a href="http://sourceforge.net/project/showfiles.php?group_id=2435">Direct Link (SourceForge)</a><br />
MinGW is a open source development suit for Microsoft Windows.  It stands for MINimalist Gnu for Windows. It is Windows port of famous GCC ( Gnu Compiler Collection ) development suit. It supports many languages like C/C++/Objective C/Java/Fortran77/Ada.</p>
<h3>Dev-C++ (4.9.9.2) /wxDev-C++ (6.10.2)</h3>
<p><a href="http://sourceforge.net/project/showfiles.php?group_id=10639">Download </a>(4.9.9.2)<br />
<a href="http://sourceforge.net/project/showfiles.php?group_id=95606">Download </a>(6.10.2)<br />
It comes WITH MinGW or Without MinGW. You can always download latest MinGW or even compile its source from older compiler. You have to download both Dev-C++ 4.9.9.2 and wxDev-C++ 6.10.2 as wxDev is just an Executable file which runs on the old 4.9.9.2 base.</p>
<h2>Tutorial</h2>
<p>All optionals are recommended.</p>
<h4>Assuming we have a PC and it has a windows.</h4>
<p>To know how to install Dev-C++ <a href="http://">Click Here</a></p>
<h4>Extract Dev-C++ 6.10.2.</h4>
<p>Extract it to Dev-Cpp/bin and rename the devcpp.exe to olddevcpp.exe and rename devcpp</p>
<h4>Install MinGW (only if you have installed the Dev-C++ without MinGW).</h4>
<p>Click Here</p>
<h4>[optional] Install/set the path of MinGW/bin or Dev-Cpp/bin in user path variable.</h4>
<p><a href="http://support.microsoft.com/kb/310519">Click Here</a></p>
<h4>[optional] Create a C++ Development Command Prompt.</h4>
<p><em>coming soon</em></p>
<h4>Start Dev-C++</h4>
<p>Now click on File -&gt; New -&gt; Project.</p>
<p><a href="http://shishirsharma.com/wp/wp-content/uploads/2008/07/a.jpg" rel="lightbox[14]" title="windows programming a"><img class="aligncenter size-medium wp-image-22" title="windows programming a" src="http://shishirsharma.com/wp/wp-content/uploads/2008/07/a-300x207.jpg" alt="windows programming a" width="300" height="207" /></a></p>
<p>Select the langauge C++ most probable. Type the name of the project. Select the type as Windows Project.</p>
<p><a href="http://shishirsharma.com/wp/wp-content/uploads/2008/07/b.jpg" rel="lightbox[14]" title="windows programming b"><img class="aligncenter size-medium wp-image-23" title="windows programming b" src="http://shishirsharma.com/wp/wp-content/uploads/2008/07/b-300x207.jpg" alt="windows programming b" width="300" height="207" /></a></p>
<p>Enter the path to save the project.</p>
<p><a href="http://shishirsharma.com/wp/wp-content/uploads/2008/07/c.jpg" rel="lightbox[14]" title="windows programming c"><img class="aligncenter size-medium wp-image-24" title="windows programming c" src="http://shishirsharma.com/wp/wp-content/uploads/2008/07/c-300x215.jpg" alt="windows programming c" width="300" height="215" /></a></p>
<p>Now you will get a template of windows program. Save the unsaved main.cpp file. If you don&#8217;t know what to write in it. Click <a href="http://">here </a>to get a template program.</p>
<p><a href="http://shishirsharma.com/wp/wp-content/uploads/2008/07/d.jpg" rel="lightbox[14]" title="windows programming d"><img class="aligncenter size-medium wp-image-25" title="windows programming d" src="http://shishirsharma.com/wp/wp-content/uploads/2008/07/d-300x207.jpg" alt="windows programming d" width="300" height="207" /></a></p>
<p>Before compiling the project you must include the library path of gdi32 in project. for this Right click on project name in project inspector -&gt; Project Options.</p>
<p><a href="http://shishirsharma.com/wp/wp-content/uploads/2008/07/e.jpg" rel="lightbox[14]" title="windows programming e"><img class="aligncenter size-medium wp-image-26" title="windows programming e" src="http://shishirsharma.com/wp/wp-content/uploads/2008/07/e-300x207.jpg" alt="windows programming e" width="300" height="207" /></a></p>
<p>In the linker section type -lgdi32</p>
<p><a href="http://shishirsharma.com/wp/wp-content/uploads/2008/07/f.jpg" rel="lightbox[14]" title="windows programming f"><img class="aligncenter size-medium wp-image-27" title="windows programming f" src="http://shishirsharma.com/wp/wp-content/uploads/2008/07/f-300x207.jpg" alt="windows programming f" width="300" height="207" /></a></p>
<p>Now compile it or Build the project.</p>
<p><a href="http://shishirsharma.com/wp/wp-content/uploads/2008/07/g.jpg" rel="lightbox[14]" title="windows programming g"><img class="aligncenter size-medium wp-image-28" title="windows programming g" src="http://shishirsharma.com/wp/wp-content/uploads/2008/07/g-300x205.jpg" alt="windows programming g" width="300" height="205" /></a></p>
<p>We get a beautiful output.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shishirsharma.com/2008/07/29/windows-programing-with-dev-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

