Auto centering in dialog

Auto centering in dialog

Postby Gilbert » Thu Nov 30, 2006 8:16 pm

Hi All,

I would like to automatically center a button in a dialog box. I can`t find out how to do this. Is there a way it can be done ?

Regards,
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Re: Auto centering in dialog

Postby Enrico Maria Giordano » Fri Dec 01, 2006 9:06 am

This is a working sample:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oBtn

    DEFINE DIALOG oDlg

    @ 0, 0 BUTTON oBtn PROMPT "&Close";
           ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             ON INIT CENTERBTN( oDlg, oBtn );
             CENTER

    RETURN NIL


STATIC FUNCTION CENTERBTN( oDlg, oBtn )

    LOCAL aDlgRect := GETCLIENTRECT( oDlg:hWnd )

    LOCAL nDlgWidth  := aDlgRect[ 4 ] - aDlgRect[ 2 ]
    LOCAL nDlgHeight := aDlgRect[ 3 ] - aDlgRect[ 1 ]

    LOCAL nRow := ( nDlgHeight - oBtn:nHeight() ) / 2
    LOCAL nCol := ( nDlgWidth - oBtn:nWidth() ) / 2

    oBtn:Move( nRow, nCol )

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Gilbert » Fri Dec 01, 2006 9:25 pm

Hi Enrico,

Hi sure will do some testing this week end.

Thanks

Regards,

Gilbert
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby Gilbert » Sat Dec 02, 2006 1:20 am

Hi Enrico,

It`s a bit more complicated that I tought it would be, but it works nicely.

Thanks
Regards,

Gilbert
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 14 guests