Navigation

 ·   Wiki Home
 ·   Wiki Help
 ·   Categories
 ·   Title List
 ·   Uncategorized Pages
 ·   Random Page
 ·   Recent Changes
 ·   RSS
 ·   Atom
 ·   What Links Here

Active Members:

Search:

 

Create or Find Page:

 

View Live Styles

Return to MonkeyStyler

This feature lets you link MonkeyStyler to one or more applications. You can then update the style(s) within that application in a single mouse click. To link an application all you need to is add a couple of supplied units to your software and set a couple of properties.

The client can update both the default style from the TApplication object and the contents of one or more StyleBook objects stored on your forms (or elsewhere).

Enabling your application
Look in the Redist folder under the MonkeyStyler program folder (C:\Program Files (x86)\MonkeyStyler\Redist) and copy the following files to your project:
Solent.Logging
Solent.DDECommon
Solent.DDEClient
Styler.CommsClient

Add Styler.CommsClient to the implementations sections uses clause of your main unit.

In your Create method or FormCreate event handler you need to set up the client. Here is a typical scenario

StylerComms.AppName := 'CommsTest';
StylerComms.AddStyleBook(StyleBook1StyleFileName);
StylerComms.DefaultStyleFileName := DefaultStyleFileName;
StylerComms.Enabled := True


We need to give our application a unique name so MonkeyStyler can identify it.
StylerComms.AppName := 'CommsTest'


We can add any number of TStyleBook objects which will be updated with a given file when that file is changed. Note that the file name must be a fully qualified path to the file. You can add as many stylebooks as you want, so you can add those for your main form and any child forms if they use a different StyleBook object[1].
StylerComms.AddStyleBook(StyleBook1StyleFileName); 


If you want to be able to update the applications default style file, set the DefaultStyleFileName property:
StylerComms.DefaultStyleFileName := DefaultStyleFileName


To initiate the communications we need to set the Enabled property to True. (You probably only want to do this during development. For a redistributable application simply leave Enabled as False to prevent styles being updated by an end user).
StylerComms.Enabled := True


The order of the above commands is not significant.

Finally, you can remove a stylebook from the comms object with the RemoveStyleBook method. This is best done in the forms FormDestroy event handler:
StyleComms.RemoveStyleBook(StyleBook1); 


In MonkeyStyler

To 'apply' a modified style from within MonkeyStyler:
Open and select the file as the current file.
Click the Apply item on the menu bar.

It may take a moment or two for the style to be reloaded by your application. During that time MonkeyStyler and your application will not be responsive (this delay should be very short on a modern computer).

It does not matter whether you start MonkeyStyler or your application first.

Sample application
MonkeyStyler is supplied with a sample application which demonstrates how to create a client application. On a default Windows installation this will be located at C:\Users\Publib\Documents\MonkeyStyler\Samples\Comms

If you build this you will need to copy the style files to your compilers output folder (e.g. Win32\Debug). The style files are Custom.Style and Default.Style.

Troubleshooting

If you experience problems:
First check that everything is set up correctly.
Check the filenames are the same within your application and MonkeyStyler (in particular ensure your application uses fully qualified file names).

If that looks good, look for the log files. There will be one for the client and one or MonkeyStyler:
C:\Users\<Username>\AppData\Roaming\MonkeyStyler\CommsLog.Log
C:\Users\<Username>\AppData\Roaming\MonkeyStyler Client\ClientLog.Log

You should be able to see any communications errors in these files.

Footnotes

[1]Personally I like to reuse a single StyleBook object throughout my projects. You can do this in each child forms FormCreate event handler:
StyleBook := TForm(Application.MainForm).StyleBook

You can see this technique in the Comms sample application detailed above.

Category:MonkeyStyler

Categories: