Home > Archive > Clarion > January 2006 > Regions : Advice request
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Regions : Advice request
|
|
| horizonx@noos.fr 2005-12-17, 6:55 pm |
| Hi,
Back again hand coding in Clarion. I'd like to be able to create
regions the user could :
- take action upon when mousing on
- resize
- move
- create new ones
hopefully avoid redraw flickering while moving regions, but that I can
live with
cariety of region shapes as in :
CreateEllipticRgn
CreateRoundRectRgn
CreatePolygonRgn
I tried to get the winAPI GDI functions to work but I can't display the
regions I create. I do get a handle for the region created though.
I got Rectangle() to work but have to keep redrawing it whereas colors
on Region should hopefully be "sticky" when moved.
I can't get PaintRgn nor FillRgn to display anything, actually those
functions fail.
Question :
Are regions the best construct to do what I want ?
Any code sample to paint regions created through the GDI functions ?
Thanks for everything,
Arb
| |
| sandinzz@yahoo.com 2006-01-10, 3:55 am |
| Hi. Here is the code with no flickering while moving region. Flickering
may apears when the window is too complex - consists of many controls.
!
! LOCAL VARIABLES
!
TRIGGERED BYTE(False)
! REGION POSITIONS
GETAT1 SHORT
GETAT1 SHORT
GETAT1 SHORT
GETAT1 SHORT
! BEGINNING POSITIONS
BEG_X SHORT
BEG_Y SHORT
! CURRENT POSITIONS
CUR_X SHORT
CUR_Y SHORT
! DELTA = DIFFERENCE OF POSITIONS
DEL_X SHORT
DEL_Y SHORT
!
! CODE IN REGION CONTROL ?Region1
!
! Accepted
!
CASE KEYCODE()
OF MOUSELEFT
TRIGGERED = TRUE
BEG_X = MOUSEX()
BEG_Y = MOUSEY()
GETPOSITION(?REGION1,GETAT1,GETAT2,GETAT3,GETAT4)
!OF MOUSELEFT2
! do something else ...
!WIN1()
END
!
! MouseMove
!
CUR_X = MOUSEX()
CUR_Y = MOUSEY()
IF TRIGGERED
DEL_X = CUR_X - BEG_X
DEL_Y = CUR_Y -BEGC_Y
IF GETAT1 + DEL_X < 0
GETAT1 = -DEL_X
END
IF GETAT2 + DEL_Y < 0
GETAT2 = -DEL_Y
END
SETPOSITION(?REGION1,GETAT1 + DEL_X,GETAT2 + DEL_Y,GETAT3,GETAT4)
END
!
! MouseUp
!
! UPDATE values in database ...
TRIGGERED = FALSE
About creating controls, see example in Clarion help, topic - CREATE
(return new control created). Zoran
| |
| horizonx@noos.fr 2006-01-10, 3:55 am |
| Hi Sandy,
Thanks for the GETPOSITION function.
I solved a lot of issues, but I am still fighting with this one :
I created several controls and now I'd like to know which one just got
clicked.
FIELD() should do the job, however I can't get the Field number unless
I double click on the REGION which is not handy when you wish to move
it ...
Arb
sandinzz@yahoo.com a =E9crit :
> Hi. Here is the code with no flickering while moving region. Flickering
> may apears when the window is too complex - consists of many controls.
> !
> ! LOCAL VARIABLES
> !
> TRIGGERED BYTE(False)
> ! REGION POSITIONS
> GETAT1 SHORT
> GETAT1 SHORT
> GETAT1 SHORT
> GETAT1 SHORT
> ! BEGINNING POSITIONS
> BEG_X SHORT
> BEG_Y SHORT
> ! CURRENT POSITIONS
> CUR_X SHORT
> CUR_Y SHORT
> ! DELTA =3D DIFFERENCE OF POSITIONS
> DEL_X SHORT
> DEL_Y SHORT
> !
> ! CODE IN REGION CONTROL ?Region1
> !
> ! Accepted
> !
> CASE KEYCODE()
> OF MOUSELEFT
> TRIGGERED =3D TRUE
> BEG_X =3D MOUSEX()
> BEG_Y =3D MOUSEY()
> GETPOSITION(?REGION1,GETAT1,GETAT2,GETAT3,GETAT4)
> !OF MOUSELEFT2
> ! do something else ...
> !WIN1()
> END
> !
> ! MouseMove
> !
> CUR_X =3D MOUSEX()
> CUR_Y =3D MOUSEY()
> IF TRIGGERED
> DEL_X =3D CUR_X - BEG_X
> DEL_Y =3D CUR_Y -BEGC_Y
> IF GETAT1 + DEL_X < 0
> GETAT1 =3D -DEL_X
> END
> IF GETAT2 + DEL_Y < 0
> GETAT2 =3D -DEL_Y
> END
> SETPOSITION(?REGION1,GETAT1 + DEL_X,GETAT2 + DEL_Y,GETAT3,GETAT4)
> END
> !
> ! MouseUp
> !
> ! UPDATE values in database ...
> TRIGGERED =3D FALSE
>
> About creating controls, see example in Clarion help, topic - CREATE
> (return new control created). Zoran
| |
| sandinzz@yahoo.com 2006-01-10, 3:55 am |
| Hi, Arb.
I have the same problem about controls. So, see the topic: "Performing
a code when user "hover" the
cursor over a control." I got two sugestions and Leonid Chudakov
pointed me to the Icetips site where I
found (btnicon.zip) template which could solve the problem. There is
not template but ABC class and user
must derive new subclass. Some other clarion programmer sugested me to
do the following procedure,
so:
1. copy *.inc and *.clw source files to clarion's libsrc folder
2.In global properties - classes - refresh applicatoin builder class
Information
3. go to application builder class viewer, tab Class files - there is
new class btnintr.inc
4. Go to the "main" procedure - properties - window behaviour - classes
- toolbar class (???) - turn off: use
default abc: toolbar class, choose use application builder class, find
our new class WndButtonClass --- I
stopped here (***) cause I did not find WndButtonClass --- check derive
option, go to new class method -
insert New Method name and New Method prototype:
New Method name: GetMenuIcon
New Method Prototype: (signed equateLabel, *cstring resourceNamea),
derived
I did not finish the procedure because of (***). Tell me if you have
any sugestions.
Here is description how I solved the problem.
1. declare an array of short type, MyArray, DIM is 10 for example,
which will keep FEQ of your controls !!!
2. Initialize MyArray
MyArray[1] = ?Button1
MyArray[2] = ?Button2
etc
3. Place region control over the whole window and check immediate prop.
(I think it must be placed on the
very beginnig of the window)
4. set timer prop. for your window, so in window timer event put the
code which finds out if the cursor is over
button (or any other) control. This is why is good to use array.
LOOP IDX# = 1 TO 10
GETPOSITION(MyArray[IDX#],XPOSB,YPOSB,WI
DTHB,HEIGHTB)
IF XPOSB =< MOUSEX() AND MOUSEX() < XPOSB + WIDTHB AND |
YPOSB =< MOUSEY() AND MOUSEY() < YPOSB + HEIGHTB
SELECTEDB = IDX#
!
! program acts as if you selected an button by clicking on it
! good is that you DON'T have tu put code an EVERY button
control
! usually, you would have to put SELECTEDB = 1 in ?Button1
control, for example
!
BREAK
ELSE
SELECTEDB = 0
END
END
5. put the code in region's accepted, move, up embed points if you want
to do something/anything with
selected control, if SELECTEDB is not zero.
All this works fine.Have on mind the FEQ for window is 0. If you get
any strange behavior, check out
initialisation of your array.
Best wishes. Zoran
|
|
|
|
|