From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,PDS_FROM_2_EMAILS autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f95357b07ebf392d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-23 02:39:07 PST Path: nntp.gmd.de!dearn!blekul11!ccsdec1.ufsia.ac.be!reks.uia.ac.be!idefix.CS.kuleuven.ac.be! Belgium.EU.net!EU.net!howland.reston.ans.net!gatech!udel!news.mathworks.com!uhog.mit.edu!news.mtholyoke.edu!news.byu.edu!cwis.isu.edu!mica.inel.gov!usenet From: "jjj@sage.inel.gov" Newsgroups: comp.lang.ada Subject: Re: Windows Programming With ActiveAda for Win32s Date: 22 Mar 1995 14:59:33 GMT Organization: Idaho National Engineering Laboratory Message-ID: <3kpe0l$p5g@mica.inel.gov> References: <3kn64g$209@ansel.intersource.com> NNTP-Posting-Host: pc-jjj.inel.gov Date: 1995-03-22T14:59:33+00:00 List-Id: 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