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 8589 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 !