Multiline GET - CRLF

Multiline GET - CRLF

Postby Otto » Tue Mar 16, 2010 5:49 pm

I can’t find out how to insert a CRLF.
Could someone please help me out?
Thanks in advance
Otto



Code: Select all  Expand view
#include "fivewin.ch"

function main()
    local oWnd
    local cVar    := memoread(".\testMem2.prg")
    local oGet
    local oBtn2
    DEFINE WINDOW oWnd      
    @ 1,1 get oGet VAR cVar MEMO SIZE 250,100 OF oWnd
    @ 9, 7  BUTTON oBtn2 PROMPT "CRLF"  OF oWnd  ACTION (MsgBeep(),;
        oGet:SetFocus(.t.),;
       oGet:KeyDown( VK_RETURN ) )  

        //oGet:KeyChar(ASC("M"))   OK

    ACTIVATE WINDOW oWnd

return nil
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6148
Joined: Fri Oct 07, 2005 7:07 pm

Re: Multiline GET - CRLF

Postby Armando » Tue Mar 16, 2010 7:23 pm

Otto:

I think you do not need the CRLF button, try to hold on the CONTROL key and push the RETURN key at same time when you are writting the memo field.

I hope these can help you.

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3106
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Multiline GET - CRLF

Postby Otto » Tue Mar 16, 2010 8:28 pm

Hello Armando,
thank you for your answer.
I need this for a kiosk application. There you have no keyboard only a touch screen.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6148
Joined: Fri Oct 07, 2005 7:07 pm

Re: Multiline GET - CRLF

Postby Armando » Tue Mar 16, 2010 11:20 pm

Otto:

Ooopsss, I understand.

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3106
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Multiline GET - CRLF

Postby James Bott » Tue Mar 16, 2010 11:20 pm

I know how when you are using a control defined as a resource. Then you just check "Want Return" for the multiline Get.

If you want to define the control using code, you might try creating a resource, then look at the style and copy that style to the code GET.

I hope that was clear.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Multiline GET - CRLF

Postby fraxzi » Wed Mar 17, 2010 12:05 am

Sir,

Just add this style to your resource:

ES_WANTRETURN|ES_MULTILINE


Regards,
FAP
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Multiline GET - CRLF

Postby Jonathan Hodder » Wed Mar 17, 2010 12:12 am

Hi Otto
As I see it I think u had the same prob as me a few years back.
People would type a line of text into a memo and then move onto the next task
but it wouldn't trigger a save unless they pressed <Return>.

I solved it as follows

Resource
Code: Select all  Expand view

EDITTEXT 110, 16, 46, 342, 128, ES_MULTILINE | ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_TABSTOP


Added Instance var to MGet
Code: Select all  Expand view

...
DATA lChanged             AS LOGIC INIT .F. // JH 01/07 For saving edits
...
METHOD KeyDown( nKey, nFlags ) CLASS TMultiGet

   do case
      case ( nKey == VK_INSERT .and. GetKeyState( VK_SHIFT ) ) .or. ;
           ( nKey == ASC("V") .and. GetKeyState( VK_CONTROL ) ) .or. ;
           ( nKey == ASC('X') .and. GetKeyState( VK_CONTROL ) )

          ::lChanged:=.t.     // JH 01/07 For saving edits
          if !::lReadOnly
             CallWindowProc( ::nOldProc, ::hWnd, WM_KEYDOWN, nKey, nFlags )
             if ::bChange != nil
                Eval( ::bChange, nKey, nFlags, Self )
             endif
          endif

          return 0

      case nKey == VK_DELETE
           ::lChanged:=.t.    // JH 01/07 For saving edits
           if ::lReadOnly
              return 0
           endif
           if ::bChange != nil
              Eval( ::bChange, nKey, nFlags, Self )
           endif
   endcase

   IF nKey>=32 .AND. nKey<127 // JH 01/07 For saving edits
      ::lChanged:=.t.         // JH 01/07 For saving edits
   ENDIF                      // JH 01/07 For saving edits

return Super:KeyDown( nKey, nFlags )
...
 


My code
Code: Select all  Expand view

...
   REDEFINE GET ::oMemo VAR ::oCreditor:Notes                      ; // NEED TO PRESS ENTER TO RECORD NEW TEXT
      MEMO                                                         ;
...
   ::oMemo:bLostFocus:={|| IIF((::lChanged:=::oMemo:lChanged .OR. ::lChanged), (::oUndo:Enable(), ::oSave:Enable()), NIL) }
...
METHOD SaveIt() CLASS TDlg

   IF ::lChanged
...
 


Maybe this will solve the problem.
The downside is that I have to update MGet each time I upgrade FW.
Jonathan Hodder
 
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm

Re: Multiline GET - CRLF

Postby Otto » Wed Mar 17, 2010 9:01 am

Hello James and Fraxzi,
I tried with want-return but with no success.

Jonathan I will make the changes and then come back.
Best regards,
Otto


test-file

Code: Select all  Expand view
#include "FiveWin.ch"
#define ID_MEMO 110

function Main()


   local oDlg, oGet, n:=0
   local cText := ""

   SET _3DLOOK ON

   DEFINE DIALOG oDlg RESOURCE "MemoEdit"

   REDEFINE GET oGet VAR cText MEMO ID ID_MEMO OF oDlg

   REDEFINE BUTTON ID 2 OF oDlg ;
      ACTION  (MsgBeep(),;
        oGet:SetFocus(.t.),;
       oGet:KeyDown( VK_RETURN ) )

   ACTIVATE DIALOG oDlg CENTERED VALID (ALERT("Info : "+STR(n++)),!EMPTY(cText))

