Page 1 of 2

HILITE and Right button in GET problems

Posted: Thu May 11, 2023 9:10 am
by skiman
Hi,

After the HILITE problem with Xbase2.0 and a windows scale of 125% I found the cause was passing the oDialog:drawingarea instead of oDialog, customers are complaining now they can't use the right button in a GET. :x

I can't find a way where everything is working correctly:
1. Hilite of GET on Windows of 125%.
2. Opening dialog has to be centered in the right part of the main dialog.
3. Default behaviour of right mouse click in a get to copy should work.
4. Selecting text of a get with the mouse should work.

These are not very special features in my opinion?

With the below sample you can simulate the problems.

First button with main dialog as parameter:
- Hilite is fine, both on 100 and 125%.
- Centering is wrong.
- Right mouse button and selecting of text is NOT working.

Second button with drawingarea as parameter.
- Hilite has wrong position at 125%.
- Centering is correct.
- Right mouse button and selecting of text is working.

Code: Select all

function hilitesample()
*********************
Local getlist := {} , oStartDialog , lOk := .F. , oLeftBar , getoptions := {}

DCSTATUSBAR oLeftbar WIDTH 300 ALIGN DCGUI_ALIGN_LEFT TYPE XBPSTATIC_TYPE_RAISEDBOX

@ 1,1 dcpushbuttonxp caption "Parameter;oStartDialog" size 20,3 ;
		action {|| showdialog(oStartDialog)} parent oLeftbar
		
@ 7,1 dcpushbuttonxp caption "Parameter;Drawingarea" size 20,3 ;
		action {|| showdialog(oStartDialog:drawingarea)} parent oLeftbar
		
DCGETOPTIONS WINDOWHEIGHT 600 ;
             WINDOWWIDTH 920 ;
		
DCREAD GUI ADDBUTTONS to lOk PARENT @oStartDialog OPTIONS getoptions 

return nil

Function showdialog(oParentDlg)
*******************************
Local getlist := {} , cVar := "Click right button to copy." , getoptions := {}
Local cVar2 := "Try to select text to copy."

@ 1,1 dcsay "Click right button to select:" get cVar sayright saysize 20 getsize 30

@ 3,1 dcsay "Try to select with mouse:" get cVar2 sayright saysize 20 getsize 30

DCGETOPTIONS HILITEGETS GRA_CLR_RED

DCREAD GUI FIT ADDBUTTONS APPWINDOW oParentDlg ;
	EVAL {|o| DC_CenterObject(o) } OPTIONS getoptions 

return nil
I really do hope that there is something wrong with my code so it is easy to solve. Otherwise there is a problem when using the Windows scale. I wasn't aware of this, but it seems as about 25% of our users has this set to 125%.

Re: HILITE and Right button in GET problems

Posted: Sat May 13, 2023 4:47 pm
by bwolfsohn
Years ago, I had a similar issue where 125% scale or, anything other than 100% scale would create display problems. We threw up a dialog box at the start of the program telling the user to change the scale back to 100%.

Doesn't solve or even address the issues you're having, but it is a workaround..

Re: HILITE and Right button in GET problems

Posted: Sat May 13, 2023 5:11 pm
by Auge_Ohr
hi Chris,

how does your XP Manifest look like :?:

you can add this in Manifest

Code: Select all

  <application xmlns="urn:schemas-microsoft-com:asm.v3">
         <windowsSettings> <dpiAware      xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>                     </windowsSettings>
         <windowsSettings> <dpiAwareness  xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2,PerMonitor</dpiAwareness> </windowsSettings>
  </application>
than it doesn´t matter what Scale User have Set ... your App will be always "native" Size

Re: HILITE and Right button in GET problems

Posted: Mon May 15, 2023 12:28 am
by skiman
Hi Jimmy,

I added your suggestion to my manifest file, but the result isn't good. With this modification the icons on my buttons are messed up. I'm using an icon font and it looks as the change in de manifest file is a problem.

Anyway, thanks for the suggestion.

Re: HILITE and Right button in GET problems

Posted: Mon May 15, 2023 12:32 am
by skiman
Hi Brian,
Years ago, I had a similar issue where 125% scale or, anything other than 100% scale would create display problems. We threw up a dialog box at the start of the program telling the user to change the scale back to 100%.
I was wondering how you detected the scale was changed? I tried this with the :getscalefactor but the result is always 1.00.

When I checked the docs and there is the following:
Compatibility note: Xbase Part-based applications normally use a fixed unit system. On physical screens using a different scale factor (DPI), the operating system automatically scales the application UI to the user's preferred scale. For this reason, the value contained in :scaleFactor normally is 1.0.

If I can detect the scale factor I can suppress the HILITEGETS when the scale is different of 1.

Re: HILITE and Right button in GET problems

Posted: Mon May 15, 2023 6:58 am
by Wolfgang Ciriack
Hi Chris,
you can try this function:

Code: Select all

Function GetTextDPI(nArt)
** Returns with nArt=1 DPI, nArt=2 Zoomfactor
LOCAL oPS  := XbpPresSpace():New():Create(AppDesktop():WinDevice(), {100, 100}, GRA_PU_LOENGLISH)
LOCAL aTmp := oPS:SetViewport()

   oPS:Destroy()
   Default nArt to 1
Return (iif(nArt == 1, aTmp[3] - aTmp[1], Round((aTmp[3] - aTmp[1]) / 96, 2)))

