[Q] Is there a generic QueryString? - Windows Phone 7 Software Development

I am trying to parse an html string into tokens based on querystring, in a similar method to how its done with NavigationContext, but I can't seem to find anything that works in WP7. Since the URL might change, id like to do it without too much fuss. Is there an easy built in function like this?
The object I have is just a standard string variable which contains the url.
Code:
if (this.NavigationContext.QueryString.ContainsKey("size"))
obj.size = NavigationContext.QueryString["size"];

Related

Truetype fonts in evC++

Hi gents.
I want to ask you,how can I use external font loaded from ttf file in my app,developed under Embedded Visual C++?
I need to easily change color and size of the font and using the DrawText() function make an output into current DC.
Can someone make an example for me please?
Thank you.
Here's the bare bones of it ,you'll have to flesh it out to suit. It might not be perfect but it works.
Global Variable
Code:
HFONT g_hfont;
Forward declaration of EnumFontProc()
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData);
In WM_PAINT print it out. I'll use Wingdings. The name in the EnumFonts must match the actual name of the font as declared in the TTF file.
Code:
case WM_PAINT:
RECT rt;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
EnumFonts(hdc,TEXT("Wingdings"),(FONTENUMPROC) EnumFontsProc,NULL);
SelectObject(hdc,g_hfont);
DrawText(hdc,TEXT("12345"),5, &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
DeleteObject(g_hfont);
EndPaint(hWnd, &ps);
break;
In EnumFontsProc set the font to the first font given. Returning 0, ends the enumeration, non zero, give me the next.
To change the size do it here by changing lplf->lfHeight and lplf->lfWidth
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
g_hfont = CreateFontIndirect(lplf);
return 0;
}
To load and release your font add the code below to the message handling sections.
Code:
WM_CREATE:
AddFontResource(TEXT("\\Storage Card\\myfont.TTF"));
WM_DESTROY:
RemoveFontResource(TEXT("\\Storage Card\\myfont.TTF"));
Here's the proof it works, (with Wingdings anyway!)
Thanks man,I will try it ASAP.
Well,is it possible to read the ttf file directly from exe resource also?
I am still learning C++,so some things are a bit unclear for me. Can you please post this source?
This stuff is explained fully at:
http://msdn.microsoft.com/en-us/library/aa911455.aspx
I've just taken a few shortcuts with it.
The zip file contains the main .cpp file of the above project. It does not include the AddFontResource or RemoveFontResource statements.
Create a shell WinMo application and replace the main program .cpp file with it.
AddFontResource can only accept the path to a True Type font TTF file as an argument.
The thing you have got to get your head around are CALLBACK routines, they are used during most enumeration routines, and are widely used in Win32 for all sorts of things. A Win32 app's WndProc it itself a callback routine. In the case of EnumFonts, you pass the address of the callback routine to the enumerating function, which will call your function once for every instance it finds that matches your request. You terminate the sequence by returning 0 or it will carry on until there are no instances left. You have to decide what to do with the results. In my case I take the first Wingding font I'm offered, then quit.
Be aware that there is little, or no error handling in this code. I cobbled it together pretty quickly to prove the point.
I remember reading somewhere that if you drop the .TTF file in the Windows directory, and do a soft reset, then Windows will pick it up as a resident font, so the AddFontResource and RemoveFontResource functions are not required. EnumFonts() should know about it, and present it accordingly.
Well,thank you very much for that,but can you please provide me full project source,including all the files? With working project,I can better understand the font loading principle.
Unfortunately,I am too busy nowadays to discover something,that I don't understand well,so every time save is a big plus for me. Thank you very much again.
Attached,
But, it is a VS 2008 Smart Device project. EVC won't read it.
You will have to create a shell hello world project in EVC and copy the modified code in the panels above from TestFont.CPP.
Hello.
Actually i've got it working,but I still cannot discover,how to resize the font.
Where should I exactly put the lfWidth and lfHeight?
I am now a bit confused of that.
This is my code:
Functions and declarations of HFONT,CALLBACK,WM_CREATE,WM_DESTROY are present as you described.
void ShowNumber(HDC hdc, int Value,int xrect,int yrect,int wrect,int hrect,HBITMAP source)
{
EnumFonts(hdc,TEXT("Sam's Town"),(FONTENUMPROC) EnumFontsProc,NULL);
SelectObject(hdc,g_hfont);
TCHAR szText[MAX_LOADSTRING];
int width,height;
rtText.right=wrect;rtText.bottom=hrect;width=wrect-xrect;height=hrect-yrect;
TransparentImage(hdc,xrect,yrect,width,height,source,xrect,yrect,width,height,RGB(255,0,255));
SetBkMode(hdc,TRANSPARENT);
if(Value<10) wsprintf (szText, TEXT ("0%d"),Value);else wsprintf (szText, TEXT ("%d"),Value);
rtText.left=xrect ;rtText.top=yrect ;SetTextColor(hdc,RGB(0,0,0)); DrawText(hdc,szText,2,&rtText,DT_SINGLELINE | DT_LEFT | DT_TOP);
DeleteObject(g_hfont);
}
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
g_hfont = CreateFontIndirect(lplf);
return 0;
}
Click to expand...
Click to collapse
This doesn't work:
lplf.lfWidth=0;
g_hfont = CreateFontIndirect(lplf);
Click to expand...
Click to collapse
Actually I want to put one more parameter into ShowNumber() function,which will tell the function the size of the font.
You are nearly there...........
The code to set the font size will have to go in here.......
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
lplf->lfHeight=14;
lplf->lfWidth=8;
g_hfont = CreateFontIndirect(lplf);
return 0;
}
Or whatever your values are, I just picked 8 and 14 as examples. If these values are passed as variables to another function above, store them as global variables, and use them here.
As lplf is passed to this function as a pointer to a LOGFONT structure, you have to use the -> operator to access its members. lplf.lfHeight won't work as you mentioned, that is for predeclared or static structures.
These values have to be changed here in the EnumFontsProc() routine before the font is created, as we are passing that pointer to create the font.
Good Luck!!
P.S. While we are here, let's tidy it up a bit.
Replace:
Code:
if(Value<10) wsprintf(szText,TEXT ("0%d"),Value);else wsprintf (szText,TEXT("%d"),Value);
with
Code:
wsprintf(szText, TEXT ("02%d"),Value);
A very big thanks for that.
I am still beginner in C++,so something can look very comic for others.
My beloved programming language is Pascal.
I really didn't think,that -> is an operator,I've just mentioned,you wrote it as something else(something like "to")
You are more than welcome.
Some features in C/C++ are not immediately obvious, but the real battle is fighting your way through the Win32 programming model, trying to get it to do what you want. Sometimes the simplest of things become maddeningly complicated, but the effort to do it properly is usually worth the effort.
Glad you got it working, best wishes, stephj.
Hello a bit later.
First of all,thank your for your explanation and now I am using this method successfuly.
I want to ask you now,if there is a way to get fixed pitch of the font,that is truetype. With standart font I can achieve with this...
lf.lfPitchAndFamily = (tm.tmPitchAndFamily & 0xf0) | TMPF_FIXED_PITCH;
I am using font,that displays numbers in "digital" mode(7-segment display) and I get the number "1" very narrow in comparison with others(actually it is narrow on any kind display,but is displayed on right segments,so "01" has adequate spacing on hard display). Now I get "0l_" instead of "0_l",that's not preferable.
Thanks in advance for reactions.
I don't think there the above method will work as each character has it own width associated with it.
A simpler approach, a bit of a pain, but which should work, is to draw/print the numeric value out one character at a time using DrawText(). Set a RECT structure up to hold the coordinates of the top left and bottom right of the area for each character.
Setting uFormat to DT_RIGHT will force the character to right align in the RECT area, so the '1' should appear correctly. Move the left and right values along a fixed amount for each character. A bit of trial and error will be involved first until you get the values just right.
Good luck, stephj.

[Q] [Resolved] [.Net CF 3.5] How do i create a treeview based file browser

I have a problem with a project i'm working on and that is:
How do i create a TreeView based file browser that can export a selected path and filename to a textbox and a Process.Start call at the same time. That's it in a nut shell. The main part if the tree view bit but i haven't figured out how to do variables yet and i'm gonna need one for the second part. I have spent hours googling and i have this question posted on a dedicated VB forum.
I'm using Visual Basic 2008 as the IDE and .Net CF 3.5 as the language (obviously)
If anyone has any ideas on this i'll gladly hear them coz i am really stuck. I found writting code to soft reset a device was easier
TreeNodeCollection tr=treeView1.Nodes;
TreeNode tn;
foreach (string dirs in System.IO.Directory.GetDirectories(System.IO.Directory.GetDirectoryRoot(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName)))
{
tn = new TreeNode(dirs);
//tr = new TreeNodeCollection();
tr.Add(tn);
}
ergintiravoglu said:
TreeNodeCollection tr=treeView1.Nodes;
TreeNode tn;
foreach (string dirs in System.IO.Directory.GetDirectories(System.IO.Directory.GetDirectoryRoot(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName)))
{
tn = new TreeNode(dirs);
//tr = new TreeNodeCollection();
tr.Add(tn);
}
Click to expand...
Click to collapse
Is that C# code or VB?
M3PH said:
Is that C# code or VB?
Click to expand...
Click to collapse
C#....VB don't have the curly brackets
So i've come back to this question after a few months avoiding VB. I'm now working on a new product and the lack of an folderbrowserdialog object in .Net CF is killing me.
What i need is this (oh and thanks to everyone that posted above but i can't make that solution work). A way to list all the folders on a device and then select one that can be passed to a variable so it's path can be used elsewhere. Maybe also pass the path to a textbox just so it's clear what you have selected. I've spent 2 days googling this and i did find a few things. Most don't work and the rest are in c# which is not much good. So if anyone wants to help me out i would really appreciate it.
Get your head round this.........
O.K. Here's how it's done, with a crash course in one of the most powerful of programming techniques - Recursion. It can confuse the hell out of rookie programmers, as they just can't get their heads round what's going on. It is dependant on a function's local variables and fortunately, .NET's stack based architecture allows us to use it to the full.
You will need, 1.) a TreeView object - named "treeView1" and 2.), a label named "label1" placed underneath it. The label is only there to prove the point that we can get at the full pathname of the selected directory in the Treeview. In reality it can be dropped, just put your processing code directly in the TreeView's AfterSelect() event.
The Form_Load() event gets the directories in the root directory, by calling GetDirList with an initial directory of "\".
GetDirList() adds the directories to the TreeView then calls GetDirList again on each directory to get any subdirectories, and again on each subdirectory, ad nauseum. Keep going until there are no more directories returned.
When completed TreeView contains a list of every directory/subdirectory on the device.
When you select an item from the TreeView the full pathname is displayed in the label. The image at the bottom shows it running under debug on the WinMo 5.0 emulator. There are several directories you would not normally see on your device.
Good Luck, stephj.
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Me.GetDirList("\")
End Sub
Private Sub GetDirList(ByVal PathName As String)
Dim dirs As String
For Each dirs In Directory.GetDirectories(PathName)
Dim tn As New TreeNode(dirs)
Me.treeView1.Nodes.Add(tn)
Me.GetDirList(tn.FullPath)
Next
End Sub
Private Sub treeView1_AfterSelect(ByVal sender As Object, ByVal e As TreeViewEventArgs)
Me.label1.Text = e.Node.FullPath
End Sub
P.S.
You will need the VB equivalent of using System.IO adding to your project.
This stuff has been around since .NET CF 1.1
The original project was written in C#, I used .NET Reflector to translate it into VB from the original. The original C# is included here:-
Code:
using System;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GetDirList("\\");
}
private void GetDirList(string PathName)
{
foreach (string dirs in System.IO.Directory.GetDirectories(PathName))
{
TreeNode tn = new TreeNode(dirs);
treeView1.Nodes.Add(tn);
GetDirList(tn.FullPath);
}
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
label1.Text = e.Node.FullPath;
}
}
}
cool thanks. I'll have a look at coding this tomorrow (i having some fun time right now).
I did have a look at doing this with a list box yesterday but i was getting errors left, right and centre so i really do appreciate the help.
Just an FYI the VB equivelent of "using" is "imports" otherwise most of the objects are the same but i don't nee to worry about adding it as the program is already interacting with the file system.
Again thanks very much. I really appreciate you taking the time to help me out.
I've just had a look at implementing this but i'm having trouble getting the treeview to populate with the folder list. What am i doing wrong? the object names all match up and i can't see why it's not working. Am i just being plain dense?
What i have Is pretty much what you posted except for a few changes to allow for the fact that the treeview object is in a tabcontrol and i already have a bunch of labels knocking around so the label is called label28 and not label1.
I'm sorry if it appears like i'm not trying or i'm asking you to do all the work but i am genuinely really stuck. I get the recursion principal, That's not an issue but i'm trying to create something from scratch that should really have been included in .net CF and i'm just not that good a programmer yet
Should work..... but without seeing the actual code it's rather hard to remotely debug it.
To prove the point, here's the complete VS2008 VB .NET CF 3.5 project.
In the \bin\release directory is the actual executable. If you have .NET CF 3.5 on your device, drop DirList.exe onto it and run it.
I had a look at the project you posted and just copied the coded over. I did make some tweaks so it only loaded the folder list when the tab the treeview was on was clicked but that didn't work so i repated the code in as is and voila! it works. Now all i need is to create a variable to store the selected path in but i think i can manage that.
Again a huge thanks.
Hierarchical view......
Here's the project to indent, compress, and expand the directory tree structure.
I was just playing around with this and i noticed that when you click on a directory below "\" the path becomes "\\this\path". This is obviously not a valid windows mobile path and it is causing an IOexception and I have no idea how to fix it. Google suggests lots of c# pages that say to use a regular expression to strip out the illegal characters but the example i found was for the entire path and it seemed to check each character against a variable of illegal values. I'm sure if that would work for me. Heres the link.
Let me know what you think.
I have no idea where the \\this is coming from, I can't replicate it.
To filter out the extra leading slash use this:-
Code:
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
If TreeView1.SelectedNode.FullPath.Length() = 1 Then
Label1.Text = TreeView1.SelectedNode.FullPath
Else
Label1.Text = TreeView1.SelectedNode.FullPath.Substring(1)
End If
Interesting new problem has cropped up with this code. It doesn't seem to work on rhodiums. It works fine in the emulator, my HD2 and all of CajunFlavouredBob's devices but i have a user that has a rhodium that get the error posted here. I can't replicte it and i don't have a rhodium to test it with. Any ideas?
Hmmmmm another tricky one. Without seeing the device actually throw the error, it can be a bit difficult.
Does this machine actually report the storage card as "\Storage Card"? Some machines don't. In which case you may have to use some storage card enumeration trick to get hold of the real name it uses. This may not apply in this case.
Also, to make things trickier still, the stack dump shows 'GetInternalDirectoryNames()' as the function throwing the error first. This is a level below your call of GetDirectories(), and is being used by the OS to actually go get the info. You may have to create a test version of EXCT2 full of Try...Catch programming blocks, to try to get to the real point where the error is being thrown.
well this turned out to be a memory related issue. So instead of using the folder browser we now use the stock winmo savedialog. because it uses less memory and allows us access to the locations we need.
Thanks for helping though steph.

