CheckBox Centered and Multiline text
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
CheckBox Centered and Multiline text
Grigory Filatov has adopted MULTILINE in CheckBox as more one property in 17.01 version.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
CheckBox can be MULTILINE
I was wonder if this solution can be adapted to CHECKBOX control.
I've modified Krzysztof sample, and it's work very fine. Thanks for sharing your knowledge!
My change
I've modified Krzysztof sample, and it's work very fine. Thanks for sharing your knowledge!
My change
Code: Select all
function ChangeHeightOfCHeckBox
param cControl, cForm
local cText
local nLines
local nHandle
local nHeight
nHandle := GetControlHandle(cControl, cForm)
cText := GetWindowText(nHandle)
nLines := HB_TokenCount(cText, .T. /*lEOL*/)
nHeight := GetTextHeight(0, cText, GetWindowFont(nHandle)) * nLines
IF nLines > 1
HMG_ChangeWindowStyle(nHandle, 0x2000 /*BS_MULTILINE*/, NIL, .F.)
SetProperty(cForm, cControl, "Height", nHeight)
ENDIF
return nHeight
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
CheckBox can be MULTILINE
Hi Marek,
Thanks for your interest and contribution.
I am very happy to know that we contribute and serve as inspiration for the noble colleagues here in the forum.
I made some adaptations based on your example that I found convenient and I share here with all of you:
Guy, joining all our esforces we get the best result and we win all together !
Indeed to say we always learn a lot with colleagues like Krzysztof, Claudio and many all of us always when we are sharing... to all of them many thanks for participating at our community.
But please Mr. Marek do not get me wrong, but it would have been more convenient for you to have posted your example in the CheckBox - Multiline post.
Here in this post we are dealing with RadioGroup issues.
Would you kindly ask to forum administrator to move these two messages (yours and mine about CheckBox) ?
So with this we do not mix the main subjects.
Can you please ask to Mr. Rathinagiri ?
Thanks in advanced.
Notes: Source code was re-edited to include style option.
Thanks for your interest and contribution.
I am very happy to know that we contribute and serve as inspiration for the noble colleagues here in the forum.
I made some adaptations based on your example that I found convenient and I share here with all of you:
Guy, joining all our esforces we get the best result and we win all together !
Code: Select all
#include <hmg.ch>
Function Main()
DEFINE WINDOW Demo1 AT 163, 357 WIDTH 188 HEIGHT 251 TITLE "CheckBox Text Height" MAIN NOMAXIMIZE NOMINIMIZE NOSIZE
DEFINE CHECKBOX Check_1
ROW 30
COL 40
WIDTH 100
HEIGHT 28
CAPTION "Check_1 "+CRLF+"in three"+CRLF+"lines" // Forcing 3 line breaks
BACKCOLOR {192,192,192}
END CHECKBOX
DEFINE CHECKBOX Check_2
ROW 100
COL 40
WIDTH 100
HEIGHT 60
CAPTION "Check_2 with long text that it could takes more than three lines long"
BACKCOLOR {192,192,192}
END CHECKBOX
END WINDOW
Demo1.Center
CheckBoxAutoAdjust("Check_1", "Demo1", .T.)
CheckBoxAutoAdjust("Check_2", "Demo1")
Demo1.Activate
Return Nil
Function CheckBoxAutoAdjust(cControl, cForm, lCenter)
LOCAL nHandle := GetControlHandle(cControl, cForm)
LOCAL nWidth := GetProperty(cForm, cControl,"WIDTH")
LOCAL cText := GetProperty(cForm, cControl,"CAPTION")
LOCAL nLines, nTextWidth, nTextHeight, Style, nBoxSize := 20
DEFAULT lCenter := .F.
nTextWidth := GetTextWidth(0, cText, GetWindowFont(nHandle))
Style := 0x2000 + If( lCenter, 0x300, 0x0 ) + 0xC00 // BS_MULTILINE + BS_CENTER + BS_VCENTER
If CRLF $ cText
nLines := hb_TokenCount(cText, .T. /*lEOL*/) + 1
Else
nLines := ( nTextWidth / ( nWidth - nBoxSize ) )
nLines := Int(nLines) + If(nLines == Int(nLines), 1, 2)
Endif
nTextHeight := GetTextHeight(0, cText, GetWindowFont(nHandle)) * nLines
HMG_ChangeWindowStyle(nHandle, Style, NIL, .F.)
SetProperty(cForm, cControl, "Height", nTextHeight)
Return Nil
But please Mr. Marek do not get me wrong, but it would have been more convenient for you to have posted your example in the CheckBox - Multiline post.
Here in this post we are dealing with RadioGroup issues.
Would you kindly ask to forum administrator to move these two messages (yours and mine about CheckBox) ?
So with this we do not mix the main subjects.
Can you please ask to Mr. Rathinagiri ?
Thanks in advanced.
Notes: Source code was re-edited to include style option.
Last edited by Pablo César on Tue Feb 07, 2017 4:40 pm, edited 9 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: RadioGroup can be MULTILINE
No problem. My sample was a little digression to current topic.I don't want to assign CheckBox modification function to my account, because it's only Krzysztof solution little modification
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
CheckBox can be MULTILINE
Many thanks Marek.
If you had not posted your previous message, I would never imagine that in my first code was needed for improving...
Firstly when I make changes first I'm doing for myself and if I think it's good one then I share.
Far from wanting to compete with anyone here in the forum.
Someone knows more of something than someone, I know less than maybe someone and others know more than others in some things.
And when someone presents something better, I and the others should find this very healthy by improving something and instigating to do better...
No one is perfect and letting go of vanity aside is too good to give way for learning.
This is a highly altruistic place and if we do not make good use of it: why publish ? I am right ?
You don't worry and take in mind: we are rich and happy when we have options...
Last edited by Pablo César on Tue Feb 07, 2017 4:56 pm, edited 3 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
CheckBox Centered and Multiline text
Thank you Rathi for moving messages into here.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein