Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Microsoft Toolbar Version 6.0
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00133434
Message ID:
00134900
Vues:
14
OK. I have the answer to everyone's question on this as i have found a work around that, while it may take a little while to implement, works beautifully.

The trick is to create a subclass of the Toolbar control and a subclass of the coolbar control (both version 6).

the code to do this follows:

**************************************************
*-- Class: ccoolbar (c:\proj\talon\libs\activex.vcx)
*-- ParentClass: olecontrol
*-- BaseClass: olecontrol
*-- OLEObject = C:\WINDOWS\SYSTEM\COMCT332.OCX
*
DEFINE CLASS ccoolbar AS olecontrol


Height = 100
Width = 100
cimagelistclass = ""
cimagelistclasslib = ""
Name = "ccoolbar"


PROCEDURE recalclayout
LPARAMETERS loBand

ASSERT VarType(loBand) = "O" MESSAGE THIS.Class + "::RecalcLayout() loBand parameter not optional!"

IF VarType(loBand.Child) = "O"
IF loBand.Width - 5 < loBand.Child.nMaxWidth &&loBand.Width - 5 <> loBand.Child.Width && OR loBand.Left <> loBand.Child.Left
LOCAL lnLeft, lnIndex

lnIndex = loBand.Index - 1

IF lnIndex > 0
lnLeft = THIS.Bands[lnIndex].Width + 10
ELSE
lnLeft = 5
ENDIF

loBand.Child.Width = loBand.Width - 5
loBand.Child.Top = 0
loBand.Child.Left = lnLeft
ENDIF
ENDIF
ENDPROC


PROCEDURE Init
IF NOT DoDefault()
RETURN .F.
ENDIF

THIS.Width = THISFORM.Width - 2

THIS.Resize()
ENDPROC


PROCEDURE Resize
*** ActiveX Control Event ***
LOCAL llLockScreen, lnLoop, lnBands

llLockScreen = THISFORM.LockScreen
THISFORM.LockScreen = .T.

IF VarType(THIS.Bands[1]) = "O"
lnBands = THIS.Bands.Count

IF lnBands > 0
FOR lnLoop = 1 TO lnBands
IF VarType(THIS.Bands[lnLoop]) = "O"
THIS.RecalcLayout(THIS.Bands[lnLoop])
ENDIF
ENDFOR
ENDIF
ENDIF

THISFORM.LockScreen = llLockScreen
ENDPROC


PROCEDURE MouseMove
*** ActiveX Control Event ***
LPARAMETERS button, shift, x, y

THIS.Resize()
ENDPROC


ENDDEFINE
*
*-- EndDefine: ccoolbar
**************************************************


**************************************************
*-- Class: ctoolbar (c:\proj\talon\libs\activex.vcx)
*-- ParentClass: olecontrol
*-- BaseClass: olecontrol
*-- OLEObject = C:\WINDOWS\SYSTEM\MSCOMCTL.OCX
*
DEFINE CLASS ctoolbar AS olecontrol


Height = 40
Width = 100
Align = 1
oconfig = .NULL.
oimagelist = .NULL.
cconfigurationclass = ""
cconfigurationclasslib = ""
cimagelistclass = ""
cimagelistclasslib = ""
nmaxwidth = 0
Name = "ctoolbar"


PROCEDURE addbutton
LPARAMETERS lnIndex, lcKey, lcCaption, lnStyle, lcImage, lcToolTip

ASSERT VarType(lnIndex) = "N" MESSAGE THIS.Class + "::AddButton() lnIndex parameter not optional!"
ASSERT VarType(lcKey) = "C" MESSAGE THIS.Class + "::AddButton() lnIndex parameter not optional!"
ASSERT VarType(lcCaption) = "C" MESSAGE THIS.Class + "::AddButton() lnIndex parameter not optional!"
ASSERT VarType(lnStyle) = "N" MESSAGE THIS.Class + "::AddButton() lnIndex parameter not optional!"
ASSERT VarType(lcImage) = "C" MESSAGE THIS.Class + "::AddButton() lnIndex parameter not optional!"

LOCAL loButton

loButton = THIS.Buttons.Add(lnIndex, lcKey, lcCaption, lnStyle, lcImage)

