Thank you maestro !srvet_claudio wrote:Very Nice Pablo!!!
PS: After using the handle DC you must release
Now fixed and improved !
<Attached files was removed by the reason, there is at last my message in this topic with updated files.>
Moderator: Rathinagiri
Thank you maestro !srvet_claudio wrote:Very Nice Pablo!!!
PS: After using the handle DC you must release
Code: Select all
/*
DrawEdge Demo
Author: Pablo César Arrascaeta
The Win32 API features a new function called DrawEdge.
Its purpose is to draw 3D effects for all Windows applications.
The DrawEdge function is a useful function provided by the Win32 API.
It can draw a variety of the edge styles used to draw buttons,
frames and borders around controls and forms.
*/
#include <hmg.ch>
* type of inner and outer edges (some of them)
#DEFINE BDR_RAISEDOUTER 1
#DEFINE BDR_SUNKENOUTER 2
#DEFINE BDR_RAISEDINNER 4
#DEFINE BDR_SUNKENINNER 8
#DEFINE EDGE_BUMP BDR_RAISEDOUTER + BDR_SUNKENINNER
#DEFINE EDGE_ETCHED BDR_SUNKENOUTER + BDR_RAISEDINNER
#DEFINE EDGE_RAISED BDR_RAISEDOUTER + BDR_RAISEDINNER
#DEFINE EDGE_SUNKEN BDR_SUNKENOUTER + BDR_SUNKENINNER
* type of border (some of them)
#DEFINE BF_LEFT 1
#DEFINE BF_TOP 2
#DEFINE BF_RIGHT 4
#DEFINE BF_BOTTOM 8
#DEFINE BF_RECT 15
#DEFINE BF_DIAGONAL 16
#DEFINE BF_SOFT 4096
#DEFINE BF_FLAT 16384
Function Main()
DEFINE WINDOW Screen_1 AT 151 , 70 WIDTH 900 HEIGHT 560 TITLE "DrawEdge Demo" BACKCOLOR {0,0,64};
MAIN;
ON PAINT Proc_OnPaint()
DEFINE LABEL Label_1
ROW 20
COL 20
WIDTH 192
HEIGHT 24
VALUE "EDGE_BUMP"
FONTNAME "Arial"
FONTSIZE 12
TOOLTIP ""
FONTBOLD .T.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR {0,128,255}
FONTCOLOR NIL
CENTERALIGN .T.
END LABEL
DEFINE MONTHCALENDAR MonthCal_1
ROW 50
COL 20
WIDTH 192
HEIGHT 175
VALUE CTOD(" / / ")
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
TABSTOP .T.
VISIBLE .T.
NOTODAY .F.
NOTODAYCIRCLE .F.
WEEKNUMBERS .F.
END MONTHCALENDAR
DEFINE LABEL Label_2
ROW 20
COL 240
WIDTH 192
HEIGHT 24
VALUE "EDGE_ETCHED"
FONTNAME "Arial"
FONTSIZE 12
TOOLTIP ""
FONTBOLD .T.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR {0,128,255}
FONTCOLOR NIL
CENTERALIGN .T.
END LABEL
DEFINE MONTHCALENDAR MonthCal_2
ROW 50
COL 240
WIDTH 192
HEIGHT 175
VALUE CTOD(" / / ")
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
TABSTOP .T.
VISIBLE .T.
NOTODAY .F.
NOTODAYCIRCLE .F.
WEEKNUMBERS .F.
END MONTHCALENDAR
DEFINE LABEL Label_3
ROW 20
COL 460
WIDTH 192
HEIGHT 24
VALUE "EDGE_RAISED"
FONTNAME "Arial"
FONTSIZE 12
TOOLTIP ""
FONTBOLD .T.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR {0,128,255}
FONTCOLOR NIL
CENTERALIGN .T.
END LABEL
DEFINE MONTHCALENDAR MonthCal_3
ROW 50
COL 460
WIDTH 192
HEIGHT 175
VALUE CTOD(" / / ")
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
TABSTOP .T.
VISIBLE .T.
NOTODAY .F.
NOTODAYCIRCLE .F.
WEEKNUMBERS .F.
END MONTHCALENDAR
DEFINE LABEL Label_4
ROW 20
COL 680
WIDTH 192
HEIGHT 24
VALUE "EDGE_SUNKEN"
FONTNAME "Arial"
FONTSIZE 12
TOOLTIP ""
FONTBOLD .T.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR {0,128,255}
FONTCOLOR NIL
CENTERALIGN .T.
END LABEL
DEFINE MONTHCALENDAR MonthCal_4
ROW 50
COL 680
WIDTH 192
HEIGHT 175
VALUE CTOD(" / / ")
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
TABSTOP .T.
VISIBLE .T.
NOTODAY .F.
NOTODAYCIRCLE .F.
WEEKNUMBERS .F.
END MONTHCALENDAR
PRIVATE Flag_Screen1 := .F.
DEFINE BUTTON Button_2
ROW 270
COL 350
WIDTH 220
HEIGHT 30
ACTION (Flag_Screen1 := .T., Proc_OnPaint())
CAPTION "DrawEdge"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .T.
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
END WINDOW
If !(_HMG_SYSDATA [ 250 ]) // Is XP ?
Setproperty("Screen_1","Width",GetProperty("Screen_1","Width")+100)
Setproperty("Screen_1","MonthCal_2","Col",GetProperty("Screen_1","MonthCal_2","Col")+20)
Setproperty("Screen_1","MonthCal_3","Col",GetProperty("Screen_1","MonthCal_3","Col")+40)
Setproperty("Screen_1","MonthCal_4","Col",GetProperty("Screen_1","MonthCal_4","Col")+60)
Endif
Screen_1.Center
Screen_1.Activate
Return Nil
Procedure Proc_OnPaint()
IF Flag_Screen1 == .T.
Set_Screen1("Screen_1")
ENDIF
Return
Function Set_Screen1 ( cForm )
Local hWnd:=GetFormHandle ( cForm )
Local hDC:=GetDC (hWnd)
DrawEdge( hDC, GetControlCoords(cForm,"MonthCal_1",2), EDGE_BUMP , BF_RECT )
DrawEdge( hDC, GetControlCoords(cForm,"MonthCal_2",2), EDGE_ETCHED, BF_RECT )
DrawEdge( hDC, GetControlCoords(cForm,"MonthCal_3",2), EDGE_RAISED, BF_RECT )
DrawEdge( hDC, GetControlCoords(cForm,"MonthCal_4",2), EDGE_SUNKEN, BF_RECT )
ReleaseDC (hWnd, hDC)
Return Nil
Function GetControlCoords(cForm,cComp,nAdd)
Local aRect:={0,0,0,0}
HB_DEFAULT( @nAdd, 0 )
aRect[1]:=GetProperty(cForm,cComp,"ROW")-nAdd
aRect[2]:=GetProperty(cForm,cComp,"COL")-nAdd
aRect[3]:=GetProperty(cForm,cComp,"HEIGHT")+aRect[1]+(nAdd*2)
aRect[4]:=GetProperty(cForm,cComp,"WIDTH")+aRect[2]+(nAdd*2)
Return aRect
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
HB_FUNC( DRAWEDGE )
{
RECT rc;
rc.top = hb_parvni( 2, 1);
rc.left = hb_parvni( 2, 2);
rc.bottom = hb_parvni( 2, 3);
rc.right = hb_parvni( 2, 4);
hb_retl( DrawEdge( ( HDC ) hb_parnl( 1 ), // handle to device context
&rc, // rectangle coordinates
hb_parnl( 3 ), // type of edge
hb_parnl( 4 ) // type of border
));
}
#pragma ENDDUMP
Thank Claudio for this valuable clarification !srvet_claudio wrote:The correct way to draw on a DC is through the ON PAINT event...
Hi Pablo.Pablo César wrote:But my problem is needing to REFRESHing the current form, but I have not found the right way to do it.
Code: Select all
InvalidateRect (Form.HANDLE , NIL , .F.)
No consegui.srvet_claudio wrote:Code: Select all
InvalidateRect (Form.HANDLE , NIL , .F.)
Now thanks to Claudio indication to start DrawEdge at ON PAINT, this work in good order.esgici wrote:a little problem : when screen changed ( fe selecting another task ) edges goes away
Pablo mira este código:Pablo César wrote:No consegui.srvet_claudio wrote:Code: Select all
InvalidateRect (Form.HANDLE , NIL , .F.)
Probé de todas las formas y lo máximo que consegui es algo invertido/alternado (cuando maximo/minimizo o clico en otra sesion. Archivo adjunto). Algo que todavia no conseguí entender...
Code: Select all
DEFINE BUTTON Button_2
ROW 270
COL 350
WIDTH 220
HEIGHT 30
ACTION ( Flag_Screen1 := ! Flag_Screen1, Set_Screen1 ("Screen_1",Flag_Screen1) )
CAPTION "DrawEdge"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .T.
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
...............
Function Set_Screen1 ( cForm, lOn )
Local hWnd := GetFormHandle ( cForm )
Local hDC := GetDC (hWnd)
DrawEdge( hDC, GetControlCoords(cForm,"MonthCal_1",2), If(lOn,EDGE_BUMP,0) , BF_RECT )
DrawEdge( hDC, GetControlCoords(cForm,"MonthCal_2",2), If(lOn,EDGE_ETCHED,0), BF_RECT )
DrawEdge( hDC, GetControlCoords(cForm,"MonthCal_3",2), If(lOn,EDGE_RAISED,0), BF_RECT )
DrawEdge( hDC, GetControlCoords(cForm,"MonthCal_4",2), If(lOn,EDGE_SUNKEN,0), BF_RECT )
ReleaseDC (hWnd, hDC)
SetProperty(cForm,"Button_2","Caption",If(lOn,"DrawEdge ON","DrawEdge OFF"))
InvalidateRect ( hWnd, NIL, ! lOn )
Return NIL