FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to Center a mdi child browse ?
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
How to Center a mdi child browse ?
Posted: Fri Oct 31, 2025 05:34 PM
To All .. been a while since I have written much code .. got a request today to Center an MDICHILD xbrowse in the Center of the screen ??

was hoping it was a simple as adding Center to the



DEFINE ICON oIco RESOURCE "INVENTORY"

DEFINE WINDOW oWndChildA ;
FROM 0,0 to 39,125 ;
MDICHILD ;
OF oWnd ;
ICON oIco ;
TITLE xTITLE

DEFINE DIALOG oInvt RESOURCE "INVTBROW" of oWndChildA

REDEFINE xBROWSE oLBX ;
RECORDSET oRsInvt ;
COLUMNS "INVENTORY ID", ;
"DESCRIPTION", ;
"QTY", ;
"PRICE", ;
"PRICE1", ;
"MANUFACTURER", ;
"MODEL", ;
"BIN", ;
"LOCATION", ;
"INVENTORY TYPE", ;
"PRODUCT CLASS", ;
"UNIT", ;
"MSRPRICE" ;
COLSIZES 160,295,40,50,60,98,105,60,50,50,95,50,50 ;
HEADERS "Stock Number", ;
"Description", ;
"Qty", ;
"Price", ;
"Wholesale", ;
"Manufacturer", ;
"Model", ;
"Bin", ;
"Location", ;
"Type", ;
"Prod Class", ;
"Unit", ;
"Msrp" ;
ID 172 of oInvt ;
AUTOCOLS LINES AUTOSORT CELL CENTER // <<----------------------------- center here ??

oLbx:lRecordSelector := .f.
oLbx:lFooter := .t.
oCol := oLbx:aCols[ 1 ]
oCol:bFooter := { || Ltrim( Str( oLbx:KeyNo() ) ) + " / " + LTrim( Str( oLbx:KeyCount() ) ) }
oLbx:bChange := { || oCol:RefreshFooter() }

// pic
ADD oCol to oLbx at 9 HEADER 'Pic' size 60 //60
oLbx:aCols[ 9 ]:addbmpfile( "dcam16" )
oLbx:aCols[ 9 ]:addbmpfile( "cam16" )
oLbx:aCols[ 9 ]:bBmpData := { | lValue | If(oRsInvt:eof, ,If( (empty(oRsInvt:Fields("PicFileName"):Value) .or.;
oRsInvt:Fields("PicFileName"):Value = " "), 1, 2 )) }
oLbx:aCols[ 9 ]:lBtnTransparent := .t.
oLbx:aCols[ 9 ]:nHeadStrAlign := AL_CENTER

WITH OBJECT oLbx
:lTabLikeExcel := .t.
END

_BrowColor( oLbx )

oLbx:bLDblClick := { |nRow,nCol | _InvtView( "V", oWnd, oWndChildA, oRsInvt,oLbx ) }

REDEFINE SAY oSay1 ID 129 OF oInvt UPDATE
oSay1:SetFont( oFontB )
REDEFINE SAY oSay2 ID 131 OF oInvt UPDATE
oSay2:SetFont( oFontB )
REDEFINE SAY oSay3 ID 136 OF oInvt UPDATE
oSay3:SetFont( oFontB )
REDEFINE SAY oSay4 ID 138 OF oInvt UPDATE
oSay4:SetFont( oFontB )
REDEFINE SAY oSay5 ID 141 OF oInvt UPDATE
oSay5:SetFont( oFontB )
REDEFINE SAY oSay6 ID 130 OF oInvt UPDATE
oSay6:SetFont( oFontB )
REDEFINE SAY oSay7 ID 133 OF oInvt UPDATE
oSay7:SetFont( oFontB )
REDEFINE SAY oSay8 ID 140 OF oInvt UPDATE
oSay8:SetFont( oFontB )
oSay8:SetColor( CLR_BLUE )

REDEFINE COMBOBOX oLoc1 var cLoc1 ID 127 of oInvt ;
ITEMS aLoc ;
ON CHANGE ( _Isearch( oStockno, cStockno, oDesc, cDesc, ;
oBin, cBin, cLoc1, cType1, oPclass, cPclass, oMan, cMan, oLbx, oRsInvt, @cQuery, oQuery)) ;
UPDATE

REDEFINE COMBOBOX oType1 var cType1 ID 135 of oInvt ;
ITEMS aType1 ;
ON CHANGE ( _Isearch( oStockno, cStockno, oDesc, cDesc, ;
oBin, cBin, cLoc1, cType1, oPclass, cPclass, oMan, cMan, oLbx, oRsInvt, @cQuery, oQuery)) ;
UPDATE

