Hide controls in a dialog before activating it.

Hide controls in a dialog before activating it.

Postby concentra » Thu May 27, 2010 12:08 pm

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
User avatar
concentra
 
Posts: 115
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Hide controls in a dialog before activating it.

Postby ukoenig » Thu May 27, 2010 12:56 pm

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:
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

Re: Hide controls in a dialog before activating it.

Postby concentra » Thu May 27, 2010 5:12 pm

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...
User avatar
concentra
 
Posts: 115
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Hide controls in a dialog before activating it.

Postby James Bott » Thu May 27, 2010 6:34 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Hide controls in a dialog before activating it.

Postby Antonio Linares » Thu May 27, 2010 8:55 pm

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.
regards, saludos

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

Re: Hide controls in a dialog before activating it.

Postby concentra » Fri May 28, 2010 10:27 am

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...
[[]]
User avatar
concentra
 
Posts: 115
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Hide controls in a dialog before activating it.

Postby Antonio Linares » Fri May 28, 2010 11:57 am

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 :-)
regards, saludos

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

Re: Hide controls in a dialog before activating it.

Postby concentra » Fri May 28, 2010 1:01 pm

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.
User avatar
concentra
 
Posts: 115
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Hide controls in a dialog before activating it.

Postby Antonio Linares » Fri May 28, 2010 1:18 pm

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
regards, saludos

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

Re: Hide controls in a dialog before activating it.

Postby concentra » Fri May 28, 2010 4:14 pm

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 ?
User avatar
concentra
 
Posts: 115
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Hide controls in a dialog before activating it.

Postby Antonio Linares » Fri May 28, 2010 4:32 pm

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
regards, saludos

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

Re: Hide controls in a dialog before activating it.

Postby James Bott » Fri May 28, 2010 4:37 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Hide controls in a dialog before activating it.

Postby Antonio Linares » Fri May 28, 2010 4:43 pm

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()
regards, saludos

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

Re: Hide controls in a dialog before activating it.

Postby James Bott » Fri May 28, 2010 5:07 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Hide controls in a dialog before activating it.

Postby Antonio Linares » Fri May 28, 2010 6:32 pm

James,

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

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

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Vanzegbroeck and 110 guests