Silverfrost Forums

Welcome to our forums

WINDOWS 8.1 and Microsoft Surface Pro Tablet

13 Jan 2014 12:02 #13531

Has anyone tried running a Fortran95 program on a tablet running Windows 8.1.

I tried this simple program which creates a window and a menu. The program crashes when I try operate the menu by touch or stylus. It works fine with a Mouse.

I have written the program for both Fortran 95 and C++ compilers and get the same problem.

It also crashes when using Visual Studio and Fortran95 express to build the executable.

Below is the Fortran program listing.

  external t
  integer t
  I=WINIO@('%ca[A TEST WINDOW FOR TOUCH MENU]&')
  I=WINIO@('%sz&',1000,500) 
  I=WINIO@('%sp&',200,200) 
  i=winio@('%mn[Alpha,Beta[beta1,beta2,beta3],Gamma]',t,t,t,t,t)
  STOP
  END

  integer function t()
  call msg(' menu item selected')
  t=1
  return
  end

  SUBROUTINE MSG(STR)

c----------------- win32 api --------------------------------------- STDCALL MESSAGEBOX 'MessageBoxA' (VAL,REF,REF,VAL)
&:INTEGER4 PARAMETER( MB_SYSTEMMODAL=Z'1000') CHARACTER STR(*) ISTATUS =MESSAGEBOX(0,STR,'test'//char(0), MB_SYSTEMMODAL) RETURN END

13 Jan 2014 5:32 #13536

Are you using the latest release of FTN95?

13 Jan 2014 6:07 #13538

Paul

I have downloaded personal editions of both FTN95 (V7.00.0) and FTN95 express for this test.

14 Jan 2014 8:31 #13541

Does a simple Fortran, program Work?

14 Jan 2014 3:36 #13544

I have tried using the touch screen with a large program ,which exhibits the same problem i.e. it is fine with the mouse, but it can be made to crash when selecting the menu by touch.

I have also ported to the tablet an old version of 'paintshop pro version 6' which according to the 'About' screen was built in 1999. This works fine with touch.

I have tried a c++ program in which I have registered the application window for WM_TOUCH messages. The programs window procedure recognises the WM_TOUCH messages ok, but still crashes when selecting the menu by touch.

The program listing is shown below.-

// Touch test

#include <windows.h>

#ifndef WINVER #define winver 0x0601 #endif

// trial code #define WM_TOUCH 0x0240 #define WM_GESTURE 0x0119

WINUSERAPI BOOL WINAPI RegisterTouchWindow(HWND hwnd, ULONG ulFlags);

LRESULT WINAPI MainWndProc( HWND, UINT, WPARAM, LPARAM );

int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,win_int);

int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,win_int nCmdShow) { HWND hWnd; HWND ParentHandle;
WNDCLASS wc;
DWORD WindowStyle; wchar_t *Alpha =L'Alpha' ; wchar_t *Beta =L'Beta' ; wchar_t *Beta1 =L'Beta1' ; wchar_t *Beta2 =L'Beta2' ; wchar_t *Beta3 =L'Beta3' ; wchar_t *Gamma =L'Gamma' ; int xtop,ytop,xbottom,ybottom; char caption[50]; MSG Msg;
strcpy(caption,'Touch test');
xtop =300; ytop =300; xbottom = 800; ybottom = 800; ParentHandle =NULL; WindowStyle = WS_OVERLAPPEDWINDOW |WS_VSCROLL |WS_HSCROLL |WS_VISIBLE |WS_MAXIMIZE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

if (!hPrevInstance) 
  {
   wc.style =  CS_VREDRAW| CS_HREDRAW ;
   wc.lpfnWndProc = MainWndProc;
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hInstance = hInstance;
   wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 
   wc.hCursor = NULL; /* set by mouse movement */
   wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);; 
   wc.lpszMenuName =  NULL ;
   wc.lpszClassName = 'TouchClass';
   if (!RegisterClass(&amp;wc)) 
       MessageBox(NULL,'Unable to Register Class','touchclass',MB_OK) ;
 }
  hWnd = CreateWindow(
    'touchclass',
    caption,    
    WindowStyle,
    xtop,
    ytop,
    xbottom,
    ybottom,
    ParentHandle,
    NULL,
    hInstance,
    NULL
    );

// trial code // RegisterTouchWindow(hWnd,0);

ShowWindow(hWnd, nCmdShow); 

// Menu HMENU TheMenu = CreateMenu(); AppendMenuW(TheMenu, MF_STRING,1,Alpha); HMENU BetaMenu = CreatePopupMenu(); AppendMenuW(BetaMenu, MF_STRING,21,Beta1); AppendMenuW(BetaMenu, MF_STRING,22,Beta2); AppendMenuW(BetaMenu, MF_STRING,23,Beta3); AppendMenuW(TheMenu,MF_POPUP,(UINT)BetaMenu,Beta); AppendMenuW(TheMenu, MF_STRING,3,Gamma); SetMenu(hWnd,TheMenu);

while (GetMessage(&amp;Msg, NULL,0,0))
  {
   TranslateMessage(&amp;Msg);
   DispatchMessage(&amp;Msg);
  }               
return 0;

}

LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) { switch (message)
{ case WM_DESTROY: PostQuitMessage(0); // case WM_TOUCH: // MessageBox(0,'TOUCH','touched',MB_OK); case WM_GESTURE: MessageBox(0,'GESTURE','touched',MB_OK); case WM_COMMAND: switch(wParam) { case 1: MessageBox(0,'MENU HIT Alpha','touched',MB_OK); return (0); case 3: MessageBox(0,'MENU HIT Gamma','touched',MB_OK); return (0); case 21: MessageBox(0,'MENU HIT Beta1','touched',MB_OK); return (0); case 22: MessageBox(0,'MENU HIT Beta2','touched',MB_OK); return (0); case 23: MessageBox(0,'MENU HIT Beta3','touched',MB_OK); return (0); }

    default:  return DefWindowProc(hWnd,message,wParam,lParam) ;
  }
 

}

14 Jan 2014 3:39 #13545

The windows procedure got truncated imn my last reply - Here is what it should be.

LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) { switch (message)
{ case WM_DESTROY: PostQuitMessage(0); // case WM_TOUCH: // MessageBox(0,'TOUCH','touched',MB_OK); case WM_GESTURE: MessageBox(0,'GESTURE','touched',MB_OK); case WM_COMMAND: switch(wParam) { case 1: MessageBox(0,'MENU HIT Alpha','touched',MB_OK); return (0); case 3: MessageBox(0,'MENU HIT Gamma','touched',MB_OK); return (0); case 21: MessageBox(0,'MENU HIT Beta1','touched',MB_OK); return (0); case 22: MessageBox(0,'MENU HIT Beta2','touched',MB_OK); return (0); case 23: MessageBox(0,'MENU HIT Beta3','touched',MB_OK); return (0); }

    default:  return DefWindowProc(hWnd,message,wParam,lParam) ;
  }
 

}

14 Jan 2014 5:15 #13546

I have just tried one of the clearwin examples that comes with the compiler. It is Treeview.exe which I built using visual studio that comes with the latest version of FTN95 express.

It has a small menu which crashes the program when selected by touch or stylus. Ok with mouse.

The error message is a floating point stack fault

14 Jan 2014 8:12 #13548

I am thinking that this could be a Microsoft Windows problem. Is there a way for you to test without using SCC or FTN95?

15 Jan 2014 5:24 #13560

I have now downloaded a trial version of Visual Studio 2012.

I created a project using the same 'c++' code as in the listing above, and compiled and linked it with the Microsoft C++ compiler and linker.

The executable runs fine on the tablet.

The only changes needed were an additional include file

#include 'stdafx.h'

and conversion of the 8bit ascii text to wide characters (16bit ISO code)

eg. wchar_t *Beta2 =L'Beta2' ;

17 Jan 2014 8:10 #13568

I will see what can be done about this. I don't have access to a suitable device at the moment but I might be able to let you have a debug version of the dll. This, hopefully will provide you with a full trace back on failure.

23 Jan 2014 9:23 #13607

I have created a debug version of salflibc.dll but this does not add anything to the trace back.

Two things...

  1. Can you try using the latest beta version of salflibc.dll by downloading from http://www.silverfrost.com/beta/salflibc.exe.

  2. If there is no improvement, can you post the trace back that you get on failure.

23 Jan 2014 4:53 #13613