REDEFINE CHECKBOX oViewQuery var lViewQuery ID 174 of oInvt ;
ON CLICK ( _ViewQuery( lViewQuery,oQuery) )

REDEFINE GET oStockno var cStockno ID 137 of oInvt ;
ON CHANGE ( _Isearch( oStockno, cStockno, oDesc, cDesc, ;
oBin, cBin, cLoc1, cType1, oPclass, cPclass, oMan, cMan, oLbx, oRsInvt,@cQuery, oQuery)) ;
UPDATE

REDEFINE GET oDesc var cDesc ID 139 of oInvt ;
ON CHANGE ( _Isearch( oStockno, cStockno, oDesc, cDesc, ;
oBin, cBin, cLoc1, cType1, oPclass, cPclass, oMan, cMan, oLbx, oRsInvt,@cQuery, oQuery)) ;
UPDATE

REDEFINE GET oBin var cBin ID 142 of oInvt ;
ON CHANGE ( _Isearch( oStockno, cStockno, oDesc, cDesc, ;
oBin, cBin, cLoc1, cType1, oPclass, cPclass, oMan, cMan, oLbx, oRsInvt,@cQuery, oQuery)) ;
UPDATE

REDEFINE GET oPclass var cPclass ID 128 of oInvt ;
ON CHANGE ( _Isearch( oStockno, cStockno, oDesc, cDesc, ;
oBin, cBin, cLoc1, cType1, oPclass, cPclass, oMan, cMan, oLbx, oRsInvt,@cQuery, oQuery)) ;
UPDATE

REDEFINE GET oMan var cMan ID 132 of oInvt ;
ON CHANGE ( _Isearch( oStockno, cStockno, oDesc, cDesc, ;
oBin, cBin, cLoc1, cType1, oPclass, cPclass, oMan, cMan, oLbx, oRsInvt,@cQuery, oQuery)) ;
UPDATE

REDEFINE GET oQuery var cQuery ID 134 of oInvt READONLY


REDEFINE BTNBMP oBtn8 ID 147 of oInvt ; // reset search
RESOURCE "RELOAD", "DRELOAD", "DRELOAD" ;
PROMPT "Reset"+CRLF+"Search" LEFT 2007;
ACTION ( oRsInvt:Filter := "[Inventory Id] = 'bogus'",;
cLoc1 := "All",;
cType1 := "All",;
cStockno := space(50),;
cDesc := space(50),;
cBin := space(50),;
cPclass := space(50),;
cMan := space(50),;
oLoc1:ReFresh(),;
oType1:ReFresh(),;
oStockno:ReFresh(),;
oStockno:ReFresh(),;
oDesc:ReFresh(),;
oBin:Refresh(),;
oPclass:ReFresh(),;
oMan:ReFresh(),oLbx:ReFresh() )



REDEFINE BTNBMP oBtn1 ID 160 PROMPT "View All" ;
RESOURCE "INVTALL" ;
of oInvt 2007 ;
ACTION ( oRsInvt:Filter := "",oLbx:ReFresh(),oLbx:SetFocus(),SysReFresh())


REDEFINE BTNBMP oBtn2 ID 161 PROMPT "&Add" CENTER ;
of oInvt 2007 ;
ACTION ( _InvtView( "A", oWnd, oWndChildA, oRsInvt,oLbx ))

REDEFINE BTNBMP oBtn3 ID 144 PROMPT "&Edit" CENTER ;
of oInvt 2007 ;
ACTION ( _InvtView( "E", oWnd, oWndChildA, oRsInvt,oLbx ))

REDEFINE BTNBMP oBtn4 ID 143 PROMPT "&Del" CENTER ;
of oInvt 2007 ;
Action _DeleteUm(oRsInvt,oLbx)

* action nil // dont forget to delete jInventoryTaxes

REDEFINE BTNBMP oBtn5 ID 145 PROMPT "&View" CENTER ;
of oInvt 2007 ;
ACTION ( _InvtView( "V", oWnd, oWndChildA, oRsInvt,oLbx ))

REDEFINE BTNBMP oBtn6 ID 146 PROMPT "&Image" LEFT ;
RESOURCE "CAMERA" ;
of oInvt 2007 ;
ACTION ( _ZoomFromBrow( oRsInvt,oWnd ))


