DrawEdge - New feature

Source code related resources

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

DrawEdge - New feature

Post by Pablo César »

srvet_claudio wrote:Very Nice Pablo!!!

PS: After using the handle DC you must release
Thank you maestro ! :)

Now fixed and improved ! :D

<Attached files was removed by the reason, there is at last my message in this topic with updated files.>
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: DrawEdge - New feature

Post by srvet_claudio »

Hi Pablo.
The correct way to draw on a DC is through the ON PAINT event, see this demo:

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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

DrawEdge - New feature

Post by Pablo César »

srvet_claudio wrote:The correct way to draw on a DC is through the ON PAINT event...
Thank Claudio for this valuable clarification ! :)

I made it improvements with your sample, please look up this:

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()
Local Flag_Screen1 := .T.

DEFINE WINDOW Screen_1 AT 151 , 70 WIDTH 900 HEIGHT 360 TITLE "DrawEdge Demo" BACKCOLOR {0,0,64};
    MAIN;
    ON PAINT Set_Screen1("Screen_1",Flag_Screen1)

    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

    DEFINE BUTTON Button_2
        ROW    270
        COL    350
        WIDTH  220
        HEIGHT 30
        ACTION (Flag_Screen1 := Set_Screen1("Screen_1",Flag_Screen1),DoMethod("Screen_1","Minimize"),DoMethod("Screen_1","Restore"))
        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

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)
// RedrawWindow ( hWnd )
lOn := !(lOn)
SetProperty(cForm,"Button_2","Caption",If(lOn,"DrawEdge ON","DrawEdge OFF"))
Return lOn

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
I decided not to create private variable, in place and declared as local and pass it by function with parameter and assignable. I also discovered that is possible to remove DrawEdge from the form too. But my problem is needing to REFRESHing the current form, but I have not found the right way to do it.
So I did through the Minimize/Restore method, which It worked but I would like just updated the screen. Can you tell me how I do this ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: DrawEdge - New feature

Post by srvet_claudio »

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.
Hi Pablo.

Code: Select all

 InvalidateRect (Form.HANDLE , NIL , .F.) 
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

DrawEdge - New feature

Post by Pablo César »

srvet_claudio wrote:

Code: Select all

 InvalidateRect (Form.HANDLE , NIL , .F.) 
No consegui. :cry:

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...

<Attached files was removed. DEMO2 was updated at next messages of this topic>
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

DrawEdge - New feature

Post by Pablo César »

Lo mejor que conseguí es utilizar InvalidateRect alternando con Minimize/Maximize... :oops:

Es decir el InvalidateRect funciona bien en este caso cuando preciso adiconar el DrawEdge.

<Attached files was removed. DEMO2 was updated at next messages of this topic>
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

DrawEdge - New feature

Post by Pablo César »

esgici wrote:a little problem : when screen changed ( fe selecting another task ) edges goes away
Now thanks to Claudio indication to start DrawEdge at ON PAINT, this work in good order. :)

Switchable button DrawEdge ON / OFF implemented.

<Attached files was removed. Files updated at next messages with corrections.>
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: DrawEdge - New feature

Post by srvet_claudio »

Pablo César wrote:
srvet_claudio wrote:

Code: Select all

 InvalidateRect (Form.HANDLE , NIL , .F.) 
No consegui. :cry:

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...
Pablo mira este código:

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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

DrawEdge - New feature

Post by Pablo César »

Great Claudio !!! Thank you very much. I was missing the logic that alternated Button_2 the flag and had no error with the InvalidateRect only solved with the right flag.

Let your example with the corrected name Demo2 for another learning:
Demo2(Exe).rar
(832.16 KiB) Downloaded 297 times
Demo2(Source).rar
(1.93 KiB) Downloaded 275 times
Thank you Claudio ! :D
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: DrawEdge - New feature

Post by Javier Tovar »

Gracias por compartir, Claudio y Pablo César.

Saludos
Post Reply