How to show a defined Dialog-Pos in relation to Window ?

How to show a defined Dialog-Pos in relation to Window ?

Postby ukoenig » Tue Jun 03, 2008 9:57 am

Hello,

during some tests, i wanted to show a dialog on
a defined position in a window.
As a sample : the top / left-pos. of the dialog in the center of the window
The calculated top and left for the dialog are not
shown on the position, where expected.

Screen : 720 x 576
oDlg:Move( 288, 360, oDlg:nWidth, oDlg:nHeight, .f. ), ;
( Top / Left of dialog to be shown on screen-center )

Image

Is there a way, to do a correct calculation for it ?

Best regards

Uwe :lol: [/img]
Last edited by ukoenig on Tue Jun 03, 2008 11:35 am, edited 2 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Antonio Linares » Tue Jun 03, 2008 11:14 am

Uwe,

Have you tried with oDlg:Center( [oWndParent] ) ?

where oWndParent is an optional parameter
regards, saludos

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

Defined Dialog-Pos

Postby ukoenig » Tue Jun 03, 2008 11:29 am

Antonio, thank you for the reply

I still have to test your solution

As well, i checked the screen-resolution and values :
( there was something wrong on my sample )
For screen 1024 x 768

Code: Select all  Expand view  RUN

ACTIVATE DIALOG oDlg ;
ON INIT ( oDlg:Move( 384, 512, oDlg:nWidth, oDlg:nHeight, .f. ) )



That looks much better
Top / left of the dialog starts at the window-center :

Image

But it seems, it is not 100 % the calculated position ?

The reason for all this is :
I want to make it possible, to draw frames, underlines and more
with alpha-bmp's in relation to any object in a resource.
a working sample : a alpha-bmp placed to the 4 corners of a xbrowse.
In the moment, I'm preparing a nice collection of frames, borders and underlines as alpha-bmp's for the forum.

Image

World.bmp resized and used as a Browser-background
Image

For this, i have to do a exact calculation.
To use Alpa-Bmp's for lines it would be nice,
the bmp could be adjusted with < bottom and right >
to the related resource.
like :
ABPaint( hDC1, Top, Left, Bottom, Right, oBmp3:hBitmap, 220 )

The complete calculation sample :

Code: Select all  Expand view  RUN

#include "FiveWin.ch"
#include "InKey.ch"
#include "xbrowse.ch"

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

FUNCTION Main()

local oWnd, oBmp, hDC, oBmp2, aCORS

DEFINE BITMAP oBmp2 FILENAME "World.bmp"
DEFINE BRUSH oBmp RESOURCE "Background"

DEFINE WINDOW oWnd TITLE "New TXBrowse class (only for FWH)" ;
BRUSH oBmp ;
MENU BuildMenu( oWnd, oBmp2 ) MDI ;
MENUINFO 3

SET MESSAGE OF oWnd TO FWVERSION + ", " + FWCOPYRIGHT CENTERED TIME DATE

ACTIVATE WINDOW oWnd MAXIMIZED ;
ON PAINT ABPaint( hDC, 10, 10, oBmp2:hBitmap, 220 ) // 0-255 transparency level

RETURN NIL

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

function BuildMenu( oWnd, oBmp2 )

local oMenu
local cFile

cFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "readme.txt"

MENU oMenu
         MENUITEM "Dialog browse" ACTION NewDialog( oWnd, oBmp2 )
ENDMENU

RETURN oMenu

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

STATIC FUNCTION NewDialog( oWnd, oBmp2 )

local oDlg, oBrw, hDC1, oBmp3, hWnd

DEFINE BITMAP oBmp3 FILENAME "World.bmp"

DEFINE DIALOG oDlg RESOURCE "TEST" OF oWnd

*aCORS := GetCoors( oWnd:hWnd )
*MsgAlert( aCORS[1] )

oBrw := TXBrowse():New( oWnd )

REDEFINE XBROWSE oBrw ID 101  ;
HEADERS "An array", "test" ;
OF oDlg ;
ARRAY { { "first", "row" }, { "second", "row" } } AUTOCOLS

// GETCOORS
// 4 elements: { 1 = nTop, 2 = nLeft, 3 = nBottom, 4 = nRight }

ACTIVATE DIALOG oDlg ;
ON INIT ( oDlg:Move( 150, 200, oDlg:nWidth, oDlg:nHeight, .f. ) ) ;
ON PAINT (  hDC1 := oDlg:GetDC(), ;
     aRect1 := GETCOORS( oBrw:hWnd ), ;
     nTOPPOS := oBrw:nTop, ;
     nLEFTPOS := oBrw:nLeft, ;
     nBOTTOMPOS := nTOPPOS + ( aRect1[3] - aRect1[1] ), ;
     nRIGHTPOS := nLEFTPOS + ( ( aRect1[4] - aRect1[2] ) ), ;
     ABPaint( hDC1, nLEFTPOS-50, nTOPPOS-50, oBmp3:hBitmap, 220 ), ;
     ABPaint( hDC1, nRIGHTPOS-50, nTOPPOS-50, oBmp3:hBitmap, 220 ), ;
    ABPaint( hDC1, nLEFTPOS-50, nBOTTOMPOS-50, oBmp3:hBitmap, 220 ), ;
    ABPaint( hDC1, nRIGHTPOS-50, nBOTTOMPOS-50, oBmp3:hBitmap, 220 )  )

RETURN NIL



Best regards

Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 83 guests