How to get objects with ID -1 ?

How to get objects with ID -1 ?

Postby toninhofwi » Sat Aug 25, 2012 9: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.
toninhofwi
 
Posts: 172
Joined: Tue Oct 18, 2005 10:01 am

Re: How to get objects with ID -1 ?

Postby FranciscoA » Sun Aug 26, 2012 3:42 pm

Dear Toninho:
I created the following function to detect says not redefined ( they have ID number but are not redefined)

Code: Select all  Expand view
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
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: How to get objects with ID -1 ?

Postby Antonio Linares » Sun Aug 26, 2012 4:51 pm

Toninho,

Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42074
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to get objects with ID -1 ?

Postby toninhofwi » Sun Aug 26, 2012 5:32 pm

Nice hint Francisco and Antonio.

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

Thank you.
toninhofwi
 
Posts: 172
Joined: Tue Oct 18, 2005 10:01 am

Re: How to get objects with ID -1 ?

Postby elvira » Tue May 13, 2014 7:42 am

Antonio,

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

Code: Select all  Expand view
#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!,
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: How to get objects with ID -1 ?

Postby Antonio Linares » Tue May 13, 2014 1:30 pm

Try this:

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42074
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to get objects with ID -1 ?

Postby elvira » Tue May 13, 2014 2:09 pm

Antonio,

It says Edit or Static.

Here is the .rc so you can check:

Code: Select all  Expand view
// 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!!
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: How to get objects with ID -1 ?

Postby Antonio Linares » Tue May 13, 2014 4:39 pm

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

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

Re: How to get objects with ID -1 ?

Postby elvira » Tue May 13, 2014 7:01 pm

Antonio,

And can you please teach us how to change the SAY´s text in rutime mode?.
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: How to get objects with ID -1 ?

Postby Antonio Linares » Wed May 14, 2014 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42074
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to get objects with ID -1 ?

Postby elvira » 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.
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: How to get objects with ID -1 ?

Postby Biel EA6DD » 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/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Re: How to get objects with ID -1 ?

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42074
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to get objects with ID -1 ?

Postby Enrico Maria Giordano » Thu May 15, 2014 8: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: Select all  Expand view
SetWindowText( hCtrl, "New text" )


?

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

Re: How to get objects with ID -1 ?

Postby elvira » Sat May 17, 2014 4:10 pm

Mr. Enrico,

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

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



Thank you so much!!.
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 38 guests