Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Imageviewer
Message
 
À
12/06/2010 03:29:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01467175
Message ID:
01468751
Vues:
59
>Yes, that's what I wanted to do at first but ... I was asked if it was possible to have a changing background and if buttons could be a >bit transparent and freely placed on the screen.

Yes it is, but you'd have to "roll your own" buttons using containers, image class and timer event. It's gonna consume keyboard time to get it done right - but maybe this will help get you started:
* The parent container class might look like this
DEFINE CLASS cntButtonClass as Container
* State is left digit of tag "0"=None,"1"=Mixed ON,
* "2"=Mixed OFF,"3"=Enabled,"4"/Disabled
top=3
height=24
width=24
backstyle=0
borderwidth=0
style=3 &&Themed
visible=.t.
PROCEDURE MouseDown (nButton, nShift, nXCoord, nYCoord)
IF this.enabled
   this.Style= 0
   this.BackStyle=0
   this.specialeffect= 1
ELSE 
ENDIF 
ENDPROC 
PROCEDURE MouseEnter (nButton, nShift, nXCoord, nYCoord)
IF this.Enabled
   this.backStyle= 1
   this.BorderWidth=1
ELSE
ENDIF 
ENDPROC 
PROCEDURE MouseLeave (nButton, nShift, nXCoord, nYCoord)
this.backStyle= 0
this.BorderWidth=0
ENDPROC 
PROCEDURE Mouseup (nButton, nShift, nXCoord, nYCoord)
this.Style= 3
this.BackStyle=1
this.specialeffect=2
ENDPROC 
PROCEDURE click
IF this.tag=[4] && Disabled
   *Do nothing
ELSE 
   runSomething(this.name)
ENDIF 
ENDPROC
ADD OBJECT imgButtonAble as imgButtonClass
ADD OBJECT imgButtonDisable as imgButtonClass
ENDDEFINE &&CLASS cntButtonClass as Container
You'd also need a routine to manage the state of the button when clicked or, for example, an alternative process services the process a button click does
PROCEDURE buttonProgramaticEnable(oButton as Container,lEnable as logical)
WITH oButton
IF lEnable AND .tag=[4] OR !lEnable AND .tag=[3]
   .imgButtonAble.visible=lEnable &&!this.imgButtonAble.visible
   .imgButtonDisable.visible=!lEnable &&!this.imgButtonDisable.visible
   .Enabled=lEnable
   .tag=IIF(lEnable,[3],[4])
ELSE && Just leave it alone
ENDIF 
ENDWITH 
ENDPROC &&buttonProgramaticEnable(oButton,lEnable)
You need the image class. This one has an enabled and disabled image and is added to the button class at instantiation
DEFINE CLASS imgButtonClass as Image
top=1
left=1
height=22
width=22
backstyle=0
backcolor=RGB(255,255,255)
stretch=0
PROCEDURE init
this.tooltiptext=this.Parent.tooltiptext
ENDPROC 
PROCEDURE MouseDown (nButton, nShift, nXCoord, nYCoord)
this.Parent.MouseDown (nButton, nShift, nXCoord, nYCoord)
ENDPROC 
PROCEDURE MouseUp (nButton, nShift, nXCoord, nYCoord)
this.Parent.MouseUp (nButton, nShift, nXCoord, nYCoord)
ENDPROC 
PROCEDURE MouseEnter (nButton, nShift, nXCoord, nYCoord)
this.Parent.MouseEnter (nButton, nShift, nXCoord, nYCoord)
ENDPROC 
PROCEDURE MouseLeave (nButton, nShift, nXCoord, nYCoord)
this.Parent.MouseLeave (nButton, nShift, nXCoord, nYCoord)
ENDPROC 
PROCEDURE click
this.parent.click
ENDPROC 
ENDDEFINE
* You might want a separator to put between the buttons:
DEFINE CLASS cntSeperatorClass as Container
top=3
height=25
width=2
style=0 &&Normal
specialeffect=1 && Sunken
backstyle = 0 && Transpartentb
visible=.t.
ENDDEFINE
Next the subclass
DEFINE CLASS cntHelpClass as cntButtonClass
tag=[0]
visible=.t.
Tooltiptext=[Open the help screen]
PROCEDURE init
this.imgButtonAble.Picture=("tix\helpable.gif")
this.imgButtonDisable.Picture=("tix\helpdisable.gif")
this.imgButtonAble.visible=.t.
this.imgButtondisable.visible=.f.
ENDPROC 
ENDDEFINE
* And finally - after all that you'd want to put you buttons in a tool bar (container)
DEFINE CLASS cntToolBarClass as Container
*LEFT_FOR_SEPERATOR_AFTER_TB_BUTTON 27
*LEFT_FOR_TB_BUTTON_AFTER_SEPERATOR 5
*LEFT_FOR_TB_BUTTON_AFTER_TB_BUTTON 27
*LEFT_FOR_MB_BUTTON_AFTER_TB_BUTTON 24
*LEFT_FOR_SEPERATOR_AFTER_MB_BUTTON 12
top=3
left=LEFT_PANEL_LEFT
height=30
style=3
backstyle=1
width=WIDTH_PAGEFRAME-4 && Note these guys look great on top of a page object
ADD OBJECT cntHelp as cntHelpClass && Width 24
cntClose.left=3
ADD OBJECT s1 as cntSeperatorClass && WIdth 2
s1.left=this.cntClose.left+LEFT_FOR_SEPERATOR_AFTER_TB_BUTTON
visible=.t.
ENDDEFINE
* Then a click event
PROCEDURE runSomething(pcButtonName as string)
IF pcButtonName="CNTHELP"
       runOpenHelpForm()
   ELSE 
   ENDIF 