REDEFINE BTNBMP oBtn7 ID 162 PROMPT "Close" ;
RESOURCE "INVTCANC" ;
of oInvt 2007 ;
ACTION (oWndChildA:End())


ACTIVATE DIALOG oInvt NOMODAL ;
ON INIT( If( lViewQuery = .t., oQuery:Show(),oQuery:Hide() ),;
_Hidum( cMode,oBtn2,oBtn3,oBtn4) );
VALID(!GETKEYSTATE( 27 ))

ACTIVATE WINDOW oWndChildA ;
ON INIT ( oInvt:Move( 0,0, oWndChildA:nWidth, oWndChildA:nHeight, .T. ), ;
oWndChildA:bResized := {|| _ReSizeUm1( oInvt,oWndChildA,oLbx) }, ;
oInvt:refresh(.t.));
VALID ( IIF( !lOK3, ExitPgm3(.T.,oWndChildA,oRsInvt,oLbx,@lOk3,oFontB), .F. ))


Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: How to Center a mdi child browse ?
Posted: Fri Oct 31, 2025 06:10 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to Center a mdi child browse ?
Posted: Fri Oct 31, 2025 08:38 PM
Karinha

Thank you for your response .. my code is kinda hard to follow, unfortunately this is a mdi window and not a simple dialog .. I tried to add the CENTER tag to the Activate line

ACTIVATE WINDOW oWndChildA CENTER