return nil


 



rc-file
Code: Select all  Expand view


#define DIALOG_1        1
#include "..\include\WinApi.ch"
#include "TestMemo.ch"

MemoEdit DIALOG 18, 18, 187, 113
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "MemoEditing"
FONT 8, "Arial"
{
 EDITTEXT ID_MEMO, 4, 6, 180, 85, ES_MULTILINE | ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_TABSTOP
 DEFPUSHBUTTON "&Ok", 1, 51, 96, 36, 14
 PUSHBUTTON "&Cancel", 2, 100, 96, 36, 14
}

 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6148
Joined: Fri Oct 07, 2005 7:07 pm

Re: Multiline GET - CRLF

Postby Otto » Wed Mar 17, 2010 9:19 am

As it seems that there is no easy solution - I have still to try the suggestion from Jonathan - I tried to insert the CRLF into the Variable.
Code: Select all  Expand view
cText := substr( ctext,1,oGet:nPos) + CRLF + substr( ctext,oGet:nPos + 1), oGet:refresh()


For me this is working.
Thank you all for your help.
Best regards,
Otto

Code: Select all  Expand view
#include "FiveWin.ch"
#define ID_MEMO 110

function Main()


   local oDlg, oGet, n:=0
   
    local cText := "Otto Mustermann Musterort"

   SET _3DLOOK ON

   DEFINE DIALOG oDlg RESOURCE "MemoEdit"

   REDEFINE GET oGet VAR cText MEMO ID ID_MEMO OF oDlg

  /* REDEFINE BUTTON ID 2 OF oDlg ;
      ACTION  (MsgBeep(),;
        oGet:SetFocus(.t.),;
       oGet:KeyDown( VK_RETURN ) )

*/

 
 
  REDEFINE BUTTON ID 2 OF oDlg ;
      ACTION  ( cText := substr( ctext,1,oGet:nPos) + CRLF + substr( ctext,oGet:nPos + 1), oGet:refresh()    )
 
 
   ACTIVATE DIALOG oDlg CENTERED VALID (ALERT("Info : "+STR(n++)),!EMPTY(cText))

return nil
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6148
Joined: Fri Oct 07, 2005 7:07 pm

Re: Multiline GET - CRLF

Postby James Bott » Wed Mar 17, 2010 2:05 pm

Otto,

>I tried with want-return but with no success

My notes say that you also have to check "Multiline." Try that.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Multiline GET - CRLF

Postby James Bott » Wed Mar 17, 2010 2:11 pm

Otto,

I just looked at the code from the TMulitGet (the New() method) and it seems that the style it already including "wantreturn" and "mulitline." Even a version from 2000 was this way, so perhaps the multiline GET has not ever been handling the Return key properly.

Code: Select all  Expand view
  ::nStyle   = nOR( WS_CHILD, WS_VISIBLE, ES_LEFT,;
                     ES_WANTRETURN, ES_MULTILINE,;
                     If( ! lReadOnly, WS_TABSTOP, 0 ),;
                     If( ! lNoVScroll, WS_VSCROLL, 0 ),;
                     If( lDesign, WS_CLIPSIBLINGS, 0 ),;
                     If( lHScroll, WS_HSCROLL, 0 ),;
                     If( lCenter, ES_CENTER, If( lRight, ES_RIGHT, ES_LEFT ) ) )
 


This wouldn't have any effect on the style of multiline GETs defined in resources.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Multiline GET - CRLF

Postby Jonathan Hodder » Wed Mar 17, 2010 9:25 pm

multiline GET has not ever been handling the Return key properly.

True even if defined in resources.

Ottos code should work as the button acts as a wait state.

When user decides to go to another task (eg another window) no event is activated in TMultiGet.
I had no wait state in my code - customers complained.
I had major problems until I implemented the above many years ago.
Has anyone another solution when there is no wait state.

James - do you know how to check that TMultiGet captures the event (assuming ES_WANTRETURN is sent) when the control looses focus?
Jonathan Hodder
 
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm

Re: Multiline GET - CRLF

Postby James Bott » Wed Mar 17, 2010 10:56 pm

This works fine for me (FWH 10.2). Can anyone confirm it is working for them?

James

TEST03.PRG
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()
   local oDlg, oGet
   local cText := ""

   DEFINE DIALOG oDlg RESOURCE "Dialog1"

   REDEFINE GET oGet VAR cText MEMO ID 101 OF oDlg

   ACTIVATE DIALOG oDlg CENTERED VALID (msgInfo( cText ), .t.)

return nil


TEST03.RC
Code: Select all  Expand view

/****************************************************************************


test03.rc

produced by Borland Resource Workshop


*****************************************************************************/



DIALOG1 DIALOG 6, 15, 194, 119
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "DIALOG_1"
FONT 8, "MS Sans Serif"
{
 DEFPUSHBUTTON "OK", 1, 80, 95, 50, 14
 PUSHBUTTON "Cancel", 2, 135, 95, 50, 14
 EDITTEXT 101, 10, 5, 170, 85, ES_MULTILINE | ES_WANTRETURN | WS_BORDER | WS_TABSTOP
}
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 57 guests