ELSE 
ENDIF
ENDPROC
It took me a week to figure it out. Once you get the static images working, you could substitute a timer/image service to get the effect you're looking for.



>I tried many roads, using layered forms. I also create a top level trasparent form for each button but... i noticed that i had to click over its border to activate it before the button or the image contained became enabled. The other problem was that I had a rectangular shape
>of the form alo if the button is circular... it's a pity VFP don't support png trasparency :(
>Actually I'm trying to put all the buttons on a single trasprent top level form..
>The application is not a pos application but jus a totem information point :)
>thank you for your reply
>Alessio
>>>What's that ?
>>
>>It a doodle demonstrating the use of timers to control location and size of images. I use a version of it as an "atom" that spins in my tool bar. I read your previous post and responded.IMO - you may not need to consider timers and moving images.
>>
>>If the app is a business app for a touch screen the a left menu for function and a horizontal for operations within the function (like the "My Computer" Dialog. It may be more efficient just to reuse the objects and [simply] change their captions [plus] include a switch routine in the method that will route to processes based on the current function.
>>
>>>>Alessio
>>>>
>>>>The answer is obviously to use one form instead of 2 and use the imgCanvas to fade in /out the images.
>>>>
>>>>>Well, I made the image mixer myself by managing two different form using a timer and GDI+X
>>>>>these two forms are the background of my application.
>>>>>Actually I broke into this new problem :
>>>>>As I need to place a certain number of commandButtons over this changing backgound, i placed each of this commandbutton over
>>>>>a different form which is a toplevel form with the alwaysontop property set on .T. and a bit trasparent too.
>>>>>What happened is that I cannot click the button unless I select the form first. What can I do ? The application need to be managed
>>>>>by a touch screen.
>>>>>
>>>>>Thanks
>>>>>Alessio
>>>>>
>>>>>>>Hi all,
>>>>>>>I want to switch the background picture of a form from a picture to another with a rtansition effect.
>>>>>>>I was thinking about placing an ocx which can do the job on that form, but I havent- found one yet.
>>>>>>>
>>>>>>>thanks
>>>>>>>Alessio
>>>>>>
>>>>>>As Sergey said, an activex would cover everything on the form.
>>>>>>
>>>>>>If it is only a simple Fade-In/Fade-Out transition that can be done easily using GDI+X and a timer.
>>>>>>
>>>>>>Basically you add an imagecanvas object and a timer. You create 2 graphic objects and then you increase the Alpha of one while reducing the alpha of the other.
>>>>>>
>>>>>>I have already created such a class so if your email here on the UT is current let me know and I will send the class and sample form to you.
>>>>>>
>>>>>>Bernard
Imagination is more important than knowledge
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform