Changing with and height of a window and a dialog

Re: Changing with and height of a window and a dialog

Postby Antonio Linares » Thu Nov 05, 2015 8:18 pm

Gale,

As a first idea I think that we could use FWH functions ScreenWidth() and ScreenHeight() and a timer to control rotation.

I am thinking how to avoid the use of the timer...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Changing with and height of a window and a dialog

Postby Antonio Linares » Thu Nov 05, 2015 8:25 pm

Gale,

Could you try this example and rotate the tablet ?

Please let me know if it beeps when you rotate it, thanks

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd
   
   DEFINE WINDOW oWnd
   
   oWnd:bResized = { || MsgBeep() } 
    
   ACTIVATE WINDOW oWnd MAXIMIZED   

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Changing with and height of a window and a dialog

Postby Gale FORd » Thu Nov 05, 2015 8:53 pm

i will try it later. just thinking about it, if you want to try it without adding to handleevent then it might be better on paint. i am not sure the dialog/window size changes unless keyboard is visible and sometimes not even then. Windows 7 keyboard undocked does not resize dialog or screen.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Changing with and height of a window and a dialog

Postby Antonio Linares » Thu Nov 05, 2015 9:07 pm

Gale,

Then you may change in my example:

oWnd:bPainted = { || MsgBeep() }

thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Changing with and height of a window and a dialog

Postby Gale FORd » Fri Nov 06, 2015 10:06 pm

bPainted does get called when you rotate display. bResized does not get called.
I cannot get accurate screen sizes when I use bPainted. screenwidth() and screenheight() are not always correct. Maybe it has something to do with buffer/dispbegin().
One of the things I need to do when screen is rotated is change the dialog/window position and size. This also affects bPainted.
If i modify tDialog with bOnRotate and I check screenwidth() and screenheight() in bOnRotate it returns correct sizes.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Changing with and height of a window and a dialog

Postby nageswaragunupudi » Sat Nov 07, 2015 5:58 am

We know we can easily ascertain Protrait / Landscape mode by comparing ScreenWidth() and ScreenHeight(). If the application window is maximized on Tablet, rotation restults in Resize event and our normal ON RESIZE can react to the change. Whether the window is maximized or not, rotation defintely generates WM_DISPLAYCHANGE message. We can respond to that message.

There is another change we need to know and respond. In Windows 10, whether on Desktop or Tablet, user can toggle between Desktop and Tablet mode. When the user switches from DeskTop to Tablet mode, normal window automatically gets maximized (generates resize event) and we may need to consider switching to Universal App look in this case and vice versa. This toggle generates WM_SETTINGCHANGE message. In response to this message, we need to ascertain whether the pc/tablet is in Desktop mode or Tablet mode. In other words, we can be in Desktop mode on a Tablet and Tablet Mode on Desktop.

We can find this from the registry entry HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell\TabletMode". If the value is 1, then TabletMode is true. But the problem is it takes around one or two seconds for this entry to be updated after we receive the WM_SETTINGCHANGE message. So we need to query this value after a slight delay.

Here is a sample program which responds to rotation and also change in desktop/tablet mode (in case of windows 10 only). Incidentally, this program also detects presence of Touch screen and Mouse.

Code: Select all  Expand view
#include "fivewin.ch"

#define SM_TABLETPC             86
#define WM_DISPLAYCHANGE    0x007E
#define WM_SETTINGCHANGE    WM_WININICHANGE
#ifndef SM_DIGITIZER
#define SM_DIGITIZER            94
#endif
#define SM_CMOUSEBUTTONS        43

static cMsg  := ""
static oTimer
static cLog

//----------------------------------------------------------------------------//

function Main()

   local oWnd
   local oFont

   cLog  := cFileSetExt( ExeName(), "log" )
   FErase( cLog )

   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-30

   oWnd  := TMyWindow():New()
   oWnd:SetColor( CLR_WHITE, CLR_GREEN )

   oWnd:bRClicked          := { || oWnd:Refresh() }
   oWnd:bOnDisplayChange   := { || oWnd:Refresh(), 0 }
   oWnd:bOnSettingChange   := { || WaitRefresh( oWnd ) }

   ACTIVATE WINDOW oWnd CENTERED ;
      ON PAINT oWnd:SayText( cMsg := DisplayMessage( oWnd ), , , oFont ) ;
      ON RESIZE ( oWnd:Refresh() )

   RELEASE FONT oFont

   if oTimer != nil
      oTimer:End()
   endif

   if File( cLog )
      WinExec( "notepad.exe " + cLog )
   endif

