Thursday, 9 August 2007

Pop-up menu from button

Recently I had to create a pop-up menu when pressing a button, as shown on the picture.

Here is the code for this task to complete in Borland Delphi.
case PopupMenu1.Items.Count of
0 : // no menu items
begin
MessageDlg( _( 'No items to show' ), mtInformation, [mbOK], 0 );
exit;
end;
1 : // only one item - execute
PopupMenu1.Items[0].Click;
else
with BitBtn1, ClientToScreen( Point( 0, Height ) ) do
PopupMenu1.Popup( X, Y );
end;
BitBtn1 is the button to be pressed, PopupMenu1 contains the menu items to pop up. If there's no menu items, a message is shown, if only one menu item, it is launched by default, if more - popup menu appears.

Wednesday, 8 August 2007

Forwarding Remote Desktop Connection via SSH

A problem: there's a remote Windows machine A which you need to access. You don't have direct access to that machine, however, you can SSH to some server B which does have access to A.

Solution: since Remote Desktop Connection uses single port 3389 for connection, it is just possible to make local SSH forwarding of, say, your port 3389 to the A:3389. Then use your Remote Desktop Connection client to connect to localhost (assuming that you don't have RDserver running on your current machine), and you are done. Right? Not always.

For me, the solution above worked if my current machine was a linux box. Also, I know some people, for whom this solution worked on Windows machines too. But for me, the scenario above produced complaint from standard Windows Remote Desktop Connection client:

The client could not connect. You are already connected to the console of this computer. A new console session cannot be established.

I've found the solution for this problem here. The idea is that if you use putty as your SSH client, the current version allows to bind local ports not just to localhost (127.0.0.1), but also for something like 127.0.0.2 (127.*.*.*). The configuration of putty connection should look like this (substitute target for the name of your machine):


Now, the connection configuration for RDC client must look like that:


Well, that's all. You should be able to connect to machine A now from your Windows box.

Tuesday, 7 August 2007

Иван Купала - lietuviskai

Vienu metu man labai patiko rusų grupė "Иван Купала". Žmonės sumaišė senas rūsų liaudies dainas su šiuolaikiniais bumčikais - ir laimėjo.

Neseniai išgirdau kažką panašaus, tik lietuviškai. Žinoma, liaudies dainos irgi lietuviškos. Atlikėjai Rasa ir Jonas. Albumas "Saulala Raudona". Šaunuoliai!!!

Last.fm'e reikėjo užsiregistruoti - patingėjau. Bet kelios jų dainos yra Youtube:

http://www.youtube.com/watch?v=AGkojFAV_DM

Monday, 6 August 2007

Using internet browser as calculator

Most modern internet browsers support JavaScript. JavaScript may be executed in various ways, one of them - through pseudo url javascript:some_code. If this JavaScript code returns some value, the contents of all current web page is replaced with the result, converted to text (Safari on Windows v. 3.0.3 does not support this, apparently...).

Since JavaScript has means to perform mathematical operations, the internet browsers may be used as calculators. For example, to calculate 2+2 you could enter the following URL: javascript:2+2

Some more advanced math is possible, but it is not as straightforward, because advanced math functionality resides in JavaScript object Math. For example, to calculate number Pi, you should enter something like that: javascript:Math.PI , to calculate e10, you need the following line javascript:Math.exp(10), and so on.

P.S. And, speaking about browsers and calculators, don't forget about calculator built into google search engine. Just try googling for 2+2 ;)

Saturday, 4 August 2007

Lietuviškos radijo stotys internete WinAMP'ui

Čia yra playlist su Lietuviškomis radijo stotimis internete, skirtas grotuvui WinAMP.

WinAMP'e reikia :
  1. pasirinkti "Add new URL",
  2. nurodyti šį adresą: http://100files.googlepages.com/radio_LT.m3u
  3. Pasirinkti, kokią iš 40+ radijo stočių klausytis :)
Daugiau info galima rasti:
  1. Radijo stočių puslapiuose
  2. http://www.klausyk.lt/lt/visos_radijo_stotys/
  3. http://www.audio.lt/tiesiogine-transliacija/
  4. http://www.radijo.info/
  5. http://audio.mums.lt/
  6. http://www.fm.lt/lt/ltlist/
  7. http://dsl.zebra.lt/radijas.php
  8. Google

Thursday, 2 August 2007

Installing the BDE

Recently I had to install the BDE (Borland Database Engine) for an old software.

There's a stand-alone BDE updater named bde511en.exe, which is available from this page. Note that you'll have to scroll till the bottom of the page. However, this one is good only if you already have some older version of BDE. You may have it installed with some old installer of BDE-enabled application.

If You want to install BDE on the fresh machine, BDEInfoSetup.zip will help. It is available from here. It will install you BDE version 5.2, the last one at the moment. Theoretically, it is possible to check updater page if some new versions are available, however, since BDE is not developed any more, this will probably be of no help. After install, you may need to run bdeadmin.exe to set up aliases. BDEadmin should be available here:

"c:\Program Files\Borland\Common Files\BDE\BDEADMIN.EXE"

Also, at about.com there's a paper on how to install BDE manually. I've never tried it, actually, as long as the internet is available and installer is accessible online, but it could help in some situation, i guess.

Wednesday, 1 August 2007

ReportManager version incompatibility

There's a freeware report generator ReportManager, that I do use a lot. Starting from some version (don't remember which, but 2.6a has it), the generated report files are incompatible with the older versions (again, I don't remember till which, but 2.4e has this problem).

After some investigation, the problem seems to have a fix. Report files are essentially a Delphi forms (a kind of resources for Borland Delphi programs), in plain text. The incompatibility is originated by 2 new properties of report parameters:
  • ErrorMessage
  • Validation
After all, these properties are good and extend the functionality of ReportManager. Besides, RM is free, so you can just download the latest version and be well off. However, if you don't use these new features, and want your report to work with older versions of RM engine, just open your *.rep file in any text editor (notepad will do, but I personally prefer VIM), and delete all lines that look like

ErrorMessage = ''
Validation = ''

in VIM, this could be done with the following commands:

:gl /^ *ErrorMessage *=/ del
:gl /^ *Validation *=/ del