Page 1 of 1

REFRESH in TexBox control (bug)

Posted: Sat Oct 15, 2016 8:25 pm
by KDJ
Run time error occurs, if you call REFRESH method for TextBox control.

In the following example, click on "Show password" CheckBox:

Code: Select all

#include 'hmg.ch'

FUNCTION Main()

  DEFINE WINDOW Main_WA;
    MAIN;
    ROW    100;
    COL    100;
    WIDTH  225;
    HEIGHT 150;
    TITLE  'TextBox Password Test';
    NOSIZE;
    NOMAXIMIZE;
    NOMINIMIZE

    DEFINE LABEL Pass_LA
      ROW     10
      COL     10
      WIDTH  200
      HEIGHT  13
      VALUE  'Type password:'
    END LABEL

    DEFINE TEXTBOX Pass_TE
      ROW        26
      COL        10
      WIDTH     200
      HEIGHT     21
      VALUE     'my password'
      PASSWORD  .T.
    END TEXTBOX

    DEFINE CHECKBOX Pass_CBO
      ROW       55
      COL       10
      WIDTH    200
      HEIGHT    16
      CAPTION  'Show password'
      ONCHANGE ShowPassword()
    END CHECKBOX

    DEFINE BUTTON OK_BU
      ROW     85
      COL     25
      WIDTH   80
      HEIGHT  25
      CAPTION 'OK'
      ACTION  Main_WA.RELEASE
    END BUTTON

    DEFINE BUTTON Cancel_BU
      ROW     85
      COL    115
      WIDTH   80
      HEIGHT  25
      CAPTION 'Cancel'
      ACTION  Main_WA.RELEASE
    END BUTTON

    ON KEY ESCAPE ACTION Main_WA.RELEASE

  END WINDOW

  Main_WA.ACTIVATE

RETURN NIL

FUNCTION ShowPassword()
  LOCAL lShowPass := Main_WA.Pass_CBO.VALUE

  SendMessage(Main_WA.Pass_TE.HANDLE, 0x00CC /*EM_SETPASSWORDCHAR*/, If(lShowPass, 0, 0x25CF), 0)
  Main_WA.Pass_TE.REFRESH

  //solution:
  //RedrawWindow(Main_WA.Pass_TE.HANDLE)

RETURN NIL

REFRESH in TexBox control (bug)

Posted: Sat Oct 15, 2016 9:25 pm
by Pablo César
Yes, TextBox with PASSWORD is with error at _DataTextBoxRefresh.

Field mismatch type.

Very nice solution with SenMessage :) Thank you for sharing

Re: REFRESH in TexBox control (bug)

Posted: Sat Oct 15, 2016 11:54 pm
by esgici
KDJ wrote:Run time error occurs, if you call REFRESH method for TextBox control.
In the following example, click on "Show password" CheckBox:
...
Thanks KDJ (personally, instead of "machine code" I prefer be addressed to human names ;) )

Good "show password" method, good error catch, good solution and very nice sample :arrow:
Textbox Password Test Result.JPG
Textbox Password Test Result.JPG (17.02 KiB) Viewed 4524 times
Viva HMG :D

Re: REFRESH in TexBox control (bug)

Posted: Sun Oct 16, 2016 12:11 am
by srvet_claudio
KDJ wrote:Run time error occurs, if you call REFRESH method for TextBox control.

In the following example, click on "Show password" CheckBox:

Code: Select all

#include 'hmg.ch'

FUNCTION Main()

  DEFINE WINDOW Main_WA;
    MAIN;
    ROW    100;
    COL    100;
    WIDTH  225;
    HEIGHT 150;
    TITLE  'TextBox Password Test';
    NOSIZE;
    NOMAXIMIZE;
    NOMINIMIZE

    DEFINE LABEL Pass_LA
      ROW     10
      COL     10
      WIDTH  200
      HEIGHT  13
      VALUE  'Type password:'
    END LABEL

    DEFINE TEXTBOX Pass_TE
      ROW        26
      COL        10
      WIDTH     200
      HEIGHT     21
      VALUE     'my password'
      PASSWORD  .T.
    END TEXTBOX

    DEFINE CHECKBOX Pass_CBO
      ROW       55
      COL       10
      WIDTH    200
      HEIGHT    16
      CAPTION  'Show password'
      ONCHANGE ShowPassword()
    END CHECKBOX

    DEFINE BUTTON OK_BU
      ROW     85
      COL     25
      WIDTH   80
      HEIGHT  25
      CAPTION 'OK'
      ACTION  Main_WA.RELEASE
    END BUTTON

    DEFINE BUTTON Cancel_BU
      ROW     85
      COL    115
      WIDTH   80
      HEIGHT  25
      CAPTION 'Cancel'
      ACTION  Main_WA.RELEASE
    END BUTTON

    ON KEY ESCAPE ACTION Main_WA.RELEASE

  END WINDOW

  Main_WA.ACTIVATE

RETURN NIL

FUNCTION ShowPassword()
  LOCAL lShowPass := Main_WA.Pass_CBO.VALUE

  SendMessage(Main_WA.Pass_TE.HANDLE, 0x00CC /*EM_SETPASSWORDCHAR*/, If(lShowPass, 0, 0x25CF), 0)
  Main_WA.Pass_TE.REFRESH

  //solution:
  //RedrawWindow(Main_WA.Pass_TE.HANDLE)

RETURN NIL 
Use Redraw method, Refresh is supported only by small group of controls.

Re: REFRESH in TexBox control (bug)

Posted: Sun Oct 16, 2016 11:38 am
by esgici
srvet_claudio wrote:...
Use Redraw method...
Yes; using "known" method instead of undocumented (developer only) function is better.

Code: Select all

  //solution:
  * RedrawWindow(Main_WA.Pass_TE.HANDLE)
Main_WA.Pass_TE.REDRAW
Refresh is supported only by small group of controls
May will be tiring adding "RedrawWindow" function to refresh method from TextBox (and other controls that not support refresh method) or removing that method from documentation.

In other point of view: does for a single control, redrawing whole window is a good way ?, I'am asking to myself :?

Viva HMG :D

Re: REFRESH in TexBox control (bug)

Posted: Sun Oct 16, 2016 4:46 pm
by KDJ
srvet_claudio wrote:Use Redraw method, Refresh is supported only by small group of controls.
REFRESH method is documented for TexBox control and is realized in source code. But it generates a runtime error.
REDRAW method is not documented, but it works fine.
The documentation update is needed.

And it would be good to shortly describe all HMG functions, eg:
GetSystemMetrics(nIndex) --> Return nValue
HMG_ChangeWindowStyle(hWnd, [nAddStyle], [nRemoveStyle], [lExStyle], [lRedrawWindow]) --> Return nOldStyle
HMG_IsValidFileName(cFileNameWithoutPath) --> Return lValid
HMG_SendMessage(hWnd, nMsg, [@]wParam, [@]lParam) --> Return nResult
SendMessage(hWnd, nMsg, wParam, lParam) --> Return nResult

Re: REFRESH in TexBox control (bug)

Posted: Thu Feb 15, 2018 9:36 pm
by ROBROS
Hi friends,
I got the same runtime error. :(

But I remembered, I had succsessfully changed the code of the following prg to match my needs:
C:\hmg.3.4.4\SAMPLES\Controls\DATA_BOUND\datacontrols.prg

And it works :)

the method is called by procedure refresh()

With the help of you and by the tons of code stuff I get closer to hit my target.

I like hmg.

Robert