Re: HILITE and Right button in GET problems

Posted: Mon May 15, 2023 7:32 am
by bwolfsohn
Chris,

Here's some 20 year old code that MIGHT be how we did it... Haven't looked at any of this since I sold the company 4 1/2 years go.. :)

Code: Select all

*********************
function issmallfonts(lDisplay)
*********************
// Pixels per inch if small or large font is active
#define SMALLFONT 96
#define LARGEFONT 120
// DeviceCap ID to retrieve device pix/inch attribute
#define LOGPIXELSX     88
#define LOGPIXELSY     90

  LOCAL oDesktop := AppDesktop()
  LOCAL hWND
  LOCAL hDC
  LOCAL nLogPix,cMsg
  default lDisplay:=.f.
  IF(ValType(oDesktop)!="O" .AND. !oDesktop:IsDerivedFrom("XbpIWindow"))
    // Non GUI mode
    RETURN(NIL)
  ENDIF
  hWND := oDesktop:GetHWND()
  hDC   := GetDC(hWND)
  IF(hDC==-1)
    // could not aquire device
    RETURN(NIL)
  ENDIF
  nLogPix := GetDeviceCaps(hDC,LOGPIXELSX)
  ReleaseDC(hWND,hDC)
  IF lDisplay
    cMsg:="Font Size is "+dc_xtoc(nLogPix)+" DPI"
    cMsg+=". 96 DPI is the only DPI setting compatible with CUS Software"
    dc_msgbox(cMsg)
  ENDIF

RETURN(nLogPix== SMALLFONT)


Re: HILITE and Right button in GET problems

Posted: Mon May 15, 2023 7:45 am
by skiman
Hi Wolfgang,

Thanks for the code but it isn't working on my system.

The array aTmp is always { 0,0,96,96 } no matter if I set the windows scale to 100, 125 or 150 %.

Re: HILITE and Right button in GET problems

Posted: Mon May 15, 2023 7:55 am
by skiman
Hi Brian,

Thanks to get back to your Xbase code for me instead of backing bread. :)

The result is always 96DPI, no matter which scale I set in Windows.

Re: HILITE and Right button in GET problems

Posted: Mon May 15, 2023 10:00 am
by Auge_Ohr
hi,

i do use DESKTOPHORZRES and LOGPIXELSX to find "Scale" Factor

Code: Select all

#INCLUDE "Common.CH"
#INCLUDE "GRA.CH"

#INCLUDE "ot4xb.CH"
#include "WinUser_constants.ch"
#include "WinGdi_constants.ch"

PROCEDURE MAIN
LOCAL aSize := AppDeskTop():CurrentSize()
LOCAL hDC := @user32:GetDC( HWND_DESKTOP )
LOCAL nXLogPixel := @Gdi32:GetDeviceCaps( hDC, LOGPIXELSX )
LOCAL nYLogPixel := @Gdi32:GetDeviceCaps( hDC, LOGPIXELSY )
LOCAL nVERTRES   := @Gdi32:GetDeviceCaps( hDC, VERTRES    )
LOCAL nHORZRES   := @Gdi32:GetDeviceCaps( hDC, HORZRES    )
LOCAL nDHORZRES  := @Gdi32:GetDeviceCaps( hDC, DESKTOPHORZRES ) // native Monitor Size !
LOCAL nDVERTRES  := @Gdi32:GetDeviceCaps( hDC, DESKTOPVERTRES ) // native Monitor Size !

   @user32:ReleaseDC( HWND_DESKTOP,hDC)

   ? VAR2CHAR(aSize)
   ? "---------------------------"
   ? nXLogPixel, 72/nXLogPixel
   ? nYLogPixel, 72/nYLogPixel
   ? "---------------------------"
   ? "aDesk/nRES "
   ? nHORZRES,nVERTRES
   ? aSize[1]/nHORZRES
   ? aSize[2]/nVERTRES
   ? "---------------------------"
   ? "native Res" 
   ? nDHORZRES, nDVERTRES
   ? nDHORZRES/nHORZRES
   ? nDVERTRES/nVERTRES
   ? "---------------------------"
*   ? "Jan",DPIVerhaeltnis()
*   ? "---------------------------"
*   ? "Wolfgang",GetTextDPI(1),GetTextDPI(2)
WAIT
RETURN

FUNCTION DPIVerhaeltnis
LOCAL oPS := NIL
LOCAL aTmp := {}
   oPS := XbpPresSpace():New():Create( AppDesktop():WinDevice(), ;
                                    {100, 100}, ;                                                  // Genau 1x1 Zoll groß
                                    GRA_PU_LOENGLISH)                                              // Eine Einheit ist 0.01 Inch
   aTmp := oPS:SetViewport()
   oPS:Destroy()
RETURN (aTmp[3] - aTmp[1])

FUNCTION GetTextDPI(art)
** Rückgabe bei art=1 dpi, 2=Zoomfaktor
LOCAL oPS, aTmp
DEFAULT art TO 1
   oPS := XbpPresSpace():New():Create( AppDesktop():WinDevice(), ;
                                       {100,100}, GRA_PU_LOENGLISH )
   aTmp:= oPS:SetViewport()
   oPS:Destroy()
RETURN iif(art=1, aTmp[3]-aTmp[1],round((aTmp[3]-aTmp[1])/96,2))