Page 1 of 1

Modifly on fly text of Say and button objects

Posted: Mon Dec 08, 2014 5:36 pm
by MarcoBoschi
Hi,
This is the question:
In function "traduci" I modify the text of tsay and tbutton objects in the dialog

There are other not-redefined object in RC files
Is it possible to modify these objects too?
(NOT REDEFINED)

Thanks to all
Marco

Code: Select all

#include "fivewin.ch"

FUNCTION MAIN()

LOCAL oDlg
LOCAL oSay1
LOCAL oBut1


DEFINE DIALOG oDlg RESOURCE "DIALOGO"

REDEFINE SAY oSay1 PROMPT "Primo Testo" ID 401 OF oDlg
REDEFINE BUTTON oBut1 ID 201 OF oDlg


ACTIVATE DIALOG oDlg ON INIT traduci( oDlg )


RETURN NIL
FUNCTION TRADUCI( oDlg )
LOCAL j , oCtl

FOR j = 1 TO LEN( oDlg:aControls )

    oCtl = oDlg:aControls[ j ]
    IF oCtl:classname = "TSAY" .OR.  oCtl:classname = "TBUTTON"
       oCtl:settext( "MARCO" )
    ENDIF
NEXT j

RETURN NIL

 

This is RC file

Code: Select all

// RESOURCE SCRIPT generated by "Pelles C for Windows, version 6.00".

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

DIALOGO DIALOG DISCARDABLE 10, 28, 399, 136
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialogo"
FONT 8, "MS Sans Serif"
{
  CONTROL "First Say", 401, "Static", WS_GROUP, 4, 8, 56, 10
  CONTROL "", 101, "Edit", WS_BORDER|WS_TABSTOP, 68, 7, 134, 12
  CONTROL "Send", 201, "Button", BS_DEFPUSHBUTTON|WS_TABSTOP, 80, 80, 84, 24
  CONTROL "Cancel", 202, "Button", WS_TABSTOP, 176, 80, 84, 24
  CONTROL "Second Say", 402, "Static", WS_GROUP, 4, 25, 56, 10
  CONTROL "", 102, "Edit", WS_BORDER|WS_TABSTOP, 68, 24, 134, 12
}
 

Re: Modifly on fly text of Say and button objects

Posted: Mon Dec 08, 2014 7:29 pm
by Gale FORd
Yes. You could would work on oDlg:aControls[ j ] the same whether they are from redefined from resource or defined directly.
I do that all the time with both. Sometimes I also use the cargo to place names so I don't have to keep the get object around, I can just check the name in the cargo to get the correct control.

Re: Modifly on fly text of Say and button objects

Posted: Mon Dec 08, 2014 9:43 pm
by fgondi
Marco,

http://forums.fivetechsupport.com/viewt ... d+GW_CHILD

I use this code to find the controls defined to -1, and change the language

Code: Select all

   hCtrl := GetWindow( oDlg:hWnd, GW_CHILD )
   WHILE hCtrl != 0
      if GetWindowLong( hCtrl, GWL_ID ) == -1 
        cTxt  := GetWindowText( hCtrl )
        cLang := GHE_GetIdioma( cTxt ) 
        SetWindowText( hCtrl, cLang )
      endif
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT )
   END

Re: Modifly on fly text of Say and button objects

Posted: Tue Dec 09, 2014 8:20 am
by MarcoBoschi
Ok Thank You very Much

It works in this way not -1 but 65535


if GetWindowLong( hCtrl, GWL_ID ) == 65535

I use Pelles

Best regards
Marco