[eVC++] How to rename/delete/copy/move a file from specified location?

Hello.
Just a quick question,I didn't found answer for,not so difficult for skilled programmers.
I have a file "\Somewhere\abc.xyz",which I want to rename to something else,delete,copy or move to different location.
How can I do this in classic Embedded Visual C++ 4.0SP3?
Can anyone post here some source code,how to use some functions please?
Thank you for the tips in advance.
Use the functions DeleteFile(), MoveFile(), DeleteAndRenameFile() and CopyFile(), all functions are already in coredll.dll, and are declared in winbase.h, should be part of a standard app.
Parameters change from one function to the next, you'll have to look in the online help for the full definitions, but most of them use long pointers to one or more wide character strings. Be aware of the fact that '\' in C++ is an escape character itself, so a backslash in a pathname must be specified as a double backslash, if used in a quoted string. A hard coded example of the above is :
Code:
DeleteFile(TEXT("\\Somewhere\\abc.xyz"));
The compiler macro TEXT converts the string to a wide character TCHAR string, as required by the function.
Variable strings passed to the function should be TCHAR arrays. Use the predefined value MAX_PATH for the length. To put values in them at run time by the program use wsprintf();
for example :-
Code:
TCHAR szFile[MAX_PATH];
SYSTEMTIME stime;
GetLocalTime(&stime);
wsprintf(szFile,"\\Storage Card\\%04d%02d%02d.TXT",stime.wYear,stime.wMonth,stime.wDay);
DeleteFile(szFile);
deletes the file on the storage card with today's date as YYYYMMDD.TXT, if it exists, e.g. \Storage Card\20101121.TXT

