Page 1 of 3
Draw border
Posted: Wed Sep 25, 2013 11:05 am
by esgici
Hi All
Almost every control has their own border, except a few ones, like Label and image.
This is an humble work to search an easy way to draw a border around controls.
To your interest, critics and suggestions.
- Screen shoot of Test Draw Border prg
- Screen shoot of test DrawBorder.png (153.72 KiB) Viewed 6518 times
- TestBorder.zip
- Source files for Test Draw Border prg
- (66.13 KiB) Downloaded 432 times
By the way, I have a problem; please look at TestBorder.prg line 54-55;
will be appreciated your advice.
Happy HMG'ing
Re: Draw border
Posted: Wed Sep 25, 2013 11:28 am
by bpd2000
Nice
Thank you Esgici
Regards
Re: Draw border
Posted: Wed Sep 25, 2013 11:47 am
by bpd2000
Dear Esgici,
Interesting to me
Where to find more about HB_Default()
Re: Draw border
Posted: Wed Sep 25, 2013 12:44 pm
by serge_girard
Esgici,
Try msgbox with str(aColor [1]) + ' ' + str(aColor [2]) + ' ' + str(aColor [3]).
This should help !
Serge
Re: Draw border
Posted: Wed Sep 25, 2013 1:00 pm
by mol
Hi Esgici!
Your borders look amazing!
Tahks for sharing!
By the way, it's a pity we have no possibility to vertical align of value of label
It was possible in HMG4.
Maybe Rathi or Claudio can do such an improvement...
Regards, Marek
Re: Draw border
Posted: Wed Sep 25, 2013 1:31 pm
by esgici
Hi Dave
bpd2000 wrote:
Where to find more about HB_Default()
Thank to your interest and nice words
Sadly not found (at least I don't know) any documentation about HB_Default()
Based on my experience :
Code: Select all
#include <hmg.ch>
PROCEDURE Main()
TestDefa()
RETURN // Main()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE TestDefa( xParam )
MsgDebug( "Before", xParam ) // NIL
HB_Default( @xParam, 123 ) // IF NIL, assign 123
MsgDebug( "After", xParam ) // 123
RETURN // TestDefa()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
Happy HMG'ing
Re: Draw border
Posted: Wed Sep 25, 2013 1:32 pm
by esgici
Hi Marek
Thank to your interest and nice words
Happy HMG'ing
Re: Draw border
Posted: Wed Sep 25, 2013 1:42 pm
by esgici
Hi Serge
serge_girard wrote:
Try msgbox with str(aColor [1]) + ' ' + str(aColor [2]) + ' ' + str(aColor [3]).
This should help !
Thank to your interest and suggestion
I'm afraid that I couldn't tell
Problem isn't about Message function ( MsgDebug() is very good enhancement, thank to Dr. Soto ).
Problem is in border of image.
Please look at below image: while MsgDebug() is in screen, border seen fine,
- Image border if message in it place
- before.png (307.87 KiB) Viewed 6468 times
when Msg gone ( or replaced ) the border changes
- Image border after message replaced
- after.png (457.74 KiB) Viewed 6468 times
PS: don't look border of Label_4; this image is a bit older.
Happy HMG'ing
Draw border
Posted: Wed Sep 25, 2013 2:20 pm
by Pablo César
Nice work Esgici, I liked !
As you said, the main problem is not based on Msg functions at all (it's my tip too). Even if you do not use msg function and minimize the main window, you will see border will be also changed. I believe it an tipic behaviour of API of OS and probably there is not solution for this...
But I find a way to put borders around IMAGEs:
- Screen.PNG (77.9 KiB) Viewed 6457 times
I put an extra label with same size and position of IMAGE. This could it be not the best practice but could helps until get better solution.
Code: Select all
#include <hmg.ch>
#include "DrawBorder.ch"
Function Main()
* aMyColors := InitColors()
DEFINE WINDOW frmTestBorder AT 100 , 100 WIDTH 583 HEIGHT 385 ;
TITLE "Test Border Function" ICON NIL MAIN ON INIT Draw_All() ;
BACKCOLOR {230,230,216}
ON KEY ESCAPE OF frmTestBorder ACTION ThisWindow.Release
DEFINE LABEL Label_1
ROW 20
COL 40
WIDTH 120
HEIGHT 20
VALUE "Label_1"
FONTNAME "Verdana"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR NIL
FONTCOLOR NIL
END LABEL
DEFINE LABEL Label_2
ROW 80
COL 40
WIDTH 120
HEIGHT 30
VALUE "Label_2"
FONTNAME "Verdana"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR NIL
FONTCOLOR NIL
END LABEL
DEFINE LABEL Label_3
ROW 140
COL 40
WIDTH 120
HEIGHT 60
VALUE "Label_3"
FONTNAME "Verdana"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR NIL
FONTCOLOR NIL
END LABEL
DEFINE BUTTON Button_1
ROW 280
COL 40
WIDTH 100
HEIGHT 28
ACTION Nil
CAPTION "Button_1"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
HELPID Nil
FLAT .F.
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
MULTILINE .F.
PICTURE Nil
PICTALIGNMENT TOP
END BUTTON
DEFINE BUTTON Button_2
ROW 280
COL 220
WIDTH 100
HEIGHT 28
ACTION Nil
CAPTION "Button_2"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
HELPID Nil
FLAT .F.
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
MULTILINE .F.
PICTURE Nil
PICTALIGNMENT TOP
END BUTTON
DEFINE BUTTON Button_3
ROW 280
COL 420
WIDTH 100
HEIGHT 28
ACTION DrawWideBorder( "frmTestBorder", "Image_1", { 164, 260, 155 } )
CAPTION "Button_3"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
HELPID Nil
FLAT .F.
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
MULTILINE .F.
PICTURE Nil
PICTALIGNMENT TOP
END BUTTON
DEFINE LABEL Label_4
ROW 230
COL 40
WIDTH 480
HEIGHT 20
VALUE "Label_4"
FONTNAME "Verdana"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR NIL
FONTCOLOR NIL
END LABEL
DEFINE LABEL Label_5
ROW 41
COL 221
WIDTH 300
HEIGHT 150
VALUE ""
FONTNAME "Verdana"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR NIL
FONTCOLOR NIL
END LABEL
DEFINE IMAGE Image_1
ROW 40
COL 220
WIDTH 300
HEIGHT 150
PICTURE "HMG_Unicode.PNG"
HELPID Nil
VISIBLE .T.
STRETCH .F.
ACTION Nil
END IMAGE
END WINDOW
* frmTestBorder.Center
frmTestBorder.Activate
Return Nil
Function Draw_All()
DRAW BORDER WINDOW "frmTestBorder" CONTROL "Label_1"
DRAW BORDER WINDOW "frmTestBorder" CONTROL "Label_2" PENWIDTH 3 UPCOLOR 1 DOWNCOLOR 0
DRAW BORDER WINDOW "frmTestBorder" CONTROL "Label_3" PENWIDTH 3 UPCOLOR 0 DOWNCOLOR 1
DRAW BORDER WINDOW "frmTestBorder" CONTROL "Label_4" PENWIDTH 3 UPCOLOR { 190, 210, 230 } DOWNCOLOR { 100, 149, 237 }
DRAW BORDER WINDOW "frmTestBorder" CONTROL "Label_5" PENWIDTH 3 UPCOLOR 1 DOWNCOLOR 0
DRAW BORDER WINDOW "frmTestBorder" CONTROL "Button_1"
DRAW BORDER WINDOW "frmTestBorder" CONTROL "Button_2" PENWIDTH 3 UPCOLOR 1 DOWNCOLOR 0
DRAW BORDER WINDOW "frmTestBorder" CONTROL "Button_3" PENWIDTH 3 UPCOLOR 0 DOWNCOLOR 1
// DrawWideBorder( "frmTestBorder", "Image_1", { 164, 260, 155 } )
// DrawWideBorder( "frmTestBorder", "Label_5", { 164, 260, 155 } )
Return Nil
Function DrawWideBorder( cWindowName, cControlName, aColor, nSpace, nStep )
Local nWidness
HB_DEFAULT( @nSpace, 10 )
HB_DEFAULT( @nStep, 1 )
FOR nWidness := 1 TO nSpace STEP nStep
DRAW BORDER WINDOW cWindowName CONTROL cControlName UPCOLOR aColor DOWNCOLOR aColor SPACE nWidness
aColor[ 1 ] -= 10
aColor[ 2 ] -= 10
aColor[ 3 ] += 10
NEXT
* Problem :
* results of below changes on color array gone away After that msg :(
MsgDebug( aColor )
Return Nil
One suggestion is to have as option of rounded border at corner if is possible.
Thank you for your sharing and I also did not know about
HB_DEFAULT(), thank again for sharing !
Re: Draw border
Posted: Wed Sep 25, 2013 3:00 pm
by esgici
Hi Serge
esgici wrote:
I'm afraid that I couldn't tell
Sorry for inaccurate information
Anyway this message was added to see ( and demonstrate ) deterioration in the border
Happy HMG'ing