REFRESH in TexBox control (bug)

Moderator: Rathinagiri

Post Reply
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

REFRESH in TexBox control (bug)

Post 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
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

REFRESH in TexBox control (bug)

Post 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
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: REFRESH in TexBox control (bug)

Post 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 4421 times
Viva HMG :D
Viva INTERNATIONAL HMG :D
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: REFRESH in TexBox control (bug)

Post 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.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: REFRESH in TexBox control (bug)

Post 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
Viva INTERNATIONAL HMG :D
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: REFRESH in TexBox control (bug)

Post 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
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: REFRESH in TexBox control (bug)

Post 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
Post Reply