return nil

//----------------------------------------------------------------------------//

static function WaitRefresh( ownd )

   static n := 0

   if oTimer == nil
      DEFINE TIMER oTimer OF oWnd INTERVAL 400 ;
         ACTION ( n++, oWnd:Refresh(), If( n > 4, (oTimer:End(), oTimer := nil, n := 0), nil ) )
      ACTIVATE TIMER oTimer
   endif

return nil

//----------------------------------------------------------------------------//

static function DisplayMessage( oWnd )

   local lPortrait   := ScreenWidth() < ScreenHeight()
   local lTabletMode := IsTabletMode()
   local lTouch      := ( GetSysMetrics( SM_DIGITIZER ) > 0 )

   cMsg  := If( IsWindows10(), If( lTabletMode, "TABLET MODE", "DESKTOP MODE" ) + CRLF, "" )

   cMsg  += If( lPortrait,   "POTRAIT", "LANDSCAPE" ) + CRLF + ;
            If( IsZoomed( oWnd:hWnd ), "MAXIMIZED", "NORMAL" ) + " WINDOW" + CRLF + ;
            If( lTouch, "", "NO " ) + "TOUCH INPUT" + CRLF + ;
            "MOUSE" + If( GetSysMetrics( SM_CMOUSEBUTTONS ) > 0, "", " NOT" ) + " PRESENT"

return cMsg

//----------------------------------------------------------------------------//

CLASS TMyWindow FROM TWindow

   CLASSDATA lRegistered

   DATA bOnDisplayChange
   DATA bOnSettingChange

   METHOD HandleEvent( nMsg, nWParam, nLParam )

ENDCLASS

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow

   do case
   case nMsg == WM_DISPLAYCHANGE
      if ValType( ::bOnDisplayChange ) == 'B'
         return Eval( ::bOnDisplayChange, Self, nWParam, nLParam )
      endif
   case IsWindows10() .and. nMsg == WM_SETTINGCHANGE
      if ValType( ::bOnSettingChange ) == 'B'
         return Eval( ::bOnSettingChange, Self, nWParam, nLParam )
      endif
   endcase

return ::Super:HandleEvent( nMsg, nWParam, nLParam )

//----------------------------------------------------------------------------//
 


Tested on Windows 10 Desktops (touch and without touch screen) and Windows 10 Tablet.

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10622
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Changing with and height of a window and a dialog

Postby Gale FORd » Sun Nov 08, 2015 3:07 am

Is the function IsTabletMode() in later vesrion of FWH?
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Changing with and height of a window and a dialog

Postby nageswaragunupudi » Sun Nov 08, 2015 3:10 am

Gale FORd wrote:Is the function IsTabletMode() in later vesrion of FWH?