and the CENTER tag was just ignored .. did not cause an error .. just nothing changed :(
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: How to Center a mdi child browse ?
Posted: Fri Oct 31, 2025 08:45 PM
Rick, can you provide a demo with the dialog and source code for me to test? If you can, please upload it to Mega Download:

Rick, ¿podrías facilitarme una demo con el diálogo y el código fuente para que la pruebe? Si es posible, súbela a Mega Download:

https://mega.nz/fm/

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to Center a mdi child browse ?
Posted: Sat Nov 01, 2025 10:32 AM

Dear Rick,

Try it this way:

oWndChildA:Center()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to Center a mdi child browse ?
Posted: Sat Nov 01, 2025 01:05 PM
Antonio

Thank you for your advice .. I think you are on the right track .. got a runtime error

390 ACTIVATE WINDOW oWndChildA:Center() ; // CENTER ;
391 ON INIT ( oInvt:Move( 0,0, oWndChildA:nWidth, oWndChildA:nHeight, .T. ), ;
392 oWndChildA:bResized := {|| _ReSizeUm1( oInvt,oWndChildA,oLbx) }, ;
393 oInvt:refresh(.t.));
394 VALID ( IIF( !lOK3, ExitPgm3(.T.,oWndChildA,oRsInvt,oLbx,@lOk3,oFontB), .F. ))


// error.log

Application
===========
Path and name: C:\Fox\CCI\SaLiteNew\Saw32.Exe (32 bits)
Size: 7,829,504 bytes
Compiler version: xHarbour 1.3.1 Intl. (SimpLex) (Build 20240413)
FiveWin version: FWH 24.04
C compiler version: Borland/Embarcadero C++ 7.7 (32-bit)
Windows 11 64 Bits, version: 6.2, Build 9200

Time from start: 0 hours 0 mins 15 secs
Error occurred at: 11/01/2025, 08:55:00
Error description: Error BASE/1004 Class: 'ARRAY' has no exported method: BLCLICKED
Args:
[ 1] = A {,12736808} length: 2

Stack Calls
===========
Called from: => BLCLICKED( 0 )
Called from: INVTBROW.PRG => _INVTBROW( 394 )
Called from: Main.prg => (b)_BUILDMENU( 728 )
Called from: .\source\classes\menu.prg => TMENU:COMMAND( 1552 )
Called from: .\source\classes\window.prg => TWINDOW:COMMAND( 1155 )
Called from: .\source\classes\mdiframe.prg => TMDIFRAME:COMMAND( 278 )
Called from: => TMDIFRAME:HANDLEEVENT( 0 )
Called from: .\source\classes\window.prg => _FWH( 1000 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\window.prg => TMDIFRAME:ACTIVATE( 1114 )
Called from: Main.prg => MAIN( 543 )

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to Center a mdi child browse ?
Posted: Sat Nov 01, 2025 01:34 PM

Dear Rick,

This way:

ACTIVATE WINDOW oWndChildA ;

ON INIT ( oWndChildA:Center(), oInvt:Move( 0,0, oWndChildA:nWidth, oWndChildA:nHeight, .T. ), ;

oWndChildA:bResized := {|| _ReSizeUm1( oInvt,oWndChildA,oLbx) }, ;

oInvt:refresh(.t.));

VALID ( IIF( !lOK3, ExitPgm3(.T.,oWndChildA,oRsInvt,oLbx,@lOk3,oFontB), .F. ))

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to Center a mdi child browse ?
Posted: Sat Nov 01, 2025 04:29 PM
Antonio

Thank you very much !! just a quick change if you can .. the window is centred right and left but if possible can be also centred up and down .. right now the windows is not centred up and down

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to Center a mdi child browse ?
Posted: Sat Nov 01, 2025 04:33 PM

Try it this way:

ACTIVATE WINDOW oWndChildA ;

ON INIT ( oWndChildA:Center( oWndChildA:oWnd ), ...

or

ACTIVATE WINDOW oWndChildA ;

ON INIT ( oWndChildA:Center( oWndChildA:oWnd:oWndClient ), ...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to Center a mdi child browse ?
Posted: Sat Nov 01, 2025 05:35 PM

Antonio

Neither of the last suggestions made any difference .. I get the same result .. centred right and left and not so much top and bottom .. let me see if I can create a self contained sample and send it to you ..

I really appreciate your help ..

Working on a self contained sample as we speak

Thanks

Rick Lipkin

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to Center a mdi child browse ?
Posted: Sat Nov 01, 2025 08:34 PM

After calling oWndChildA:Center( ... ), oWndChildA:Move( oWndChildA:nTop -= 30, oWndChildA:nLeft ), ...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to Center a mdi child browse ?
Posted: Mon Nov 03, 2025 03:00 PM

Antonio

Please forgive me .. I work in a busy computer store and I am under constant interruptions and this is very tedious .. Here is my current code and if I can ask you to plug in your above changes I would be most grateful...

ACTIVATE WINDOW oWndChildA ;

ON INIT ( oWndChildA:Center(), oInvt:Move( 0,0, oWndChildA:nWidth, oWndChildA:nHeight, .T. ), ;

         oWndChildA:bResized := {|| _ReSizeUm1( oInvt,oWndChildA,oLbx) }, ;

         oInvt:refresh(.t.));

VALID ( IIF( !lOK3, ExitPgm3(.T.,oWndChildA,oRsInvt,oLbx,@lOk3,oFontB), .F. ))

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to Center a mdi child browse ?
Posted: Mon Nov 03, 2025 05:27 PM

ACTIVATE WINDOW oWndChildA ;

ON INIT ( oWndChildA:Center(), oWndChildA:Move( oWndChildA:nTop -= 30, oWndChildA:nLeft ), oInvt:Move( 0,0, oWndChildA:nWidth, oWndChildA:nHeight, .T. ), ;

oWndChildA:bResized := {|| _ReSizeUm1( oInvt,oWndChildA,oLbx) }, ;

oInvt:refresh(.t.));

VALID ( IIF( !lOK3, ExitPgm3(.T.,oWndChildA,oRsInvt,oLbx,@lOk3,oFontB), .F. ))

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to Center a mdi child browse ?
Posted: Mon Nov 03, 2025 09:00 PM

Antonio

I cut in your code .. and on init the window goes to the l center and then moves around and then goes back up to the left corner .. Let me try to get you a working sample .. I am sorry .. it is medicare open market in the US and our computer store gets probably 20-30 SPAM calls a day .. The interruptions are driving me nuts .. I am rem'ing out all the program code to leave only the inventory module .. In this program I use MS Access ( sql) and when I get my sample together I will include the oledb Access library .. Bear with me Please .. I know there has to be a solution .. thank you for your patience ..

Rick Lipkin

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to Center a mdi child browse ?
Posted: Tue Nov 04, 2025 05:14 PM
Antonio

My Customer has changed their mind and only wants the inventory dialog centred right to left and NOT up and down ( now he tells me )
Here is the original code for the invtbrow.prg

// old origional save
ACTIVATE WINDOW oWndChildA ;
ON INIT ( oInvt:Move( 0,0, oWndChildA:nWidth, oWndChildA:nHeight, .T. ), ;
oWndChildA:bResized := {|| _ReSizeUm1( oInvt,oWndChildA,oLbx) }, ;
oInvt:refresh(.t.));
VALID ( IIF( !lOK3, ExitPgm3(.T.,oWndChildA,oRsInvt,oLbx,@lOk3,oFontB), .F. ))

It was impossible to create a self contained program .. this is a HUGE application .. If I could once again impose on you to make your change just to center the window in the top center of the screen .. we can call this a done deal .. thank you for your help.

Continue the discussion