Mar 302009
 

Here we go, the HelloWorld for Windows written in Ada – put the codes below to a hellowwindows.adb, then run:

gnat make -IC:\GNAT\2008\include\Win32ada -LC:\GNAT\2008\lib\Win32Ada HelloWindows

HelloWindows

sure you need to change the include and library directory to the right one.

Compile it, run it with “hellowindows”, you will see a pop-up window as shown on right.

Here are codes:

-- 我的第一个Windows Ada程序
with Ada.Command_Line;
with Ada.Unchecked_Conversion;
with Interfaces.C;
with System;
with Win32;
with Win32.WinDef;
with Win32.WinMain;
with Win32.WinUser;

procedure HelloWindows is

    function CP (pch: Interfaces.C.CHAR_Array) return Win32.LPCSTR is
        function CSTR_To_Address is new Ada.Unchecked_Conversion(System.Address, Win32.LPCSTR);
    begin
        return CSTR_To_Address(pch(pch'FIRST)'ADDRESS);
    end CP;

    function WinMain( hInstance    : Win32.Windef.HINSTANCE;
	              hPrevInstance: Win32.Windef.HINSTANCE;
	              lpszCmdLine  : Win32.PCSTR;
	              nCmdShow     : Win32.INT) return Win32.UINT is


        szMessage : constant Interfaces.C.CHAR_Array := Interfaces.C.To_C( "你好,Ada世界!", True );
        szTitle   : constant Interfaces.C.CHAR_Array := Interfaces.C.To_C( "第一个Windows Ada程序" );

        hWnd : Win32.Windef.HWND;
        nretVal : Interfaces.C.int;
    begin
        hWnd := Win32.Winuser.GetDesktopWindow;
        nRetVal := Win32.Winuser.MessageBox( hWnd, CP(szMessage), CP(szTitle), Win32.Winuser.MB_OK );
        return 0;
    end WinMain;

begin
    Ada.Command_Line.Set_Exit_Status(
        Ada.Command_Line.Exit_Status(
            WinMain( Win32.Winmain.Get_hInstance,
                     Win32.Winmain.Get_hPrevInstance,
                     Win32.Winmain.Get_lpCmdline,
                     Win32.Winmain.Get_nCmdShow )
        )
    );

end HelloWindows;
 Posted by at 16:52
Mar 302009
 

I just got my new driver license from DMV, and compare the new photo with the photo I took 4 years ago … I’m super fat now.

Actually I know I’m getting fat, but was thinking that’s the problem on tummy only. However, it turned out I’m fat everywhere, at least my face become … ugly, this is the only word in my mind. I have to say, DMV employee’s bad skill of taking photo contribute a lot to the ugly face I have, but if I’m not that fat it will not look like this.

I’ve got my recent numbers on weight, waist, etc. I’m going to track it every week. Sure I won’t post those numbers here as they were treated as top privacy here in US (why? :-W ), but I will let you know how much I manage to reduce, if I make any good progress. 🙂

 Posted by at 10:21
Mar 302009
 

There was an earthquake just now, pretty obvious to me.

I was feeling dizzy at that time, it seems common feeling while having earthquake, I’m not sure if it was caused by shaking, or some sort of “wave”, I will dig around later once get some time.

Tough Monday morning, way too many things to do.

 Posted by at 09:48