Yes.
This is the source code:
Code: Select all  Expand view
function IsTabletMode()


   local oReg, lTabletMode := .f.

   if IsWindows10()

      oReg:= TReg32():New( HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell" )
      lTabletMode := ( oReg:Get( "TabletMode", 0 ) > 0 )

   endif

return lTabletMode
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10622
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Changing with and height of a window and a dialog

Postby Gale FORd » Mon Nov 09, 2015 5:38 pm

Thank you for your help.
I still have some small issue. One of the reasons I need this is to change the dialog size and re-position some controls. Without a timer in bOnDisplayChange the ScreenWidth() and ScreenHeight() are not always correct if the on-screen keyboard is displayed.
If the on-screen keyboard is not displayed then it seems to work ok.
I modified your code and added lUseWait and some resize code. If you left click mouse or touch with finger it swaps lUseWait.
With lUseWait = .T. the ScreenWidh() and ScreenHeight() works correctly. With lUseWait = .f. it is not always correct with on-screen keyboard visible .
I am using a Panasonic Toughpad FZ-G1 with Windows 7 and a Microsoft Surface Pro 3 with Windows 10.

Code: Select all  Expand view
#include "fivewin.ch"

#define SM_TABLETPC             86
#define WM_DISPLAYCHANGE    0x007E
#define WM_SETTINGCHANGE    WM_WININICHANGE
#ifndef SM_DIGITIZER
#define SM_DIGITIZER            94
#endif
#define SM_CMOUSEBUTTONS        43

static cMsg  := ""
static oTimer
static cLog
static lUseWait

//----------------------------------------------------------------------------//

function Main()

   local oWnd
   local oFont

   lUseWait := .t.

   cLog  := cFileSetExt( ExeName(), "log" )
   FErase( cLog )

   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-30

   oWnd  := TMyWindow():New()
   oWnd:SetColor( CLR_WHITE, CLR_GREEN )

   oWnd:bRClicked          := { || oWnd:Refresh }
   oWnd:blClicked          := { || ( lUseWait := !luseWait, oWnd:Refresh() ) }
   oWnd:bOnDisplayChange   := { || WaitReSize( oWnd, 'DispChange' ), 0 }
   //oWnd:bOnDisplayChange   := { || oWnd:Refresh(), 0 }
   oWnd:bOnSettingChange   := { || WaitRefresh( oWnd ) }

   ACTIVATE WINDOW oWnd CENTERED on INIT WaitReSize( oWnd, 'Init' );
      ON PAINT oWnd:SayText( cMsg := DisplayMessage( oWnd ), , , oFont ) ;
      ON RESIZE ( oWnd:Refresh() )

   RELEASE FONT oFont

   if oTimer != nil
      oTimer:End()
   endif

   if File( cLog )
      WinExec( "notepad.exe " + cLog )
   endif

return nil

//----------------------------------------------------------------------------//

static function WaitRefresh( ownd )

   static n := 0
   TraceSize( 'WaitRefresh' )
   if oTimer == nil
      DEFINE TIMER oTimer OF oWnd INTERVAL 400 ;
         ACTION ( n++, oWnd:Refresh(), If( n > 4, (oTimer:End(), oTimer := nil, n := 0), nil ) )
      ACTIVATE TIMER oTimer
   endif

return nil

static function WaitResize( oWnd, cAction )
   static n := 0
   if lUseWait
      if oTimer == nil
         DEFINE TIMER oTimer ;
         INTERVAL 400 ACTION ( n++, if( n = 1, ReSize( oWnd, cAction ), (oTimer:End(), oTimer := nil, n := 0) ) )
         oTimer:Activate()
      endif
   else
      ReSize( oWnd, cAction )
   endif
return nil

Static function ReSize( oWnd, cAction )
   local nTop, nLeft, nWidth, nHeight
   //sysrefresh()
   TraceSize( cAction )
   nTop := 40
   nLeft := 40
   nWidth := ScreenWidth() - ( nLeft*2 )
   nHeight := ScreenHeight() - ( nTop*2 )
   oWnd:Move( nTop, nLeft, nWidth, nHeight )
   oWnd:Refresh()
return nil

Static Function TraceSize( cAction )
   tracelog( cAction, lUseWait, ScreenWidth(), ScreenHeight(), ScreenWidth() < ScreenHeight() )
return nil

//----------------------------------------------------------------------------//

static function DisplayMessage( oWnd )

   local lPortrait   := ScreenWidth() < ScreenHeight()
   local lTabletMode := IsTabletMode()
   local lTouch      := ( GetSysMetrics( SM_DIGITIZER ) > 0 )

   cMsg  := If( IsWindows10(), If( lTabletMode, "TABLET MODE", "DESKTOP MODE" ) + CRLF, "" )

   cMsg  += If( lPortrait,   "POTRAIT", "LANDSCAPE" ) + CRLF + ;
            If( IsZoomed( oWnd:hWnd ), "MAXIMIZED", "NORMAL" ) + " WINDOW" + CRLF + ;
            If( lTouch, "", "NO " ) + "TOUCH INPUT" + CRLF + ;
            "MOUSE" + If( GetSysMetrics( SM_CMOUSEBUTTONS ) > 0, "", " NOT" ) + " PRESENT" + CRLF + ;
            If( lUseWait,   "USE WAIT", "NO WAIT" ) + CRLF

return cMsg

//----------------------------------------------------------------------------//

CLASS TMyWindow FROM TWindow

   CLASSDATA lRegistered

   DATA bOnDisplayChange
   DATA bOnSettingChange

   METHOD HandleEvent( nMsg, nWParam, nLParam )

ENDCLASS

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow

   do case
   case nMsg == WM_DISPLAYCHANGE
      if ValType( ::bOnDisplayChange ) == 'B'
         return Eval( ::bOnDisplayChange, Self, nWParam, nLParam )
      endif
   case IsWindows10() .and. nMsg == WM_SETTINGCHANGE
      if ValType( ::bOnSettingChange ) == 'B'
         return Eval( ::bOnSettingChange, Self, nWParam, nLParam )
      endif
   endcase

return ::Super:HandleEvent( nMsg, nWParam, nLParam )

//----------------------------------------------------------------------------//
#define  HKEY_CURRENT_USER       2147483649

function IsTabletMode()
   local oReg, lTabletMode := .f.
   if IsWindows10()
      oReg:= TReg32():New( HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell" )
      lTabletMode := ( oReg:Get( "TabletMode", 0 ) > 0 )
      oReg:Close()
   endif
return lTabletMode

#define  HKEY_LOCAL_MACHINE  2147483650  // 0x80000002

function IsWindows10()
   local oReg := TReg32():New( HKEY_LOCAL_MACHINE,;
                               "SOFTWARE\Microsoft\Windows NT\CurrentVersion",;
                               .f. )
   local cProductName := oReg:Get( "ProductName" )
   oReg:Close()
return "Windows 10" $ cProductName
 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Changing with and height of a window and a dialog

Postby Gale FORd » Mon Nov 09, 2015 10:52 pm

Here is another issue. With Windows 10 the On Screen Keyboard does not adjust screenheight(). So it makes no difference if the keyboard is visible or not. You have to know whether the on screen keyboard is visible in order to make a correct window size. The only way I have found to check it is to use IsWindowEnabled(). Any other way does not work with Windows 10 because it is always running and the position is still withing the window.
With Windows 7, screenheight() does get adjusted if keyboard is visable. So I think something like below will work for Windows 10 and Windows 7. I think Windows 8 will work like windows 10 but have not tried it.

Code: Select all  Expand view

// To Check if Keyboard on Screen
      if IsWindows10() .or. IsWin8()
         lReturn := IsWindowEnabled( hWndInputPanel )
      else
         lReturn := IsWindowVisible( hWndInputPanel )
      endif
// To get the correct screen height. IsKeyBoardVisible() is a function that contains code above. See full examples in code at end of this post.
  if IsKeyboardVisible() .and. ( IsWindows10() .or. IsWin8() )
      hWndInputPanel := FindWindow("IPTip_Main_Window")
      aCoord := GetWndRect( hWndInputPanel )
      nHeight := aCoord[ 1 ] - 1
   else
      nHeight := ScreenHeight()
   endif

 


So a complete working example that seems to work under Windows 7 and Windows 10 that adjusts window size when tablet is rotated.
You can test the affect the wait has with on screen keyboard by pressing or clicking on the window to toggle wait timer.

Code: Select all  Expand view
#include "fivewin.ch"

#define SM_TABLETPC             86
#define WM_DISPLAYCHANGE    0x007E
#define WM_SETTINGCHANGE    WM_WININICHANGE
#ifndef SM_DIGITIZER
#define SM_DIGITIZER            94
#endif
#define SM_CMOUSEBUTTONS        43

static cMsg  := ""
static oTimer
static cLog
static lUseWait

//----------------------------------------------------------------------------//

function Main()

   local oWnd
   local oFont

   lUseWait := .t.

   cLog  := cFileSetExt( ExeName(), "log" )
   FErase( cLog )

   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-30

   oWnd  := TMyWindow():New()
   oWnd:SetColor( CLR_WHITE, CLR_GREEN )

   oWnd:bRClicked          := { || oWnd:Refresh }
   oWnd:blClicked          := { || ( lUseWait := !luseWait, oWnd:Refresh() ) }
   oWnd:bOnDisplayChange   := { || WaitReSize( oWnd, 'DispChange' ), 0 }
   //oWnd:bOnDisplayChange   := { || oWnd:Refresh(), 0 }
   oWnd:bOnSettingChange   := { || WaitRefresh( oWnd ) }

   ACTIVATE WINDOW oWnd CENTERED on INIT WaitReSize( oWnd, 'Init' );
      ON PAINT oWnd:SayText( cMsg := DisplayMessage( oWnd ), , , oFont ) ;
      ON RESIZE ( oWnd:Refresh() )

   RELEASE FONT oFont

   if oTimer != nil
      oTimer:End()
   endif

   if File( cLog )
      WinExec( "notepad.exe " + cLog )
   endif

return nil

//----------------------------------------------------------------------------//

static function WaitRefresh( ownd )

   static n := 0
   TraceSize( 'WaitRefresh' )
   if oTimer == nil
      DEFINE TIMER oTimer OF oWnd INTERVAL 400 ;
         ACTION ( n++, oWnd:Refresh(), If( n > 4, (oTimer:End(), oTimer := nil, n := 0), nil ) )
      ACTIVATE TIMER oTimer
   endif

return nil

//----------------------------------------------------------------------------//

static function DisplayMessage( oWnd )

   local lPortrait   := ScreenWidth() < ScreenHeight()
   local lTabletMode := IsTabletMode()
   local lTouch      := ( GetSysMetrics( SM_DIGITIZER ) > 0 )
   local lKeyboardVisible := IsKeyboardVisible()

   cMsg  := If( IsWindows10(), If( lTabletMode, "TABLET MODE", "DESKTOP MODE" ) + CRLF, "" )

   cMsg  += If( lPortrait,   "POTRAIT", "LANDSCAPE" ) + CRLF + ;
            If( IsZoomed( oWnd:hWnd ), "MAXIMIZED", "NORMAL" ) + " WINDOW" + CRLF + ;
            If( lTouch, "", "NO " ) + "TOUCH INPUT" + CRLF + ;
            "MOUSE" + If( GetSysMetrics( SM_CMOUSEBUTTONS ) > 0, "", " NOT" ) + " PRESENT" + CRLF + ;
            If( lUseWait,   "USE WAIT", "NO WAIT" ) + CRLF + ;
            If( lKeyboardVisible,   "Keyboard Visable", "Keyboard Not Visable" )

return cMsg

//----------------------------------------------------------------------------//

CLASS TMyWindow FROM TWindow

   CLASSDATA lRegistered

   DATA bOnDisplayChange
   DATA bOnSettingChange

   METHOD HandleEvent( nMsg, nWParam, nLParam )

ENDCLASS

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow

   do case
   case nMsg == WM_DISPLAYCHANGE
      if ValType( ::bOnDisplayChange ) == 'B'
         return Eval( ::bOnDisplayChange, Self, nWParam, nLParam )
      endif
   case IsWindows10() .and. nMsg == WM_SETTINGCHANGE
      if ValType( ::bOnSettingChange ) == 'B'
         return Eval( ::bOnSettingChange, Self, nWParam, nLParam )
      endif
   endcase

return ::Super:HandleEvent( nMsg, nWParam, nLParam )

//----------------------------------------------------------------------------//

static function WaitResize( oWnd, cAction )
   static n := 0
   if lUseWait
      if oTimer == nil
         DEFINE TIMER oTimer ;
         INTERVAL 400 ACTION ( n++, if( n = 1, ReSize( oWnd, cAction ), (oTimer:End(), oTimer := nil, n := 0) ) )
         oTimer:Activate()
      endif
   else
      ReSize( oWnd, cAction )
   endif
return nil

Static function ReSize( oWnd, cAction )
   local nTop, nLeft, nWidth, nHeight
   local lIsKeyboardVisible := IsKeyboardVisible()
   //sysrefresh()
   TraceSize( cAction )
   nTop := 40
   nLeft := 40
   nWidth := ScreenWidth() - ( nLeft*2 )
   nHeight := MyScreenHeight() - ( nTop*2 )   //ScreenHeight() - ( nTop*2 )
   oWnd:Move( nTop, nLeft, nWidth, nHeight )
   oWnd:Refresh()
return nil

Static Function TraceSize( cAction )
   tracelog( cAction, if( lUseWait, 'UseWait', 'NotUseWait' ), if( gIsLandscape(), 'LandScape','Portrait' ), ScreenWidth(), ScreenHeight(), MyScreenHeight() )
return nil


#define  HKEY_CURRENT_USER       2147483649

function IsTabletMode()
   local oReg, lTabletMode := .f.
   if IsWindows10()
      oReg:= TReg32():New( HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell" )
      lTabletMode := ( oReg:Get( "TabletMode", 0 ) > 0 )
      oReg:Close()
   endif
return lTabletMode

#define  HKEY_LOCAL_MACHINE  2147483650  // 0x80000002

function IsWindows10()
   local oReg := TReg32():New( HKEY_LOCAL_MACHINE,;
                               "SOFTWARE\Microsoft\Windows NT\CurrentVersion",;
                               .f. )
   local cProductName := oReg:Get( "ProductName" )
   oReg:Close()
return "Windows 10" $ cProductName

function IsKeyboardVisible()
   Local hWndInputPanel
   Local aCoord
   Local lReturn := .f.
   hWndInputPanel := FindWindow("IPTip_Main_Window")
   aCoord := GetWndRect( hWndInputPanel )
   if hWndInputPanel != 0
      if IsWindows10() .or. IsWin8()
         lReturn := IsWindowEnabled( hWndInputPanel )
      else
         lReturn := IsWindowVisible( hWndInputPanel )
      endif
      tracelog( 'Check Keyboard', if( lUseWait, 'UseWait', 'NotUseWait' ), if( gIsLandscape(), 'LandScape','Portrait' ), ScreenWidth(), ScreenHeight(), aCoord[1], aCoord[2], aCoord[3], aCoord[4],  if( lReturn, 'Keyboard Visible', 'Keyboard Not Visible' ) )
   endif
return lReturn

function MyScreenHeight()
   Local hWndInputPanel
   Local aCoord
   Local nHeight
   Local lReturn := .f.
   if IsKeyboardVisible() .and. ( IsWindows10() .or. IsWin8() )
      hWndInputPanel := FindWindow("IPTip_Main_Window")
      aCoord := GetWndRect( hWndInputPanel )
      nHeight := aCoord[ 1 ] - 1
   else
      nHeight := ScreenHeight()
   endif
return nHeight

function gIsLandscape()
return( screenwidth() > screenheight() )


Code: Select all  Expand view
 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Changing with and height of a window and a dialog

Postby Gale FORd » Mon Nov 09, 2015 11:04 pm

The previous post works correctly if the on screen keyboard is docked. Some adjustments may need to be made if keyboard is not docked. Windows 7 looks like it works ok as is.
We would need to find out if keyboard docked on Windows 10 and 8.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Changing with and height of a window and a dialog

Postby cnavarro » Mon Nov 09, 2015 11:53 pm

Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Changing with and height of a window and a dialog

Postby Gale FORd » Tue Nov 10, 2015 1:58 am

Thanks for your input but we are way past that. We are talking about tablets when they rotate, not just starting the keyboard.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Changing with and height of a window and a dialog

Postby nageswaragunupudi » Tue Nov 10, 2015 2:16 am

If our window/dialog is is in maximized mode, when the tablet is rotated, the window is automatically resized to fit the new orientation. We do not need to recalculate the dimensions of the window. I personally prefer to keep our program code to the minimum and depend more on the system.

Should we resize our window when the OSK popsup?

The normal practice on tablets is to have all windows/dialogs maximized and to keep input controls on the top half of the Window so that OSK, when pops up, does not cover the input controls. It is a good idea to keep input controls on the top and pure display controls on the bottom of the window. Please note that even on desktops, when the user switches from desktop mode to tablet mode, the window gets automatically maximized.

On rotation, we may still need to reposition some controls. For this purpose, we do not depend on ScreenHeight(), ScreenWidth() but on ClientRect of the window. That is accurate. This adjustment can be done in normal On Resize clause.

Note: We are also considering relative coordinate system for controls in future versions. Example:
@ 40, 0.25 GET ....... SIZE 0.50,20 PIXEL OF oWnd. (The meaning should be obvious)
With this change, we need not write specific code in our program in response to changes in modes / rotations.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10622
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Changing with and height of a window and a dialog

Postby Gale FORd » Tue Nov 10, 2015 2:55 am

even if the dialog is maximized screenheight() still has to be calculated to find the control positions so they are visible with on screen keyboard. Then you have popup dialog boxes that are not maximized. The problem of on screen keyboard and screen size will always be important.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 61 guests