FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Opcion para activar DPIAwareness
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Opcion para activar DPIAwareness
Posted: Wed Nov 19, 2025 07:39 PM

¿Es correcto?

// c:\fwh\samples\monitor.prg

#include "Fivewin.ch"
#include "Common.ch"

STATIC oFont, oWnd, nDpi

FUNCTION Main()

   LOCAL oIco, oBar, oBmp, oPopUp, oPopUp2, oPopUp3, oPopUp4, oPopUp5, oMenu
   LOCAL oBtn := ARRAY(05)
   LOCAL cWidth := 500, cHeight := 500

   // PRIVATE nDpi
	 	
   nDpi := GetDpiForSystem()

   menu oMenu
      MenuItem "From Code" action FromCode( oWnd )
      MenuItem "From Resource" action FromrES( oWnd )
   endmenu
	
   // DEFINE ICON oIco NAME "A"
   DEFINE ICON oIco FILE "..\icons\fax.ico"

   DEFINE FONT oFont NAME "Tahoma" SIZE 0, ScaleFontSize( -12, nDpi )

   DEFINE WINDOW oWnd TITLE "Prueba MyBox" SIZE 600, 400 ICON oIco PIXEL ;
      menu oMenu

   oWnd:SetFont( oFont )

   DEFINE BUTTONBAR oBar _3D SIZE 50, 40 OF oWnd 2007

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\new.bmp" FLAT            ;
      ACTION ( nil )                                                         ;
      TOOLTIP "Creates a new document"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\open.bmp" FLAT           ;
      ACTION MsgInfo( cGetFile( "*.*", "Select a document to open" ) )       ;
      TOOLTIP "Opens a document" WHEN .f.

   // Aqui Jairo.
   GetnWidthItem( 0.8 ) // Ajusta con un valor < 1, y comprueba 0.8

   MENU oPopUp POPUP 2007 COLORS HEIGHT 2.27 FONT oFont

  MENUITEM "Cadastro de Clientes"                                        ;
     FILENAME "..\bitmaps\16x16\new.bmp"                                 ;
     MESSAGE "Cadastro de Clientes - Pesquisas."                         ;
     ACTION MsgInfo( Time() )

  SEPARATOR
  MENUITEM "Cadastro de Grupos"                                          ;
     FILENAME "..\bitmaps\16x16\open.bmp"                                ;
     MESSAGE "Cadastro de Grupos - Textos Auxiliares."                   ;
     ACTION MsgInfo( Time() )

  SEPARATOR
  MENUITEM "Cadastro de Ferramentas"                                     ;
      FILENAME "..\bitmaps\16x16\printer.bmp"                            ;
     MESSAGE OemToAnsi( "Cadastro de Ferramentas da Proposta" )          ;
     ACTION MsgInfo( Time() )

  SEPARATOR
  MENUITEM "Cadastro de Mão de Obra"                                     ;
     FILENAME "..\bitmaps\16x16\prop.bmp"                                ;
     MESSAGE OemToAnsi( "Cadastro de MÆo de Obra" )                      ;
     ACTION MsgInfo( Time() )

  SEPARATOR
  MENUITEM "Cadastro de Paisagistas"                                     ;
     FILENAME "..\bitmaps\16x16\Help.bmp"                                ;
     MESSAGE OemToAnsi( "Cadastro de Paisagistas da Empresa" )           ;
     ACTION MsgInfo( Time() )

   ENDMENU

   // Aqui Jairo.
   DEFINE BUTTON oBtn[03] OF oBar ACTION oBtn[03]:ShowPopup() FLAT GROUP     ;
      FILENAME "..\bitmaps\16x16\floppy.bmp"                                 ;
      MESSAGE "Saves this document"                                          ;
      TOOLTIP "Saves this document"                                          ;
      MENU oPopup

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\printer.bmp" FLAT GROUP  ;
      ACTION MsgInfo( "Prints this document" ) TOOLTIP "Print this document" 

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\prop.bmp" FLAT GROUP     ;
      ACTION PrinterSetup() TOOLTIP "Setup the printer"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\HelpInd.bmp" FLAT        ;
      ACTION MsgInfo( Version() ) TOOLTIP "A multiple lines" +               ;
      Chr( 13 ) + Chr( 10 ) + "tooltip!" GROUP

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Help.bmp" FLAT           ;
      ACTION MsgInfo( "fivewin power!" ) TOOLTIP "fivewin power!"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT           ;
      ACTION oWnd:End() TOOLTIP "Exit this app" GROUP

   DEFINE MESSAGE OF oWnd ;
      PROMPT FWVERSION + " " + FWCOPYRIGHT ;
      NOINSET CENTERED KEYBOARD DATE CLOCK 2007

   DEFINE BITMAP oBmp FILENAME "..\bitmaps\fiveback.bmp"

   oWnd:bPainted = { | hDC | BmpTiled( hDC, oWnd, oBmp ) }

   ACTIVATE WINDOW oWnd CENTERED // MAXIMIZED

RETURN NIL

