With the reduced sample code I show how you can center a dlg on a window. The problem I now have is that the dialog may be dragged outside of its parent window. It gives the impression that it is not attached to it. The dialog should get cropped as it is dragged outside its owner boundaries.
Try this code and after opening the dialog by clicking on the only menu option, drag the dialog around, you will see that it moves anywhere including outside its parent window.
#include "fivewin.ch"
FUNCTION MAIN
LOCAL oWnd, oMenu
LOCAL x := 1024
LOCAL y := 780
LOCAL xi := INT( x * 0.10 / 2 )
LOCAL yi := INT( y * 0.10 / 2 )
x := INT( x * 0.90 ) + xi
y := INT( y * 0.90 ) + yi
MENU oMenu
MenuItem "Dialog" ACTION ShowDlgOnWnd( "Sample Text", oWnd )
ENDMENU
DEFINE WINDOW oWnd MDI FROM yi, xi TO y, x PIXEL Title "Testing Dlg On Wnd" MENU oMenu
ACTIVATE WINDOW oWnd
RETURN NIL
//-------------------------------------------------------
FUNCTION ShowDlgOnWnd( cText, oOwner )
LOCAL oDlg, nTop, nLeft
LOCAL bCenterDlg
DEFINE DIALOG oDlg ;
OF oOwner;
RESOURCE "SampleDlg" ;
TRANSPARENT ;
COLOR CLR_WHITE , RGB(240,240,240)
bCenterDlg := {|| oOwner:CoorsUpdate(), ;
nTop := oOwner:nHeight /2 - oDlg:nHeight /2,;
nLeft:= oOwner:nWidth / 2 - oDlg:nWidth /2 + oOwner:nLeft,;
oDlg:Move( nTop, nLeft ) }
REDEFINE SAY PROMPT cText ID 1 OF oDlg TRANSPARENT COLOR CLR_BLACK
REDEFINE BUTTONBMP ID 2 OF oDlg BITMAP "exit16" PROMPT "Ok" TEXTRIGHT ACTION oDlg:END()
oDlg:lHelpIcon := .f.
ACTIVATE DIALOG oDlg ON INIT Eval( bCenterDlg )
RETURN NIL
And this is the resource:
SAMPLEDLG DIALOG 6, 15, 232, 58
STYLE DS_SYSMODAL |DS_3DLOOK |DS_SETFONT |DS_MODALFRAME |WS_POPUP |WS_VISIBLE |WS_SYSMENU |WS_DLGFRAME |0x40000000
CAPTION "FW Dialog"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
CONTROL "",1001,"BUTTON",BS_GROUPBOX |WS_CHILD |WS_VISIBLE ,7,2,217,23
CONTROL "Ok",2,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,174,33,50,14
CONTROL "Redefined Text",1,"STATIC",SS_CENTER |WS_CHILD |WS_GROUP |WS_VISIBLE ,9,13,201,8
END
Any ideas?
Thank you,
Reinaldo.