with os2 ; use os2 ;  
with os2.jba; use os2.jba;  
with os2.dlg; use os2.dlg;
with os2.pmwd; use os2.pmwd ;
with os2.pmwb; use os2.pmwb ;
with os2.pmsc; use os2.pmsc ;
with System.Address_To_Access_Conversions;
with System.Storage_Elements;
package body MAINDP is 
package To_PSWP is new  System.Address_To_Access_Conversions(SWP);
package To_PWIN is new  System.Address_To_Access_Conversions(WINDOW);
mp_1 :System.Storage_Elements.Integer_Address ; 
mp_2 :System.Storage_Elements.Integer_Address ; 
mp1l:Long ; 
mp2l:Long ; 
m_Result : Ulong := 0;
p_Swp    : PSWP ; 
pWin     : PWINDOW ; 
Null_Char: constant character := character'val(0);
Null_str : constant string(1..1) := (others => Null_Char);
fild    : aliased FILEDLG ; -- Dialog Records
hwndMain    : HWND := wMainFrame.h_wnd;     -- Window that owns the file dialog
hwndDlg     : HWND  ;                      -- File dialog window
Flag_ProdInfo : integer := 0;

-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameWndProc                                 Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
function  MainFrameWndProc (h_wnd:HWND;msg:ULONG;mp1:PMPARAM;mp2:PMPARAM)return PMENTRY is
begin null;
mp_1:= System.Storage_Elements.To_Integer(mp1) ; 
mp_2:= System.Storage_Elements.To_Integer(mp2) ; 
mp1l:= Long(SHORT1FROMMP(mp1)); 
mp2l:= Long(SHORT2FROMMP(mp1)); 
    if  msg = WM_GUIGETWINDOW then
        pWin := PWINDOW(To_PWIN.To_Pointer(mp2));  -- address WINDOW
        pWin.all :=  wMainFrame; 
        return 0 ;
    end if ; 
     -- Check if window fully loaded    
     if    wMainFrame.h_wnd   = 0 then 
         return  GuiDefFrameProc (WinDefDlgProc'address , h_wnd, msg, mp1, mp2) ; 
     end if;
     case msg is 
 -- Set help file * 
         when  WM_GUISETHELPFILE => Null ; 
              GuiSetHlpFile (Null_str    ,  0);
 -- Property processing * 
         when  WM_GUIGETPROPERTY => Null ; 
         when  WM_GUISETPROPERTY => Null ; 
               -- break
 -- Window resized/repositioned * 
         when  WM_WINDOWPOSCHANGED => Null ; 
         p_Swp := PSWP(To_PSWP.To_Pointer(mp1));  -- address SWP struct in mp1
         if  (p_Swp.fl and SWP_SIZE)  > 0 then
             GuiBroadcastMsg (h_wnd, WM_GUIPARENTRESIZED,
             System.Null_Address,System.Null_Address ); 
         end if ; 
               -- break
 -- User command processing * 
         when  WM_COMMAND => Null ; 
              case mp1l is 
                  when  IDM_NEWFILE => Null ; 
                       MainFrameNewFileClick  ; 
                        -- break
                  when  IDM_OPENFILE => Null ; 
                       MainFrameOpenFileClick  ; 
                        -- break
                  when  IDM_SAVEFILE => Null ; 
                       MainFrameSaveFileClick  ; 
                        -- break
                  when  IDM_SAVEASFILE => Null ; 
                       MainFrameSaveAsFileClick  ; 
                        -- break
                  when  IDM_EXITMENU => Null ; 
                       MainFrameExitMenuClick  ; 
                        -- break
                  when  IDM_HELPUSING => Null ; 
                       MainFrameHelpUsingClick  ; 
                        -- break
                  when  IDM_HELPINDEX => Null ; 
                       MainFrameHelpIndexClick  ; 
                        -- break
                  when  IDM_HELPCONTENTS => Null ; 
                       MainFrameHelpContentsClick  ; 
                        -- break
                  when  IDM_GENERALHELP => Null ; 
                       MainFrameGeneralHelpClick  ; 
                        -- break
                  when  IDM_PRODUCTIONINFO => Null ; 
                       MainFrameProductionInfoClick  ; 
                        -- break
                  when others => Null;
                        -- break
              end case ;
              return  m_Result ; 
 -- Menu about to display * 
         when  WM_INITMENU => Null ; 
              case mp1l is 
                  when  IDM_HELPMENU => Null ; 
                       MainFrameHelpMenuInit  ; 
                        -- break
              when others => Null;end case ;
               -- break
         when others => Null;
               -- break
     end case ;
     return  GuiDefFrameProc (WinDefDlgProc'address , h_wnd, msg, mp1, mp2) ; 
End MainFrameWndProc ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameOpenFileClick                           Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameOpenFileClick   is
pszFullFile : FullFileStr   := (others => Null_Char); -- File filter string
begin null;
 -- Initialize those fields in the FILEDLG structure that are
 -- used by the application
 --      Fills of Dialog record Fild  ----------------------
 pszFullFile(1..5) :="*.hlp" ;
 InitDlgField(fild => fild, fo => OpenDialog);
 fild.szFullFile := pszFullFile;
 hwndDlg := WinFileDlg(HWND_DESKTOP, hwndMain, fild'unchecked_access);
 if hwndDlg>0 and fild.lReturn = Long(DID_OK) then
    null ;
      -- Upon successful return of a file, open it for reading and
      -- further processing
 end if;
End MainFrameOpenFileClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameExitMenuClick                           Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameExitMenuClick   is
begin null;
     GuiExitApp ( 0); 
End MainFrameExitMenuClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameNewFileClick                            Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameNewFileClick   is
begin null;
     GuiExitApp ( 0); 
End MainFrameNewFileClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameSaveFileClick                           Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameSaveFileClick   is
begin null;
     GuiExitApp ( 0); 
End MainFrameSaveFileClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameSaveAsFileClick                         Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameSaveAsFileClick   is
begin null;
     GuiExitApp ( 0); 
End MainFrameSaveAsFileClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameHelpUsingClick                          Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameHelpUsingClick   is
begin null;
     HelpUsing;
End MainFrameHelpUsingClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameProductionInfoClick                     Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameProductionInfoClick   is
begin null;
     Flag_ProdInfo := 1 ; -- Init means of display ProdInfo window
     GuiSetWindow (wDialog1'unchecked_access, IDD_DIALOG1, WT_DIALOG, Dialog1WndProc'address ,  0);
     if GuiInvokeWindow (wDialog1'unchecked_access,
     wMainFrame'unchecked_access) > 0 then Null; end if;
End MainFrameProductionInfoClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameHelpMenuInit                            Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameHelpMenuInit   is
begin null;
  HelpMenuInit ;
End MainFrameHelpMenuInit ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameHelpIndexClick                          Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameHelpIndexClick   is
begin null;
     HelpIndex  ; 
End MainFrameHelpIndexClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameHelpContentsClick                       Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameHelpContentsClick   is
begin null;
     HelpContents  ; 
End MainFrameHelpContentsClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     MainFrameGeneralHelpClick                        Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure MainFrameGeneralHelpClick   is
begin null;
     HelpGeneral ;
End MainFrameGeneralHelpClick ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     Dialog1WndProc                                   Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
function  Dialog1WndProc (h_wnd:HWND;msg:ULONG;mp1:PMPARAM;mp2:PMPARAM)return PMENTRY is
begin  
mp_1:= System.Storage_Elements.To_Integer(mp1) ; 
mp_2:= System.Storage_Elements.To_Integer(mp2) ; 
mp1l:= Long(SHORT1FROMMP(mp1)); 
mp2l:= Long(SHORT2FROMMP(mp1)); 
    if  msg = WM_GUIGETWINDOW then
        pWin := PWINDOW(To_PWIN.To_Pointer(mp2));  -- address WINDOW
        pWin.all :=  wDialog1; 
        return 0 ;
    end if ; 
     -- Check if window fully loaded    
     if    wDialog1.h_wnd = 0 then 
          return  GuiDefFrameProc (WinDefDlgProc'address , h_wnd, msg, mp1, mp2) ;
     end if;
     case msg is 
 -- Set help file * 
         when  WM_GUISETHELPFILE => Null ; 
              GuiSetHlpFile (Null_str,  0);
 -- Property processing * 
         when  WM_GUIGETPROPERTY => Null ; 
         when  WM_GUISETPROPERTY => Null ; 
               -- break
         when  WM_CONTROLPOINTER => Null ; 
              Flag_ProdInfo := 1 ;  -- Mouse on control Element
               -- break
      -- 
         when  WM_QUERYFOCUSCHAIN  => Null ; -- Mouse
         when  WM_CHAR  => Null ;   --  Pad
              if  Flag_ProdInfo=1 then  Dialog1PushButtonOKClick  ; end if;
               -- break
 -- Window resized/repositioned * 
         when  WM_WINDOWPOSCHANGED => Null ; 
         p_Swp := PSWP(To_PSWP.To_Pointer(mp1));  -- address SWP struct in mp1
         if  (p_Swp.fl and SWP_SIZE)  > 0 then
             GuiBroadcastMsg (h_wnd, WM_GUIPARENTRESIZED,
             System.Null_Address,System.Null_Address ); 
         end if ; 
               -- break
 -- User command processing * 
         when  WM_COMMAND => Null ; 
              case mp1l is 
                  when  IDD_PUSHBUTTONOK => Null ; 
                       Dialog1PushButtonOKClick  ; 
                        -- break
                  when others => Null;
                       Dialog1PushButtonOKClick  ; 
                        -- break
              end case ;
              return  m_Result ; 
    --   when 12 =>
    --          Dialog1PushButtonOKClick ; -- Push button

         when others => Null;
     StaticText (wDialog1'unchecked_access,short'image( SHORT(msg)),IDD_EVENT);
     end case ;
     return  GuiDefFrameProc (WinDefDlgProc'address , h_wnd, msg, mp1, mp2) ; 
End Dialog1WndProc ;
-- ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» 
-- Ί     Dialog1PushButtonOKClick                         Ί 
-- Ί                                                      Ί 
-- ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ 
procedure Dialog1PushButtonOKClick   is
begin null;
     GuiDismissWindow (wDialog1'unchecked_access, 1); 
     Flag_ProdInfo := 0 ; -- Init means of ProdInfo window
End Dialog1PushButtonOKClick ;
End MAINDP ;
