hi,
you are right that i have 2 x 400 Size "inside" which must be some "Frame" smaller.
but WINDOW is "smaller" under FiverWin than under Xbase++ or HMG
i have not made RULER under FiveWin yet but here are HMG Code
Code: Select all | Expand
//////////////////////////////////////////////////////////////////////
//
// hruler.prg
//
// Contents:
// Draws a horizontal ruler marked every 5 pixels on the screen
// Units are Top-Down Library columns
// Black line at each column, blue line at midcolumn
//
//////////////////////////////////////////////////////////////////////
#include "hmg.ch"
*+--------------------------------------------------------------------
*+
*+ Function MAIN()
*+
*+--------------------------------------------------------------------
*+
PROCEDURE MAIN
Local aDesk := GetDesktopArea()
Local nDeskWidth := aDesk[3] - aDesk[1]
LOCAL nDeskHeight := aDesk[4] - aDesk[2]
DEFINE WINDOW Win1 ;
AT 0, 0 ;
WIDTH nDeskWidth ;
HEIGHT 100 ;
TITLE "Ruler" ;
ICON "MYHICO" ;
MAIN ;
NOMAXIMIZE ;
NOMINIMIZE ;
NOSIZE ;
ON INIT DoInit() ;
ON PAINT Proc_ON_PAINT()
DEFINE CONTEXT MENU OF Win1
MENUITEM " 10 %" ACTION SetTransparency( 10)
MENUITEM " 20 %" ACTION SetTransparency( 20)
MENUITEM " 30 %" ACTION SetTransparency( 30)
MENUITEM " 40 %" ACTION SetTransparency( 40)
MENUITEM " 50 %" ACTION SetTransparency( 50)
MENUITEM " 60 %" ACTION SetTransparency( 60)
MENUITEM " 70 %" ACTION SetTransparency( 70)
MENUITEM " 80 %" ACTION SetTransparency( 80)
MENUITEM " 90 %" ACTION SetTransparency( 90)
MENUITEM "100 %" ACTION SetTransparency(100)
END MENU
// DEFINE STATUSBAR
// DATE
// CLOCK
// END STATUSBAR
END WINDOW
CENTER WINDOW Win1
ACTIVATE WINDOW Win1
RETURN
STATIC PROCEDURE SetTransparency(nIn)
LOCAL nValue := 255/100
ThisWindow.AlphaBlendTransparent := INT(nValue * nIn)
RETURN
*+--------------------------------------------------------------------
*+
*+ Procedure DoInit()
*+
*+ Called from ( hruler.prg ) 1 - function main()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE DoInit()
LOCAL nValue := 255/100
ThisWindow.AlphaBlendTransparent := INT(nValue * 70)
RETURN
*+--------------------------------------------------------------------
*+
*+ Procedure Proc_ON_PAINT()
*+
*+ Called from ( hruler.prg ) 1 - function main()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE Proc_ON_PAINT
LOCAL Width := BT_ClientAreaWidth( "Win1" )
LOCAL Height := BT_ClientAreaHeight( "Win1" ) - BT_StatusBarHeight( "Win1" )
LOCAL hDC, BTstruct
LOCAL cText
LOCAL i
hDC = BT_CreateDC( "Win1", BT_HDC_INVALIDCLIENTAREA, @BTstruct )
FOR i := 0 TO Width STEP 10
IF ( i % 100 ) = 0
BT_DrawLine( hDC, 100 - 30, i, 35, i, BLACK, 2 )
cText := LTRIM( STR( i ) )
nTypeText := BT_TEXT_TRANSPARENT // BT_TEXT_OPAQUE
nAlingText := BT_TEXT_CENTER + BT_TEXT_TOP
BT_DrawText( hDC, 10, i, cText, "MS Sans Serif", 10, BLUE, { 228, 228, 228 }, nTypeText, nAlingText )
ELSEIF ( i % 50 ) = 0
BT_DrawLine( hDC, 100 - 30, i, 50, i, BLACK, 2 )
ELSE
BT_DrawLine( hDC, 100 - 30, i, 60, i, BLACK, 2 )
ENDIF
NEXT
FOR i := 5 TO Width STEP 10
BT_DrawLine( hDC, 100 - 30, i, 65, i, BLACK, 2 )
NEXT
BT_DeleteDC( BTstruct )
RETURN
STATIC FUNCTION GetDesktopArea()
LOCAL aDesk := {0,0,0,0}
aDesk[3] := GetDesktopWidth()
aDesk[4] := GetDesktopHeight()
RETURN aDesk
*+ EOF: HRULER.PRG
Xbase++ Code
Code: Select all | Expand
#include "Gra.ch"
#include "Xbp.ch"
#include "Appevent.ch"
#include "Font.ch"
#include "OS.ch"
#include "DLL.ch"
#define HWND_DESKTOP 0
#define LOGPIXELSX 88
#define LOGPIXELSY 90
#define DESKTOPVERTRES 117
#define DESKTOPHORZRES 118
DLLFUNCTION GetDeviceCaps(hDC,Index) USING STDCALL FROM GDI32.DLL
DLLFUNCTION GetDC( hDC ) USING STDCALL FROM USER32.DLL
PROCEDURE APPSYS
LOCAL cTitle := "Horizontal Ruler"
LOCAL hWndDlg := DllCall( "User32.dll", DLL_STDCALL, "FindWindowA", 0, cTitle )
IF !( hWndDlg == 0 )
DllCall( "User32.dll", DLL_STDCALL, "SetForegroundWindow", hWndDlg )
DllCall( "User32.dll", DLL_STDCALL, "BringWindowToTop", hWndDlg )
DllCall( "User32.dll", DLL_STDCALL, "ShowWindow", hWndDlg, 1 )
DllCall( "User32.dll", DLL_STDCALL, "UpdateWindow", hWndDlg )
*** It is a second instance.... Bye Bye
QUIT
ENDIF
RETURN
PROCEDURE Main
LOCAL oDlg, oXbp, drawingArea, oPS
LOCAL nEvent, mp1, mp2
LOCAL lIsW98Run
LOCAL hWnd := 0
LOCAL aDesk := AppDesktop():currentSize()
LOCAL aSize := {aDesk[1]-100,62}
LOCAL xDesk := {0,0}
LOCAL aNewPos := {0,0}
LOCAL aPos := {0,0}
LOCAL cText
LOCAL i
LOCAL hDC := GetDC( HWND_DESKTOP )
LOCAL nXLogPixel := GetDeviceCaps( hDC, LOGPIXELSX )
LOCAL nYLogPixel := GetDeviceCaps( hDC, LOGPIXELSY )
LOCAL nDHORZRES := GetDeviceCaps( hDC, DESKTOPHORZRES ) // native Monitor Size !
LOCAL nDVERTRES := GetDeviceCaps( hDC, DESKTOPVERTRES ) // native Monitor Size !
LOCAL nDPi,nFaktor
LOCAL aDragArea
LOCAL nX, nY
LOCAL lMove := .F.
* ------------------------------------------------- *
*
* add Zoll/cm on upper site
*
* ------------------------------------------------- *
// native Monitor Size
xDesk[1] := nDHORZRES
xDesk[2] := nDVERTRES
// Scale
nFaktor := xDesk[1] / aDesk[1]
// up to 125% old style = 120DPi
IF nFaktor < 1.26
nFaktor := 1
ENDIF
// real Pixel / Zoll
nDPi := ROUND(nFaktor*nXLogPixel,0)
// new add Zoll/cm on upper side
aSize[2] := aSize[2]+40
// start Position
aPos := {50,aDesk[2]-aSize[2]}
* ------------------------------------------------- *
IF Os(OS_FAMILY) == "WIN9X"
lIsW98Run := .T. // W98 is running
ELSE
lIsW98Run := .F. // XP is running
ENDIF
oDlg := XbpDialog():new( AppDesktop(), , aPos, aSize, , .F.)
oDlg:taskList := .T.
oDlg:title := "Horizontal Ruler"
oDlg:Border := XBPDLG_NO_BORDER
oDlg:maxButton := .F.
oDlg:minButton := .T.
oDlg:icon :=100
oDlg:drawingArea:rbClick := {|aPos, uNIL, obj| MenuTPZ(hWnd,oDlg,aPos) }
oDlg:create()
hWnd := oDlg:getHWND()
drawingArea := oDlg:drawingArea
drawingArea:setColorBG( GRA_CLR_PALEGRAY )
drawingArea:setFontCompoundName( "8.Arial" )
aNewPos[2] := 20
FOR i := 1 TO aSize[1] STEP 100
IF i = 1
aNewPos[1] := 0
cText := "0"
ELSE
aNewPos[1] := i -12
cText := LTRIM(STR(i-1))
ENDIF
// Pixel
oXbp := XbpStatic():new( drawingArea, , aNewPos, {30,12}, { { XBP_PP_COMPOUNDNAME, "8.MS Sans Serif" } } )
oXbp:caption := cText
oXbp:clipSiblings := .T.
oXbp:options := XBPSTATIC_TEXT_VCENTER+XBPSTATIC_TEXT_LEFT
oXbp:create()
NEXT
oPS := XbpPresSpace():new()
oPS:create( oDlg:drawingArea:winDevice() )
oDlg:drawingArea:paint := {|| DrawGraphic( oPS, aSize, nDPi ) }
IF lIsW98Run
oDlg:show()
ELSE
SetWindowLayered(hWnd,.T.) // Stil setzen
SetWindowTransparency(hWnd,100) // unsichtbar machen
oDlg:show()
SetWindowTransparency(hWnd,100,15) // sichtbar machen
ENDIF
SetAppFocus( oDlg )
nEvent := xbe_None
DO WHILE nEvent <> xbeP_Close
nEvent := AppEvent( @mp1, @mp2, @oXbp )
DO CASE
CASE nEvent == xbeM_LbDown .AND. oXbp:isDerivedFrom("XbpIWindow")
oDlg:drawingArea:setPointer(, XBPSTATIC_SYSICON_WAIT, XBPWINDOW_POINTERTYPE_SYSPOINTER )
aDragArea := GetCursorPos()
aPos := oDlg:currentpos()
nX := aDragArea[ 1 ] - aPos[ 1 ]
nY := aDragArea[ 2 ] - aPos[ 2 ]
aDragArea[ 1 ] -= nX
aDragArea[ 2 ] -= nY
//
// set to Cursor Position
//
oDlg:setPos( aDragArea )
oDlg:drawingArea:setPointer(, XBPSTATIC_SYSICON_MOVE, XBPWINDOW_POINTERTYPE_SYSPOINTER )
oDlg:drawingArea:captureMouse( .T. )
lMove := .T.
CASE nEvent == xbeM_Motion .AND. oXbp:isDerivedFrom("XbpIWindow")
IF lMove = .T.
aDragArea := GetCursorPos()
aDragArea[ 1 ] -= nX
aDragArea[ 2 ] -= nY
oDlg:setPos( aDragArea )
ENDIF
CASE nEvent == xbeM_LbUp .AND. oXbp:isDerivedFrom("XbpIWindow")
//
//
//
aDragArea := GetCursorPos()
aDragArea[ 1 ] -= nX
aDragArea[ 2 ] -= nY
oDlg:setPos( aDragArea )
SETAPPFOCUS( oDlg )
oDlg:drawingArea:setpointer(, XBPSTATIC_SYSICON_ARROW, XBPWINDOW_POINTERTYPE_SYSPOINTER )
oDlg:drawingArea:captureMouse( .F. )
lMove := .F.
OTHERWISE
oXbp:handleEvent( nEvent, mp1, mp2 )
ENDCASE
ENDDO
RETURN
PROCEDURE DrawGraphic( oPS, aSize, nDPI )
LOCAL aAttr[ GRA_AA_COUNT], i
LOCAL n
aAttr[GRA_AA_COLOR] := GRA_CLR_BLACK
GraSetAttrLine(oPS, aAttr)
for i = 0 to aSize[1] step 10
graline( oPs, {i, 0}, {i, if(i % 100 = 0, 20, if(i % 50 = 0, 16, 12))})
next
aAttr[GRA_AL_COLOR] := GRA_CLR_BLUE
GraSetAttrLine(oPS, aAttr)
for i = 5 to aSize[1]-5 step 10
graline( oPs, {i, 0}, {i, 8})
next
* ------------------------------------------------- *
*
* add Zoll/cm on upper site
*
* ------------------------------------------------- *
FOR i = 0 to aSize[1] step 1
IF (i % ROUND(nDPI/25.4*10/2,0) = 0) // 0.5 cm
aAttr[GRA_AL_COLOR] := GRA_CLR_BLUE
GraSetAttrLine(oPS, aAttr)
Graline( oPs, {i, 60}, {i,72})
ENDIF
IF (i % ROUND(nDPI/25.4*10,0) = 0) // 1 cm
aAttr[GRA_AL_COLOR] := GRA_CLR_RED
GraSetAttrLine(oPS, aAttr)
Graline( oPs, {i, 55}, {i,72})
ENDIF
IF (i % nDPI = 0) // 1 Zoll
aAttr[GRA_AL_COLOR] := GRA_CLR_CYAN
GraSetAttrLine(oPS, aAttr)
Graline( oPs, {i, 40}, {i,72})
ENDIF
NEXT
RETURN
*
* eof
*
i do NOT agree about ALT+PrintScreen -> Paste into PAINT that SIZE is "wrong"
your Sample want 400,600 but got 394,587 under FiveWin 22.07 ( BCC7 32 Bit )
PAINT and my both RULER show same Size 394,587 which is (much) smaller than expect 400,600
---
open PAINT and make a Bitmap with 400 x 600 Color RED
start you App and move it over Bitmap
you will "see" RED Backgound of Bitmap while FiveWin App does NOT cover hole Area
so what i´m doing wrong
