HILITE and Right button in GET problems

This forum is for eXpress++ general support.
Message
Author
skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

HILITE and Right button in GET problems

#1 Post 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%.
Best regards,

Chris.
www.aboservice.be

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: HILITE and Right button in GET problems

#2 Post 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..
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
Auge_Ohr
Posts: 1406
Joined: Wed Feb 24, 2010 3:44 pm

Re: HILITE and Right button in GET problems

#3 Post 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
greetings by OHR
Jimmy

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: HILITE and Right button in GET problems

#4 Post 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.
Best regards,

Chris.
www.aboservice.be

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: HILITE and Right button in GET problems

#5 Post 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.
Best regards,

Chris.
www.aboservice.be

Wolfgang Ciriack
Posts: 479
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: HILITE and Right button in GET problems

#6 Post 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)))
_______________________
Best Regards
Wolfgang

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: HILITE and Right button in GET problems

#7 Post 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)

Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: HILITE and Right button in GET problems

#8 Post 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 %.
Best regards,

Chris.
www.aboservice.be

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: HILITE and Right button in GET problems

#9 Post 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.
Best regards,

Chris.
www.aboservice.be

User avatar
Auge_Ohr
Posts: 1406
Joined: Wed Feb 24, 2010 3:44 pm

Re: HILITE and Right button in GET problems

#10 Post 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))
greetings by OHR
Jimmy

Post Reply