IF VarType(loButton) = "O"
loButton.Description = lcToolTip
ENDIF
ENDPROC


PROCEDURE decoratetoolbar
IF VarType(THIS.oImageList) = "O"
THIS.ImageList = THIS.oImageList
ENDIF

IF VarType(THIS.oConfig) = "O"
LOCAL lcConfig, lnLoop, lcString, lnIndex, lcKey, lcCaption, lnStyle, lcImage, lcToolTip, lnBegin, lnChars

lcConfig = THIS.oConfig.GetConfigString()

IF NOT Right(lcConfig, 1) = ";"
lcConfig = lcConfig + ";"
ENDIF

IF NOT Left(lcConfig, 1) = ";"
lcConfig = ";" + lcConfig
ENDIF

lnOccurs = Occurs(";", lcConfig) - 1

FOR lnLoop = 1 TO lnOccurs
lnBegin = At(";", lcConfig, lnLoop) + 1
lnChars = At(";", lcConfig, lnLoop + 1) - lnBegin

lcString = Alltrim(SubStr(lcConfig, lnBegin, lnChars))

lnIndex = Val(Alltrim(SubStr(lcString, 1, At("|", lcString) - 1)))
lcString= Alltrim(SubStr(lcString, At("|", lcString) + 1))

lcKey = Alltrim(SubStr(lcString, 1, At("|", lcString) - 1))
lcString= Alltrim(SubStr(lcString, At("|", lcString) + 1))

lcCaption = Alltrim(SubStr(lcString, 1, At("|", lcString) - 1))
lcString= Alltrim(SubStr(lcString, At("|", lcString) + 1))

lnStyle = Val(Alltrim(SubStr(lcString, 1, At("|", lcString) - 1)))
lcString= Alltrim(SubStr(lcString, At("|", lcString) + 1))

lcImage = Alltrim(SubStr(lcString, 1, At("|", lcString) - 1))
lcString= Alltrim(SubStr(lcString, At("|", lcString) + 1))

lcToolTip = Alltrim(SubStr(lcString, 1, At("|", lcString) - 1))

THIS.AddButton(lnIndex, lcKey, lcCaption, lnStyle, lcImage, lcToolTip)
ENDFOR
ENDIF
ENDPROC


PROCEDURE Destroy
IF VarType(THIS.oConfig) = "O"
THIS.oConfig = .NULL.
ENDIF

IF VarType(THIS.oImageList) = "O"
THIS.oImageList = .NULL.
ENDIF

DoDefault()
ENDPROC


PROCEDURE Init
IF NOT DoDefault()
RETURN .F.
ENDIF

IF !EMPTY(THIS.cConfigurationClass) AND !EMPTY(THIS.cConfigurationClassLib)
LOCAL loConfig

loConfig = NewObject(THIS.cConfigurationClass, THIS.cConfigurationClassLib)

IF VarType(loConfig) = "O"
THIS.oConfig = loConfig
ENDIF
ENDIF

IF !EMPTY(THIS.cImageListClass) AND !EMPTY(THIS.cImageListClassLib)
LOCAL loImageList

IF NOT VarType(THISFORM.oImageList) = "O"
THISFORM.NewObject("oImageList", THIS.cImageListClass, THIS.cImageListClassLib)
ENDIF

IF VarType(THISFORM.oImageList ) = "O"
THIS.oImageList = THISFORM.oImageList
ENDIF
ENDIF

THIS.DecorateToolbar()

THIS.nMaxWidth = THIS.Buttons.Count * THIS.ButtonWidth
ENDPROC


ENDDEFINE
*
*-- EndDefine: ctoolbar
**************************************************


**************************************************
*-- Class: cimagelist (c:\proj\talon\libs\activex.vcx)
*-- ParentClass: olecontrol
*-- BaseClass: olecontrol
*-- OLEObject = C:\WINDOWS\SYSTEM\MSCOMCTL.OCX
*
DEFINE CLASS cimagelist AS olecontrol


Height = 100
Width = 100
cconfig1 = ""
cconfig2 = ""
cconfig3 = ""
cconfig4 = ""
cconfig5 = ""
Name = "cimagelist"


