FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to get objects with ID -1 ?
Posts: 182
Joined: Tue Oct 18, 2005 10:01 AM

How to get objects with ID -1 ?

Posted: Sat Aug 25, 2012 09:39 PM

Hi.

I have a lot of resource dialogs with objects like SAY with ID -1.

I need get it to change some properties like fonts and colors.

There are a way to get it without change ID ?

TIA, best regards,

Toninho.

Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM

Re: How to get objects with ID -1 ?

Posted: Sun Aug 26, 2012 03:42 PM
Dear Toninho:
I created the following function to detect says not redefined ( they have ID number but are not redefined)

Code (fw): Select all Collapse
ACTIVATE DIALOG oDlg CENTERED ON INIT MySays(oDlg)
//--------------------
Function MySays(oDlg)
local n
For n := 1 to len(oDlg:aControls)
   //if oDlg:aControls[n]:CLASSNAME == "TSAY"
      //MsgInfo(oDlg:aControls[n]:cTitle)
      msginfo(oDlg:aControls[n]:CLASSNAME)
   //endif
Next
Return nil


Are not detected, so I think you have to put them and redefine its handle.

Another colleague may have the solution.

Greetings.
Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: How to get objects with ID -1 ?

Posted: Sun Aug 26, 2012 04:51 PM
Toninho,

Code (fw): Select all Collapse
#define GW_CHILD      5 
#define GW_HWNDNEXT   2 
#define GWL_ID  -12

function FindControlsById( oDlg )

   local n, hCtrl := GetWindow( oDlg:hWnd, GW_CHILD )

   WHILE hCtrl != 0 
      if GetWindowLong( hCtrl, GWL_ID ) == -1  // You may also use GetClassName( hCtrl ) == cClassName
          ...
      endif
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT ) 
   END 

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 182
Joined: Tue Oct 18, 2005 10:01 AM

Re: How to get objects with ID -1 ?

Posted: Sun Aug 26, 2012 05:32 PM

Nice hint Francisco and Antonio.

But Antonio's solution is that i'm looking for.

Thank you.

Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM

Re: How to get objects with ID -1 ?

Posted: Tue May 13, 2014 07:42 AM
Antonio,

I tried this sample, but I can´t get the alert("...") to manipulate says with ID -1:

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xbrowse.ch"

#define GW_CHILD      5
#define GW_HWNDNEXT   2
#define GWL_ID  -12
//----------------------------------------------------------------------------//

function Main()

   local oDlg, lSave := .f.

   local c100 := "TEST ELVIRA            "
   local c101 := 0
   local c102 := 0
   local c103 := 0



   DEFINE DIALOG oDlg RESOURCE "ELVIRA" TITLE "Prueba Elvira"

   REDEFINE GET c100        ID  100 OF oDlg
   REDEFINE GET c101        ID  101 OF oDlg   PICTURE "@E 9,999,999"  SPINNER
   REDEFINE GET c102        ID  102 OF oDlg   PICTURE "@E 9,999,999"
   REDEFINE GET c103        ID  103 OF oDlg   PICTURE "@E 9999"    SPINNER




   REDEFINE BUTTON ID 701 OF oDlg  ACTION( lSave := .T., oDlg:End() )
   REDEFINE BUTTON ID 702 OF oDlg  ACTION( lSave := .F., oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED ;
            ON INIT FindControlsById( oDlg )






return nil
//----------------------------------------------------------------------------//



//----------------------------------------------------------------------------//
function FindControlsById( oDlg )
//----------------------------------------------------------------------------//

   local n, hCtrl := GetWindow( oDlg:hWnd, GW_CHILD )

   WHILE hCtrl != 0
      if GetWindowLong( hCtrl, GWL_ID ) == -1  // You may also use GetClassName( hCtrl ) == cClassName
         alert(" ...")
      endif
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT )
   END

return nil
//----------------------------------------------------------------------------//



Thanks a lot!,
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: How to get objects with ID -1 ?

Posted: Tue May 13, 2014 01:30 PM
Try this:

Code (fw): Select all Collapse
function FindControlsById( oDlg )
//----------------------------------------------------------------------------//

   local n, hCtrl := GetWindow( oDlg:hWnd, GW_CHILD )

   WHILE hCtrl != 0
      MsgInfo( GetClassName( hCtrl ) )  // new
      if GetWindowLong( hCtrl, GWL_ID ) == -1  // You may also use GetClassName( hCtrl ) == cClassName
         alert(" ...")
      endif
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT )
   END

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM

