Page 1 of 2
RadioGroup can be MULTILINE
Posted: Sat Feb 04, 2017 11:09 pm
by Pablo César
Hi all, there is a way to increase (but not long, only two lines).

- Screen79.png (11.61 KiB) Viewed 4838 times
This is by the reason that in c_radio.c is fixed value to 28 of height item...
Here's the code to become MULTILINE in RadioGroup:
Code: Select all
#include <hmg.ch>
#define BS_MULTILINE 8192
Function Main()
Load Window Demo1
Demo1.Center
Demo1.Activate
Return Nil
Function ChngRadios()
HMG_ChangeWindowStyle ( GetControlHandle("RadioGroup_2","Demo1"), BS_MULTILINE, NIL, .F. )
Demo1.RadioGroup_2.Caption(3) := "Text will be in multiline and NOT at third line when is longer"
Return Nil
@ Claudio
Is it possible to increase height of item programmatically ? May you teach us how to do it, please ?
As you can in third item in red marked, it is not display for complete.
Re: RadioGroup can be MULTILINE
Posted: Sun Feb 05, 2017 1:24 am
by srvet_claudio
Usar:
SetWindowPos(
hWnd,
cx,
cy,
SWP_DRAWFRAME + SWP_NOMOVE + SWP_NOZORDER
)
También hay una función interna llamada _SetWindowHeight o algo parecido.
Re: RadioGroup can be MULTILINE
Posted: Sun Feb 05, 2017 6:45 pm
by Pablo César
Usar:
SetWindowPos(
hWnd,
cx,
cy,
SWP_DRAWFRAME + SWP_NOMOVE + SWP_NOZORDER
)
Antes del cx y cy existen dos parametros más. No es cierto ?
Esta función iria cambiar el ancho de los items de un RadioGroup ?
Re: RadioGroup can be MULTILINE
Posted: Sun Feb 05, 2017 7:50 pm
by KDJ
Pablo
Maybe in this way:
Code: Select all
#include "hmg.ch"
FUNCTION Main()
SET FONT TO 'MS Shell Dlg', 8
DEFINE WINDOW MainWA;
MAIN;
ROW 100;
COL 100;
WIDTH 190;
TITLE "RadioGroup multiline";
NOSIZE;
NOMAXIMIZE;
NOMINIMIZE
DEFINE FRAME RadioFR
ROW 10
COL 50
WIDTH 80
CAPTION "RadioGroup"
END FRAME
DEFINE RADIOGROUP RadioRG
ROW 30
COL 60
WIDTH 60
VALUE 2
OPTIONS {"Radio 1", e"Radio 2\ntwo lines", e"Radio 3\nthree\nlines"}
END RADIOGROUP
DEFINE BUTTON HeightBU
COL 40
WIDTH 100
HEIGHT 25
CAPTION ""
ACTION ChangeHeightRG()
END BUTTON
ON KEY ESCAPE ACTION MainWA.RELEASE
END WINDOW
ChangeHeightRG()
MainWA.CENTER
MainWA.ACTIVATE
RETURN NIL
FUNCTION ChangeHeightRG()
STATIC lFixedH := .T.
LOCAL nHeight
lFixedH := ! lFixedH
nHeight := RadioGroup_Format("RadioRG", "MainWA", 7, lFixedH)
MainWA.RadioFR.HEIGHT := nHeight + 30
MainWA.HeightBU.ROW := MainWA.RadioFR.HEIGHT + 25
MainWA.HEIGHT := (MainWA.HEIGHT - MainWA.CLIENTAREAHEIGHT) + MainWA.HeightBU.ROW + MainWA.HeightBU.HEIGHT + 10
MainWA.HeightBU.CAPTION := If(lFixedH, "&Set variable height", "&Set fixed height")
RETURN NIL
FUNCTION RadioGroup_Format(cControl, cForm, nGap, lFixedHeight) //for vertical RadioGroup
LOCAL nTotalH := 0
LOCAL nFixedH := 0
LOCAL nCount
LOCAL aHandle
LOCAL aHeight
LOCAL cText
LOCAL nLines
LOCAL nRow, nCol, nWidth
LOCAL nValue
LOCAL n
IF _IsControlDefined(cControl, cForm)
IF (! HB_IsNumeric(nGap)) .or. (nGap < 0)
nGap := 10
ENDIF
IF ! HB_IsLogical(lFixedHeight)
lFixedHeight := .F.
ENDIF
nRow := GetProperty(cForm, cControl, "ROW")
nCol := GetProperty(cForm, cControl, "COL")
nWidth := GetProperty(cForm, cControl, "WIDTH")
nValue := GetProperty(cForm, cControl, "VALUE")
aHandle := GetControlHandle(cControl, cForm)
nCount := Len(aHandle)
aHeight := Array(nCount)
FOR n := 1 TO nCount
cText := GetWindowText(aHandle[n])
nLines := HB_TokenCount(cText, .T. /*lEOL*/)
aHeight[n] := GetTextHeight(0, cText, GetWindowFont(aHandle[n])) * nLines
nFixedH := Max(nFixedH, aHeight[n])
IF nLines > 1
HMG_ChangeWindowStyle(aHandle[n], 0x2000 /*BS_MULTILINE*/, NIL, .F.)
ENDIF
IF nValue > 0
IF nValue == n
HMG_ChangeWindowStyle(aHandle[n], WS_TABSTOP, NIL, .F.)
ELSE
HMG_ChangeWindowStyle(aHandle[n], NIL, WS_TABSTOP, .F.)
ENDIF
ENDIF
NEXT
IF lFixedHeight
FOR n := 1 TO nCount
SetWindowPos(aHandle[n], 0, nCol, nRow, nWidth, nFixedH, 0x14 /*SWP_NOZORDER|SWP_NOACTIVATE*/)
nRow += nGap + nFixedH
NEXT
nTotalH += nFixedH * nCount + nGap * (nCount - 1)
ELSE
FOR n := 1 TO nCount
SetWindowPos(aHandle[n], 0, nCol, nRow, nWidth, aHeight[n], 0x14 /*SWP_NOZORDER|SWP_NOACTIVATE*/)
nRow += nGap + aHeight[n]
nTotalH += aHeight[n]
NEXT
nTotalH += nGap * (nCount - 1)
ENDIF
ENDIF
RETURN nTotalH
Re: RadioGroup can be MULTILINE
Posted: Sun Feb 05, 2017 9:37 pm
by srvet_claudio
Pablo César wrote: ↑Sun Feb 05, 2017 6:45 pm
Usar:
SetWindowPos(
hWnd,
cx,
cy,
SWP_DRAWFRAME + SWP_NOMOVE + SWP_NOZORDER
)
Antes del cx y cy existen dos parametros más. No es cierto ?
Esta función iria cambiar el ancho de los items de un RadioGroup ?
Si los parámetros son col y row
RadioGroup can be MULTILINE
Posted: Sun Feb 05, 2017 10:28 pm
by Pablo César
KDJ wrote: ↑Sun Feb 05, 2017 7:50 pm
Pablo
Maybe in this way:

