Draw border
Moderator: Rathinagiri
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Draw border
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.
By the way, I have a problem; please look at TestBorder.prg line 54-55;
will be appreciated your advice.
Happy HMG'ing
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.
By the way, I have a problem; please look at TestBorder.prg line 54-55;
will be appreciated your advice.
Happy HMG'ing
Last edited by esgici on Wed Sep 25, 2013 5:40 pm, edited 2 times in total.
Viva INTERNATIONAL HMG
Re: Draw border
Dear Esgici,
Interesting to me
Where to find more about HB_Default()
Interesting to me
Where to find more about HB_Default()
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Draw border
Esgici,
Try msgbox with str(aColor [1]) + ' ' + str(aColor [2]) + ' ' + str(aColor [3]).
This should help !
Serge
Try msgbox with str(aColor [1]) + ' ' + str(aColor [2]) + ' ' + str(aColor [3]).
This should help !
Serge
There's nothing you can do that can't be done...
Re: Draw border
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
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
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Draw border
Hi Dave
Sadly not found (at least I don't know) any documentation about HB_Default()
Based on my experience :
Happy HMG'ing
Thank to your interest and nice wordsbpd2000 wrote: Where to find more about HB_Default()
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
Last edited by esgici on Wed Sep 25, 2013 1:45 pm, edited 1 time in total.
Viva INTERNATIONAL HMG
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Draw border
Hi Serge
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,
when Msg gone ( or replaced ) the border changes
PS: don't look border of Label_4; this image is a bit older.
Happy HMG'ing
Thank to your interest and suggestionserge_girard wrote: Try msgbox with str(aColor [1]) + ' ' + str(aColor [2]) + ' ' + str(aColor [3]).
This should help !
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,
when Msg gone ( or replaced ) the border changes
PS: don't look border of Label_4; this image is a bit older.
Happy HMG'ing
Viva INTERNATIONAL HMG
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Draw border
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: 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.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 !
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: 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
Thank you for your sharing and I also did not know about HB_DEFAULT(), thank again for sharing !
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
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Draw border
Hi Serge
Anyway this message was added to see ( and demonstrate ) deterioration in the border
Happy HMG'ing
Sorry for inaccurate informationesgici wrote: I'm afraid that I couldn't tell
Anyway this message was added to see ( and demonstrate ) deterioration in the border
Happy HMG'ing
Viva INTERNATIONAL HMG