comp.lang.ada
 help / color / mirror / Atom feed
From: "jjj@sage.inel.gov" <jjj@mica.inel.gov>
Subject: Re: Windows Programming With ActiveAda for Win32s
Date: 22 Mar 1995 14:59:33 GMT
Date: 1995-03-22T14:59:33+00:00	[thread overview]
Message-ID: <3kpe0l$p5g@mica.inel.gov> (raw)
In-Reply-To: 3kn64g$209@ansel.intersource.com

charliel@ansel.intersource.com (Charlie Lenahan) wrote:
>
> We are trying to Use ActiveAda for Windows 5.1.3 to Create a Dialog Box.
> Regular Windows Programming you must use a call to MakeProcINstance before you
> call CreateDialog(). How do you Get around this by using the address of the
> callback function for that dialog box.
>
Here's what I do for a simple 'About' Dialog:

  -- About WinProc specification

  -- Note the following is in a package spec.

  function DIALOG_ABOUT_WINPROC (Window  : HWND;
                             Message : UINT;
                             WPara   : WPARAM;
                             LPara   : LPARAM) return LRESULT;

  pragma CALL_IN (WIN32, DIALOG_ABOUT_WINPROC);

  -- note the following is in a package body


  -- About Winproc Event Handler

  function DIALOG_ABOUT_WINPROC_A (hDlg    : HWND;
                               Message : UINT;
                               WPara   : WPARAM;
                               LPara   : LPARAM) return LRESULT is
      B : BOOL;

  begin
    case (Message) is
      when WM_INITDIALOG =>
        return 1;

      when WM_COMMAND =>
        case (WPara) is
          when IDOK  =>
            B := EndDialog (hDlg, 0);
            return 1;
          when others =>
            return 0;
        end case;

      when others =>
        return 0;
    end case;

    return 0;
  end DIALOG_ABOUT_WINPROC_A;


  function DIALOG_ABOUT_WINPROC (Window  : HWND;
                             Message : UINT;
                             WPara   : WPARAM;
                             LPara   : LPARAM) return LRESULT is

    RESULT : LRESULT;

  begin
    ENTER_CALLBACK;
    RESULT := DIALOG_ABOUT_WINPROC_A (Window, Message, WPara, LPara);
    EXIT_CALLBACK;
    return RESULT;

  end DIALOG_ABOUT_WINPROC;


-- Here's the main program

 Inst        : HANDLE  := GetModuleHandle (C_NULL);
 window      : HWND;
 AboutDlg    : constant STRING := "#200" & ASCII.NUL;

-- Note I am using a numeric identifier for the DialogBox but you
-- can just as easily use a string.

-- A standard Overloaded Convert Function for Ada-Windows Types
  function CONVERT is new UNCHECKED_CONVERSION (INTEGER, LPVOID);
  function CONVERT is new UNCHECKED_CONVERSION (LPVOID,  INTEGER);



  Error := DialogBox (Inst,AboutDlg'Address,Window,
                      CONVERT(DIALOG_ABOUT_WINPROC'ADDRESS));



-- I coded this using the Alsys NT ActivAda Compiler but it should
-- be pretty close to ActivAda 5.1.3

Jon Jensen
AdaSAGE Development Team
Idaho National Engineering Lab




  reply	other threads:[~1995-03-22 14:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-21 18:32 Windows Programming With ActiveAda for Win32s Charlie Lenahan
1995-03-22 14:59 ` jjj@sage.inel.gov [this message]
1995-03-24 12:39 ` Mitch Gart
  -- strict thread matches above, loose matches on Subject: below --
1995-03-24 19:41 John Lo
1995-03-24 19:51 John Lo
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox