Remove All Ads from XDA
Find Your Device:
Or Continue to Thread: [TUT][10/21/09] CPR File Editi…
1st October 2009, 02:11 AM |#3  
Cyclonezephyrxz7's Avatar
OP Senior Member
Thanks Meter: 14
Tutorial Continued
[Tutorial Part] - A Good Example of ID usage!

Let us look at my custom 'Horizon' Skin. A nice feature I added in was a CComm (Communications) Panel that allowed you to see ALL the connection status's at the same time. In order to do this I had to edit a file related to the CComm panel and tell it to add more registry entries when doing what it needed to do. Even though any of you could install my custom theme (hint hint), I will just put the code here.
<Image ID="icon1" Left="40" Top="25" Width="90" Height="115" ScaleStyle="Stretch" />
<Image ID="icon2" Left="260" Top="5" Width="40" Height="56" ScaleStyle="Stretch" />
<Image ID="icon3" Left="260" Top="58" Width="40" Height="56" ScaleStyle="Stretch" />
<Image ID="icon4" Left="260" Top="105" Width="40" Height="56" ScaleStyle="Stretch" />

While it may strike some as odd, that entire feature is right here in these 4 lines of code! See, the reason I refer to ID's as Variables is because they change as pages change! In this case, the CComm panel (like most, if not all, others) does not tell you every single page in its code! So by adding lines to the file associated with CComm (as i metioned earlier) i was able to load pointers to images into the variables icon1 - 4 and place them in the corresponding folders in the registry. [If you want to learn more into how I did that, PM me or check it out by installing and investigating]

[Tutorial Part 5] - Interactions with the Registry

Like many programs on a windows OS, there are registry keys and values related to the executable (or similar). The Today Screen is no exception to this rule. In this section I will inform you on how the Today Screen 'interacts' with the registry and how you can make your own interactions.

[Tutorial Part 5.1] - How it works!

I have been mentioning a lot about how the Today Screen (consisting of multiple DLL's and XML files) interacts with the registry, when that is actually not true! In order to interact, it must be able to write and read. To the extent of my knowledge the Today Screen CANNOT write to the registry.

"WAIT WHAT!!! So how is it that when I click on that awesome CComm set-up you have stuff happens!?!"

Well...It is magic! ... The magic of PROGRAMMING! There is no actual command for the Today Screen to write something. It can only read. So amazing people figured out how to gain this access.

Like I explained, the ID's act like variables, reading certain entries in the Registry. So let's get a bit more in depth with that by an example. Below is the code for my CComm Panel layout ... I reviewed this earlier, but will use this as a prime example.
<Image ID="icon1" Left="40" Top="25" Width="90" Height="115" ScaleStyle="Stretch" />
<Image ID="icon2" Left="260" Top="5" Width="40" Height="56" ScaleStyle="Stretch" />
<Image ID="icon3" Left="260" Top="58" Width="40" Height="56" ScaleStyle="Stretch" />
<Image ID="icon4" Left="260" Top="105" Width="40" Height="56" ScaleStyle="Stretch" />
Now, let us all grab our phones, go to the start menu, and open up RegEdit or Resco Registry (or any app that you use). I want you to navigate to:


In there is everything that has to do with the Today Screen (Remember it is also called CHome!) More specifically, for the sake of this tutorial, go into CComm. Remember I mentioned "pages" and layering. Well this is where it matters. Notice there are 6 Keys called Page1 - Page6 (and there are 6 pages on the Today Screen!) Take a walk around, investigate for a moment, the continue reading and see if you got what you thought correct....

Okay, so the correct assumptions for how all this works would be that what is written in the CPR is exactly what is taken from the Registry. But that brings us to another question...HOW does all this get there? What all-mighty programming goblin is in my phone feeding this information!?!

Simple...that is covered in the next section...

[Tutorial Part 5.2] - Going from Acting to Inter-Acting!

Now it gets a bit more, the eager [young] computer programmer wants to make a panel that gives all this information to the user and does a bunch of changes on the phone, but HOW!

The simplest (not the only) way to do this is to use MortScript (in my opinion). MortScript is a scripting language that is very basic when you get the hang of it. It will do everything you need it to do, in most cases, as long as it doesn't involve things it can't do (duhh).

I strongly advise people interested in the Today Screen to learn MortScript because it will make a bunch of things a whole lot easier!

[Tutorial Part 5.2.1] - My First Registry Interaction!

Let us say you want to make a panel that shows you the Phone Owner's name, email, and a random note. To start off, open up NotePad ++ (or whichever text editor you want to use) and make a program. Done. Haha, just kidding! Let us take this step by step.

Let us assume the panel has a registry entry already and is called MyFirstPanel (located at HKML\Software\Microsoft\CHome\MyFirstPanel) There is one page, so we go to the Page1 Key.

We can do this one of two ways. We can make it Device Specific and pre-define all that data, or we can make it device independent and use MortScript to fill in the blanks. I will opt for number 2, but for those who do decide to do the first, make some Strings with your data, then in the CPR, add those ID's (correctly with the correct tags, which I will go over in a later tutorial).

Taking the second method, go back to your text editor. Let us see what we need to do. We need to find the user information, assuming there is any, and access it. The problem with the Registry interactions and the Today Screen is that the Today Screen is LIMITED to the Chome\PANELNAME key. That is where MortScript comes in handy...

I will tell you this time that the Owner Information (which can be entered in settings) is located at HKCU\ControlPanel\Owner\ . So let us make a script that will copy this data.

//Reads the Registry Entry for the NAME
name = RegRead("HKCU", "\ControlPanel\Owner", "Name")

//Reads the Registry Entry for the Telephone Number
phone = RegRead("HKCU", "\ControlPanel\Owner", "Telephone")

//Reads the Registry Entry for the E-Mail
email = RegRead("HKCU", "\ControlPanel\Owner", "E-mail")

//Reads the Registry for an extra note
note = RegRead("HKCU", "\ControlPanel\Owner", "Notes")

//Writes the NAME to OUR PANEL for later use.
//Assigns the ID to be used to name1 (I use numbers as a precautionary)
RegWriteString("HKLM", "\Software\Microsoft\CHome\MyFirstPanel\Page1", "name1", name)

RegWriteString("HKLM", "\Software\Microsoft\CHome\MyFirstPanel\Page1", "phone1", phone)

//Writes the EMAIL to OUR PANEL
RegWriteString("HKLM", "\Software\Microsoft\CHome\MyFirstPanel\Page1", "email1", email)

//Writes the NOTE to OUR PANEL
RegWriteString("HKLM", "\Software\Microsoft\CHome\MyFirstPanel\Page1", "note1", note)
That is it! Assuming you have learned enough of this language, this should act as a great backbone when it comes to registry interactions.

So now that you know the very basics of the CPR file, and how some things work, you can rest assured that I will continue this tutorial when more time becomes available! It pains me to say it but:

Last edited by Cyclonezephyrxz7; 21st October 2009 at 09:35 PM.