<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="style.xsl" ?>

<rss version="2.0">
<channel>
   <title>Armchair Programmer</title>
   <link>http://www.geocities.com/grieg_winter/armchair/index.html</link>
   <description>Thoughts, opinions related to computer and computer programming. And of learning the aforementioned.</description>
   <language>en</language>
   <lastBuildDate>Sun, 16 Apr 2006 15:46:02 GMT</lastBuildDate>

   <item>
      <title>Transition to Windows programming (2)</title>
      <link>http://www.geocities.com/grieg_winter/armchair/index.xml#200604161545</link>
      <description>
      The purpose of the previous post is to introduce DLL. Windows itself consists of a lot of functions contained within many DLLs. A Windows program make use of these functions. So, in a way, you can think of Windows as an extension of your program, or as a collection of libraries that your program can use.&#60;br /&#62;
      &#60;p style="border-style: solid; border-width: 1px; background-color: rgb(255,255,204); padding: 1%;"&#62;&#60;code&#62;
      #include &#38;#60;window.h&#38;#62;&#60;br /&#62;
      &#60;br /&#62;
      int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)&#60;br /&#62;
      {&#60;br /&#62;
      &#160;&#160;&#160;MessageBox(NULL, TEXT("Hello World!"), TEXT("Hello"), MB_OK);&#60;br /&#62;
      &#160;&#160;&#160;return 0;&#60;br /&#62;
	  }
      &#60;/code&#62;&#60;/p&#62;
      A beginner's programming book usually presents the "Hello World" program as the first program. The Windows' equivalent is shown above. It is actually not any longer nor more complex than the console version. Also, it should be noted that the entry point for the program is conventionally called &#60;i&#62;WinMain&#60;/i&#62; rather than &#60;i&#62;main&#60;/i&#62;. However, the "Hello World" program doesn't show the mechanism behind a normal Windows program, and that is what we are interested in. I'll address this in the next post.
      </description>
      <guid isPermaLink="false">200604161545</guid>
      <pubDate>Sun, 16 Apr 2006 15:45:00 GMT</pubDate>
   </item>
   <item>
      <title>Transition to Windows programming (1)</title>
      <link>http://www.geocities.com/grieg_winter/armchair/index.xml#200604062114</link>
      <description>
      So, you've learn the basics of C or C++ programming. Up to now, as a beginner, you probably wrote only console programs. These programs run in command prompt, with the &#60;i&#62;main()&#60;/i&#62; function as the starting point and execute line after line until the end is reached. Maybe you're wondering how something that produce only such primitive-looking programs, can ever hope to result in a complex-looking Windows applications. I was asking the same question when I was learning. Let me try to tackle this question, a little at a time.&#60;br /&#62;&#60;br /&#62;
      &#60;i&#62;Code reuse&#60;/i&#62;&#60;br /&#62;
      As a programmer, you'll be looking out for codes that are needed again and again. Let's say that within a program, a piece of code needs to be executed 10 times repeatedly. You can have the same code written 10 times in a row. But a better choice would be to have just one instance of the code, and then use loop to control the repetition.&#60;br /&#62;&#60;br /&#62;      
      Frequently used codes can also be organized with functions. For example, you can write a function that, given a filename, will read a line of text from the file. The next time another program needs to do the same thing, you can reuse the function that you've already written.&#60;br /&#62;&#60;br /&#62;      
      It is also possible to reuse a function without actually adding its source code to your program. All you need to do is tell the compiler what the function is called, its arguments and its return value. This is what you do when you add &#60;i&#62;stdio.h&#60;/i&#62; header file and use &#60;i&#62;printf&#60;/i&#62; function, for example.&#60;br /&#62;&#60;br /&#62;      
      &#60;i&#62;Linking&#60;/i&#62;&#60;br /&#62;
      Compiling is only the first step to produce a runnable program. Compiling your program source code will produce an object file, which is then feed to the linker to produce the executable. Some compilers will automatically run the linker if there are no compilation errors. Taking the previous &#60;i&#62;printf&#60;/i&#62; example, the function is actually precompiled, and the linking step will add it to your program object file, resulting in the executable.&#60;br /&#62;&#60;br /&#62;      
      &#60;i&#62;Libraries&#60;/i&#62;&#60;br /&#62;
      You can use functions that others have written when you have the precompiled code and the header file that describes the functions. In fact, there are companies that sell custom functions. These precompiled functions can be organized into files called libraries.&#60;br /&#62;&#60;br /&#62;      
      &#60;i&#62;Dynamic-Linked Libraries&#60;/i&#62;&#60;br /&#62;
      In the linking step, I mentioned that the precompiled function is added to your program object file. This is all fine, except when you have a lot of programs that uses the same function, every program have a copy of the precompiled function embedded. This increases the file size of the programs unnecessarily; if only all the programs can share a single copy of the function, which will now be externalized.&#60;br /&#62;&#60;br /&#62;      
      And indeed it can done. Instead of statically linking the precompiled function into the program, only a stub is linked. At runtime, an underlying system, for example the Windows OS, will handle loading and executing the the needed function.
      </description>
      <guid isPermaLink="false">200604062114</guid>
      <pubDate>Thu, 06 Apr 2006 21:14:00 GMT</pubDate>
   </item>
   <item>
      <title>First step into programming (2)</title>
      <link>http://www.geocities.com/grieg_winter/armchair/index.xml#200601130149</link>
      <description>
      As I've said in the previous post, you'll eventually need to learn C or C++. C++ can be thought of as "C plus Object-Oriented Programming (OOP)". OOP is a technique to write programs, and C++ has features to support this technique. But It is not necessary to use OOP technique when programming for Windows system. Having said that, I found that C++ code looks cleaner when programming a &#60;i&#62;COM object&#60;/i&#62;.&#60;br /&#62;
      If you're uncertain, learn C first. You can always check out C++ later. What deserves more attention at the moment is the topic on &#60;i&#62;pointer&#60;/i&#62;. In fact, if you want to do any serious programming at all, you must learn to use pointer.
      </description>
      <guid isPermaLink="false">200601130149</guid>
      <pubDate>Fri, 13 Jan 2006 01:49:00 GMT</pubDate>
   </item>
   <item>
      <title>First step into programming</title>
      <link>http://www.geocities.com/grieg_winter/armchair/index.xml#200601082333</link>
      <description>
      The very first thing to learn is, of course, programming concepts. For this, it doesn't matter which programming language you choose; it doesn't even have to be a real programming language. However, learning something that is directly relevant is a good idea. In this case, you'd need to learn C and/or C++.&#60;br /&#62;
      Coming back to programming concepts, these includes what a computer program is, how it is structured and all the different program flow controls that can be applied. For example, looping, branching, arithmetic and logical operations. There are many books available, as are resources on the Internet. Just make a search on the Internet and you'll find many of them.
      </description>
      <guid isPermaLink="false">200601082333</guid>
      <pubDate>Sun, 8 Jan 2006 23:33:00 GMT</pubDate>
   </item>
   <item>
      <title>Archived Posts</title>
      <link>http://www.geocities.com/grieg_winter/armchair/index.xml#200601072028</link>
      <description>
      Archived posts for 2005 can be found &#60;a href="archive2005.xml"&#62;here&#60;/a&#62;.&#60;br /&#62;
      For Pocket PC version go &#60;a href="archive2005.html"&#62;here&#60;/a&#62;.
      </description>
      <guid isPermaLink="false">200601072028</guid>
      <pubDate>Sat, 7 Jan 2006 20:28:00 GMT</pubDate>
   </item>
   <item>
      <title>New Year, New Post</title>
      <link>http://www.geocities.com/grieg_winter/armchair/index.xml#200601072015</link>
      <description>
      Well, it's a new year. A new post after a long hiatus. Hopefully I'll update this page more often.&#60;br /&#62;
      Oh, Happy New Year too.
      </description>
      <guid isPermaLink="false">200601072015</guid>
      <pubDate>Sat, 7 Jan 2006 20:15:00 GMT</pubDate>
   </item>

</channel>
</rss>