- Screen82.png (19.78 KiB) Viewed 4739 times
Nice, nice NICE !! Always you Krzysztof surprising us. How nice ! I liked it !
Sometimes it doesn't seem so simple... much less so that when we have very little knowledge in C language...
I got something different. I did this a couple of hours ago and I was late to post on time while having my afternoon coffee ... sorry Krzysztof hopefully if this my message seems redundant but still think it is never late to show other ways to do. Do not you think ?

- Screen80.png (21.3 KiB) Viewed 4755 times
I really liked the way you do it, Krzysztof. Very creative by the way.
I did it this way I can work with RadioGroup horizontally as well. However, changing the spacing between the items and changing height and width has its consequences. The way I do it requires the user to discern all factors involved. Otherwise everything is weird and unfeasible.
The important thing to succeed in the result, attached what I had achieved:
My code is not finished. I know it can be done better.
Many thanks Krzysztof for your excellent and impeccable work.

I loved the use of
ClientAreaHeight based on the size of the Frame in it.
Awesome !

- Screen81.png (14.79 KiB) Viewed 4681 times
Dziękuję za nauczenie nas
(Sorry for my poor Polish language)
Re: RadioGroup can be MULTILINE
Posted: Mon Feb 06, 2017 8:59 am
by serge_girard
Thx Pablo & Krzysztof and others: DreamTeam...?
Serge
RadioGroup can be MULTILINE
Posted: Mon Feb 06, 2017 10:18 am
by Pablo César
Hahaha not so much Serge... (at least I speak for myself, I'm a continuous student)
Thanks Serge but, I believe we each of us can do part of the HMG Dream Team when we collaborating, participating and we spreading to others our work tools. As the same you do too.
I ended up forgetting to mention about the 9th optional parameter which is the number to which you want to change only.

- Screen84.png (16.32 KiB) Viewed 4694 times
Re-remembering that the 8th parameter should also must be changed.
Because the combination of these factors changes the layout of RadioGroup in a sometimes radical way.

- Screen85.png (19.8 KiB) Viewed 4694 times
Here's the little changed code:
I think this code is only useful in cases where the text size of RadioGroup items does not change at all times. I mean that even if of different sizes, they are always of the fixed size. Not the same as OptionBox, for example.
I hope it's educational and funny...
PS: The gray backcolor of RadioGroups is just to duly denote size and position of each item.
Re: RadioGroup can be MULTILINE
Posted: Mon Feb 06, 2017 7:13 pm
by KDJ
Pablo, probably there is something missing in this code.
It did not succeed to me to get such effect like on your picture.
Re: RadioGroup can be MULTILINE
Posted: Mon Feb 06, 2017 8:11 pm
by EduardoLuis
Hi Pablo:
I agree with Krzysztof, compiled you sample differs with your posted picture.-
May be something is missing.-
With regards.
Eduardo