I have developed a small progress bar class that I want to create as a separate process, to ensure the animation still works when carrying out intensive database tasks. Unfortunately it is not working. The class prg is detailed below. If you copy and paste it as a prg and run it, you will see the progress bar running.
However if you add 'OLEPUBLIC' to the class definition, add it to a project, compile it as an EXE, and then try creating an instance using CreateObject("MyEXE.msgclass") (where MyEXE is the name of the compiled project), you will notice that nothing happens.
Have I missed something out, as the class works fine as a prg, but not a EXE.
Thanks in advance
Chris
Here comes the code;
However if you add 'OLEPUBLIC' to the class definition, add it to a project, compile it as an EXE, and then try creating an instance using CreateObject("MyEXE.msgclass") (where MyEXE is the name of the compiled project), you will notice that nothing happens.
Have I missed something out, as the class works fine as a prg, but not a EXE.
Thanks in advance
Chris
Here comes the code;
Code:
Public otest
otest = CreateObject("msgclass")
otest.start("hello!")
DEFINE CLASS msgclass AS form && OLEPUBLIC
Height = 90
Width = 277
DoCreate = .T.
AutoCenter = .T.
BorderStyle = 2
Visible = .F.
TitleBar = 0
WindowType = 0
AlwaysOnTop = .T.
*-- Contains the file name of the avi video to run
avifilename = "c:\work\vfp\ems\multimedia\filemove.avi"
Name = "message"
ADD OBJECT lblmessage AS label WITH ;
Alignment = 0, ;
Caption = "lblMessage", ;
Height = 17, ;
Left = 0, ;
Top = 59, ;
Width = 274, ;
Name = "lblMessage"
ADD OBJECT vcr AS olecontrol WITH ;
Top = 0, ;
Left = 0, ;
Height = 61, ;
Width = 276, ;
Name = "VCR", ;
OleClass = "MSComCtl2.Animation.2"
ADD OBJECT progressbar AS olecontrol WITH ;
Top = 76, ;
Left = 0, ;
Height = 14, ;
Width = 276, ;
Visible = .F., ;
Name = "ProgressBar", ;
OleClass = "MSComctlLib.ProgCtrl.2"
*-- This shows the form and runs the avi
PROCEDURE start
********************************************************************
* Name: MESSAGE.START()
* Description: Shows the form and runs the AVI video
* Author: Chris Crowhurst
* Date: 28/09/2005
* Revision history:
* {Date} {Programmer} {Version} {Comments}
* 28/09/2005 CMC 7.06.01 First Version
* Inputs: none
* Outputs: none
********************************************************************
Parameters tcMessage As Character
* Display message if required
If Type("tcMessage")="C"
Thisform.lblMessage.Caption = tcMessage
Else
* No message so hide it
Thisform.lblMessage.Visible = .F.
EndIf
* Show the form
ThisForm.Show()
* Play the avi
This.Playvideo()
* Wait for very small keypress, this allows the AVI to play when
* launched from other forms
Inkey(0.01,"HM")
ENDPROC
*-- This method stops the video and releases the form
PROCEDURE stop
********************************************************************
* Name: MESSAGE.STOP()
* Description: Stops the avi file and releases this form
* Author: Chris Crowhurst
* Date: 28/09/2005
* Revision history:
* {Date} {Programmer} {Version} {Comments}
* 28/09/2005 CMC 7.06.00 First Version
* Inputs: none
* Outputs: none
********************************************************************
ThisForm.VCR.Stop()
ThisForm.Release
ENDPROC
PROCEDURE avifilename_assign
LPARAMETERS vNewVal
*To do: Modify this routine for the Assign method
THIS.avifilename = m.vNewVal
This.Playvideo()
ENDPROC
*-- Plays the avi video file
PROCEDURE playvideo
********************************************************************
* Name: MESSAGE.PLAYVIDEO
* Description: Plays the avi file specified in property avifilename
* Author: Chris Crowhurst
* Date: 28/09/2005
* Revision history:
* {Date} {Programmer} {Version} {Comments}
* 28/09/2005 CMC 7.06.01 First Version
* Inputs:
* Outputs:
********************************************************************
If Not Empty(Thisform.avifilename)
ThisForm.VCR.Stop
ThisForm.VCR.Open(Thisform.avifilename)
ThisForm.VCR.Play
EndIf
ENDPROC
*-- Displays a progress bar on the message window.
PROCEDURE showprogress
********************************************************************
* Name: MESSAGE.SHOWPROGRESS
* Description: Displays a progress bar on the window
* based on the parameters passed
* Author: Chris Crowhurst
* Date: 28/09/2005
* Revision history:
* {Date} {Programmer} {Version} {Comments}
* 28/09/2005 CMC 7.06.01 First Version
* Inputs: tnCount - Current number or percentage if on tnCount is passed
* tnMax - Max number of items on progress bar
* Outputs:
********************************************************************
LParameters tnCount,tnMax
This.ProgressBar.Min = 1
DO Case
* Show N of M
Case Type("tnCount")="N" And Type("tnMax")="N"
This.ProgressBar.Max = tnMax
DO Case
Case tnCount < 1
This.ProgressBar.Value = 1
Case tnCount > tnMax
This.ProgressBar.Value = tnMax
Otherwise
This.ProgressBar.Value = tnCount
EndCase
This.ProgressBar.Visible = .T.
* Show a percentage
Case Type("tnCount")="N" And Type("tnMax")<>"N"
This.ProgressBar.Max = 100
DO Case
Case tnCount < 1
This.ProgressBar.Value = 1
Case tnCount > 100
This.ProgressBar.Value = 100
Otherwise
This.ProgressBar.Value = tnCount
EndCase
This.ProgressBar.Visible = .T.
EndCase
ENDPROC
PROCEDURE Refresh
Thisform.VCR.Refresh
ENDPROC
PROCEDURE Resize
*!* With Thisform.VCR
*!* .Height = ThisForm.Height - Thisform.lblMessage.Height - 5
*!* .Width = ThisForm.Width - 4
*!* .Refresh
*!* EndWith
Thisform.VCR.Refresh
ENDPROC
PROCEDURE Init
********************************************************************
* Name: MESSAGE.INIT
* Description: Initialises form and video controls
* Author: Chris Crowhurst
* Date: 28/09/2005
* Revision history:
* {Date} {Programmer} {Version} {Comments}
* 28/09/2005 CMC 7.06.01 First Version
* Inputs: none
* Outputs: none
********************************************************************
* Check to see if OCX IS installed and loaded.
If Type("THIS.VCR") # "O" Or Isnull(This.VCR)
Return .F.
EndIf
_VFP.AutoYield = .F.
ENDPROC
PROCEDURE Destroy
_VFP.AutoYield = .T.
ENDPROC
ENDDEFINE
*
*-- EndDefine: message
**************************************************