I have tried the beta salflibc.dll and the program still crashes.

I get a message box (call stack/status) - Invalid floating point operation

The trace back heading is unknown (in ninput.dll)

751588ee FSTP [EBF-0X10] 751588f1 TEST EC, 0x800 751588fd JE 75179BA9 etc....

Is there a better way of posting a traceback to you. I took a screenshot of the screen but could not see a way of attaching it to this post.

24 Feb 2014 7:11 #13754

This may not make any difference but your interface for MessageBox differs from that in win32api.ins. The REFs become INSTRINGs.

25 Feb 2014 10:32 #13762

Quoted from FLEXPLAN3D I get a message box (call stack/status) - Invalid floating point operation

The trace back heading is unknown (in ninput.dll)

751588ee FSTP [EBF-0X10] 751588f1 TEST EC, 0x800 751588fd JE 75179BA9 etc....

To me, it seems like the code inside the ninput.dll is causing a floating point exception and don't restore the floating point state before returning control to the user program.

Have you tried disabling (masking) the floating point exceptions before calling functions inside the dll? Also it may be possible that DLL_PROCESS_ATTACH handler is re-enabling the floating point exceptions, so you are out of luck.

25 Feb 2014 4:02 #13763

Jalih

Does your test program use the original sample but with a corrected interface for MessageBox?

26 Feb 2014 8:29 #13764

Quoted from PaulLaidler

Does your test program use the original sample but with a corrected interface for MessageBox?

Hi Paul,

I haven't actually run any test program, as I don't have Windows 8.1 and hardware supporting touch or stylus input.

I am just guessing, that this is a Windows touchscreen drivers issue based on the callstack info provided. My guess is that floating point state is not cleaned properly in the touchscreen drivers and FTN95 program sees the error flag and thinks that it has done something wrong.

I know this is a bad practice but as a temporary hack, could the programs exception handler just ignore the error and continue program execution?

26 Feb 2014 11:55 #13766

By the way (this may not be directly related to this subj post), Jalih, do you think that this is same cause which crashed your parallelization method when usually unnoticeable underflow took place?

27 Feb 2014 9:00 #13770

I have taken the message box out all together and the program still crashes when a menu item is touched.

The c++ version of the program (listed near the top of this post) crashes in the same way.

So it is not anything to do with ftn95 or clearwin, but the ninput.dll which handles touch and stylus input.

I noticed on the MSDN forum that someone else has a similar problem

Here is a link

http://social.msdn.microsoft.com/Forums/vstudio/en-US/16f33575-500a-4564-acd3-b857b6ffe643/windows-81-pen-touch-tablet-crash?forum=vcgeneral

10 Mar 2014 9:05 #13817

I have found that if I add a 'getmessage' loop to the simple menu program which dispatches the message to the window procedure then the menu works fine with touch and stylus.

Have you any thoughts on why this should be so.

      include <windows.ins>
      external t 
      integer t,msg(20)
      common msg
      I=WINIO@('%ca[A TEST WINDOW FOR TOUCH MENU]&') 
      I=WINIO@('%sz&',1000,500) 
      I=WINIO@('%sp&',200,200) 
      i=winio@('%mn[Alpha,Beta[beta1,|,beta2,beta3],Gamma]&',t,t,t,t,t)  
      i=winio@('%lw',ictrl)

1     if(getmessage(msg,0,0,0))then
        if(msg(2).eq.WM_COMMAND)call messagebox
     * (0,'send message to window proc','wm_command',0)
        call dispatchmessage(msg)
        if(ictrl.ne.0)goto 1      
      endif
      STOP 
      END 

    


      integer function t() 
      include <windows.ins>
      integer hwnd,wparam,lparam,msg(20)
      character str*512
      common msg
      write(str,*)'hwnd=',msg(1),
     *    ' wparam=',msg(3),' lparam=',msg(4)
      call messagebox(0,str,'menu',0)
      t=1 
      return 
      end 
10 Mar 2014 12:21 #13821

Try this before the first executable statement

      external ifloat_callback
      I=TRAP_EXCEPTION@(FLT_OVERFLOW, ifloat_callback)
]

and

Create a dummy callback

      integer*4 function ifloat_callback()
      ifloat_callback = 1
      print *,'Floating overflow'
      end
Please login to reply.