<?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>yesJames.com &#187; Delphi</title>
	<atom:link href="http://www.yesjames.com/index.php/category/programming/delphi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yesjames.com</link>
	<description>ahuh... sure... what ever you say...</description>
	<lastBuildDate>Fri, 13 Nov 2009 02:59:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Delphi: Declaring and initialising constant arrays</title>
		<link>http://www.yesjames.com/index.php/2009/02/delphi-declaring-and-initialising-constant-arrays/</link>
		<comments>http://www.yesjames.com/index.php/2009/02/delphi-declaring-and-initialising-constant-arrays/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 03:54:58 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.yesjames.com/?p=141</guid>
		<description><![CDATA[In Delphi, arrays are, put simply, a list of values contained within a common variable, that are accessible by their index within that list.
But what if you don&#8217;t want your list of values to be able to be altered at run-time? You need them to be contained in a constant rather than a variable.
Example: to [...]]]></description>
			<content:encoded><![CDATA[<p><script src="http://www.yesjames.com/wp-content/themes/yesjames_blue/sh/shBrushDelphi.js" type="text/javascript"></script>In Delphi, arrays are, put simply, a list of values contained within a common variable, that are accessible by their index within that list.</p>
<p>But what if you don&#8217;t want your list of values to be able to be altered at run-time? You need them to be contained in a constant rather than a variable.</p>
<p><strong>Example:</strong> to declare an array of abbreviated week names:</p>
<pre name="code" class="delphi">
const
  Days: Array[0..6] of String = (
      'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
  );
</pre>
<p>You could then access each name by the index of the day of the week within the <strong>Days</strong> constant.</p>
<pre name="code" class="delphi">
i := DayOfWeek(Date); //returns an integer 0-6
ShowMessage('Today is  ' + Days[i]);
</pre>
<p>Another common use for constant arrays is to describe the values in an ENUM type:</p>
<pre name="code" class="delphi">
type
  TStatusCodes = [
    scUnknown, scActive, scPending,
    scDisabled, scSuspended
  ];
const
  StatusString = Array[TStatusCodes] of String = (
    'Unknown', 'Active', 'Pending',
    'Disabled', 'Suspended'
  );
</pre>
<p>Then, the description string for each status code becomes available via the ordinal value of the status code itself:</p>
<pre name="code" class="delphi">
ShowMessage('Your account is '+ StatusString[scActive]);
</pre>
<p>Would show a message box with the text &#8220;<em>Your account is Active</em>&#8220;. Of course in the real world, the status code enumeration value would come from a user object or some such similar method (like &#8220;<em>function getAccountStatus(): TStatusCode;</em>&#8221; perhaps).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yesjames.com/index.php/2009/02/delphi-declaring-and-initialising-constant-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Minimising child forms in an SDI application</title>
		<link>http://www.yesjames.com/index.php/2008/11/delphi-minimising-child-forms-in-an-sdi-application/</link>
		<comments>http://www.yesjames.com/index.php/2008/11/delphi-minimising-child-forms-in-an-sdi-application/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 22:37:10 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[SDI]]></category>
		<category><![CDATA[Win32]]></category>

		<guid isPermaLink="false">http://www.yesjames.com/?p=45</guid>
		<description><![CDATA[In an SDI application (Single Document Interface), the main form acs as the &#8220;container&#8221; for the entire application. This means that child forms, are exactly that &#8211; children of the application. The long and short of which, means that when you minimise the main form of the application, all forms are hidden. In addition to [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript" language="javascript" src="http://www.yesjames.com/wp-content/themes/yesjames_blue/sh/shBrushDelphi.js"></script>In an SDI application (Single Document Interface), the main form acs as the &#8220;container&#8221; for the entire application. This means that child forms, are exactly that &#8211; children of the application. The long and short of which, means that when you minimise the main form of the application, all forms are hidden. In addition to which, when you minimise a child form of the application, it doesn&#8217;t minimise to the task bar, instead it minimises to the application desktop. This also has the side effect that only the main application form itself has a task bar button.</p>
<p>So, How do I change this behaviour?</p>
<p><span id="more-45"></span></p>
<p>For one reason or another, you may decide that you want to let each child form in an application you create have it&#8217;s own Task Bar button, and as a result, complete control over it&#8217;s visibility when the application&#8217;s main form is minimized/restored. Ordinarily, the first form created in your application is the <i>Main Form</i>. It is the parent of all other forms that will be created in your application, and as such, when the main form closes, the application terminates. In addition, when the main form is minimised, all child forms are also minimized as the application is hidden. Only the main form in this case has a button on the task bar.</p>
<h3>So, you don&#8217;t really want your child forms to be hidden when you minimise the main form of the application&#8230;</h3>
<p>Well, you need to do two things. Both can be done inside the <b>CreateParams()</b> method of your form. SO you&#8217;ll need to override this procedure.<br/><br />
Firstly, you&#8217;ll need to change the style parameters of the form when it is created. More specifically, you need to override the  and manually set the <b>ExStyle</b> parameter. Secondly, you&#8217;ll need to change the parent of the form form the applications main form to something else &#8211; usually the Windows Desktop.</p>
<p>Firstly, you need to add the style <b><i>WS_EX_APPWINDOW</i></b> to the style of the window being created. You can do this by <b><i>or</i></b>ing this constant with the <i>ExStyle</i> paramter as such:</p>
<pre name="code" class="delphi">
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
</pre>
<p>So, the code would look like this:</p>
<pre name="code" class="delphi">
interface

type
TChildForm = class(TForm)
  ...
  protected
  procedure CreateParams(var Params: TCreateParams); override;
    ...

implementation

  procedure TChildForm.CreateParams(var Params: TCreateParams);
  begin
    inherited;
    Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
    Params.WndParent := GetDesktopWindow;
  end;
</pre>
<p>References:</p>
<p>http://delphi.about.com/od/formsdialogs/a/child_forms.htm</p>
<p>http://delphi.about.com/od/formsdialogs/l/aa073101a.htm</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yesjames.com/index.php/2008/11/delphi-minimising-child-forms-in-an-sdi-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
