<?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>Some thougths, I thought ... &#187; Delphi</title>
	<atom:link href="http://www.aberez.eu/en/category/it-thingies/delphi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aberez.eu</link>
	<description>To think is to differ - Clarence Darrow</description>
	<lastBuildDate>Tue, 04 Oct 2011 15:41:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bitcell.info</title>
		<link>http://www.aberez.eu/en/2010/01/bitcell-info/</link>
		<comments>http://www.aberez.eu/en/2010/01/bitcell-info/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 22:42:40 +0000</pubDate>
		<dc:creator>DarkByte</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[IT thingies]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.aberez.eu/?p=988</guid>
		<description><![CDATA[Un nou forum cu temă informatică, o nouă abordare. Sperăm să fie o abordare mai bună 

Vizitaţi-ne pe BitCell.info.
]]></description>
			<content:encoded><![CDATA[<p>Un nou forum cu temă informatică, o nouă abordare. Sperăm să fie o abordare mai bună <img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/happy.gif" style="border:none;background:none;" alt="happy" /></p>
<p><center><a href="http://www.bitcell.info"><img src="http://bitcell.info/styles/rednblack/imageset/site_logo.gif" alt="Bitcell Forum" /></a></center></p>
<p>Vizitaţi-ne pe <a href="http://www.bitcell.info">BitCell.info</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aberez.eu/en/2010/01/bitcell-info/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Să numărăm ferestrele &#8230;</title>
		<link>http://www.aberez.eu/en/2009/09/sa-numaram-ferestrele/</link>
		<comments>http://www.aberez.eu/en/2009/09/sa-numaram-ferestrele/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 19:20:21 +0000</pubDate>
		<dc:creator>DarkByte</dc:creator>
				<category><![CDATA[De-ale vietii]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[IT thingies]]></category>
		<category><![CDATA[multilanguage]]></category>

		<guid isPermaLink="false">http://www.aberez.eu/?p=605</guid>
		<description><![CDATA[There are (a little) more that 11 years since, for the first time, I found Windows. I have had decided, after some ferm assurances that I would be helped if necessary, to try for the computer department in highschool, although I haven&#8217;t had seen a computer in my life before (this doesn&#8217;t count movies &#8230; [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://www.aberez.eu/images/winlist.png">There are (a little) more that 11 years since, for the first time, I found Windows. I have had decided, after some ferm assurances that I would be helped if necessary, to try for the computer department in highschool, although I haven&#8217;t had seen a computer in my life before (this doesn&#8217;t count movies &#8230; and there they look good <img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/big_grin.gif" style="border:none;background:none;" alt="big grin" />)</p>
<p>Before the entrance exams in the summer of 1998 I was taken by my mother to her job where, at some offices, there were some computers, and the boss daughter used to play there often. Obviously, I went to see how a real computer looks like. Of course that, bright as I knew I was, I imagined that in two weeks I would learn everything that was possible about computers (I don&#8217;t really watch a lot of movies since that disillusionment <img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/straight_face.gif" style="border:none;background:none;" alt="straight face" />)..<span id="more-605"></span> Ştefania, the aforementioned girl, was a year older than me (already in highschool, computer department too) wasn&#8217;t born to be a teacher, so she pushed the power button, some white on black lines started to move on the screen, and I was staring at it. When the lines got tired of moving around, Ştefania wrote three letters, <em>w</em>, <em>i</em>, <em>n</em> and then pushed Enter (Enter &#8230; meaning a big key near the center of the keyboard).</p>
<p>Windows. Versiune: 3.11. Everything became bright, mostly white. Some windows. Then little colorful drawings, in each ocean of white. I immediately noticed that she dived into an ocean full of games and kept on swimming until she found Solitaire. It has been interesting, but &#8230; I mean, I don&#8217;t let the playing cards home down to play cards on a computer.</p>
<p>It&#8217;s been a long time since (from my point of view), but I sticked with Windows. This is another way of saying that it&#8217;s still raining windows. To be honest, it&#8217;s been good years since Linux got windows, too&#8230;</p>
<p>Until recently, I had forgotten how much did the Windows&#8217; windows fascinated me in high school (especially after the Olympiad in Informatics from the 9th grade &#8230; I was told to copy my source files onto a diskette, using Windows &#8230; very penitently, I had to explain to Mrs. Teacher that I had no clue how to do that). So much that, in my 11th grade, I made a program, in Delphi, that would list all the windows from the system, including the hidden ones &#8230; and, even more, to allow me to play with&#8217;em <img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/big_grin.gif" style="border:none;background:none;" alt="big grin" /> Put them <em>always on top</em>, hide them, move them &#8230; good days <img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/happy.gif" style="border:none;background:none;" alt="happy" /></p>
<p>Assuming you had patience up until now, in the next paragraphs I will present this little program, explaining some pieces of the code and, as before, to offer it as open-source.</p>
<p>The first function I needed was <strong><a href="http://msdn.microsoft.com/en-us/library/ms633497(VS.85).aspx">EnumWindows</a></strong>, an API function that retrieves the full list of the system&#8217;s windows, requiring two parameters: a <strong>callback</strong> function and programmer-defined value to be passed to this function. To be perfectly honest, I couldn&#8217;t quite get what that freaking callback is and why, in this case, it would need a parameter for a handle of a single window and my parameter. I mean, in a system there are hundreds of windows &#8230; how would it get them all in a single handle?</p>
<p>I solved this problem quickly by displaying that &#8220;unique&#8221; handle (as I was expecting) in a ShowMessage. Do I still need to say that after the 20th ShowMessage I went back in Delphi and hit Ctrl + F2 (program reset) ? The callback function was called for <strong>every</strong> main window found by EnumWindows, giving me it&#8217;s handle.</p>
<p>Oh goody &#8230; the list of windows is done. I have a list of handles to windows which, honestly, looks smashing. Hammer smashing. I wanted something flashy, eye-candy, something that would show, to whoever would watch, that the program is super-mega-ultra-blah-blah. Hmm &#8230; the title of the window (usually, it&#8217;s caption-bar) would go well &#8230;</p>
<p>I went to finding the window&#8217;s name, something that was generously offered by <strong><a href="http://msdn.microsoft.com/en-us/library/ms633520(VS.85).aspx">GetWindowText</a></strong>, if you bribe it with the window&#8217;s handle and a little room to spill the characters.</p>
<p>Yeah, it&#8217;s already looking better. Still, there are a lot of weird names around here. CiceroUIWndFrame, curtain, AXWIN Frame Window, DDE Server Window, SysFader &#8230; WTF ? Microsoft sucks! What the hell is with this windows ? We need to see them <img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/big_grin.gif" style="border:none;background:none;" alt="big grin" /></p>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/ms633548(VS.85).aspx">ShowWindow</a></strong> to the rescue. A very attractive and funny function. Give a handle, say SW_SHOW and voila &#8230; the window got out from the mist. Say SW_HIDE and &#8230; you&#8217;ll never knew it&#8217;s been there. It also knows some other stuff, but if you&#8217;re interested, all you need to do is to RTFM on the above specified link.</p>
<p>This was a real big moment. I realized that, considering the Get / Set function pairs, there had to be a <strong><a href="http://msdn.microsoft.com/en-us/library/ms633546(VS.85).aspx">SetWindowText</a></strong>. Lucky bet. I rapidly implemented the functionality and I was very proud of myself when the Windows Explorer window was calling itself as &#8220;Bond. James Bond&#8221;. I&#8217;m kidding, obviously. It was calling itself &#8220;Pop. Victor Pop&#8221;.</p>
<p>No matter the name, the function <strong><a href="http://msdn.microsoft.com/en-us/library/ms633545(VS.85).aspx">SetWindowPos</a></strong> takes care the Z-window placement, setting the top-level windows, not to mention the obvious fact that it can move / resize the window. It has been a pleasure to use this function to set a randomly picked window to be Always On Top or Always &#8230; not.</p>
<p>The rest of the code should be clear enough, but if you have any problems with it, let me know. I&#8217;ll try to play the good Samaritan, once in my life <img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/big_grin.gif" style="border:none;background:none;" alt="big grin" /></p>
<p><b>Download</b>:</p>
<p>Sursa : [download id="2"]<br />
Executabil : [download id="1"]<br />
<a href="http://www.aberez.eu/images/progs/enuwind.png" target="_blank">Screenshot</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.aberez.eu/en/2009/09/sa-numaram-ferestrele/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Oameni &#8230;</title>
		<link>http://www.aberez.eu/en/2009/08/oameni/</link>
		<comments>http://www.aberez.eu/en/2009/08/oameni/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 06:37:04 +0000</pubDate>
		<dc:creator>DarkByte</dc:creator>
				<category><![CDATA[Aberatii]]></category>
		<category><![CDATA[De-ale vietii]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://www.aberez.eu/?p=487</guid>
		<description><![CDATA[Aseară am revenit în Oradea, decis ca pe tren să-mi continui proiectele de programare care le am în curs.
În vederea acestui scop, mi-am lăsat laptopul la încărcat până în ultima clipă, apoi l-am pus în hibernare şi am plecat. Ajuns în gară, am hotărât să mă aşez în singurul locşor din tren unde există priză [...]]]></description>
			<content:encoded><![CDATA[<p>Aseară am revenit în Oradea, decis ca pe tren să-mi continui proiectele de programare care le am în curs.</p>
<p>În vederea acestui scop, mi-am lăsat laptopul la încărcat până în ultima clipă, apoi l-am pus în hibernare şi am plecat. Ajuns în gară, am hotărât să mă aşez în singurul locşor din tren unde există priză (de fapt, două alăturate &#8230; doar suntem europeni acum, nu?).</p>
<p>Am avut, totuşi, o mică surpriză, nu neapărat plăcută, când, după ce am urcat în tren, am remarcat că pe cele mai apropiate două locuri (de priză) erau două femei, una la vreo 35 de ani şi cealaltă undeva peste 50. Doar locul de dincolo de ele era gol, dar îmi displăcea profund ideea de a butona înghiontit de colegii de drum, <a href="http://www.aberez.eu/15-08-2009/feriti-a-fost-vineri-14/">cum mi s-a mai întâmplat</a>&#8230;</p>
<p>Mi-am luat inima în dinţi şi am rugat-o pe doamna mai tânără (cea care stătea chiar lângă priză), dacă se poate, să-mi doneze locul ei. Am contat pe faptul că nu avea telefon la încărcat şi nici nu părea să fie în stare  să distingă un laptop închis de o cărămidă mai interesantă.</p>
<p>După ce a trebuit să repet de câteva ori întrebarea (s-a băgat şi doamna mai în vârstă în discuţie), a fost de acord să mă lase să-mi pun telefonul la încărcat acolo &#8230; când, într-un final, a înţeles că o rugam să se mute, a făcut o mutră mai acră, dar s-a mutat, lăsându-şi totuşi bagajul să-i ţină companie trollerului meu.</p>
<p>Nu a uitat, atunci când s-a aşezat pe noul loc, să arunce o ultimă replică mai veninoasă: &#8220;Ştii, nu e frumos să ridici femeile !&#8221;. Da, ştiu, doar pe piedestal &#8230;</p>
<p>Chiar m-a blocat niţel &#8230; probabil că s-a şi văzut pe faţa mea, pentru că nu a mai adăugat nimic.</p>
<p>Tanti nu avea nici un folos pentru amărâta aia de priză, iar în acel tren doar acolo există vreo priză. Cu ce-am deranjat-o atât de tare că am rugat-o să se mute în cealaltă parte a femeii în vârstă, ţinând cont de faptul că am rugat-o frumos?</p>
<p>Cireaşa de pe tort a venit un pic mai încolo, totuşi &#8230; la prima staţie ambele femei au coborât &#8230; asta chiar m-a lăsat mască. Pentru 10 minute de călătorie s-a gândit să-mi arunce remarca aia? Sau doar pentru că era de la ţară?</p>
<p>Cred că oamenii nu se simt bine dacă nu încearcă să facă pe alţi oameni să se simtă prost &#8230; just for the fun of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aberez.eu/en/2009/08/oameni/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Calculator de bioritm</title>
		<link>http://www.aberez.eu/en/2009/08/calculator-de-bioritm/</link>
		<comments>http://www.aberez.eu/en/2009/08/calculator-de-bioritm/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 14:53:58 +0000</pubDate>
		<dc:creator>DarkByte</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[IT thingies]]></category>

		<guid isPermaLink="false">http://www.aberez.eu/?p=470</guid>
		<description><![CDATA[Destul de recent, am primit linkuri pe site-uri care-ți calculau bioritmul și afișau graficele și mi s-a părut destul de interesant, așa că &#8230; m-am apucat să-mi fac un program care să-mi afișeze bioritmul, fără să fie nevoie să intru pe vreun site sau să am măcar conexiune la Internet.
Cu toate acestea, ce trebuie să [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://www.aberez.eu/images/bio_ritm.jpg">Destul de recent, am primit linkuri pe site-uri care-ți calculau bioritmul și afișau graficele și mi s-a părut destul de interesant, așa că &#8230; m-am apucat să-mi fac un program care să-mi afișeze bioritmul, fără să fie nevoie să intru pe vreun site sau să am măcar conexiune la Internet.</p>
<p>Cu toate acestea, ce trebuie să ştiţi este că aceste cicluri bioritmice <strong>nu</strong> sunt dovedite ştiinţific, ba chiar, mai curând, infirmate. Pentru detalii, vedeţi ce zice <a href="http://en.wikipedia.org/wiki/Biorhythm">Wikipedia</a>.</p>
<p>Acestea fiind spuse, să trecem la partea tehnică și informatică din spatele acestui program.</p>
<p>Probabil că știți că pentru a desena o sinusoidală pe calculator, calculezi o serie de puncte, care le unești prin linii. O treabă foarte ușoară în Delphi. Ceea ce probabil că nu știți e faptul că există o funcție în Delphi, care unește o serie de puncte prin linii mult mai rapid decât dacă ai face o buclă, desenând liniile una câte una. Funcția se numește PolyLine (o puteți căuta în Help).</p>
<p>Mai exact, un cod de forma</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">begin</span>
   MoveTo<span style="color: #000066;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> F<span style="color: #000066;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
   <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">1</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #0000ff;">100</span> <span style="color: #000000; font-weight: bold;">do</span>
      LineTo<span style="color: #000066;">&#40;</span>i<span style="color: #000066;">,</span> F<span style="color: #000066;">&#40;</span>i<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>ar putea fi optimizat cu codul următor:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> lPoints<span style="color: #000066;">:</span> <span style="color: #000000; font-weight: bold;">array</span> <span style="color: #000000; font-weight: bold;">of</span> TPoint<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
   <span style="color: #000066;">SetLength</span><span style="color: #000066;">&#40;</span>lPoints<span style="color: #000066;">,</span> <span style="color: #0000ff;">101</span> <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #0000ff;">100</span> <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #000000; font-weight: bold;">with</span> lPoints<span style="color: #000066;">&#91;</span>i<span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #000000; font-weight: bold;">begin</span>
         X <span style="color: #000066;">:</span><span style="color: #000066;">=</span> i<span style="color: #000066;">;</span>
         Y <span style="color: #000066;">:</span><span style="color: #000066;">=</span> F<span style="color: #000066;">&#40;</span>i<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
   Polyline<span style="color: #000066;">&#40;</span>lPoints<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>În afară de acest lucru, restul codului este ușor de înțeles, fiind și parțial comentat. Sursa este scrisă în Delphi 7, dar probabil că va compila și cu alte versiuni de Delphi (mai vechi sau mai noi).</p>
<p>Download : <a href="http://www.aberez.eu/codes/bioritm/bioritm_src.zip">Sursa</a> :: <a href="http://www.aberez.eu/codes/bioritm/bioritm_exe.zip">Executabil</a> :: <a href="http://www.aberez.eu/images/bioritm.png" target="_blank">Screenshot</a></p>
<p>Comentarii, bug-uri, sugestii : binevenite. Also, partea grafică a programului m-a interesat doar din punctul de vedere al graficelor, deci &#8230; știu că poate fi îmbunătățit designul.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aberez.eu/en/2009/08/calculator-de-bioritm/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Window Spy</title>
		<link>http://www.aberez.eu/en/2008/07/window-spy/</link>
		<comments>http://www.aberez.eu/en/2008/07/window-spy/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 12:39:54 +0000</pubDate>
		<dc:creator>DarkByte</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://www.aberez.eu/?p=21</guid>
		<description><![CDATA[Probabil că ştiţi că în Windows totul se bazează pe ferestre &#8230; era destul de evident, nu ?
Să vedem cum am putea afla câte ceva legat de ferestrele vizibile şi cum am putea să le ascundem, să le dezactivăm, etc, totul din Borland Delphi, folosind funcţii API.
Pentru început, să vedem cum aflăm ce fereastră avem [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" src="http://www.aberez.eu/images/win32api.jpg" alt="Win 32 API" />Probabil că ştiţi că în Windows totul se bazează pe ferestre &#8230; era destul de evident, nu ?</p>
<p>Să vedem cum am putea afla câte ceva legat de ferestrele vizibile şi cum am putea să le ascundem, să le dezactivăm, etc, totul din Borland Delphi, folosind funcţii API.<img class="alignright" src="http://www.aberez.eu/images/delphi7.jpg" alt="Borland Delphi 7" /></p>
<p>Pentru început, să vedem cum aflăm ce fereastră avem sub cursorul de mouse.</p>
<p>Pentru asta ne trebuie să ştim poziţia cursorului, care se poate afla folosind funcţia <strong><code>GetCursorPos</code></strong>, din care putem afla handle-ul ferestrei de sub cursor, folosind funcţia <strong><code>WindowFromPoint</code></strong>Să vedem nişte cod.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> hWindow  <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Longint</span><span style="color: #000066;">;</span>
    P <span style="color: #000066;">:</span> TPoint<span style="color: #000066;">;</span>
  <span style="color: #000066;">...</span>
  <span style="color: #006600;">GetCursorPos</span><span style="color: #000066;">&#40;</span>P<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> WindowFromPoint<span style="color: #000066;">&#40;</span>P<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Destul de simplu, nu ? În variabila <strong><code>hWindow</code></strong> avem acum handle-ul care ne interesează.<br />
Pentru a &#8220;vedea&#8221; în timp real ce fereastra e sub cursor, punem codul acesta într-un TTimer.</p>
<p>Să vedem cum afişăm informaţiile găsite, cum ar fi titlul ferestrei, clasa ferestrei (adică tipul componentei) şi handle-ul asociat părintelui ei, din TTimer. Pentru asta avem nevoie (în cazul acesta) de patru TEdit-uri.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">Timer1Timer</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> hWindow  <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Longint</span><span style="color: #000066;">;</span>
    P <span style="color: #000066;">:</span> TPoint<span style="color: #000066;">;</span>
    buff <span style="color: #000066;">:</span> <span style="color: #000000; font-weight: bold;">Array</span><span style="color: #000066;">&#91;</span>0<span style="color: #000066;">..</span>255<span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">of</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  GetCursorPos<span style="color: #000066;">&#40;</span>P<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> WindowFromPoint<span style="color: #000066;">&#40;</span>P<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'$'</span> <span style="color: #000066;">+</span> <span style="color: #000066;">IntToHex</span><span style="color: #000066;">&#40;</span>hWindow<span style="color: #000066;">,</span> <span style="color: #0000ff;">8</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  GetWindowText<span style="color: #000066;">&#40;</span><span style="color: #000066;">StrToInt</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> Buff<span style="color: #000066;">,</span> <span style="color: #0000ff;">255</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  Edit1<span style="color: #000066;">.</span><span style="color: #006600;">Text</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Buff<span style="color: #000066;">;</span>
&nbsp;
  GetClassName<span style="color: #000066;">&#40;</span><span style="color: #000066;">StrToInt</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> Buff<span style="color: #000066;">,</span> <span style="color: #0000ff;">255</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  Edit3<span style="color: #000066;">.</span><span style="color: #006600;">Text</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Buff<span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">If</span> GetParent<span style="color: #000066;">&#40;</span><span style="color: #000066;">StrToInt</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span> &gt; <span style="color: #0000ff;">0</span>
    <span style="color: #000000; font-weight: bold;">then</span> Edit4<span style="color: #000066;">.</span><span style="color: #006600;">Text</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'$'</span> <span style="color: #000066;">+</span> <span style="color: #000066;">IntToHex</span><span style="color: #000066;">&#40;</span>GetParent<span style="color: #000066;">&#40;</span><span style="color: #000066;">StrToInt</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">8</span><span style="color: #000066;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">else</span> Edit4<span style="color: #000066;">.</span><span style="color: #006600;">Text</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'None'</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p><strong><code>GetWindowText</code></strong> returnează titlul ferestrei (sau textul din fereastră, dacă e vorba de un TEdit), <strong><code>GetClassName</code></strong> returnează tipul componentei, iar <strong><code>GetParent</code></strong> handle-ul părintelui. Simplu, nu ? <img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/happy.gif" style="border:none;background:none;" alt="happy" /></p>
<p>Păcat că momentan tot ce aflăm sunt lucruri destul de puţin importante şi deloc atrăgătoare. Nişte numere şi ceva text care oricum se vedea şi fără un asemenea program. Să încercăm ceva mai atrăgător.</p>
<p>Pentru început vom ascunde / reafişa fereastra, apelând funcţia <strong><code>ShowWindow</code></strong>, care are nevoie de doi parametri: handle-ul ferestrei şi un parametru care specifică dacă vrem să afişăm sau să ascundem fereastra.</p>
<p>Afişare fereastră:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">ShowWindow<span style="color: #000066;">&#40;</span>wHandle<span style="color: #000066;">,</span> SW_SHOW<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Ascundere fereastră:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">ShowWindow<span style="color: #000066;">&#40;</span>wHandle<span style="color: #000066;">,</span> SW_HIDE<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Alt lucru care-l putem face : vom seta ca fereastra selectată să devină fereastră de top-level şi înapoi. Pentru acest lucru vom folosi funcţia <strong><code>SetWindowPos</code></strong> pentru a ne defini o procedură apelabilă cu un parametru de tip <strong><code>Boolean</code></strong> care să ştie modifica stilul ferestrei în ambele moduri, al doilea parametru fiind handle-ul ferestrei care vrem s-o modificăm.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">procedure</span> SetTop<span style="color: #000066;">&#40;</span>Top <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Boolean</span><span style="color: #000066;">;</span> Handle <span style="color: #000066;">:</span> HWnd<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">Begin</span>
  <span style="color: #000000; font-weight: bold;">If</span> Top
    <span style="color: #000000; font-weight: bold;">Then</span>
      <span style="color: #000000; font-weight: bold;">Begin</span>
        SetWindowPos<span style="color: #000066;">&#40;</span>Handle<span style="color: #000066;">,</span> HWND_TOPMOST<span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span>
                     SWP_SHOWWINDOW <span style="color: #000066;">+</span> SWP_NOMOVE <span style="color: #000066;">+</span> SWP_NOSIZE<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
        SetWindowPos<span style="color: #000066;">&#40;</span>Handle<span style="color: #000066;">,</span> HWND_TOP<span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span>
                     SWP_SHOWWINDOW <span style="color: #000066;">+</span> SWP_NOMOVE <span style="color: #000066;">+</span> SWP_NOSIZE<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      <span style="color: #000000; font-weight: bold;">End</span>
    <span style="color: #000000; font-weight: bold;">Else</span> SetWindowPos<span style="color: #000066;">&#40;</span>Handle<span style="color: #000066;">,</span> HWND_NOTOPMOST<span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">,</span>
                      SWP_SHOWWINDOW <span style="color: #000066;">+</span> SWP_NOMOVE <span style="color: #000066;">+</span> SWP_NOSIZE<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">End</span><span style="color: #000066;">;</span></pre></div></div>

<p>Acum nu mai avem decât să apelăm procedura asta din butonul corespunzător.</p>
<p>Ştiind handle-ul ferestrei, o putem şi activa / dezactiva folosind <strong><code>EnableWindow</code></strong>, care necesită specificarea handle-ului ferestrei şi un parametru logic care determină activarea / dezactivarea ei.</p>
<p>Codul pentru cele şase butoane de până acum:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">bShowClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HexToInt<span style="color: #000066;">&#40;</span><span style="color: #000066;">Copy</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">,</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  ShowWindow<span style="color: #000066;">&#40;</span>hWindow<span style="color: #000066;">,</span> SW_SHOW<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">bHideClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HexToInt<span style="color: #000066;">&#40;</span><span style="color: #000066;">Copy</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">,</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  ShowWindow<span style="color: #000066;">&#40;</span>hWindow<span style="color: #000066;">,</span> SW_HIDE<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">bTopClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HexToInt<span style="color: #000066;">&#40;</span><span style="color: #000066;">Copy</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">,</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  SetTop<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">,</span> hWindow<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">bPotClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HexToInt<span style="color: #000066;">&#40;</span><span style="color: #000066;">Copy</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">,</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  SetTop<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">,</span> hWindow<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">bEnableClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HexToInt<span style="color: #000066;">&#40;</span><span style="color: #000066;">Copy</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">,</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  EnableWindow<span style="color: #000066;">&#40;</span>hWindow<span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">bDisableClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HexToInt<span style="color: #000066;">&#40;</span><span style="color: #000066;">Copy</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">,</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  EnableWindow<span style="color: #000066;">&#40;</span>hWindow<span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>Probabil că aţi remarcat linia</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">hWindow <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HexToInt<span style="color: #000066;">&#40;</span><span style="color: #000066;">Copy</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">,</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>Edit2<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>, despre care nu am scos nici un cuvânt până acum. Este inversa funcţiei <strong><code>IntToHex</code></strong> din Delphi, şi este definită mai jos.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> HexToInt<span style="color: #000066;">&#40;</span>S <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Longint</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> B <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Byte</span><span style="color: #000066;">;</span>
    C <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Char</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">Begin</span>
  Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span>
  s <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">UpperCase</span><span style="color: #000066;">&#40;</span>s<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">For</span> B <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">1</span> <span style="color: #000000; font-weight: bold;">To</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>s<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">Do</span>
    <span style="color: #000000; font-weight: bold;">Begin</span>
      Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Result <span style="color: #000066;">*</span> <span style="color: #0000ff;">16</span><span style="color: #000066;">;</span>
      c <span style="color: #000066;">:</span><span style="color: #000066;">=</span> S<span style="color: #000066;">&#91;</span>B<span style="color: #000066;">&#93;</span><span style="color: #000066;">;</span>
      <span style="color: #000000; font-weight: bold;">Case</span> c <span style="color: #000000; font-weight: bold;">Of</span>
        <span style="color: #ff0000;">'0'</span><span style="color: #000066;">..</span><span style="color: #ff0000;">'9'</span><span style="color: #000066;">:</span> <span style="color: #000066;">Inc</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> <span style="color: #000066;">Ord</span><span style="color: #000066;">&#40;</span>c<span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #000066;">Ord</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'0'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
        <span style="color: #ff0000;">'A'</span><span style="color: #000066;">..</span><span style="color: #ff0000;">'F'</span><span style="color: #000066;">:</span> <span style="color: #000066;">Inc</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> <span style="color: #000066;">Ord</span><span style="color: #000066;">&#40;</span>c<span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #000066;">Ord</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">+</span> <span style="color: #0000ff;">10</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
        <span style="color: #000000; font-weight: bold;">Else</span>
          <span style="color: #000000; font-weight: bold;">Begin</span>
            Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span>
            <span style="color: #000066;">Exit</span><span style="color: #000066;">;</span>
          <span style="color: #000000; font-weight: bold;">End</span><span style="color: #000066;">;</span>
      <span style="color: #000000; font-weight: bold;">End</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">End</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">End</span><span style="color: #000066;">;</span></pre></div></div>

<p>Puteam folosi variabila <strong><code>hWindow</code></strong> ca variabilă globală şi atunci scăpam de nevoia folosirii acestei funcţii, nu ? Dar ce se întâmpla dacă la utilizarea programului se voia reafişarea unei ferestre căreia îi ştim handle-ul ? În acest fel tot ce avem de făcut este editarea celei de-a doua căsuţe text cu handle-ul respectiv şi putem face orice, altfel putând lucra doar cu ferestrele vizibile pe ecran.</p>
<p>Cam acesta ar fi codul necesar pentru o mini-aplicaţie de lucru cu ferestrele &#8230; dar stai &#8230; e o problemă &#8230; dacă verificarea ferestrei de sub mouse se face în timp real, înseamnă că &#8230; da, dacă selectez butonul de &#8220;ascundere fereastră&#8221;, îmi va ascunde tocmai respectivul buton. Damn, nu e bine.</p>
<p>Trebuie să programăm o metodă de a opri scanarea ferestrelor în timp real, o dată ce am selectat fereastra cu care vrem să lucrăm, fără să mişcăm mouse-ul. Pentru asta ne vom defini o combinaţie de taste globală, folosind funcţia <strong><code>RegisterHotKey</code></strong>, care primeşte patru parametri: handle-ul ferestrei căreia să-i trimită mesaj în caz că s-a apăsat combinaţia noastră de taste, un identificator pentru combinaţie, definit de noi, şi combinaţia de taste, definită prin doi parametri &#8211; primul, care defineşte dacă tastele CTRL, ALT, SHIFT sau WIN sunt apăsate, şi al doilea, care defineşte o tastă normală (cum ar fi &#8220;R&#8221<img src="http://www.aberez.eu/wp-content/plugins/yahoo-messenger-emoticons/emoticons/winking.gif" style="border:none;background:none;" alt="winking" />. Apelul funcţiei, pentru a ne defini combinaţia CTRL + F8, este :</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">const</span> StopKey <span style="color: #000066;">=</span> <span style="color: #0000ff;">100000</span><span style="color: #000066;">;</span>
  <span style="color: #000066;">...</span>
  <span style="color: #006600;">RegisterHotKey</span><span style="color: #000066;">&#40;</span>Handle<span style="color: #000066;">,</span> StopKey<span style="color: #000066;">,</span> MOD_CONTROL<span style="color: #000066;">,</span> VK_F8<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Această linie trebuie apelată chiar la începutul rulării programului, în <strong><code>FormCreate</code></strong>.<br />
<strong>Atenţie</strong> : <strong><code>StopKey</code></strong> este o constantă ce trebuie definită global, înaintea secţiunii <strong><code>implementation</code></strong>.</p>
<p>Pentru a fi anunţaţi când este apăsată combinaţia noastră de taste ne vom defini o procedură care să primească mesajul trimis de sistem, interceptând mesajul <strong><code>WM_HOTKEY</code></strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">type</span>
  TForm1 <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span>TForm<span style="color: #000066;">&#41;</span>
  <span style="color: #000066;">...</span>
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
    <span style="color: #000000; font-weight: bold;">procedure</span> WMHotKey<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> Message<span style="color: #000066;">:</span> TMessage<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span> message WM_HOTKEY<span style="color: #000066;">;</span>
 <span style="color: #000066;">...</span></pre></div></div>

<p>Codul procedurii :</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">WMHotKey</span><span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> Message<span style="color: #000066;">:</span> TMessage<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">If</span> Message<span style="color: #000066;">.</span><span style="color: #006600;">WParam</span> <span style="color: #000066;">=</span> StopKey
    <span style="color: #000000; font-weight: bold;">Then</span> Timer1<span style="color: #000066;">.</span><span style="color: #006600;">Enabled</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">not</span> Timer1<span style="color: #000066;">.</span><span style="color: #006600;">Enabled</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>Practic, la fiecare apăsare a combinaţiei, TTimer-ul nostru se va opri / reporni. Pentru a nu lăsa mizerie după rularea programului, va trebui să distrugem această combinaţie de taste la oprire. Pentru acest lucru, în <strong><code>FormCloseQuery</code></strong> vom apela :</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">  UnregisterHotKey<span style="color: #000066;">&#40;</span>Handle<span style="color: #000066;">,</span> StopKey<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Cam asta ar fi tot codul.</p>
<p>Pentru a nu vă pune să lucraţi cu copy / paste şi să vă faceţi griji de componente şi asignări de evenimente, aveţi mai jos sursele şi executabilul arhivate.</p>
<p>Download : <a href="http://www.aberez.eu/codes/window_spy_src.zip">Sursa</a> :: <a href="http://www.aberez.eu/codes/window_spy_exe.zip">Executabil</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.aberez.eu/en/2008/07/window-spy/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

