Class: ShapeControl
Properties | Events | Methods | Index of Classes
Demonstrates DataFlex communicating with the Windows API
Hierarchy
cObject > cUIObject > DfBaseObject > DfBaseWindow > DfBaseUIWindow > DfBaseControl > AbstractShapeControl > ShapeControl
Show full hierarchy and direct subclasses
Library: Windows Application Class Library
Package: Dfshape.pkg
Description
ShapeControl is used to demonstrate DataFlex communicating with the Windows API. The class is primarily intended for programmers wishing to understand the integration issues involved between DataFlex and the WinAPI. While no knowledge of WinAPI is needed to use this class, it will be required to understand the class's well-documented source code.
Sample
Use DfAllent.pkg
Use Windows.pkg
Object oHtmlHelp is a cHtmlHelp
End_Object
Object oApplication is a cApplication
Set peHelpType to htHtmlHelp
End_Object // oApplication
Use DFShape.Pkg // DFShape control
Use DFSlider.pkg // TrackBar control
Enum_List
Define C_SHAPEPENCOLOR
Define C_SHAPEFILLCOLOR
Define C_SHAPEBACKCOLOR
End_Enum_List
Object oPanel is a Panel
Set Size to 155 283
Set piMinSize To 155 283
Set Location To 25 25
Set Label To 'ShapeControl Test'
Set Icon To "Default.Ico"
Property Boolean pbNoChanges False
Object oShape is a ShapeControl
Set Location to 5 5
Set Size to 65 167
Set Shape_Fill_Color To clRed
Set Shape_Style To shEllipse
// Shape_Back_Color in DFSHAPE does not redraw as it should when the color
// changes.
Procedure Set Shape_Back_Color integer iColor
Integer iShapeBackColor
Get Shape_Back_Color To iShapeBackColor
If (iShapeBackColor = iColor) Begin
Procedure_Return
End
// only react if the color has changed
Forward Set Shape_Back_Color To iColor
Send Re_Draw_Full
End_Procedure
End_Object
Object oStyleComboForm is a ComboForm
Set Size to 14 114
Set Location to 84 5
Set Label_Justification_Mode to JMode_Top
Set Label_Row_Offset to 2
Set Label_Col_Offset to 0
Set Label to "Style:"
Set Combo_Sort_State to False
Set Entry_State to False
Procedure Combo_Fill_List
Send Combo_Add_Item "Ellipse"
Send Combo_Add_Item "Circle"
Send Combo_Add_Item "Square"
Send Combo_Add_Item "Rectangle"
Send Combo_Add_Item "RoundRectangle"
End_Procedure
Procedure OnChange
String sValue
Get Value To sValue
Case Begin
Case (sValue = "Ellipse")
Set Shape_Style Of oShape To shELLIPSE
Case Break
Case (sValue = "Circle")
Set Shape_Style Of oShape To shCIRCLE
Case Break
Case (sValue = "Square")
Set Shape_Style Of oShape To shSQUARE
Case Break
Case (sValue = "Rectangle")
Set Shape_Style Of oShape To shRECTANGLE
Case Break
Case (sValue = "RoundRectangle")
Set Shape_Style Of oShape To shROUNDRECT
Case Break
Case End
End_Procedure
End_Object
Object oPenWidthSlider is a TrackBar
Set Size to 20 169
Set Location to 111 5
Set Minimum_Position To 1
Set Maximum_Position To 50
Set Label to "Pen Width:"
Set Label_Justification_Mode to JMode_Top
Set Label_Col_Offset to 0
Set Color to clBtnFace
Set peAnchors to anBottomLeft
Procedure OnFinishedSliding
Integer iPos
Get Current_Position To iPos
Set Shape_Pen_Width Of oShape To iPos
End_Procedure
End_Object
Object oColorGroup is a Group
Set Size to 127 90
Set Location to 4 183
Set Label to "Color:"
Set peAnchors to anTopLeftRight
Object oRedColorSlider is a TrackBar
Set Size to 70 23
Set Location to 25 5
Set Minimum_Position To 0
Set Maximum_Position To 255
Set Label to "Red:"
Set Label_Justification_Mode to JMode_Top
Set Label_Col_Offset to 0
Set Orientation_Mode to slVert
Procedure OnSliding
Send ChangeShapeColor
End_Procedure
Procedure OnFinishedSliding
Send ChangeShapeColor
End_Procedure
End_Object
Object oGreenColorSlider is a TrackBar
Set Size to 70 23
Set Location to 25 35
Set Minimum_Position To 0
Set Maximum_Position To 255
Set Label to "Green:"
Set Label_Justification_Mode to JMode_Top
Set Label_Col_Offset to 0
Set Orientation_Mode to slVert
Procedure OnSliding
Send ChangeShapeColor
End_Procedure
Procedure OnFinishedSliding
Send ChangeShapeColor
End_Procedure
End_Object
Object oBlueColorSlider is a TrackBar
Set Size to 70 23
Set Location to 25 61
Set Minimum_Position To 0
Set Maximum_Position To 255
Set Label to "Blue:"
Set Label_Justification_Mode to JMode_Top
Set Label_Col_Offset to 0
Set Orientation_Mode to slVert
Procedure OnSliding
Send ChangeShapeColor
End_Procedure
Procedure OnFinishedSliding
Send ChangeShapeColor
End_Procedure
End_Object
Object oColorWhatComboForm is a ComboForm
Set Size to 14 76
Set Location to 107 8
Set Label_Justification_Mode to JMode_Top
Set Label_Col_Offset to 0
Set Label_Row_Offset to 2
Set Label to "Choose:"
Set Combo_Sort_State to False
Set Entry_State to False
Procedure Combo_Fill_List
Send Combo_Add_Item "Pen Color"
Send Combo_Add_Item "Fill Color"
Send Combo_Add_Item "Back Color"
End_Procedure
Function WhatColorChoice Returns Integer
Integer iColorChoice
String sValue
Get Value To sValue
Case Begin
Case (sValue Matches "P*")
Move C_SHAPEPENCOLOR To iColorChoice
Case Break
Case (sValue Matches "F*")
Move C_SHAPEFILLCOLOR To iColorChoice
Case Break
Case (sValue Matches "B*")
Move C_SHAPEBACKCOLOR To iColorChoice
Case Break
Case End
Function_Return iColorChoice
End_Function
Procedure OnChange
Integer iColor iColorChoice
Get WhatColorChoice To iColorChoice
Case Begin
Case (iColorChoice = C_SHAPEPENCOLOR)
Get Shape_Pen_Color Of oShape To iColor
Case Break
Case (iColorChoice = C_SHAPEFILLCOLOR)
Get Shape_Fill_Color Of oShape To iColor
Case Break
Case (iColorChoice = C_SHAPEBACKCOLOR)
Get Shape_Back_Color Of oShape To iColor
Case Break
Case End
Set pbNoChanges To True
Send DisplayColor iColor
Set pbNoChanges To False
End_Procedure
End_Object
Procedure DisplayColor Integer iColor
Integer iRedColor iGreenColor iBlueColor
Move (R_From_RGB (iColor)) To iRedColor
Move (G_From_RGB (iColor)) To iGreenColor
Move (B_From_RGB (iColor)) To iBlueColor
Set Current_Position Of oRedColorSlider To iRedColor
Set Current_Position Of oGreenColorSlider To iGreenColor
Set Current_Position Of oBlueColorSlider To iBlueColor
End_Procedure
Procedure ChangeShapeColor
Integer iRedColor iGreenColor iBlueColor rgbColor iColorChoice
Boolean bNoChanges
Get pbNoChanges To bNoChanges
If (bNoChanges) Begin
Procedure_Return
End
Get Current_Position Of oRedColorSlider To iRedColor
Get Current_Position Of oGreenColorSlider To iGreenColor
Get Current_Position Of oBlueColorSlider To iBlueColor
Move (RGB (iRedColor, iGreenColor, iBlueColor)) To rgbColor
Get WhatColorChoice Of oColorWhatComboForm To iColorChoice
Case Begin
Case (iColorChoice = C_SHAPEPENCOLOR)
Set Shape_Pen_Color Of oShape To rgbColor
Case Break
Case (iColorChoice = C_SHAPEFILLCOLOR)
Set Shape_Fill_Color Of oShape To rgbColor
Case Break
Case (iColorChoice = C_SHAPEBACKCOLOR)
Set Shape_Back_Color Of oShape To rgbColor
Case Break
Case End
End_Procedure
End_Object
End_Object
Start_UI
Syntax
Use DFShape
Object object_name is a ShapeControl
Set Shape_Style To style
Set Shape_Pen_Color To rgb color
Set Shape_Pen_Width To width
Set Shape_Pen_Style To windows' pen-style
Set Shape_Fill_Color To rgb color
Set Shape_Back_Color To rgb color
Procedure UserPaint
:
End_Procedure
End_Object