Re: How to get objects with ID -1 ?

Posted: Tue May 13, 2014 02:09 PM
Antonio,

It says Edit or Static.

Here is the .rc so you can check:

Code (fw): Select all Collapse
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 7.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

ELVIRA DIALOG DISCARDABLE 23, 16, 258, 163
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION
CAPTION "Búsquedas"
FONT 10, "MS Sans Serif"
{
  CONTROL "", 100, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 51, 14, 86, 12
  CONTROL "", 101, "Edit", ES_RIGHT|ES_AUTOHSCROLL|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 52, 60, 49, 11
  CONTROL "", 102, "Edit", ES_RIGHT|WS_BORDER|WS_TABSTOP, 152, 60, 24, 11
  CONTROL "", 103, "Edit", ES_RIGHT|ES_NUMBER|ES_AUTOVSCROLL|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 208, 60, 36, 11
  CONTROL "&Nombre:", -1, "Static", WS_GROUP, 10, 16, 28, 8
  CONTROL "&Págs.:", -1, "Static", SS_RIGHT|WS_GROUP, 184, 60, 19, 12
  CONTROL "&Vols:", -1, "Static", SS_RIGHT|WS_GROUP, 30, 63, 17, 8
  CONTROL "&Ejemplares:", -1, "Static", SS_RIGHT|WS_GROUP, 112, 60, 38, 8
  CONTROL "&Aceptar", 701, "Button", WS_TABSTOP, 73, 128, 36, 14
  CONTROL "&Cancelar", 702, "Button", WS_TABSTOP, 140, 128, 36, 14
}



I need to manipúlate the Says with -1, so to translate depending on sys language.

Thank you so much!!
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: How to get objects with ID -1 ?

Posted: Tue May 13, 2014 04:39 PM

The "Static" ones are the ones that have -1 :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM

Re: How to get objects with ID -1 ?

Posted: Tue May 13, 2014 07:01 PM

Antonio,

And can you please teach us how to change the SAY´s text in rutime mode?.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: How to get objects with ID -1 ?

Posted: Wed May 14, 2014 08:52 AM

Elvira,

If you want to change the text, attributes, etc of a SAY then you have to REDEFINE it:

REDEFINE SAY oSay ID ... OF oDlg

...

ACTIVATE DIALOG ...

and from your app simply do oSay:SetText( cNewText )

of course, you have to change -1 in the RC with a different value

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM

Re: How to get objects with ID -1 ?

Posted: Wed May 14, 2014 10:08 AM
Antonio,

This is the way I am avoiding, as the application is very very large with all SAYS defined with -1.

This is why I asked for an alternative way.

I hope I explained myself better.

Thanks.
Posts: 682
Joined: Tue Feb 14, 2006 09:48 AM

Re: How to get objects with ID -1 ?

Posted: Wed May 14, 2014 10:20 AM

An alternative solution to your problem, one dll for each language with all RC inside. Then you can translate DLL, and select the appropiate DLL depending on Sys language.

Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: How to get objects with ID -1 ?

Posted: Wed May 14, 2014 11:04 AM

Elvira,

Biel´s solution is the right one, unless you want to set different IDs for all your Static (SAYs) controls.

FiveWin provides several ways to manage them as a group, but for changing texts in each of them, there is no other way of different IDs or the right way as Biel explains :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: How to get objects with ID -1 ?

Posted: Thu May 15, 2014 08:32 AM
Elvira,

elvira wrote:And can you please teach us how to change the SAY´s text in rutime mode?.


Once you have hCtrl, did you try using:

Code (fw): Select all Collapse
SetWindowText( hCtrl, "New text" )


?

EMG
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM

Re: How to get objects with ID -1 ?

Posted: Sat May 17, 2014 04:10 PM
Mr. Enrico,

Yes, it Works perfect!!!!!!:

Code (fw): Select all Collapse
      if GetWindowText( hCtrl ) = "&Ejemplares:"
         SetWindowText( hCtrl, "New text:" )
      endif



Thank you so much!!.

Continue the discussion