L'auteur
Mike Gagnon Canada Membre Simple # 0000000025 enregistré le 14/10/2004 Gagnon Mike Pointe Cla H9R 3K8 de la société Carver Technologies Inc. Fiche personnelle
Note des membres
pas de note
Contributions > 11 - GDI +
Manipulation d'images avec GDIPLUS et drag & drop (VFP9.0)
# 0000000163
ajouté le 21/03/2005 16:00:43 et modifié le 29/03/2006
consulté 12405 fois
Niveau
initié Version(s) Foxpro : VFP 9.0
Description
Pre-requis VFP 9.0
Chargez un image, changez la position et la rotation de l'image (popup menu souri droite sur l'image)
Code source :
Public oform1
oform1=Newobject ("form1" )
oform1.Show
Return
Define Class form1 As Form
Top = 12
Left = 151
Height = 598
Width = 582
DoCreate = .T.
Caption = "Form1"
olistener = .Null .
ncurrentpage = 0
*-- XML Metadata for customizable properties
_MemberData = [<VFPData><memberdata name="modifreport" type="method" display="MODIFREPORT"/><memberdata name="xoffset" type="property" display="XOffset"/><memberdata name="yoffset" type="property" display="YOffset"/></VFPData>]
picturetouse = ""
xoffset = ""
yoffset = ""
lcpic = ""
nrotate = 0
Name = "Form1"
Add Object opreviewcontainer As Shape With ;
Top = 0, ;
Left = 4, ;
Height = 554, ;
Width = 577, ;
Anchor = 15, ;
SpecialEffect = 0, ;
Name = "oPreviewContainer"
Add Object command1 As CommandButton With ;
Top = 564, ;
Left = 420, ;
Height = 27, ;
Width = 84, ;
autosize = .t. ,;
Caption = "Charger l'image" , ;
Name = "Command1"
Add Object shape1 As Shape With ;
Top = 120, ;
Left = 108, ;
Height = 97, ;
Width = 229, ;
Name = "Shape1"
Procedure QueryUnload
*** Begin form mediator object code ***
Do Case
Case Not DoDefault ()
Nodefault
Return .F.
Case ( Type ("THIS.app_mediator.BaseClass" )="C" ) And ;
( Not This .app_mediator.QueryUnload () )
Nodefault
Return .F.
Otherwise
Endcase
*** End form mediator object code ***
Endproc
Procedure DragDrop
Lparameters oSource, nXCoord, nYCoord
Endproc
Procedure opreviewcontainer.DragDrop
Lparameters oSource, nXCoord, nYCoord
oSource.Left = nXCoord - Thisform .xoffset
oSource.Top = nYCoord - Thisform .yoffset
Endproc
Procedure opreviewcontainer.MouseDown
Lparameters nButton, nShift, nXCoord, nYCoord
Messagebox ("Mouse position = X= " +Transform (nXCoord)+" Y =" + Transform (nYCoord))
Endproc
Procedure opreviewcontainer.Click
Thisform .MouseDown ()
Endproc
Procedure command1.Click
Public oLogoImage,oGr
lcpic = Getpict ()
Thisform .lcpic = lcpic
Cd Home (1)
Public oGr As GpGraphics Of Home (1)+"ffc/_gdiplus.vcx"
oGr = Newobject ('GpGraphics' ,Home (1)+'ffc/_gdiplus.vcx' )
oGr.CreateFromHWND(Thisform .HWnd )
Public oLogoImage As GpImage Of Home (1)+"ffc/_gdiplus.vcx"
oLogoImage = Newobject ('GpImage' ,Home (1)+'ffc/_gdiplus.vcx' )
oLogoImage.CreateFromFile(Thisform .lcpic)
oRect= Newobject ( ;
'GpRectangle' ,'ffc/_gdiplus.vcx' ,'' ;
, Thisform .shape1.Left ;
, Thisform .shape1.Top ;
, Thisform .shape1.Width ;
, Thisform .shape1.Height ;
)
oGr.DrawImageScaled( oLogoImage, oRect )
Endproc
Procedure shape1.RightClick
lcComm = This
Define Popup shortcut shortcut Relative From Mrow (),Mcol ()
Define Bar 1 Of shortcut Prompt "Rotate Image"
On Bar 1 Of shortcut Activate Popup rotateimag
Define Popup rotateimag shortcut Relative
Define Bar 1 Of rotateimag Prompt "Rotation 90°"
Define Bar 2 Of rotateimag Prompt "Rotation 180°"
Define Bar 3 Of rotateimag Prompt "Rotation 270°"
Define Bar 4 Of rotateimag Prompt "Rotateion 360°"
On Selection Bar 1 Of rotateimag lcComm.MouseMove (1,0,Mrow (),Mcol (),.T. ,1)
On Selection Bar 2 Of rotateimag lcComm.MouseMove (1,0,Mrow (),Mcol (),.T. ,2)
On Selection Bar 3 Of rotateimag lcComm.MouseMove (1,0,Mrow (),Mcol (),.T. ,3)
On Selection Bar 4 Of rotateimag lcComm.MouseMove (1,0,Mrow (),Mcol (),.T. ,0)
Activate Popup shortcut
Endproc
Procedure shape1.DragDrop
Lparameters oSource, nXCoord, nYCoord
This .Parent .DragDrop (oSource, nXCoord, nYCoord)
Endproc
Procedure shape1.MouseMove
Lparameters nButton, nShift, nXCoord, nYCoord, lCheck,lnValue
If lCheck
If Pcount ()= 6
Thisform .nrotate = lnValue
Endif
Endif
If nButton = 1 && Left button
Thisform .xoffset = nXCoord - This .Left
Thisform .yoffset = nYCoord - This .Top
This .Drag
oLogoImage = Newobject ('GpImage' ,Home (1)+'ffc/_gdiplus.vcx' )
oLogoImage.CreateFromFile(Thisform .lcpic)
oLogoImage.RotateFlip (Thisform .nrotate)
oRect= Newobject ( ;
'GpRectangle' ,'ffc/_gdiplus.vcx' ,'' ;
, Thisform .shape1.Left ;
, Thisform .shape1.Top ;
, Thisform .shape1.Width ;
, Thisform .shape1.Height ;
)
oGr.DrawImageScaled( oLogoImage, oRect )
Endif
Endproc
Enddefine
Commentaires
Aucun commentaire enregistré ...