PROCEDURE getconfigstring
LOCAL lcConfig, lcPropName, lnLoop

lcConfig = ""

FOR lnLoop = 1 TO 5
lcPropName = "cConfig" + Alltrim(Str(lnLoop))

lcConfig = lcConfig + Alltrim(THIS.&lcPropName)
ENDFOR

RETURN Alltrim(lcConfig)
ENDPROC


PROCEDURE addimage
LPARAMETERS lcImageName, lcImageFile

ASSERT VARTYPE(lcImageName) = "C" MESSAGE THIS.Class + "::AddImage() lcImageName parameter not optional!"
ASSERT VARTYPE(lcImageFile) = "C" MESSAGE THIS.Class + "::AddImage() lcImageFile parameter not optional!"

THIS.ListImages.Add(,lcImageName, LoadPicture(lcImageFile))
ENDPROC


PROCEDURE addimages
LOCAL lcConfig, lnOccurs, lnLoop, lcString, lnBegin, lnChars, lcImageName, lcImageFile

lcConfig = THIS.GetConfigString()

IF NOT Right(lcConfig, 1) = ";"
lcConfig = lcConfig + ";"
ENDIF

IF NOT Left(lcConfig, 1) = ";"
lcConfig = ";" + lcConfig
ENDIF

lnOccurs = Occurs(";", lcConfig) - 1

FOR lnLoop = 1 TO lnOccurs
lnBegin = At(";", lcConfig, lnLoop) + 1
lnChars = At(";", lcConfig, lnLoop + 1) - lnBegin

lcString = Alltrim(SubStr(lcConfig, lnBegin, lnChars))

lcImageName = Alltrim(SubStr(lcString, 1, At("|", lcString) - 1))
lcString= Alltrim(SubStr(lcString, At("|", lcString) + 1))
lcImageFile = Alltrim(SubStr(lcString, 1, At("|", lcString) - 1))

THIS.AddImage(lcImageName, lcImageFile)
ENDFOR
ENDPROC


PROCEDURE Init
IF NOT DoDefault()
RETURN .F.
ENDIF

THIS.AddImages()
ENDPROC


ENDDEFINE
*
*-- EndDefine: cimagelist
**************************************************


Now then, I know everyone's looking at this stuff and saying, 'What the $#@$?'

But basically here's how it works:

First I instantiate my imagelist and add the images to it at run-time. The AddImages method parses a string that tells me what the name of the image will be, and what file name to use and then I add the image to the control.

Next, I open my class browser, open the library containing these classes. Select the coolbar class and modify it or you can subclass itand modify the subclass(in case you'll be using more than 1 type of toolbar). Next I drag my toolbar class or a subclass of it onto the open coolbar, open its special properties sheet and then on the second I set the first band's child property to this toolbar.

The only thing I've noticed with this is as you resize the coolbar that has more than 1 band, and you shrink its size, the contents of the band have a tendency to flicker.

If you don't want to try doing this yourself, I will talk with Markus Egger about the possibly of making a public domain utility out of this and posting it on his web-site if there seems to be an interest in it.

Travis N. Vandersypen

>>>>By this, do you mean so that the Toolbar can be undocked and pulled outside of the form?
>>>>
>>>>>Has anyone got the MS Toolbar Version 6.0 to work as a regular
>>>>>coolbar and not a toolbar within a form ???
>>>>>
>>>>>The control works great on a form.
>>>
>>>No, I mean to turn the standard vfp toolbar into a coolbar, so it can be docked to the main vfp window, not a form, and moved around, just like the standard toolbar.
>>>
>>>Jamie.
>>
>>
>>I don't know if this has anything to do with your inquiry... but the September FPA has a cool article 'Get a Handle on User Interface' that has a neat way of using a W98 style 'coolbar' with _screen.
>>
>>
>>HTH
>>Wayne
>
>Wayne:
>
>Very close to what I am trying to accomplish, but using the new MS Toolbar 6.0 Active X control instead of the DataDynamics ActiveBar control. It's worth a shot of trying to do the same thing.
>
>Thanks.
>
>Jamie.
Travis Vandersypen
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform