Page 1 of 1

align get

Posted: Fri Aug 19, 2016 11:57 am
by marca
Hello

how do I align get right into resource

DEFINE DIALOG oDlg RESOURCE 'SV_DATA' TITLE "teste get"

REDEFINE GET oGet VAR nNota ID 101 OF oDlg

REDEFINE BUTTON oBtn ID 102 OF oDlg

ACTIVATE DIALOG oDlg CENTERED

? oGet:LRIGHT
? oGet:RIGHT


so it goes

@ 07, 28 GET nvalor OF oDlg PICTURE "999,999.99" COLORS "B/BG" SIZE 60,10 RIGHT

Re: align get

Posted: Fri Aug 19, 2016 12:51 pm
by Enrico Maria Giordano
In the resource, you have to use style ES_RIGHT instead of style ES_LEFT.

EMG

Re: align get

Posted: Fri Aug 19, 2016 1:00 pm
by marca
Enrico Maria Giordano wrote:In the resource, you have to use style ES_RIGHT instead of style ES_LEFT.

EMG


hello Enrico!!!
I want to do at runtime

already I tried so
DEFINE DIALOG oDlg RESOURCE 'SV_DATA' TITLE "teste get"

REDEFINE GET oGet VAR nNota ID 101 OF oDlg

REDEFINE BUTTON oBtn ID 102 OF oDlg

oGet:nStyle = nOR( WS_CHILD, WS_VISIBLE,;
ES_AUTOHSCROLL,;
WS_TABSTOP ,;
WS_CLIPSIBLINGS,;
0 ,;
0 ,;
---->>>> ES_RIGHT )


ACTIVATE DIALOG oDlg CENTERED

already I tried so
ACTIVATE DIALOG oDlg ON init ( oGet:nStyle = nOR( WS_CHILD, WS_VISIBLE,;
ES_AUTOHSCROLL,;
WS_TABSTOP ,;
WS_CLIPSIBLINGS,;
0 ,;
0 ,;
---->>>> ES_RIGHT ) )

already I tried so
ACTIVATE DIALOG oDlg CENTERED ON INIT ( ChangeAlignment( Get ) )

Static Procedure ChangeAlignment( poGet )

//--Already tried
SetTextAlign( poGet:hDC, 2 ) //-- TA_RIGHT = 2
poGet:Refresh()

Return


neither functioned

Re: align get

Posted: Fri Aug 19, 2016 1:06 pm
by Enrico Maria Giordano
marca wrote:
Enrico Maria Giordano wrote:In the resource, you have to use style ES_RIGHT instead of style ES_LEFT.

EMG


hello Enrico!!!
I want to do at runtime
You can't:

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

EMG

Re: align get

Posted: Fri Aug 19, 2016 1:09 pm
by Enrico Maria Giordano
I think the only option is to destroy the control and then recreate it with the new style.

EMG

Re: align get

Posted: Fri Aug 19, 2016 2:15 pm
by marca
Enrico Maria Giordano wrote:I think the only option is to destroy the control and then recreate it with the new style.

EMG


I consulted the fiveWin manager in Brazil he said there is another way , and does not see it as today. Does anyone out there know how to do?

Re: align get

Posted: Fri Aug 19, 2016 2:19 pm
by Enrico Maria Giordano
Have you read MS docs? They say it can't be done. Do you think MS docs are wrong? If you find a way please inform us. I'd also need to change this style on the fly.

EMG

Re: align get

Posted: Fri Aug 19, 2016 3:10 pm
by marca
Enrico Maria Giordano wrote:Have you read MS docs? They say it can't be done. Do you think MS docs are wrong? If you find a way please inform us. I'd also need to change this style on the fly.

EMG

if he answers put me here in the forum . Will Linares could not help us with that?

Re: align get

Posted: Mon Aug 22, 2016 6:18 am
by Antonio Linares
Have you read MS docs? They say it can't be done. Do you think MS docs are wrong? If you find a way please inform us. I'd also need to change this style on the fly.

Re: align get

Posted: Mon Aug 22, 2016 6:25 am
by Antonio Linares
See this:

https://blogs.msdn.microsoft.com/oldnew ... /?p=18173/
you can indeed change the alignement of an edit control at runtime. It works, therefore this blog entry is wrong.

————————————–

I wrote an MFC dialog with two buttons to modify the style of the edit control. here are the message handlers:

void CTestEditDlg::OnBnClickedButton1()

{

m_TestEdit.ModifyStyle( ES_RIGHT, ES_LEFT );

m_TestEdit.Invalidate();

}

void CTestEditDlg::OnBnClickedButton2()

{

m_TestEdit.ModifyStyle( ES_LEFT, ES_RIGHT );

m_TestEdit.Invalidate();

}

MFC’s ModifyStyle does SetWindowLong and SetWindowPos( SWP_FRAMCHANGED)

Re: align get

Posted: Mon Aug 22, 2016 8:13 am
by Enrico Maria Giordano
Great! This is a sample:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oGet, cVar := SPACE( 35 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET oGet VAR cVar

    @ 2, 1 BUTTON "Change style";
           ACTION CHANGESTYLE( oGet )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


#define GWL_STYLE -16
#define SWP_FRAMECHANGED 0x0020


STATIC FUNCTION CHANGESTYLE( oGet )

    SETWINDOWLONG( oGet:hWnd, GWL_STYLE, NOR( GETWINDOWLONG( oGet:hWnd, GWL_STYLE ), ES_RIGHT ) )

    SETWINDOWPOS( SWP_FRAMECHANGED )

    oGet:Refresh()

    RETURN NIL
EMG

Re: align get

Posted: Mon Aug 22, 2016 8:28 am
by Antonio Linares
Enrico,

Is it working fine ?

Parameters for SETWINDOWPOS() are not correct

Re: align get

Posted: Mon Aug 22, 2016 8:52 am
by Enrico Maria Giordano
Ops! Strangely enough, it was working. Anyway, this should be the correct version:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oGet, cVar := SPACE( 35 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET oGet VAR cVar

    @ 2, 1 BUTTON "Change style";
           ACTION CHANGESTYLE( oGet )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


#define GWL_STYLE -16
#define SWP_FRAMECHANGED 0x0020
#define SWP_NOSIZE          1
#define SWP_NOMOVE          2


STATIC FUNCTION CHANGESTYLE( oGet )

    SETWINDOWLONG( oGet:hWnd, GWL_STYLE, NOR( GETWINDOWLONG( oGet:hWnd, GWL_STYLE ), ES_RIGHT ) )

    SETWINDOWPOS( oGet:hWnd, , , , , , NOR( SWP_FRAMECHANGED, SWP_NOMOVE, SWP_NOSIZE ) )

    oGet:Refresh()

    RETURN NIL
EMG

Re: align get

Posted: Mon Aug 22, 2016 11:22 am
by marca
Thank Linares