Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

PeekMessage causing freeze

$
0
0

I am using PeekMessage to get a keyboard input.

On my computer this works fine but on some computers and with Windows10 it is causing a freeze and the user has to do 'Ctrl Alt Delete'.

I feel as if some resource or memory is getting filled. I have include the code below. I removed the ClipCursor call in case it was causing the problem.

Can you suggest what the problem could be.

Thanks 

        SUBROUTINE GETCHA (K)
!       ----------------------------------------------------------------
!       GET KEYPRESS RETURN WITH VALUE IN K

  use grad_inc

  include 'cgipar.gcb' ! FKEY
       
  type (T_MSG) msg
  
  integer*2 i,iext,k
  integer(bool)   bRet
  logical*4   lret
  

  !!lret=ClipCursor (rectmain) ! to keep cursor within drawing area to stop selecting other option

   10 bRet=PeekMessage (msg,hWndMain,WM_LBUTTONUP,WM_RBUTTONUP,PM_REMOVE) ! LRbutton getcha
  if (bret==1) then
      ! valid message
   if (msg%message==WM_LBUTTONUP) then
    k=32 ! space
    goto 90
   elseif (msg%message==WM_RBUTTONUP) then
    k=184 ! f9
    goto 90
   endif
  endif
!  next function changed from getmessage to peekmessage 22 Dec
  bret=PeekMessage (msg,hWndMain,WM_KEYDOWN,WM_KEYDOWN,PM_REMOVE) ! keydown getcha
  if (bret==1) then
      ! valid message
   k=127
   i=msg%wParam                ! virtual key code
   iext=btest(msg%lParam,24)   ! extended key flag
   if (iext==-1) then  ! changed from if (iext==1) then
    ! arrow key
    if (i==37) then         ! left arrow    VK_LEFT 0025
     k=-76
    elseif (i==38) then     ! up arrow      VK_UP 0026
     k=-85
    elseif (i==39) then     ! right arrow   VK_RIGHT 0027
     k=-82
    elseif (i==40) then     ! down arrow    VK_DOWN 0028
     k=-68
    else
     k=-i
    endif
   else
    if (i>=112.AND.i<=123) then     ! function keys VK_F1 0077 to VK_F12 007B
     k=fkey(i-111) 
    elseif (i>=44.AND.i<=90) then   ! normal keys including 0-9 & A-Z
     k=i
    elseif (i<33) then              ! special keys
     k=i
    elseif (i>=96.AND.i<=105) then  ! numeric keypad 
     k=i-48
    elseif (i>=106.AND.i<=111) then ! maths keys
     k=i-64
    elseif (i>187) then             ! special keys
     k=i-144
    else
     k=i
    endif
    if (k==27) k=184 ! Esc = f9 abort 1/11/02 David Graham
   endif
  else
   ! no messagaes
   k=0
   goto 10
  endif

90      continue
        !!lret=ClipCursor (NULL)
  return
  end subroutine

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>