Page 1 of 2

Hide controls in a dialog before activating it.

PostPosted: Thu May 27, 2010 12:08 pm
by concentra
Hi.
Is it possible to hide controls in a dialog before activating it ?
I use dialogs defined in RCs and sometimes I want to hide a control.
When redefining the RCs controls, if I set the control lVisible to .F. ( or apply the HIDE() method to it ), the control is shown when the dialog is activated...
If I apply HIDE() to the control after the dialog is activated it will disapear.
Why a control set to lVisible = .F. shows when activating a dialog ?
Sorry, but this is kind of nonsense to me...

Maurício Faria

Re: Hide controls in a dialog before activating it.

PostPosted: Thu May 27, 2010 12:56 pm
by ukoenig
You can Hide a Control on Dialog-Init :

REDEFINE SAY oSay1 prompt "Transparent-Text" ID 210 of oDlg ;
COLOR 128 PIXEL TRANSPARENT ADJUST
oSay1:SetFont(oFont2)
// oSay1:Hide()

// With a Switch-Var, You can Switch from Hide to Show inside the Dialog :
lSay1 := .F.

REDEFINE BTNBMP oBtn1 ID 30 OF oDlg ;
NOBORDER ;
FILENAME c_path + "\images\Switch.bmp" ;
TOOLTIP "Hide / Show" ;
ACTION IIF( lSay1 = .F., ( oSay1:Show(), lSay1 := .T.), ;
( oSay1:Hide(), lSay1 := .F. ) ) ;
PROMPT "Switch" ;
LEFT
oBtn1:lTransparent := .T.
oBtn1:SetColor( 0, )

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( GradBrush( oDlg, { { 0.50, 16314573, 14853684 }, ;
{ 0.50, 14853684, 16314573 } }, .T. ), ;
oSay1:Hide() ) ;

Best Regards
Uwe :lol:

Re: Hide controls in a dialog before activating it.

PostPosted: Thu May 27, 2010 5:12 pm
by concentra
ukoenig wrote:You can Hide a Control on Dialog-Init :
ON INIT ( GradBrush( oDlg, { { 0.50, 16314573, 14853684 }, ;
{ 0.50, 14853684, 16314573 } }, .T. ), ;
oSay1:Hide() ) ;


I already do this, but I want to know why it can´t be done before initialization since the dialog wasn´t painted yet.
In my brain ( maybe a not so good one :) ), when the dialog is activated it is painted and each control in it is then painted and if the control is not viseble it should not be painted...
But seems this is not the case...

Re: Hide controls in a dialog before activating it.

PostPosted: Thu May 27, 2010 6:34 pm
by James Bott
You can't hide the controls until the dialog is initialized, because the dialog doesn't exist until it is initialized.

I don't know if this is due to FW or Windows. Either way, it can't be changed, so you have to live with it.

You could draw the dialog off the screen, then hide the controls then move the dialog to a visible location of the screen.

James

Re: Hide controls in a dialog before activating it.

PostPosted: Thu May 27, 2010 8:55 pm
by Antonio Linares
James,

It is the way Windows API does it: windows are created since the very first moment, but dialogboxes have a different behavior and they don't exist until they are created and running.

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 10:27 am
by concentra
Hi.
Antonio Linares wrote:dialogboxes don't exist until they are created and running.

That is the point !
In my conception, if something do not exists and I will create it, I would inspect each of it´s components and create them according they current specifications. If a control is marked as hidden it shoud not be shown !
If I change the lVisible attribute of a control to false in a dialog before activating the dialog, the dialog constructing function ignores this and shows the control.
And worse, if I inspect the value of lVisible for this control it is marked as false ! So the control is visible but it isn´t ...
For me, this is a bit wrong.
But is Windows do it this way...
[[]]

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 11:57 am
by Antonio Linares
Concentra,

If you are creating the dialogbox from resources, you can set the style WS_DISABLED to the controls that you want to be shown as disabled :-)

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 1:01 pm
by concentra
Antonio Linares wrote:Concentra,

If you are creating the dialogbox from resources, you can set the style WS_DISABLED to the controls that you want to be shown as disabled :-)


The issue is that sometimes I want it enabled and other times not.

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 1:18 pm
by Antonio Linares
Concentra,

Then you have to do it from the ACTIVATE DIALOG ... ON INIT ... clause

We could implement a DISABLED clause for controls, but for now, it is not available yet

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 4:14 pm
by concentra
Antonio Linares wrote:Concentra,
Then you have to do it from the ACTIVATE DIALOG ... ON INIT ... clause


I already do this.
I asked for an alternative because I thought I was missing something.

Antonio Linares wrote:We could implement a DISABLED clause for controls, but for now, it is not available yet

Don´t. It´s not necessary.

But what about the fact that a control can have :lVisible = .F. and it´s actually been visible ?

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 4:32 pm
by Antonio Linares
Concentra,

> But what about the fact that a control can have :lVisible = .F. and it´s actually been visible ?

Thats what the clause DISABLED would set:

DISABLED --> :lVisible := .F. --> EnableWindow( ::hWnd, .F. )
Command --> Data (Method) --> Windows API call

but as I have told you, this is not implemented actually. We just provide oControl:Disable() and oControl:Enable() methods calls

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 4:37 pm
by James Bott
Antonio,

So, is lVisible a class var that should really be hidden (or at least thought of as hidden) and not set directly by the user, but rather only set within the class via the Enable() and Disable() methods?

James

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 4:43 pm
by Antonio Linares
James,

lVisible should be a DATA used by each control, not a Class Var
(one value shared for all). A CLASSDATA and a Class Var are equivalent (just the type of inheritance from other classes is different).

Method Enable() and Disable() are equivalents to do oControl:lVisible := .T. and oControl:lVisible := .F., these pseudo DATAs would be in fact Methods that call to Windows API EnableWindow()

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 5:07 pm
by James Bott
Antonio,

>lVisible should be a DATA used by each control, not a Class Var

Yes, I do understand the difference. I was referring to data of the class, not CLASSDATA.

I am confused. Here are the disable() and enable() methods of the TWindow class.

Code: Select all  Expand view
  METHOD Disable()  INLINE ::lActive := .f.,;
                            If( ::hWnd != 0, EnableWindow( ::hWnd, .f. ),)

   METHOD Enable()   INLINE ::lActive := .t.,;
                            If( ::hWnd != 0, EnableWindow( ::hWnd, .t. ),)

It seems neither deals with lVisible, but rather lActive.

Also, it would seem that disabling is graying out not making a control invisible. Shouldn't Show() and Hide() handle visibility?

Code: Select all  Expand view
  METHOD Hide() INLINE ShowWindow( ::hWnd, SW_HIDE )

   METHOD Show() INLINE  ShowWindow( ::hWnd, SW_SHOWNA )

Neither of these methods is dealing with lVisible either.

So, I am confused as to the difference between Show()/Hide() and lVisible.


James

Re: Hide controls in a dialog before activating it.

PostPosted: Fri May 28, 2010 6:32 pm
by Antonio Linares
James,

Yes, you are right, my mistake sorry :-)

We are talking about Methods Hide() and Show(), not Disable() and Enable()