Function FromCode( oWnd )

   local oDlg
   local oGet1, oGet2, oGet3, oGet4
   local cVar1, cVar2, cVar3, cVar4
   local lActive := .f.
   

   cVar1 := 0
   cVar2 := 0
   cVar3 := 0
   cVar4 := 0
   

   define dialog oDlg title "From Code" pixel size 300, 300 FONT oFont

   oDlg:lHelpIcon := .F.

   @ 10,10 get oGet1 var cVar1 bitmap "..\bitmaps\on.bmp" action( msginfo( "With Transparent" ) ) of oDlg pixel size 60,12
   @ 40,10 get oGet2 var cVar2 bitmap "..\bitmaps\on.bmp" action( msginfo( "Without Transparent" ) ) of oDlg pixel size 60,12
   @ 70,10 get oGet3 var cVar3 bitmap "..\bitmaps\chkyes.bmp" action( msginfo( "With Adjust-Transparent" ) ) of oDlg pixel size 120,12
   @ 100,10 get oGet4 var cVar4 bitmap "..\bitmaps\chkyes.bmp" ;
   action( if( lActive,oGet3:disable(),oGet3:enable()), lActive:= !lActive, oDlg:update() ) of oDlg pixel size 120,12
   

   oGet1:lBtnTransparent := .t.       // transparent button get oGet1
   

   oGet3:disable()
   oGet3:lBtnTransparent := .t.       // transparent button get oGet3
   oGet3:lAdjustBtn      := .t.       // Button Get Adjust Witdh oGet3
   oGet3:lDisColors      := .f.       // Deactive disable color
   oGet3:nClrTextDis     := CLR_WHITE // Color text disable status
   oGet3:nClrPaneDis     := CLR_BLUE  // Color Pane disable status
   

   oGet4:lAdjustBtn      := .t.
   

   activate dialog oDlg centered
 
return nil
   

Function FromRes( oWnd )

   local oDlg
   local oGet1, oGet2, oGet3, oGet4
   local cVar1, cVar2, cVar3, cVar4
   local lActive := .f.
   

   cVar1 := 0
   cVar2 := 0
   cVar3 := 0
   cVar4 := 0
   

   define dialog oDlg resource "fromres" of oWnd FONT oFont

   oDlg:lHelpIcon := .F.

   redefine get oGet1 var cVar1 id 100 bitmap "on" action( msginfo( "With Transparent" ) ) of oDlg  

   redefine get oGet2 var cVar2 id 101 bitmap "on" action( msginfo( "Without Transparent" ) ) of oDlg 
   redefine get oGet3 var cVar3 id 102 bitmap "chkyes" action( msginfo( "With Adjust-Transparent" ) );
   COLOR CLR_BLACK, CLR_CYAN of oDlg 
   redefine get oGet4 var cVar4 id 103 bitmap "chkyes" ;
   action( if( lActive,oGet3:disable(),oGet3:enable()), lActive:= !lActive, oDlg:update() ) of oDlg 
   

   oGet1:lBtnTransparent := .t.       // transparent button get oGet1
   

   oGet3:disable()
   oGet3:lBtnTransparent := .t.       // transparent button get oGet3
   oGet3:lAdjustBtn      := .t.       // Button Get Adjust Witdh oGet3
   oGet3:lDisColors      := .f.       // Deactive disable color
   oGet3:nClrTextDis     := CLR_WHITE // Color text disable status
   oGet3:nClrPaneDis     := CLR_BLUE  // Color Pane disable status

   oGet4:lAdjustBtn := .t.
   

   activate dialog oDlg centered
 
return nil

STATIC FUNCTION BmpTiled( hDC, oWnd, oBmp )

   local nWidth := oWnd:nWidth(), nHeight := oWnd:nHeight()
   local nRow := 0, nCol := 0, n
   local nBmpWidth  := oBmp:nWidth(),  nBmpHeight := oBmp:nHeight()

   if oBmp:hBitmap == 0
      return nil
   endif

   while nRow < nHeight
      nCol = 0
      while nCol < nWidth
         PalBmpDraw( hDC, nRow, nCol, oBmp:hBitmap )
         nCol += nBmpWidth
      end
      nRow += nBmpHeight
   end

return nil

DLL32 FUNCTION GetDpiForSystem() AS LONG PASCAL LIB "User32.dll"

FUNCTION ScaleFontSize( nBaseSize, nDpi )

RETURN Int( nBaseSize * nDpi / 96 )

// FIN / END

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Opcion para activar DPIAwareness
Posted: Wed Nov 19, 2025 07:41 PM
// c:\fwh\samples\monitor.rc

// RESOURCE SCRIPT generated by "Pelles C for Windows, version 5.00".
#ifndef __64__
  1 24 "winxp\WindowsXP.Manifest" 
#endif

#ifdef __64__
  1 24 "winxp\WindowsXP.Manifest64"
#endif 


FROMRES DIALOG 0, 0, 150, 150
STYLE DS_MODALFRAME | WS_BORDER | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
FONT 8, "MS Sans Serif"
CAPTION "Dialog"
BEGIN
    EDITTEXT        100, 11, 10, 80, 15, ES_AUTOHSCROLL
    EDITTEXT        101, 10, 40, 80, 15, ES_AUTOHSCROLL
    EDITTEXT        102, 9, 70, 129, 17, ES_AUTOHSCROLL
    EDITTEXT        103, 10, 100, 130, 14, ES_AUTOHSCROLL
END

ON BITMAP "..\bitmaps\on.bmp"

CHKYES BITMAP "..\bitmaps\chkyes.bmp"

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Opcion para activar DPIAwareness
Posted: Wed Nov 19, 2025 08:41 PM

sip.

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)

Continue the discussion