home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / os2apipm.zip / PMEXAM / MENU / WIN.ADB < prev    next >
Text File  |  1996-08-12  |  45KB  |  1,368 lines

  1. with System;
  2. with Text_IO;
  3. with OS2; use OS2;
  4. with OS2.PMwb; use OS2.PMwb;
  5. with OS2.PMwd; use OS2.PMwd;
  6. with OS2.PMSC; use OS2.PMsc;
  7. with OS2.PMCP; use OS2.PMCP;
  8.  
  9. with Unchecked_Conversion;
  10. with Unchecked_Deallocation;
  11.  
  12. package body Win is
  13.  
  14.   Short_True     : constant Ushort := 1;
  15.   Short_False    : constant Ushort := 0;
  16.  
  17.   Long_True      : constant Ulong := 1;
  18.   Long_False     : constant Ulong := 0;
  19.  
  20.   Boolean_Value  : constant array (Boolean) of Ulong := (0, 1);
  21.  
  22.   Boolean_Result : constant array (Ulong range 0 .. 1)
  23.                      of Boolean := (False, True);
  24.  
  25.   MB_Response : constant array (Ushort range 1 .. 9)
  26.                    of MB_Response_Type :=
  27.      (1 => MB_Ok_Pressed,
  28.       2 => MB_Cancel_Pressed,
  29.       3 => Mb_Abort_Pressed,
  30.       4 => Mb_Retry_Pressed,
  31.       5 => Mb_Ignore_Pressed,
  32.       6 => Mb_Yes_Pressed,
  33.       7 => Mb_No_Pressed,
  34.       8 => Mb_Help_Pressed,
  35.       9 => Mb_Enter_Pressed);
  36.  
  37.   MB_Buttons : constant array (Mb_Button_Styles_Type) of Ulong :=
  38.      (MB_Ok                 => 16#0000#,
  39.       MB_Ok_Cancel          => 16#0001#,
  40.       MB_Cancel             => 16#0006#,
  41.       MB_Enter              => 16#0007#,
  42.       MB_Enter_Cancel       => 16#0008#,
  43.       MB_Retry_Cancel       => 16#0002#,
  44.       MB_Abort_Retry_Ignore => 16#0003#,
  45.       MB_Yes_No             => 16#0004#,
  46.       MB_Yes_No_Cancel      => 16#0005#);
  47.  
  48.   MB_Icons : constant array (Mb_Icon_Styles_Type) of Ulong :=
  49.       (Mb_No_Icon          => 16#0000#,
  50.        Mb_Icon_Hand        => 16#0040#,
  51.        Mb_Icon_Question    => 16#0010#,
  52.        Mb_Icon_Exclamation => 16#0020#,
  53.        Mb_Icon_Asterisk    => 16#0030#,
  54.        Mb_Information      => 16#0030#,
  55.        Mb_Query            => 16#0010#,
  56.        Mb_Warning          => 16#0020#,
  57.        Mb_Error            => 16#0040#);
  58.  
  59.   MB_Action : constant array (Mb_Default_Action_Type) of Ulong :=
  60.        (MB_Default_on_Button_1 => 16#0000#,
  61.         MB_Default_on_Button_2 => 16#0100#,
  62.         MB_Default_on_Button_3 => 16#0200#);
  63.  
  64.   MB_Modality : constant array (Mb_Modality_Type) of Ulong :=
  65.        (Mb_Application_Modal => 16#0000#,
  66.         Mb_System_Modal      => 16#1000#);
  67.  
  68.   MB_Help     : constant array (Boolean)
  69.                     of Ulong := (16#0000#, 16#2000#);
  70.   MB_Moveable : constant array (Boolean)
  71.                     of Ulong := (16#0000#, 16#4000#);
  72.  
  73.   ------------------------------------------------
  74.  
  75.   Win_Style_Values : constant array (Class_Style_Type) of Ulong :=
  76.        (Cs_Size_Redraw    => 16#0000_0004#,
  77.         Cs_Sync_Paint     => 16#0200_0000#,
  78.         Cs_Move_Notify    => 16#0000_0001#,
  79.         Cs_Clip_Children  => 16#2000_0000#,
  80.         Cs_Clip_Siblings  => 16#1000_0000#,
  81.         Cs_Parent_Clip    => 16#0800_0000#,
  82.         Cs_Save_Bits      => 16#0400_0000#,
  83.         Cs_Public         => 16#0000_0010#,
  84.         Cs_Hit_Test       => 16#0000_0008#,
  85.         Cs_Frame          => 16#0000_0020#);
  86.  
  87.   ------------------------------------------------
  88.  
  89.    Win_Position_Values : constant array (Position_Options_Type)
  90.                                                      of Ulong :=
  91.        (Swp_Size             => 16#0001#,
  92.         Swp_Move             => 16#0002#,
  93.         Swp_Z_Order          => 16#0004#,
  94.         Swp_Show             => 16#0008#,
  95.         Swp_Hide             => 16#0010#,
  96.         Swp_No_Redraw        => 16#0020#,
  97.         Swp_No_Adjust        => 16#0040#,
  98.         Swp_Activate         => 16#0080#,
  99.         Swp_Deactivate       => 16#0100#,
  100.         Swp_Ext_State_Change => 16#0200#,
  101.         Swp_Minimize         => 16#0400#,
  102.         Swp_Maximize         => 16#0800#,
  103.         Swp_Restore          => 16#1000#,
  104.         Swp_Focus_Active     => 16#2000#,
  105.         Swp_Focus_Deactivate => 16#4000#,
  106.         Swp_No_Auto_Close    => 16#8000#);
  107.  
  108.   ------------------------------------------------
  109.  
  110.    Window_Style_Values : constant array (Window_Style_Type)
  111.                                         of Ulong := (
  112.       Ws_Sync_Paint         => 16#0200_0000#,
  113.       Ws_Clip_Children      => 16#2000_0000#,
  114.       Ws_Clip_Siblings      => 16#1000_0000#,
  115.       Ws_Disabled           => 16#4000_0000#,
  116.       Ws_Maximized          => 16#0080_0000#,
  117.       Ws_Mimimized          => 16#0100_0000#,
  118.       Ws_Parent_Clip        => 16#0800_0000#,
  119.       Ws_Save_Bits          => 16#0400_0000#,
  120.       Ws_Visible            => 16#8000_0000#,
  121.       Ws_Animate            => 16#0040_0000#,
  122.       Ws_Group              => 16#0001_0000#,
  123.       Ws_Tab_Stop           => 16#0002_0000#,
  124.       Ws_Multi_Select       => 16#0004_0000#,
  125.  
  126.       Fs_Screen_Align       => 16#0000_0200#,
  127.       Fs_Mouse_Align        => 16#0000_0400#,
  128.       Fs_Sizing_Border      => 16#0000_0800#,
  129.       Fs_Border             => 16#0000_0100#,
  130.       Fs_Dialog_Border      => 16#0000_0080#,
  131.       Fs_System_Modal       => 16#0000_0040#,
  132.       Fs_No_Byte_Align      => 16#0000_0010#,
  133.       Fs_Task_List          => 16#0000_0008#,
  134.       Fs_No_Move_With_Owner => 16#0000_0020#,
  135.       Fs_Auto_Icon          => 16#0000_1000#);
  136.  
  137.   ------------------------------------------------
  138.  
  139.    Frame_Values : constant array (Frame_Control_Flag_Type)
  140.                    of Ulong := (
  141.         Fcf_Title_Bar          => 16#0000_0001#,
  142.         Fcf_System_Menu        => 16#0000_0002#,
  143.         Fcf_Menu               => 16#0000_0004#,
  144.         Fcf_Min_Max            => 16#0000_0030#,
  145.         Fcf_Min_Button         => 16#0000_0010#,
  146.         Fcf_Max_Button         => 16#0000_0020#,
  147.         Fcf_Vert_Scroll_Bar    => 16#0000_0040#,
  148.         Fcf_Horz_Scroll_Bar    => 16#0000_0080#,
  149.         Fcf_Sizing_Border      => 16#0000_0008#,
  150.         Fcf_Border             => 16#0000_0200#,
  151.         Fcf_Dialog_Border      => 16#0000_0100#,
  152.         Fcf_Accel_Table        => 16#0000_8000#,
  153.         Fcf_Icon               => 16#0000_4000#,
  154.         Fcf_Shell_Position     => 16#0000_0400#,
  155.         Fcf_System_Modal       => 16#0001_0000#,
  156.         Fcf_No_Byte_Align      => 16#0000_1000#,
  157.         Fcf_Task_List          => 16#0000_0800#,
  158.         Fcf_No_Move_With_Owner => 16#0000_2000#,
  159.         Fcf_Standard           => 16#0000_CC3F#,
  160.         Fcf_Screen_Align       => 16#0002_0000#,
  161.         Fcf_Mouse_Align        => 16#0004_0000#,
  162.         Fcf_Auto_Icon          => 16#4000_0000#,
  163.         Fcf_Hide_Button        => 16#0100_0000#,
  164.         Fcf_Hide_Max           => 16#0100_0020#);
  165.  
  166.   Frame_Id_Values : constant array (Frame_Id_Type) of Ulong := (
  167.          Fid_System_Menu      => 16#8002#,
  168.          Fid_Titlebar         => 16#8003#,
  169.          Fid_Min_Max          => 16#8004#,
  170.          Fid_Menu             => 16#8005#,
  171.          Fid_Vert_Scroll_Bar  => 16#8006#,
  172.          Fid_Horz_Scroll_Bar  => 16#8007#,
  173.          Fid_Client           => 16#8008#,
  174.          Fid_DBE_App_Stat     => 16#8010#,
  175.          Fid_DBE_Kbd_Stat     => 16#8011#,
  176.          Fid_DBE_Pecic        => 16#8012#,
  177.          Fid_Dbe_KK_Pop_Up    => 16#8013#);
  178.  
  179.    Command_Source_Values : constant array (Ushort range 0 .. 7)
  180.                             of Command_Source_Type :=
  181.        (0 => Cmd_Src_Other,
  182.         1 => Cmd_Src_Push_Button,
  183.         2 => Cmd_Src_Menu,
  184.         3 => Cmd_Src_Accelerator,
  185.         4 => Cmd_Src_Font_Dialog,
  186.         5 => Cmd_Src_File_Dialog,
  187.         6 => Cmd_Src_Print_Dialog,
  188.         7 => Cmd_Src_Color_Dialog);
  189.  
  190.   ------------------------------------------------
  191.  
  192.    MIS_Values : constant array (Menu_Style_Type) of Ushort := (
  193.        MIS_Text             => 16#0001#,
  194.        MIS_Bitmap           => 16#0002#,
  195.        MIS_Separator        => 16#0004#,
  196.        MIS_Owner_Draw       => 16#0008#,
  197.        MIS_Submenu          => 16#0010#,
  198.        MIS_Mult_Menu        => 16#0020#,
  199.        MIS_Sys_Command      => 16#0030#,
  200.        MIS_Help             => 16#0080#,
  201.        MIS_Static           => 16#0100#,
  202.        MIS_Button_Separator => 16#0200#,
  203.        MIS_Break            => 16#0400#,
  204.        MIS_Break_Separator  => 16#0800#,
  205.        MIS_Group            => 16#1000#,
  206.        MIS_Single           => 16#2000#);
  207.  
  208.   ------------------------------------------------
  209.  
  210.    MIA_Values : constant array (Menu_Attribute_Type) of Ushort := (
  211.         MIA_No_Dismiss  => 16#0020#,
  212.         MIA_Framed      => 16#1000#,
  213.         MIA_Checked     => 16#2000#,
  214.         MIA_Disabled    => 16#4000#,
  215.         MIA_Highlighted => 16#8000#);
  216.  
  217.   ------------------------------------------------
  218.  
  219.    Pop_Up_Values : constant array (Pop_Up_Option_Type) of Ushort := (
  220.       Pu_Position_On_Item     => 16#0001#,
  221.       Pu_Horz_Constrained     => 16#0002#,
  222.       Pu_Vert_Constrained     => 16#0004#,
  223.       Pu_None                 => 16#0000#,
  224.       Pu_Mouse_Button_1_Down  => 16#0008#,
  225.       Pu_Mouse_Button_2_Down  => 16#0010#,
  226.       Pu_Mouse_Button_3_Down  => 16#0018#,
  227.       Pu_Select_Item          => 16#0020#,
  228.       Pu_Mouse_Button_1       => 16#0040#,
  229.       Pu_Mouse_Button_2       => 16#0080#,
  230.       Pu_Mouse_Button_3       => 16#0100#,
  231.       Pu_Keyboard             => 16#0200#);
  232.  
  233.   ------------------------------------------------
  234.  
  235.    type OS2_Menu_Item_Type is
  236.       record
  237.         IPosition   : Short;
  238.         Style       : Ushort;
  239.         Attribute   : Ushort;
  240.         Id          : Ushort;
  241.         SubMenu     : HWND;
  242.         Item_Handle : Ulong;
  243.       end record;
  244.  
  245.   ------------------------------------------------
  246.   function Create_Standard_Window (
  247.             Parent_Window       : HWND;
  248.             Window_Styles       : Window_Styles_Type;
  249.             Frame_Control_Flags : Frame_Control_Flags_Type;
  250.             Class_Name          : String;
  251.             Window_Title        : String;
  252.             Class_Style         : Class_Styles_Type;
  253.             Resource            : ULong;
  254.             Resource_ID         : ULong;
  255.             New_Window          : PHWND)
  256.                                      return HWND is
  257.  
  258.        Class_Str   : String (Class_Name'first .. Class_Name'last + 1);
  259.        Title_Str   : String (Window_Title'first .. Window_Title'last + 1);
  260.  
  261.        Frame_Value : Aliased ULong := 0;
  262.        Win_Style   : ULong := 0;
  263.        Style       : ULong := 0;
  264.        hwndFrame   : HWND;
  265.  
  266.     begin
  267.       Class_Str (Class_Str'first .. Class_Str'last - 1) := Class_Name;
  268.       Class_Str (Class_Str'last) := Ascii.Nul;
  269.  
  270.       Title_Str (Title_Str'first .. Title_Str'last - 1) := Window_Title;
  271.       Title_Str (Title_Str'last) := Ascii.Nul;
  272.  
  273.       for I in Frame_Control_Flags'range loop
  274.         if Frame_Control_Flags (I) then
  275.            Frame_Value := Frame_Value + Frame_Values (I);
  276.         end if;
  277.       end loop;
  278.  
  279.       for I in Window_Styles'range loop
  280.         if Window_Styles (I) then
  281.            Win_Style := Win_Style + Window_Style_Values (I);
  282.         end if;
  283.       end loop;
  284.  
  285.        for I in Class_Style'range loop
  286.          if Class_Style (I) then
  287.            Style := Style + Win_Style_Values (I);
  288.          end if;
  289.        end loop;
  290.  
  291.  hwndFrame:=   WinCreateStdWindow (
  292.         hwndParent                 => Parent_Window,
  293.         flStyle                    => Win_Style,
  294.         pflCreateFlags             => Frame_Value'unchecked_Access,
  295.         pszClientClass             => Class_Str (Class_Str'first)'address,
  296.         pszTitle                   => Title_Str (Title_Str'first)'address,
  297.         styleClient                => Style,
  298.         hmod                       => Resource,
  299.         idResources                => Resource_Id,
  300.         phwndClient                => New_Window);
  301.  
  302.       return  hwndFrame;
  303.   end Create_Standard_Window;
  304.   ------------------------------------------------
  305.  
  306.    function Failed (Value : Boolean) return Boolean is
  307.      begin
  308.        return not Value;
  309.      end Failed;
  310.   ------------------------------------------------
  311.  
  312.   function To_Boolean   (Void : Void_Type) return Boolean is
  313.     begin
  314.       return Void = 1;
  315.     end To_Boolean;
  316.  
  317.   ------------------------------------------------
  318.   function To_Short     (Void : Void_Type) return Short is
  319.     begin
  320.       return Short (Void);
  321.     end To_Short;
  322.  
  323.   ------------------------------------------------
  324.   function To_U_Short   (Void : Void_Type) return Ushort is
  325.     begin
  326.       return Ushort (Void);
  327.     end To_U_Short;
  328.  
  329.   ------------------------------------------------
  330.   function Parm_to_SPT is new Unchecked_Conversion (
  331.                                  Target => Short_Point_Type,
  332.                                  Source => Win.Parameter_Type);
  333.  
  334.   ------------------------------------------------
  335.   function Is_Null (Window       : HWND) return Boolean is
  336.     begin
  337.       return Window = Null_Window;
  338.     end Is_Null;
  339.  
  340.   ------------------------------------------------
  341.   ------------------------------------------------
  342.   function Is_Null (Bitmap        : Bitmap_Handle_Type) return Boolean is
  343.     begin
  344.       return Bitmap = Null_Bitmap;
  345.     end Is_Null;
  346.  
  347.   ------------------------------------------------
  348.   function Is_Null (Internal_Menu : Internal_Menu_Item_Type) return Boolean is
  349.     begin
  350.       return Internal_Menu = Null_Internal_Menu;
  351.     end Is_Null;
  352.  
  353.   ------------------------------------------------
  354.   function Get_Error_Info (Anchor_Block : Anchor_Block_Handle_Type)
  355.                                      return PErrinfo is
  356.  
  357.     begin
  358.       return WinGetErrorInfo (Anchor_Block);
  359.     end Get_Error_Info;
  360.  
  361.   ------------------------------------------------
  362.   function Get_Last_Error (Anchor_Block : Anchor_Block_Handle_Type)
  363.                                                   return Ulong is
  364.  
  365.  
  366.       Error : Ulong;
  367.     begin
  368.  
  369.       Text_IO.Put ("Ulong Size => ");
  370.       Text_Io.Put_Line (Integer'Image (Ulong'size));
  371.  
  372.       Error := WinGetLastError (Anchor_Block);
  373.       Text_Io.Put ("Error num is ");
  374.       Text_Io.Put_Line (Integer'image (Integer (Error)));
  375.       return Error;
  376.     end Get_Last_Error;
  377.  
  378.   ------------------------------------------------
  379.   function Initialize (
  380.                        Options : Ulong := System_Default
  381.                                        ) return Anchor_Block_Handle_Type  is
  382.  
  383.     begin
  384.  
  385.       return WinInitialize (Options);
  386.     end Initialize;
  387.  
  388.   ------------------------------------------------
  389.   procedure Initialize (
  390.                Options      : in     Ulong := System_Default;
  391.                Anchor_Block :    out Anchor_Block_Handle_Type) is
  392.     begin
  393.       Anchor_Block := Initialize (Options);
  394.       --Currently OS/2 does not use the Anchor_Block parameter.  It is
  395.       --usally set to null and not used.
  396.     end Initialize;
  397.  
  398.   ------------------------------------------------
  399.  
  400.    function Register_Class (Anchor_Block   : Anchor_Block_Handle_Type;
  401.                            Class_Name      : String;
  402.                            Message_Handler : Message_Handler_Function;
  403.                            Class_Style     : Class_Styles_Type;
  404.                            Extra_Storage   : Ushort)
  405.                                                         return Boolean is
  406.  
  407.        Class_Str : String (Class_Name'first .. Class_Name'last + 1);
  408.  
  409.        Style     : Ulong := 0;
  410.  
  411.        Result    : Ulong;
  412.  
  413.     begin
  414.        Class_Str (Class_Str'first .. Class_Str'last - 1) := Class_Name;
  415.        Class_Str (Class_Str'last) := Ascii.Nul;
  416.  
  417.        for I in Class_Style'range loop
  418.          if Class_Style (I) then
  419.            Style := Style + Win_Style_Values (I);
  420.          end if;
  421.        end loop;
  422.  
  423.        Result := WinRegisterClass (
  424.              ha           => Anchor_Block,
  425.              pszClassName => Class_Str (Class_Str'first)'address,
  426.              pfnWndProc   => Message_Handler,
  427.              flStyle      => Style,
  428.              cbWindowData => Ulong(Extra_Storage));
  429.  
  430.        if Result = 1 then   return True; end if;
  431.  
  432.       return False;
  433.  
  434.     end Register_Class;
  435.  
  436.   ------------------------------------------------
  437.  
  438.   procedure Register_Class (Anchor_Block    : Anchor_Block_Handle_Type;
  439.                             Class_Name      : String;
  440.                             Message_Handler : Message_Handler_Function;
  441.                             Class_Style     : Class_Styles_Type;
  442.                             Extra_Storage   : Ushort) is
  443.    begin
  444.     if Register_Class (Anchor_Block,
  445.                        Class_Name,
  446.                        Message_Handler,
  447.                        Class_Style,
  448.                        Extra_Storage) then
  449.       null;
  450.     else
  451.       raise Register_Failed;
  452.     end if;
  453.    end Register_Class;
  454.  
  455.   ------------------------------------------------
  456.  
  457.    Kc_Flag_Values : constant array (Key_Flag_Type) of Ushort :=
  458.        (Kc_None              => 16#0000#,
  459.         Kc_Char              => 16#0001#,
  460.         Kc_Virtual_Key       => 16#0002#,
  461.         Kc_Scan_Code         => 16#0004#,
  462.         Kc_Shift             => 16#0008#,
  463.         Kc_Ctrl              => 16#0010#,
  464.         Kc_Atl               => 16#0020#,
  465.         Kc_Key_Up            => 16#0040#,
  466.         Kc_Previous_Down     => 16#0080#,
  467.         Kc_Lone_Key          => 16#0100#,
  468.         Kc_Dead_Key          => 16#0200#,
  469.         Kc_Composite         => 16#0400#,
  470.         Kc_Invalid_Composite => 16#0800#,
  471.         Kc_Toggle            => 16#1000#,
  472.         Kc_Invalid_Character => 16#2000#,
  473.         Kc_DB_CSR_SR_VD1     => 16#4000#,
  474.         Kc_Db_CSR_SR_VD2     => 16#8000#);
  475.  
  476.  
  477.     function Set_Flags (Key_Flag_Values : Ushort)
  478.                                               return Key_Flags_Type is
  479.        Values : Ushort := Key_Flag_Values;
  480.        Flags  : Key_Flags_Type := (Others => False);
  481.  
  482.     begin
  483.  
  484.        if Key_Flag_Values = 0 then
  485.           Flags (Kc_None) := True;
  486.        else
  487.  
  488.          for I in reverse Flags'range loop
  489.  
  490.            exit when I = Flags'first;
  491.  
  492.            if Values >= Kc_Flag_Values (I) then
  493.               Flags (I) := True;
  494.               Values := Values - Kc_Flag_Values (I);
  495.            end if;
  496.  
  497.          end loop;
  498.        end if;
  499.  
  500.        return Flags;
  501.    end Set_Flags;
  502.  
  503.   ------------------------------------------------
  504.  
  505.    function Set_Virtual_Key (Virtual_Code : Ushort)
  506.                                             return Virtual_Key_Type is
  507.       V_Key : Virtual_Key_Type;
  508.      begin
  509.  
  510.        if Virtual_Code in 16#01# .. 16#38# then
  511.           V_Key := Virtual_Key_Type'Val (Integer (Virtual_Code) - 1);
  512.        else
  513.           V_Key := Vk_Null;
  514.        end if;
  515.  
  516.        if V_Key = Vk_F10 then
  517.           V_Key := Vk_Menu;
  518.        end if;
  519.  
  520.        return V_Key;
  521.      end Set_Virtual_Key;
  522.  
  523.  ------------------------------------------------
  524.  
  525.   type CM_1_Type is
  526.     record
  527.      Flags    : UShort;
  528.      Repeat   : Uchar;
  529.      Scancode : Uchar;
  530.     end record;
  531.  
  532.   function Parm_To_Cm_1 is new Unchecked_Conversion (
  533.                                     Source => Parameter_Type,
  534.                                     Target => Cm_1_Type);
  535.  
  536.   type Cm_2_Type is
  537.     record
  538.      Char_Code    : Ushort;
  539.      Virtual_Code : Ushort;
  540.     end record;
  541.  
  542.   function Parm_To_Cm_2 is new Unchecked_Conversion (
  543.                                     Source => Parameter_Type,
  544.                                     Target => Cm_2_Type);
  545.  
  546.  function Key_Info_Is (Message_Parameter_1 : Parameter_Type;
  547.                        Message_Parameter_2 : Parameter_Type)
  548.                                      return Key_Press_Info_Type is
  549.      Info : Key_Press_Info_Type;
  550.  
  551.      Cm_1 : Cm_1_Type;
  552.      Cm_2 : Cm_2_Type;
  553.  
  554.     begin
  555.  
  556.       Cm_1 := Parm_To_Cm_1 (Message_Parameter_1);
  557.       Cm_2 := Parm_To_Cm_2 (Message_Parameter_2);
  558.  
  559.       Info.Flags          := Set_Flags (Cm_1.Flags);
  560.       Info.Repeat_Count   := Cm_1.Repeat;
  561.       Info.Scan_Code      := Cm_1.Scancode;
  562.  
  563.       Info.Character_Code := Cm_2.Char_Code;
  564.       Info.Virtual_Key    := Set_Virtual_Key (Cm_2.Virtual_Code);
  565.  
  566.       return Info;
  567.  
  568.     end Key_Info_Is;
  569.  
  570.   ------------------------------------------------
  571.  
  572.   type Command_Info_2_Type is
  573.     record
  574.      Source     : Ushort;
  575.      By_Pointer : Ushort;
  576.     end record;
  577.  
  578.   function Parm_To_CI_2 is new Unchecked_Conversion (
  579.                                    Source => Parameter_Type,
  580.                                    Target => Command_Info_2_Type);
  581.  
  582.   function Command_Info_Is (Message_Parameter_1 : Parameter_Type;
  583.                             Message_Parameter_2 : Parameter_Type)
  584.                                           return Command_Info_Type is
  585.      Info   : Command_Info_Type;
  586.      Info_2 : Command_Info_2_Type;
  587.     begin
  588.  
  589.       Info.Id         := Command_Id_Type (Message_Parameter_1);
  590.       Info_2          := Parm_To_Ci_2 (Message_Parameter_2);
  591.       Info.Source     := Command_Source_Values (Info_2.Source);
  592.       Info.By_Pointer := Info_2.By_Pointer = 1;
  593.  
  594.       return Info;
  595.     end Command_Info_Is;
  596.  
  597.   ------------------------------------------------
  598.  
  599.   function Pointer_Is (Parameter : Parameter_Type) return Point_Type is
  600.      Spt : Short_Point_Type;
  601.    begin
  602.      Spt := Parm_To_Spt (Parameter);
  603.      return (Pixel_Type (Spt.X), Pixel_Type (Spt.Y));
  604.    end Pointer_Is;
  605.  
  606.   ------------------------------------------------
  607.  
  608.      type Two_Shorts is
  609.        record
  610.          Short_1 : Ushort;
  611.          Short_2 : Ushort;
  612.        end record;
  613.  
  614.      function Shorts_To_Mp is new Unchecked_Conversion (
  615.                                            Target => Parameter_Type,
  616.                                            Source => Two_Shorts);
  617.  
  618.      function Check_Menu_Item (
  619.               Menu    : HWND;
  620.               Item_Id : Command_Id_Type;
  621.               Check   : Boolean) return Boolean is
  622.  
  623.        Mp_1   : Parameter_Type;
  624.        Mp_2   : Parameter_Type;
  625.  
  626.        Values : Two_Shorts;
  627.  
  628.        Result : Boolean;
  629.  
  630.      begin
  631.  
  632.         Values.Short_1 := Ushort (Item_Id);
  633.         Values.Short_2 := Short_True;
  634.         Mp_1 := Shorts_To_Mp (Values);
  635.  
  636.         Values.Short_1 := MIA_Values (Mia_Checked);
  637.  
  638.         if Check then
  639.           Values.Short_2 := MIA_Values (Mia_Checked);
  640.         else
  641.           Values.Short_2 := Short_False;
  642.         end if;
  643.  
  644.         Mp_2 := Shorts_To_Mp (Values);
  645.  
  646.         Result := To_Boolean (
  647.                     Send_Message (
  648.                         To_Window   => Menu,
  649.                         Message     => MM_Set_Item_Attr,
  650.                         Parameter_1 => Mp_1,
  651.                         Parameter_2 => Mp_2));
  652.  
  653.         return Result;
  654.  
  655.       end Check_Menu_Item;
  656.  
  657.   ------------------------------------------------
  658.  
  659.   function Is_Menu_Item_Checked (
  660.               Menu     : HWND;
  661.               Item_Id  : Command_Id_Type) return Boolean is
  662.     begin
  663.       return False;
  664.     end Is_Menu_Item_Checked;
  665.  
  666.   ------------------------------------------------
  667.  
  668.   function Is_Menu_Item_Enabled (
  669.               Menu     : HWND;
  670.               Item_Id  : Command_Id_Type) return Boolean is
  671.     begin
  672.       return False;
  673.     end Is_Menu_Item_Enabled;
  674.  
  675.   ------------------------------------------------
  676.  
  677.   function Is_Menu_Item_Valid (
  678.               Menu     : HWND;
  679.               Item_Id  : Command_Id_Type) return Boolean is
  680.     begin
  681.       return False;
  682.     end Is_Menu_Item_Valid;
  683.  
  684.   ------------------------------------------------
  685.  
  686.     function Enable_Menu_Item (
  687.               Menu     : HWND;
  688.               Item_Id  : Command_Id_Type;
  689.               Enable   : Boolean) return Boolean is
  690.  
  691.        Mp_1   : Parameter_Type;
  692.        Mp_2   : Parameter_Type;
  693.  
  694.        Values : Two_Shorts;
  695.  
  696.        Result : Boolean;
  697.  
  698.      begin
  699.  
  700.         Values.Short_1 := Ushort (Item_Id);
  701.         Values.Short_2 := Short_True;
  702.         Mp_1 := Shorts_To_Mp (Values);
  703.  
  704.         Values.Short_1 := MIA_Values (Mia_Disabled);
  705.  
  706.         if Enable then
  707.           Values.Short_2 := MIA_Values (Mia_Disabled);
  708.         else
  709.           Values.Short_2 := Short_False;
  710.         end if;
  711.  
  712.         Mp_2 := Shorts_To_Mp (Values);
  713.  
  714.         Result := To_Boolean (
  715.                     Send_Message (
  716.                         To_Window   => Menu,
  717.                         Message     => MM_Set_Item_Attr,
  718.                         Parameter_1 => Mp_1,
  719.                         Parameter_2 => Mp_2));
  720.  
  721.         return Result;
  722.  
  723.       end Enable_Menu_Item;
  724.  
  725.   ------------------------------------------------
  726.  
  727.    function Load_Menu (
  728.                   Owner_Window : HWND;
  729.                   Resource     :  ULong;
  730.                   Menu_Id      : Id_Type) return HWND is
  731.  
  732.  
  733.       Result : HWND;
  734.  
  735.    begin
  736.  
  737.      Result := WinLoadMenu (
  738.                                   Owner_Window,
  739.                                   Resource,
  740.                                   Menu_Id);
  741.  
  742.      return Result;
  743.    end Load_Menu;
  744.  
  745.   ------------------------------------------------
  746.  
  747.    function Convert_Pop_Up_Options (Options : Pop_Up_Options_Type) return Ushort is
  748.      Value : Ushort := 0;
  749.    begin
  750.      for I in Options'range loop
  751.        if Options (I) then
  752.          Value := Value + Pop_Up_Values (I);
  753.        end if;
  754.      end loop;
  755.      return Value;
  756.    end Convert_Pop_Up_Options;
  757.  
  758.   ------------------------------------------------
  759.  
  760.    function Pop_Up_Menu (
  761.         Window       : HWND;
  762.         Frame_Window : HWND;
  763.         Menu_Window  : HWND;
  764.         X            : Pixel_Type;
  765.         Y            : Pixel_Type;
  766.         Item_Id      : Command_Id_Type;
  767.         Options      : Pop_Up_Options_Type) return Boolean is
  768.  
  769.       Result : Ulong;
  770.       opt    : Ulong;
  771.    begin
  772.       opt    := Ulong(Convert_Pop_Up_Options (Options));
  773.       Result := WinPopupMenu (
  774.                    hwndParent => Window,
  775.                    hwndOwner  => Frame_Window,
  776.                    hwndMenu   => Menu_Window,
  777.                    x          => X,
  778.                    y          => Y,
  779.                    idItem     => Long (Item_Id),
  780.                    fs         => opt  );
  781.  
  782.       return Result = 1;
  783.    end Pop_Up_Menu;
  784.  
  785.   -------------------------------------------------------
  786.    procedure Pop_Up_Menu (
  787.         Window       : in HWND;
  788.         Frame_Window : in HWND;
  789.         Menu_Window  : in HWND;
  790.         X            : in Pixel_Type;
  791.         Y            : in Pixel_Type;
  792.         Item_Id      : in Command_Id_Type;
  793.         Options      : in Pop_Up_Options_Type) is
  794.     begin
  795.       if Failed (Pop_Up_Menu (
  796.                    Window       => Window,
  797.                    Frame_Window => Frame_Window,
  798.                    Menu_Window  => Menu_Window,
  799.                    X            => X,
  800.                    Y            => Y,
  801.                    Item_Id      => Item_Id,
  802.                    Options      => Options)) then
  803.          raise Win_Error;
  804.       end if;
  805.     end Pop_Up_Menu;
  806.  
  807.   ------------------------------------------------
  808.  
  809.    function Create_Internal_Menu return Internal_Menu_Item_Type is
  810.      begin
  811.        return new OS2_Menu_Item_Type;
  812.      end Create_Internal_Menu;
  813.  
  814.   ------------------------------------------------
  815.    procedure Reclaim_Internal_Menu is new Unchecked_Deallocation (
  816.                                              OS2_Menu_Item_Type,
  817.                                              Internal_Menu_Item_Type);
  818.  
  819.    procedure Destroy_Internal_Menu (Internal_Menu : in out Internal_Menu_Item_Type) is
  820.      begin
  821.        Reclaim_Internal_Menu (Internal_Menu);
  822.        Internal_Menu := Null_Internal_Menu;
  823.      end Destroy_Internal_Menu;
  824.  
  825.   ------------------------------------------------
  826.  
  827.    function Make_Mia_Value (Atts : Menu_Attributes_Type) return Ushort is
  828.      Value : Ushort := 0;
  829.    begin
  830.  
  831.      for I in Atts'range loop
  832.        if Atts (I) then
  833.          Value := Value + Mia_Values (I);
  834.        end if;
  835.      end loop;
  836.  
  837.      return Value;
  838.    end Make_Mia_Value;
  839.  
  840.   ------------------------------------------------
  841.  
  842.  
  843.    function Convert_To_Internal (Menu_Item : Menu_Item_Type)
  844.                                         return Internal_Menu_Item_Type is
  845.        I_Menu : Internal_Menu_Item_Type;
  846.      begin
  847.        I_Menu := Create_Internal_Menu;
  848.  
  849.        I_Menu.IPosition   := Short (Menu_Item.Position);
  850.        I_Menu.Style       := MIS_Values (Menu_Item.Style);
  851.        I_Menu.Attribute   := Make_MIA_Value (Menu_Item.Attributes);
  852.        I_Menu.Id          := Ushort (Menu_Item.Item_Id);
  853.        I_Menu.SubMenu     := Menu_Item.Sub_Menu;
  854.        I_Menu.Item_Handle := Ulong (Menu_Item.Item_Handle);
  855.  
  856.        return I_Menu;
  857.  
  858.      end Convert_To_Internal;
  859.  
  860.   ------------------------------------------------
  861.  
  862.    function Convert_To_Style (Value : Ushort)
  863.                                          return Menu_Style_Type is
  864.      begin
  865.  
  866.        for I in MIS_Values'range loop
  867.          if MIS_Values (I) = Value then
  868.            return I;
  869.          end if;
  870.        end loop;
  871.  
  872.        return Mis_Text;
  873.      end Convert_To_Style;
  874.  
  875.   ------------------------------------------------
  876.  
  877.    function Convert_To_Attribute (Value : Ushort)
  878.                                        return Menu_Attributes_Type is
  879.       Atts : Menu_Attributes_Type;
  880.       Val  : Ushort := Value;
  881.  
  882.      begin
  883.  
  884.        Atts := (others => False);
  885.        for I in reverse MIA_Values'range loop
  886.  
  887.          if Val >= MIA_Values (I) then
  888.             Atts (I) := True;
  889.             Val := Val - Mia_Values (I);
  890.          end if;
  891.  
  892.        end loop;
  893.  
  894.        return Atts;
  895.  
  896.      end Convert_To_Attribute;
  897.  
  898.   ------------------------------------------------
  899.  
  900.    function Convert_To_External (Menu_Item : Internal_Menu_Item_Type)
  901.                                                   return Menu_Item_Type is
  902.       Data : Menu_Item_Type;
  903.      begin
  904.  
  905.        Data.Position    := Menu_Position_Type (Menu_Item.IPosition);
  906.        Data.Style       := Convert_To_Style (Menu_Item.Style);
  907.        Data.Attributes  := Convert_To_Attribute (Menu_Item.Attribute);
  908.        Data.Item_Id     := Command_Id_Type (Menu_Item.ID);
  909.        Data.Sub_Menu    := Menu_Item.SubMenu;
  910.        Data.Item_Handle := Bitmap_Handle_Type (Menu_Item.Item_Handle);
  911.  
  912.        return Data;
  913.  
  914.      end Convert_To_External;
  915.  
  916.   ------------------------------------------------
  917.  
  918.      function Addr_To_Parm is new Unchecked_Conversion (
  919.                                  Target => Win.Parameter_Type,
  920.                                  Source => System.Address);
  921.  
  922.      function Int_Menu_To_Addr is new Unchecked_Conversion (
  923.                                  Target => Win.Parameter_Type,
  924.                                  Source => Internal_Menu_Item_Type);
  925.  
  926.      function Addr_To_Int_Menu is new Unchecked_Conversion (
  927.                                  Target => Internal_Menu_Item_Type,
  928.                                  Source => System.Address);
  929.  
  930.   ------------------------------------------------
  931.  
  932.    function Query_Menu_Item (
  933.               Menu    : HWND;
  934.               Item_Id : Command_Id_Type) return Menu_Item_Type is
  935.  
  936.       Data    : Menu_Item_Type      ;
  937.       I_Menu  : OS2_Menu_Item_Type;
  938.       Mp_1    : Parameter_Type;
  939.       Mp_2    : Parameter_Type;
  940.       Mp_Data : Two_Shorts;
  941.  
  942.       Good  : Boolean;
  943.      begin
  944.  
  945.       Mp_Data.Short_1 := Ushort (Item_Id);
  946.       Mp_Data.Short_2 := Short_True;
  947.  
  948.       Mp_1 := Shorts_To_Mp (Mp_Data);
  949.       Mp_2 := Addr_To_Parm (I_Menu'address);
  950.  
  951.       Good := To_Boolean (
  952.                   Send_Message (
  953.                     To_Window   => Menu,
  954.                     Message     => MM_Query_Item,
  955.                     Parameter_1 => Mp_1,
  956.                     Parameter_2 => Mp_2));
  957.  
  958.       if Good then
  959.          return Convert_To_External (Addr_To_Int_Menu (I_Menu'address));
  960.       else
  961.          Text_Io.Put_Line ("The Send Message in Query_Menu_Item failed");
  962.          raise Win_Error;
  963.       end if;
  964.  
  965.       return Data;
  966.  
  967.      end Query_Menu_Item;
  968.  
  969.   ------------------------------------------------
  970.  
  971.    procedure Insert_Menu_Item (
  972.                      Menu      : in HWND;
  973.                      Menu_Data : in Menu_Item_Type;
  974.                      Text      : in String) is
  975.  
  976.       I_Menu  : Internal_Menu_Item_Type;
  977.       Mp_1    : Parameter_Type;
  978.       Mp_2    : Parameter_Type;
  979.       Str     : String (Text'first .. Text'last + 1);
  980.  
  981.       Good  : Boolean;
  982.      begin
  983.  
  984.       Str := Text & ASCII.Nul;
  985.  
  986.       I_Menu := Convert_To_Internal (Menu_Data);
  987.  
  988.       Mp_1   := Int_Menu_To_Addr (I_Menu);
  989.       Mp_2   := Addr_To_Parm (Str (Str'first)'address);
  990.  
  991.       Good := To_Boolean (
  992.                   Send_Message (
  993.                     To_Window   => Menu,
  994.                     Message     => MM_Insert_Item,
  995.                     Parameter_1 => Mp_1,
  996.                     Parameter_2 => Mp_2));
  997.  
  998.       if Good then
  999.          null;
  1000.       else
  1001.          Text_Io.Put_Line ("Insert Menu Failed");
  1002.       end if;
  1003.  
  1004.      end Insert_Menu_Item;
  1005.  
  1006.   ------------------------------------------------
  1007.  
  1008.    procedure Delete_Menu_Item (
  1009.                      Menu      : in HWND;
  1010.                      Item_Id   : Command_Id_Type) is
  1011.       Mp_1    : Parameter_Type;
  1012.       Mp_Data : Two_Shorts;
  1013.  
  1014.       Count   : Integer := 0;
  1015.       Good    : Boolean := False;
  1016.      begin
  1017.  
  1018.       Mp_Data.Short_1 := Ushort (Item_Id);
  1019.       Mp_Data.Short_2 := Short_True;
  1020.  
  1021.       Mp_1 := Shorts_To_Mp (Mp_Data);
  1022.  
  1023.       Good := To_Boolean (Send_Message (
  1024.                     To_Window   => Menu,
  1025.                     Message     => MM_Delete_Item,
  1026.                     Parameter_1 => Mp_1,
  1027.                     Parameter_2 => 0));
  1028.       if Good then
  1029.         null;
  1030.       else
  1031.         Text_Io.Put_Line ("Delete Menu Item Failed");
  1032.       end if;
  1033.  
  1034.      end Delete_Menu_Item;
  1035.  
  1036.   ------------------------------------------------
  1037.  
  1038.   function Default_Window_Procedure
  1039.                           (Window              : HWND;
  1040.                            Message             : Message_Type;
  1041.                            Message_Parameter_1 : Parameter_Type;
  1042.                            Message_Parameter_2 : Parameter_Type)
  1043.                                               return Ulong is
  1044.  
  1045.       Result : Ulong;
  1046.     begin
  1047.       Result := WinDefWindowProc (
  1048.                          hwn       => Window,
  1049.                          Msg       => Message,
  1050.                          Mp1       => Ulong(Message_Parameter_1),
  1051.                          Mp2       => Ulong(Message_Parameter_2));
  1052.       return Result;
  1053.  
  1054.     end Default_Window_Procedure;
  1055.  
  1056.   ------------------------------------------------
  1057.  
  1058.   function Window_From_Id (
  1059.             Parent_Window : HWND;
  1060.             Frame_Id      : Frame_Id_Type) return HWND is
  1061.  
  1062.      Window : HWND;
  1063.    begin
  1064.  
  1065.      Window := WinWindowFromId (
  1066.                 hwndParent    => Parent_Window,
  1067.                 id            => Frame_id_Values (Frame_ID));
  1068.  
  1069.      return Window;
  1070.    end Window_From_Id;
  1071.   ------------------------------------------------
  1072.   function Set_Window_Position (
  1073.               Window           : HWND;
  1074.               Behind_Window    : HWND;
  1075.               X                : Device_Screen_Space_Type;
  1076.               Y                : Device_Screen_Space_Type;
  1077.               Width            : Device_Screen_Space_Type;
  1078.               Height           : Device_Screen_Space_Type;
  1079.               Position_Options : Position_Type) return Boolean is
  1080.  
  1081.      Pos_Value : Ulong := 0;
  1082.  
  1083.    begin
  1084.  
  1085.      if Boolean_Value (Position_Options (Swp_Minimize)) +
  1086.         Boolean_Value (Position_Options (Swp_Maximize)) +
  1087.         Boolean_Value (Position_Options (Swp_Restore)) > 1 then
  1088.           raise Min_Max_Restore_Usage_Error;
  1089.      end if;
  1090.  
  1091.      for I in Position_Options'range loop
  1092.        if Position_Options (I) then
  1093.          Pos_Value := Pos_Value + Win_Position_Values (I);
  1094.        end if;
  1095.      end loop;
  1096.  
  1097.      return 0 /= WinSetWindowPos (
  1098.                  hwn                => Window,
  1099.                  hwndInsertBehind   => Behind_Window,
  1100.                  x                  => X,
  1101.                  y                  => Y,
  1102.                  cx                 => Width,
  1103.                  cy                 => Height,
  1104.                   fl                => Pos_Value);
  1105.    end Set_Window_Position;
  1106.  
  1107.   ------------------------------------------------
  1108.  
  1109.   procedure Set_Window_Position (
  1110.               Window           : in HWND;
  1111.               Behind_Window    : in HWND;
  1112.               X                : in Device_Screen_Space_Type;
  1113.               Y                : in Device_Screen_Space_Type;
  1114.               Width            : in Device_Screen_Space_Type;
  1115.               Height           : in Device_Screen_Space_Type;
  1116.               Position_Options : in Position_Type) is
  1117.     begin
  1118.       if Set_Window_Position (Window,
  1119.                               Behind_Window,
  1120.                               X, Y,
  1121.                               Width, Height,
  1122.                               Position_Options) then
  1123.         null;
  1124.       else
  1125.         raise Set_Failed;
  1126.       end if;
  1127.     end Set_Window_Position;
  1128.  
  1129.   ------------------------------------------------
  1130.  
  1131.  function Terminate_App (Anchor : Anchor_Block_Handle_Type) return Boolean is
  1132.  
  1133.    begin
  1134.      return WinTerminate (Anchor) /= 0;
  1135.    end Terminate_App;
  1136.  
  1137.   ------------------------------------------------
  1138.  
  1139.   function Create_Message_Queue (
  1140.               Anchor_Block  : Anchor_Block_Handle_Type;
  1141.               Queue_Size    : Long := System_Default)
  1142.                               return Queue_Handle_Type is
  1143.    begin
  1144.      return WinCreateMsgQueue (Anchor_Block, Queue_Size);
  1145.    end Create_Message_Queue;
  1146.  
  1147.   ------------------------------------------------
  1148.  
  1149.   procedure Create_Message_Queue (
  1150.               Anchor_Block  : in     Anchor_Block_Handle_Type;
  1151.               Queue_Size    : in     Long := System_Default;
  1152.               Queue         :    out Queue_Handle_Type) is
  1153.      Temp_Queue : Queue_Handle_Type := Null_Queue;
  1154.     begin
  1155.       Temp_Queue := Create_Message_Queue (Anchor_Block, Queue_Size);
  1156.  
  1157.       if Is_Null (Temp_Queue) then
  1158.         raise Message_Queue_Was_Not_Created;
  1159.       end if;
  1160.  
  1161.       Queue := Temp_Queue;
  1162.     end Create_Message_Queue;
  1163.  
  1164.   ------------------------------------------------
  1165.  
  1166.   procedure Terminate_App (Anchor : in out Anchor_Block_Handle_Type) is
  1167.     Temp : Boolean;
  1168.    begin
  1169.     Temp   := Terminate_App (Anchor);
  1170.     Anchor := Null_Anchor_Block;
  1171.    end Terminate_App;
  1172.  
  1173.   ------------------------------------------------
  1174.  
  1175.   procedure Destroy_Message_Queue (Message_Queue : in out Queue_Handle_Type) is
  1176.     Temp : Boolean;
  1177.    begin
  1178.      Temp := Destroy_Message_Queue (Message_Queue);
  1179.      --Could add a check here and raise an exception if the message queue is
  1180.      --not destroyed. BJY 1/31/94
  1181.      Message_Queue := Null_Queue;
  1182.    end Destroy_Message_Queue;
  1183.  
  1184.   ------------------------------------------------
  1185.  
  1186.   function Destroy_Message_Queue (Message_Queue : Queue_Handle_Type)
  1187.                                                             return Boolean is
  1188.  
  1189.    begin
  1190.      return WinDestroyMsgQueue (Message_Queue) /= 0;
  1191.    end Destroy_Message_Queue;
  1192.  
  1193.   ------------------------------------------------
  1194.  
  1195.   procedure Destroy_Window (Window : in out HWND) is
  1196.      Temp : Boolean;
  1197.     begin
  1198.      Temp := Destroy_Window (Window);
  1199.      --Could add a check and raise and exception if the windows
  1200.      --is not destroyed.  BJY 1/31/94
  1201.      Window := Null_Window;
  1202.     end Destroy_Window;
  1203.  
  1204.   ------------------------------------------------
  1205.  
  1206.   function Destroy_Window (Window : HWND) return Boolean is
  1207.  
  1208.    begin
  1209.      return WinDestroyWindow (Window) /= 0;
  1210.    end Destroy_Window;
  1211.  
  1212.   ------------------------------------------------
  1213.  
  1214.    function Make_Style (
  1215.             Buttons        : MB_Button_Styles_Type;
  1216.             Icons          : MB_Icon_Styles_Type;
  1217.             Default_Action : MB_Default_Action_Type;
  1218.             Modality       : MB_Modality_Type := MB_Application_Modal;
  1219.             Help_Button    : Boolean          := False;
  1220.             Moveable       : Boolean          := True)
  1221.                                             return Ulong is
  1222.        Style_Value : Ulong := 0;
  1223.      begin
  1224.        Style_Value := Mb_Buttons (Buttons)
  1225.                        + MB_Icons (Icons)
  1226.                         + MB_Action (Default_Action)
  1227.                          + MB_Modality (Modality)
  1228.                           + MB_Help (Help_Button)
  1229.                            + MB_Moveable (Moveable);
  1230.        return Style_Value;
  1231.      end Make_Style;
  1232.  
  1233.   ------------------------------------------------
  1234.  
  1235.   function Message_Box (
  1236.             Parent_Window  : HWND;
  1237.             Request_Owner  : HWND;
  1238.             Message        : String;
  1239.             Title          : String;
  1240.             Help_Id        : Help_Id_Type;
  1241.             Buttons        : MB_Button_Styles_Type;
  1242.             Icons          : MB_Icon_Styles_Type;
  1243.             Default_Action : MB_Default_Action_Type;
  1244.             Modality       : MB_Modality_Type := MB_Application_Modal;
  1245.             Help_Button    : Boolean          := False;
  1246.             Moveable       : Boolean          := True)
  1247.                                             return MB_Response_Type is
  1248.  
  1249.        Response : Ushort;
  1250.        Style    : Ulong;
  1251.  
  1252.        Text_Str  : String (Message'first .. Message'last + 1);
  1253.        Title_Str : String (Title'first .. Title'last + 1);
  1254.  
  1255.     begin
  1256.  
  1257.       Text_Str (Text_Str'first .. Text_Str'last - 1) := Message;
  1258.       Text_Str (Text_Str'last) := AscII.Nul;
  1259.  
  1260.       Title_Str (Title_Str'first .. Title_Str'last - 1) := Title;
  1261.       Title_Str (Title_Str'last) := AscII.Nul;
  1262.  
  1263.       Style := Make_Style (Buttons,
  1264.                            Icons,
  1265.                            Default_Action,
  1266.                            Modality,
  1267.                            Help_Button,
  1268.                            Moveable);
  1269.  
  1270.       Response := Ushort( WinMessageBox (
  1271.                               hwndParent  => Parent_Window,
  1272.                               hwndOwner   => Request_Owner,
  1273.                               pszText     => Text_Str (Text_Str'first)'address,
  1274.                               pszCaption  => Title_Str (Title_Str'first)'address,
  1275.                               idWindow    => Ulong  (Help_Id),
  1276.                               flStyle     => Style)
  1277.                              ) ;
  1278.  
  1279.       if Response in MB_Response'range then
  1280.          return Mb_Response (Response);
  1281.       end if;
  1282.  
  1283.       return Mb_Error;
  1284.  
  1285.     end Message_Box;
  1286.  
  1287.   ------------------------------------------------
  1288.  
  1289.    function Get_Message (
  1290.                Anchor_Block : Anchor_Block_Handle_Type;
  1291.                Message      : Queue_Message_Pointer_Type;
  1292.                Window       : HWND;
  1293.                First        : Ulong;
  1294.                Last         : Ulong) return Boolean is
  1295.  
  1296.      begin
  1297.         return WinGetMsg (Anchor_Block, Message, Window, First, Last) = 1;
  1298.      end Get_Message;
  1299.  
  1300.   ------------------------------------------------
  1301.  
  1302.    procedure Dispatch_Message (
  1303.                Anchor_Block : in Anchor_Block_Handle_Type;
  1304.                Message      : in Queue_Message_Pointer_Type) is
  1305.  
  1306.     Junk : Ulong;
  1307.    PJunk : Mresult:=junk'address;
  1308.  
  1309.    begin
  1310.    PJunk :=  WinDispatchMsg (Anchor_Block, Message);
  1311.    end Dispatch_Message;
  1312.  
  1313.   ------------------------------------------------
  1314.  
  1315.    function Send_Message (
  1316.          To_Window   : HWND;
  1317.          Message     : Message_Type;
  1318.          Parameter_1 : Parameter_Type;
  1319.          Parameter_2 : Parameter_Type) return Void_Type is
  1320.  
  1321.      Result : Void_Type;
  1322.    begin
  1323.      Result := Ulong (WinSendMsg (
  1324.                 hwn         => To_Window,
  1325.                 msg         => Message,
  1326.                 mp1         => Ulong(Parameter_1),
  1327.                 mp2         => Ulong(Parameter_2))
  1328.                ) ;
  1329.  
  1330.  
  1331.      return Result;
  1332.    end Send_Message;
  1333.  
  1334.   ------------------------------------------------
  1335.  
  1336.    function Post_Message (
  1337.          To_Window   : HWND;
  1338.          Message     : Message_Type;
  1339.          Parameter_1 : Parameter_Type;
  1340.          Parameter_2 : Parameter_Type) return Boolean is
  1341.  
  1342.      begin
  1343.        return WinPostMsg (To_Window, Message,
  1344.        Ulong(Parameter_1),
  1345.        Ulong(Parameter_2) ) >0;
  1346.      end Post_Message;
  1347.  
  1348.   ------------------------------------------------
  1349.  
  1350.    function Get_PS (Window : HWND) return Ps_Type is
  1351.  
  1352.      begin
  1353.        return WinGetPS (Window);
  1354.      end Get_Ps;
  1355.  
  1356.   ------------------------------------------------
  1357.  
  1358.  
  1359.    procedure Release_Ps (Ps_Handle : in out Ps_Type) is
  1360.  
  1361.     begin
  1362.       if WinReleasePs (PS_Handle) = 1 then
  1363.          PS_Handle := Null_Ps;
  1364.       end if;
  1365.     end Release_Ps;
  1366.   ------------------------------------------------
  1367. end Win;
  1368.