[Q] visual studio 2010 code help

been trying to figger out how to write this code for the better part of a day and just cant figger it out. hopefuly someone here can help.
its nothing complex by far, just my lack of knowledge lol.
so,
from the MainPage.xaml, i have a button that i want to link to "item2" on PanoramaPage1.xaml.
i know that this:
NavigationService.Navigate(new Uri("/PanoramaPage1.xaml", UriKind.Relative));
will get me to the Panorama page, but is there a way so ig goes right to item2?
ive tried code like:
NavigationService.Navigate(new Uri("/PanoramaPage1.xaml(item2.SelectedIndex)", UriKind.Relative));
NavigationService.Navigate(new Uri("/PanoramaPage1.xaml(item2)", UriKind.Relative));
NavigationService.Navigate(new Uri("/PanoramaPage1.xaml/item2", UriKind.Relative));
Etc...
but nothing is working for me.
thanx for any help.
poy
Create a property holding the pivotpage you'd like to go to, perhaps _selectedPivotPage. Then set this, to whatever number you need, before calling Navigate() and add something like this.PivotControl.SelectedIndex = _selectedPivotPage to Page_Loaded() in PivotPage1.xaml.cs (or whatever page you're calling).
i really didnt understand much of what you just said... lol
is there anyway you could give me an example?
I've made a quick project which shows this:
http://dl.dropbox.com/u/129101/Panorama.zip
The idea is this:
In the PanoramaPage1's xaml, you add a name for the panorama so you can refer to it in code.
In the PanoramaPage1's xaml.cs, you override the OnNavigatedTo function, which is called when the page is about to be displayed:
// <summary>
/// Overrides PhoneApplicationPage's OnNavigatedTo function, which is called when the page is about to be displayed.
/// </summary>
/// <param name="e"></param>
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
//item2 is the second item, but 0 indexed.
myPanorama.DefaultItem = myPanorama.Items[1];
base.OnNavigatedTo(e);
}
Edit:
This may not be what you're asking. If you're trying to figure out how to send a value which affects the next page (for example change the title of the next page, pass an object, etc), you probably want this example instead
http://dl.dropbox.com/u/129101/Panorama_querystring.zip
williammel said:
Edit:
This may not be what you're asking. If you're trying to figure out how to send a value which affects the next page (for example change the title of the next page, pass an object, etc), you probably want this example instead
http://dl.dropbox.com/u/129101/Panorama_querystring.zip
Click to expand...
Click to collapse
This is exactly what i needed. Thank you sooo much!
poy
No problem. If you're planning on passing complex objects (or any really) you can store them in app.xaml.cs and cut down on the typing, and the time it takes to use the object (since it doesn't have to generate a dictionary you have to query)
Something like this:
Public static string navigationParam;
Or
Public static object navigationobj;
And in any file:
App.navigationparam = "item2";
or
App.navigationobj = (object)myclassvariable;
And just do the opposite to get the item back.

Hack to change default browser

Hello,
I recently bought and installed surfcube (which is pretty cool) but whenever i click on any link outside the browser (ex: twitter/ facebook), it automatically opens an IE window. Any hack out there to get that to go to a different browser, such as surfcube?
This may be based on the default handler for the http: URI format. If anybody finds a way to change this (either the URI handlers, file extension handlers, or just default browser) we would all love to know. I don't think anybody has pulled this off yet, though.
GoodDayToDie said:
This may be based on the default handler for the http: URI format. If anybody finds a way to change this (either the URI handlers, file extension handlers, or just default browser) we would all love to know. I don't think anybody has pulled this off yet, though.
Click to expand...
Click to collapse
And almost more importantly, SurfCube doesn't have the code to read a URL from a command line (or whatever method is used), so the best it would do is just open the app without the specified URL.
davux said:
And almost more importantly, SurfCube doesn't have the code to read a URL from a command line (or whatever method is used), so the best it would do is just open the app without the specified URL.
Click to expand...
Click to collapse
Hi,
I am the developer of SurfCube - if somebody can figure out how to open it as the default browser, we will work hard on making it actually open the URL if it gets passed to us.
That would be pretty cool. I would suspect that there is a registry key for the default handling of URL's. Passing that URL to the third party browserr would most likely need command line and lower file system access.
Sent from my Samsung Focus
HKEY_CLASSES_ROOT is present on WP7, although it works a little differently than on desktop Windows. One thing worth noting is that built-in software, such as IE, is invoked differently from installable apps. Built-in software is compiled to actual EXEs, which of course have a standard way to be passed parameters. WP7 apps are DLLs, invoked by a hosting EXE. Also, the way apps are specified is a bit weird; it's by GUID instead of by path.
There is one installable app which is registered as the handler for a file extension (Adobe Reader for PDF). By picking apart its registry entries, I have at least a partial view of how it works.
HKCR\.pdf:
Default = PDFFile
Content Type = application/pdf
HKCR\PDFFile
AppID = "BC4F319A-9A9A-DF11-A490-00237DE2DB9E"
Application Task = "app://BC4F319A-9A9A-DF11-A490-00237DE2DB9E/_default?"
EditFlags = d:0x00010000
HKCR\PDFFile\shell\open\command
Default = "app://5B04B775-356B-4AA0-AAF8-6491FFEA5665/_default?type=PDFFile&file=%s"
There are some interesting hings here. First of all, the BC4F GUID is the one for the Adobe Reader app. Therefore, AppID is the GUID for an installed app that handles a file or protocol association.
Second of all, the shell\open\command\Default value is present for every openable type, but the GUIDs it contains are *not* in the Applications list (note the difference between it and the AppID value). This appears to be how the OS specifies native applications.
Third, it *is* possible to pass parameters to installable apps. See the %s on the end of the value? That gets replaced by the filename, I suspect. Anybody want do pull apart the Adobe Reader or YouTube apps (the only ones with AppID values) and see how they do it?
Fourth, I'm pretty sure we can use this to add our own associations even if we can't get it to open files in them. I'm not sure how easy it will be, but it should be possible.
For those interested in browsers:
HKCR\http
Default = "HyperText Transfer Protocol"
Source Filter = "{97e7c245-4d6f-483b-a772-de22b15fa999}"
URL Protocol = ""
HKCR\http\Extensions
.3g2 = "{97e7c245-4d6f-483b-a772-de22b15fa999}"
.3gp = "{97e7c245-4d6f-483b-a772-de22b15fa999}"
.aif = "{e436ebb6-524f-11ce-9f53-0020af0ba770}"
... and 20-odd more like this
HKCR\http\Shell\Open\Command
Default = "app://5B04B775-356B-4AA0-AAF8-6491FFEA5665/_default?StartURL=%s"
HKCR\PROTOCOLS\Handler\about
CLSID = "{3050F406-98B5-11CF-BB82-00AA00BDCE0B}"
HKCR\PROTOCOLS\Handler\javascript
CLSID = "{3050F3B2-98B5-11CF-BB82-00AA00BDCE0B}"
HKCR\PROTOCOLS\Handler\mailto
CLSID = "{3050f3DA-98B5-11CF-BB82-00AA00BDCE0B}"
HKCR\PROTOCOLS\Handler\res
CLSID = "{3050F3BC-98B5-11CF-BB82-00AA00BDCE0B}"
... note that these GUIDs are very similar but not the same.
HKCR\.html
Default = "htmlfile"
Content Type = "text/html"
HKCR\htmlfile
Default = "HTML Document"
EditFlags = d:0x00010000
HKCR\htmlfile\CLSID
Default = "{25336920-03F9-11cF-8FD0-00AA00686F13}"
HKCR\htmlfile\Shell\Open\Command
Default = "app://FB04B775-356B-4AA0-AAF8-6491FFEA5660/_default?StartURL=file://%s
HKCR\MIME\Database\Content Type\text/html
CLSID = "{25336920-03F9-11cf-8FD0-00AA00686F13}"
Encoding = 08-00-00-00 (binary)
Extension = ".htm"
I'm omitting a few fairly irrelevant keys, like DefaultIcon. This FB04B775 app is interesting - it seems to serve as a launcher, although that's just a guess for now. In any case, it accepts parameters like StartURL, Type, and File (with the last two coming together) and file substitution (the %s that stands in for the URL or file).
Anybody want to have a go at detangling this?
Also, Good News Everyone: it *is* possible to add associations between unknown extensions and known files, at least. I just added HKCR\.log as a clone of HKCR\.txt (Default = "txtfile"; Content Type = "text/plain") and opening a .LOG file in Outlook now opens the file in Work (it used to trigger a MessageBox saying file type was not known). So cool!
Looks like you can override OnNavigatedTo (from PhoneApplicationBase class) and use NavigationContext.QueryString() to get the required information.
If you use something like
Default = "app://5B04B775-356B-4AA0-AAF8-6491FFEA5665/_default?type=PDFFile&file=%s"
you could use
var params = NavigationContext().QueryString();
if (params.ContainsKey("file"))
{
// code here
}
so any param of the caller url will be part of the query string dictionary.
Hope this helps.
P.S.: Office does it in a more elegant way , They use only one param "CmdLine" and can use the normal cmd line argument parsing on this param, e.g. ...........?CmdLine=-opendoc %s
kuerbis2 said:
Looks like you can override OnNavigatedTo (from PhoneApplicationBase class) and use NavigationContext.QueryString() to get the required information.
...
P.S.: Office does it in a more elegant way , They use only one param "CmdLine" and can use the normal cmd line argument parsing on this param, e.g. ...........?CmdLine=-opendoc %s
Click to expand...
Click to collapse
Yes, this is pretty much what I wanted to go with. The question now is how to get SurfCube to open if you click on a link in en email or twitter or the poeple hub.
I can only imagine one solution (but my imagination is limited <g>): Create two apps.
1.) SurfCube prepared for parameter passing
2.) HomeBrew App which replaces HKCR\http\Shell\Open\Command
-t
kuerbis2 said:
I can only imagine one solution (but my imagination is limited <g>): Create two apps.
1.) SurfCube prepared for parameter passing
2.) HomeBrew App which replaces HKCR\http\Shell\Open\Command
-t
Click to expand...
Click to collapse
Yes, this is exactly what I am thinking about. But I need help with the second one from this group. Also, is there any way to do the registry edits on the emulator? I would prefer to play with that until things get fairly stable.
After digging a bit deeper, it looks like you are out of luck. I don't know why but the AppID of MobileIE is hardcoded in the WebBrowserTask (reference assemblies and Samsung Omnia 7 GAC assembly):
ChooserHelper.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA5660/_default?StartURL=" + this.URL);
So, even if you manage to change the html handler, you won't get the calls from the correspondig task.
Long time since I've seen something hardcoded like this on a windows platform...
I can't confirm this now, but I think 5b04b is actually the application host process. In other words, it's the thing that makes the navigation buttons work, and which runs the installable app DLLs. The StartURL parameter may just mean "look up things defined as a URL Protocol (HTTP is one such thing) and launch the corresponding app." The Filter value may be relevant here, perhaps even as the actual app id for IE. In any case, I get the feeling that the reason it's hard-coded is because it's the launcher app, and StartUrl is just how you tell it to invoke the web browser.
However, the hardcoded GUID and the ones in htmlfile, http and related keys is different from for example the one used in PDFFile.
Crap, you're right. I wasn't paying enough attention to the last couple digits. It doesn't help that searching registry data (as opposed to keys and value names) doesn't seem to work. I'm tempted to say that some experimentation is in order, although I'd prefer to know what I'm messing with.

Categories

Resources