idea for a small application... any help? - Mogul, XV6800 General

Ok, when I'm in my office I have poor signal issues that drain my battery and miss calls. If I switch to Roaming Only in my phone settings, then everything is just peachy. Problem is, its a lot of menus to click through every single time I come in to my office (Start, settings, phone, services, roaming, get settings, roaming only).
And then when I'm leaving, I want to turn the romaing settings back to automatic, once again its a lot of clicking.
I would imagine it would not be too difficult to write an app that could toggle that setting. Then it could be one click, or someone could even map the app to a hardware button for the ultimate ease of use.
I'm sure there are others who can see how useful such an app would be. Many of us do something like this all the time.
So, what do you think? Anyone willing to help develop this?

Sounds like a do-able program that would be very useful even for people not in your situation. Of course, I don't know how to, I'm just endorsing this idea.

In for this

GREAT!
Now, who can actually help figuring out how to code this? Can that sort of data even be accessed from standard APIs?

MortScript
Ok folks, until I have the time to find out what actually goes on behind the scenes when roaming settings are changed, I think our best bet is to write a script of keypresses/mouseclicks using mortscript.
Mortscript, in case you didn't know, is a simple batch process program, which lets you assign a series of commands to a script, sort of like a macro.
This will essentially be a script to go through the menus and click through options to do what we would do by hand. It will speed things up a bit, but it won't be as simple as a standalone app.
playing with mortscript now, I'll keep you guys posted.
EDIT: Anyone who wants to take a crack at this as well, by all means, mortscript is free! I'm just learning how to use it now, but if anyone has any experience with it, hit me up with suggestions! Or better yet, write a script and show me how it works!

Can anyone tell me what registry changes are made when you switch from roaming to automatic?
I can't seem to compare registry backups taken with PHM RegEdit (some propietary format, and no export to text option!)

Mortscript to the rescue....
This is still not the most ideal solution, but it works for me.
I wrote two Mortscript scripts that simulate the key taps automatically. The downside to this is that you can't toggle it on/off, you need to run one program to force roam, and another one to put it back to automatic.
USE THESE AT YOUR OWN RISK!
If you have any bugs/questions/comments, let me know.
Requirements
MortScript:
You need to install the mortscript interpreter first.
http://www.sto-helit.de/downloads/mortscript/MortScript-4.0.zip
The zip file attached below contains two .mscr files:
Roam
Roam-NO
Pretty self explanatory what does what. You can rename them if you want, this just works for me.

Dishe said:
I wrote two Mortscript scripts that simulate the key taps automatically. The downside to this is that you can't toggle it on/off, you need to run one program to force roam, and another one to put it back to automatic.
Click to expand...
Click to collapse
If you wanted to, you could write a temp file or reg key to check if the setting is on or off. In fact, the file wouldn't even need any data in it, you could just check for it's existence. That way you only need one script. Hope that helps you out.

I havent been able to find (or pull) the ril.dll file from a Mogul Wm6 installation, but once you have that file, you should be able to dump the exports and use the RIL_* functions by ordinal. This has been done on GSM phones.
I haven't had time yet, but I believe someone has dumped the files from the newest update rom.

Dishe,
I took your script and applied my suggestion to it. I also wrapped it up in a standalone package, so if anyone else wants to run it, they won't need MortScript installed as the exe is in here. If you already have MortScript installed, you can just run the .mscr file instead of the .exe of the same name.
What it will do is run the prog, then check for the existence of the file "roam" in the script path. If it's not there, it will run your roam function and then create the file. If it already exists (meaning you turned on roaming only), then it run your function to turn off roaming and delete the temp file. Hope it helps you out.
EDIT: If for some reason the key presses do the wrong thing, you can just set your phone back to automatic and delete the "roam" file in the script path if it's there, then you're back in business.
EDIT2: Added a longer wait time (5 secs) for the Comm Manager, should allow it to work with more graphic intensive Comm Managers (like the Kaiser 10-button, tested).

Vinny75 said:
I havent been able to find (or pull) the ril.dll file from a Mogul Wm6 installation, but once you have that file, you should be able to dump the exports and use the RIL_* functions by ordinal. This has been done on GSM phones.
I haven't had time yet, but I believe someone has dumped the files from the newest update rom.
Click to expand...
Click to collapse
I know, qouting myself, but.. you don't need the ordinal, you can get the function by name from the dll, so far I am able to use RIL_Initialize and RIL_GetRoamingMode to call my pfResultCallback, but the value I am getting in reutrn isn't making sense, so have to figure that out. I am using a modified tstril util. I can post the changes if anyone wants to take a look.

Got the following for RIL_GetRoaming Mode
Mode Value
Sprint Only 0x00000001
Automatic 0x000000FF
Roaming Only 0x000000FE
Now using RIL_SetRoamingMode, I can set the Sprint Only mode, the other two throw a 0x80004005 HRESULT, I can use 0x00000002 and 0x0000003 (constants defined if you search the internet), and they don't throw an error, but they dont actually change any settings...

You can get tstril from here:
http://wiki.xda-developers.com/index.php?pagename=RIL
Expanded ril.h (not sure how accurate):
http://www.xs4all.nl/~itsme/projects/xda/ril/ril.h
Replace the DoRIL function in tstril.cpp with this code to test:
Code:
typedef HRESULT (*pfnRIL_Initialize)(DWORD, RILRESULTCALLBACK, RILNOTIFYCALLBACK, DWORD, DWORD, HRIL*);
typedef HRESULT (*pfnRIL_GetRoamingMode)(HRIL);
typedef HRESULT (*pfnRIL_SetRoamingMode)(HRIL, DWORD);
//HRIL g_hRIL;
HINSTANCE g_hDLL;
HRESULT g_hResult;
DWORD
DoRIL(LPVOID lpvoid)
{
HRESULT result;
DWORD dwNotificationClasses = 0xFF0000;
LRESULT lresult;
TCHAR szString[256];
SendMessage(g_hwndEdit, LB_RESETCONTENT, 0, 0);
lresult = SendMessage(g_hwndEdit, LB_GETHORIZONTALEXTENT, 0, 0);
SendMessage(g_hwndEdit, LB_SETHORIZONTALEXTENT, 1000, 0);
//result = RIL_Initialize(1, ResultCallback, NotifyCallback,
// dwNotificationClasses, g_dwParam, &g_hRil);
//wsprintf(szString, L"RIL Handle: %08X, result %08X", g_hRil, result);
//SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
g_hRil = NULL;
g_hDLL = LoadLibrary(L"ril.dll");
//HRESULT hResult = 0;
if (g_hDLL != NULL)
{
pfnRIL_Initialize lpfnRIL_Initialize = (pfnRIL_Initialize)GetProcAddress(g_hDLL, L"RIL_Initialize");
if (lpfnRIL_Initialize)
{
result = (lpfnRIL_Initialize)(1, ResultCallback, NULL /*NotifyCallback*/, 0 /*dwNotificationClasses*/, 0 /*g_dwParam*/, &g_hRil);
if (result == S_OK)
{
wsprintf(szString, L"Initialize RIL Handle: %08X, result %08X", g_hRil, result);
SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
pfnRIL_GetRoamingMode lpfnRIL_GetRoamingMode = (pfnRIL_GetRoamingMode)GetProcAddress(g_hDLL, L"RIL_GetRoamingMode");
if (lpfnRIL_GetRoamingMode)
{
g_hResult = (lpfnRIL_GetRoamingMode)(g_hRil);
wsprintf(szString, L"GetRoamingMode RIL Handle: %08X, g_hResult %08X", g_hRil, g_hResult);
SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
}
//pfnRIL_SetRoamingMode lpfnRIL_SetRoamingMode = (pfnRIL_SetRoamingMode)GetProcAddress(g_hDLL, L"RIL_SetRoamingMode");
//if (lpfnRIL_SetRoamingMode)
//{
// g_hResult = (lpfnRIL_SetRoamingMode)(g_hRil, 254);
// wsprintf(szString, L"SetRoamingMode RIL Handle: %08X, g_hResult %08X", g_hRil, g_hResult);
// SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
//}
}
}
//FreeLibrary(g_hDLL);
}
// while(1) {
// Sleep(100);
//// wsprintf(szString, L"%s",L"...");
//// SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
// }
return 0;
}

Thanks for the work on those Mort Scripts!

Thank you!

wow, I haven't checked this thread in a while...
Vinny75, I haven't had time to play with this, but it looks like you've been making some progress... how far have you gotten with this?

The following values you should work for the second parameter of the RIL_GetRoamingMode and RIL_SetRoamingMode functions... they appeared to work on my phone
Mode RIL_GetRoamingMode RIL_SetRoamingMode
Sprint Only 0x00000001 0x00000001
Automatic 0x000000FF 0x00000004
Roaming Only 0x000000FE 0x00000005
I found the RIL_SetRoamingMode value in the following Registry Key
[HKEY_LOCAL_MACHINE\SOFTWARE\OEM\PhoneSetting\NetworkService]

Vinny75 said:
The following values you should work for the second parameter of the RIL_GetRoamingMode and RIL_SetRoamingMode functions... they appeared to work on my phone
Mode RIL_GetRoamingMode RIL_SetRoamingMode
Sprint Only 0x00000001 0x00000001
Automatic 0x000000FF 0x00000004
Roaming Only 0x000000FE 0x00000005
I found the RIL_SetRoamingMode value in the following Registry Key
[HKEY_LOCAL_MACHINE\SOFTWARE\OEM\PhoneSetting\NetworkService]
Click to expand...
Click to collapse
So would editing the registry be sufficient to change the roaming mode of the phone?
Did you compile an app to do this?

slightly off topic, but i think vinny75 might know the answer. id like to modify my alltel-based rom to give sprint only, automatic, roaming only options (alltel gives home only and automatic.) is ril.dll all that is needed from the sprint rom?

Dishe said:
So would editing the registry be sufficient to change the roaming mode of the phone?
Did you compile an app to do this?
Click to expand...
Click to collapse
I just compiled a quick and dirty app to test the values... the source is in my previous posts

Related

phoneOpen, phoneGetVolume (TAPI)

Hello,
I try to retrieve (then set) the volume, ring type ... of my XDA using TAPI
I call phoneInitializeEx, phoneOpen, phoneGetVolume but I always get the same value for the volume (even if I chnage it of course)
Does anybody knows why ?
Does anybody have and can post a sample code source showing how to unse these functiuns (phoneInitializeEx, phoneOpen, phoneGetVolume, phoneGetStatus ...)
Regards.
To set the phone volume (in mono) try:
Code:
set(DWORD dwVolume)
{
if (dwVolume > 0xFFFF) dwVolume = 0xFFFF;
dwVolume += dwVolume * 0x10000;
DWORD ret;
switch ((ret = waveOutSetVolume(0, dwVolume))) {
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
case (etc....)
}
To get the volume, try:
Code:
DWORD get()
{
DWORD dwVolume;
DWORD ret;
switch ((ret = waveOutGetVolume(0, &dwVolume))) {
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
case (etc...)
}
// Return average of left and right:
if (dwVolume > 0xFFFF) {
dwVolume = ((dwVolume & 0xFFFF) + (dwVolume / 0xFFFF)) / 2;
}
return dwVolume;
}
This is code for XDA I. I have not tried this on XDA II which as we know, has two volume channels.....
Ben.
I upgraded my XDA1 with WM2003 and I have 2 channels for the volume too.
I will try your code but I think this will change only the system volume (I will need to do that too so thanks) but not the phone volume.
First I want to pilot the phone settings (ring, volume...) from an application.
And it seems that only TAPI can do it... but it is not working for the moment
Glad the code will be useful.
If you find the correct method for XDA II, please let me know, I'll need it my self soon.
Ben
Your code works well to set/get the sytem volume
I just modifed it a little as the output is mono
Code:
//**********************************************************************
//Set The System Volume
//Steps (0,13107,26214,39321,52428,65535)
DWORD setVolume(DWORD dwVolume)
{
if (dwVolume > 0xFFFF)
dwVolume = 0xFFFF;
if (dwVolume < 0x0000)
dwVolume = 0x0000;
DWORD ret;
switch ((ret = waveOutSetVolume(0, dwVolume)))
{
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
default :
break;
}
return 0;
}
//**********************************************************************
//Get The System Volume
DWORD getVolume()
{
DWORD dwVolume;
DWORD ret;
switch ((ret = waveOutGetVolume(0, &dwVolume)))
{
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
default :
break;
}
dwVolume = (dwVolume & 0xFFFF);
return dwVolume;
}
But the phoneGetVolume still gives incoherent results
Someone see something wrong in the code below ?
I set the phone volume to 0 on the device but PhoneGetvolume send me 40092 ???
Code:
LONG result;
HPHONE hPhone;
DWORD dwVolume;
DWORD dwRingMode;
DWORD dwNumDevs= 01;
DWORD dwAPIVersion=0x00020002;
PHONESTATUS PhoneStatus;
HPHONEAPP hPhoneApp = 0;
PHONEINITIALIZEEXPARAMS PhoneInitializeExParams;
PhoneInitializeExParams.dwTotalSize = 2 * sizeof(PHONEINITIALIZEEXPARAMS);
PhoneInitializeExParams.dwOptions = PHONEINITIALIZEEXOPTION_USEEVENT;
// PhoneInitializeExParams.dwOptions = PHONEINITIALIZEEXOPTION_USEHIDDENWINDOW;
result = phoneInitializeEx(&hPhoneApp,NULL,NULL,NULL,&dwNumDevs,&dwAPIVersion,&PhoneInitializeExParams);
result = phoneOpen(hPhoneApp, 0, &hPhone, dwAPIVersion, 0, 0,PHONEPRIVILEGE_OWNER);
result = phoneGetVolume(hPhone,PHONEHOOKSWITCHDEV_SPEAKER,&dwVolume); //range 0x00000000 to 0x0000FFFF (65535)
In fact when I set the phone volume using
PocketSetVolume the vlaue is well saved because I get it when I use after PocketGetVolume.
But the phone volume is not really changed ?
Nobody has a sample that uses these functions ?
Or not obligatory these functions but others functions that change the phone volume ?
zendrui said:
In fact when I set the phone volume using
PocketSetVolume the vlaue is well saved because I get it when I use after PocketGetVolume.
But the phone volume is not really changed ?
Nobody has a sample that uses these functions ?
Or not obligatory these functions but others functions that change the phone volume ?
Click to expand...
Click to collapse
I have found that by changing the following registry keys, I can change the volume of the Phone
[HKEY_CURRENT_USER\ControlPanel\Volume]
"Ringer"=dword:00000000
Use hex 00000000, 33333333, 66666666, 99999999, cccccccc, ffffffff
[HKEY_CURRENT_USER\ControlPanel\SoundCategories\Ring]
"InitVol"=dword:00000000
Use hex 0, 1, 2, 3, 4, 5
This work beautifully for my Qtek running WM2003, but I have tried the same approach for the system-volume by changing
[HKEY_CURRENT_USER\ControlPanel\Volume]
"Volume"=dword:00000000
Use hex 00000000, 33333333, 66666666, 99999999, cccccccc, ffffffff
But this does not work! I have checked the registry and the value goes in correctely (The in-system volum control stores the same values in the same key).
How can I use the above code-snippets from the .Net Compact Framework? (I'm guessing a P/Invoke but what DLL is the call hidden in)
Cato
I am trying to make it works, but fail...please let me know if you know how to use the registry to update it...my email is
[email protected]
Thanks
I used the P/Invoke sample from Microsoft to get a working sample that read and updated the registry, and simply tried all possible combo's of a 4byte-array to see what would produce the correct result
Cato
I found a article mention it !!!
http://www.cegadgets.com/winceregfaq.htm#2.8 Where are volume and sound settings stored?
Not sure it works or not !!!
Please let me know if you know how to use the AudioUpdateFromRegistry, defined in coredll
Thanks :wink:
One more acticle !!!
http://www.pocketpcdn.com/forum/viewtopic.php?t=111
But I dunno how to make it works.
Any runnable example?
Hello,
after many tries I didn't find how to use TAPI functions ... this seems not towork ..
But you can change all the phone settings (volume, ring mode, ring tone, notifications ...) in the registry ... as I did for PocketZenPhone
See under that key HKEY_CURRENT_USER\ControlPanel
For the system volume I use the functions I posted upper
Hey, any example to do it?
Thanks zendrui
If you use EVC
Simply open the registry key
HKEY Key;
RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\Volume"),0,0,&Key);
Then use RegQueryValueEx to retrieve the value/setting you want
Hi zendrui,
I am able to update the registry, but I am not able to call AudioUpdateFromRegistry to notify the system to update the status from registry.
Could you able to exeute this API?
Thanks,
Paul
Sorry for the last post didn't have the keys in my mind
So to change the phone volume here are the keys needed
Code:
//dwPhoneVolumeLevel between 0 and 0xFFFFFFFF
res = RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\Volume"),0,0,&Key);
if (res == ERROR_SUCCESS)
{
res = RegSetValueEx(Key,_T("Ringer"),0,REG_DWORD,(LPBYTE)&dwPhoneVolumeLevel,sizeof(DWORD));
if (res != ERROR_SUCCESS)
{
RegCloseKey(Key);
return -1;
}
}
RegCloseKey(Key);
//dwInitVol between 1 and 5
res = RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\SoundCategories\\Ring"),0,0,&Key);
if (res == ERROR_SUCCESS)
{
res = RegSetValueEx(Key,_T("InitVol"),0,REG_DWORD,(LPBYTE)&dwInitVol,sizeof(DWORD));
if (res != ERROR_SUCCESS)
{
RegCloseKey(Key);
return -1;
}
}
RegCloseKey(Key);
It changes the phone volume and the display
PS : I post this code hoping is to help people to develop freewares (or low low cost software :wink
COOL !!! Thanks zendrui !!!!
Now I can set the Ringer volume !!!
How about set the system sound volume?
Fot the system volume see upper of this thread I posted the code I use. It works perfect
O yes...It works under eVC++
Let me try to implement it in VS.NET
Thanks
bong99 said:
O yes...It works under eVC++
Let me try to implement it in VS.NET
Thanks
Click to expand...
Click to collapse
Please tell me if you make it, as I have tried various P/Invoke calls that all result in a No Supported Exception.
Cato
PS: Sorry that I could not get you a working code before but I was under with the flu last week

Win32 Mode Failure to set text in static control

I have a problem in setting controls in a Win32 application.
When I use SendMessage to set a text string in a static control I get error number 120 which translated means: "This function is only valid in Win32 mode."
Here's the background:
I'm using Visual Studio 2005, I've installed the Windows Mobile 5 SDK.
The project was created using the New Project Wizard, with the following settings:
Visual C++/Smart Device
Win32 Smart Device Project
Platform SDK is: Windows Mobile 5.0 Pocket PC SDK
Windows application
I've added a dialog template resource and can bring up a dialog based on that resource. It contains a static control that I can read the text from, but attempting to set the text gives me the above error.
The relevent code (within the WM_INITDIALOG message handler) is:
Code:
char buffer[100];
HWND hCtrl = ::GetDlgItem(hDlg, IDC_TITLE);
LRESULT result = ::SendMessage(hCtrl, WM_GETTEXT, (WPARAM)80, (LPARAM)buffer);
This works, I get the correct text (ie the text I have placed into the static control using the dialog template editor) copied into the buffer. What follows is:
Code:
buffer[0] = 'A'; // Just to set up a different string
result = ::SendMessage(hCtrl, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
if (result == 0)
{
LPVOID lpMsgBuf;
DWORD error = ::GetLastError();
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
::MessageBox(NULL, (LPCTSTR)lpMsgBuf, (LPCWSTR)"LError", MB_OK | MB_ICONINFORMATION);
::LocalFree(lpMsgBuf);
}
The attempt to set the changed text string fails (ie result == 0), and the last error is 120, which is translated to the error message above.
This works the same in both the Windows Mobile 5 emulator, and if I run it on my Atom.
What does this mean? How could it be anything other than Win32 mode?
Is there a function or something I have to call to put it into Win32 mode?
Or is it a project setting in VS2005 that I haven't been able to find?
I'd very much appreciate any help on this.
Peter
Hi Peter.
The only problem I can see in your code is that you are using char instead of WCHAR. Windows Mobile devices only use UNICODE for API calls.
I don't think it is causing the error, but it is strange that you manage to get the correct text out using it.
The only thing I can think of is using GetWindowText and SetWindowText APIs instead of sending the message directly.
Maybe this will solve your problem.
I also notice that you did not initialize the buffer. The string needs to be null terminated so try initializeing all the elements before putting your 'A' in.
I thought 120 was not supported on this system ERROR_CALL_NOT_IMPLEMENTED.
Guys,
Thanks very much for the suggestions.
As for not initializing the buffer, I think the WM_GETTEXT call does that, all I do with the buffer[0] = 'A' call is to modify a single character that now contains the text that was copied out from the control.
But I take your point about using WCHAR, I'll do that when I get a chance.
And I'll try the Get and SetWindowText calls.
Thanks again.
Ok, How about this then?
The buffer is initialized by the WM_GETTEXT message, and it is set to the correct value (ie the initial contents of the control).
Changing the first character works.
The WM_SETTEXT message fails (result == 0) and the translated error (120) as displayed in the message box is "This function is only valid in Win32 mode."
The SetWindowText also fails with the same last error.
Does anyone know what "Win32 mode" is? I have spent time searching the MSDN and googling it. I've seen some references to it as an error message, but I haven't found an explanation.
Thanks,
Peter
Code:
WCHAR buffer[100];
HWND hCtl = ::GetDlgItem(hDlg, IDC_TITLE);
LRESULT result = ::SendMessage(hCtl, WM_GETTEXT, (WPARAM)80, (LPARAM)buffer);
buffer[0] = WCHAR('A');
//BOOL textResult = ::SetWindowText(hCtl, (LPCWSTR)buffer);
result = ::SendMessage(hCtl, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
if (result == 0)
{
WCHAR errorTitle[] = L"LastError";
LPVOID lpMsgBuf;
DWORD error = ::GetLastError();
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
::MessageBox(NULL, (LPCTSTR)lpMsgBuf, (LPCWSTR)errorTitle, MB_OK | MB_ICONINFORMATION);
::LocalFree(lpMsgBuf);
}
Ok, there is no apparent reason why your code doesn't work. Like OdeeanRDeathshead said according to MSDN error 120 means 'This function is not supported on this system.', something you definitely should not be getting.
One question: is this code inside a class member function? I am asking because of the '::' in front of every API.
Try removing them and see what happens.
Also, no need to use WCHAR('A'), just write L'A' save your self some typing in the long run.
P.S. In my year and a half of programming for Windows Mobile I never heard of a 'Win32 mode' or a function not working because of it. The error may be elsewhere in your code, some problem with name-spaces perhaps?
Are you running this on an actual device or just the emulator?
Hi levenum,
Thanks for the reply. Where to start?
Firstly I tend to use the scope resolution operator wherever possible. In this case ::SendMessage (for example), is meant to be a clear message to the reader that these functions are not member functions of the class, but instead exist in the global namespace. I have tried removing them and there is no difference.
You also asked if the code was in a class member function. Well, yes. It is a static member function of a specialization of a generic dialog class. Both the about box dialog and this setup dialog specialize this generic dialog class. Each has their own static dialog message processing function.
The code is in the part that handles the WM_INITDIALOG message. This is where I would normally (ie in Win32 on good ol' PC type windows) initialize controls before the dialog box is displayed. I have shown the dialog message function, and it is almost identical to the one for the about box that is generated when you create a Win32 project in the wizard.
One other point is that the GetLastError call and the format call are exactly out of the MSDN. If you look up the FormatMessage function, there is example code to translate the error code returned by GetLastError. That's exactly what I have here, and the message it gives is about not being in Win32 mode. So now I'm curious, how do you arrive at the 'This function is not supported on this system' comment. I looked for error and 120, and the only thing I could find was something about ARM messages "improper line syntax; wrong use of local label".
By the way, the SetWindowText function (commented out) gives exactly the same error code. As you say, surely both of these are allowed on this system.
I also appreciate you comment about not having heard of a Win32 mode.
But you have got me wondering if I can simplify the problem further. I will try the initial small project you get generated from the wizard, and in the about box dialog message processing function I will try to set the text in one of the two static controls on the about box.
Thanks again,
Peter
Code:
// Message handler for the setup dalog.
INT_PTR CALLBACK
DialogSetup::DialogSetupDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
// Create a Done button and size it.
SHINITDLGINFO shidi;
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_EMPTYMENU;
shidi.hDlg = hDlg;
SHInitDialog(&shidi);
// Set up strings
//LRESULT result = ::SendDlgItemMessage(hDlg, IDC_TITLE, WM_SETTEXT, 0, (LPARAM)"Setup");
WCHAR buffer[100];
HWND hCtl = ::GetDlgItem(hDlg, IDC_TITLE);
LRESULT result = ::SendMessage(hCtl, WM_GETTEXT, (WPARAM)80, (LPARAM)buffer);
buffer[0] = WCHAR('A');
//BOOL textResult = ::SetWindowText(hCtl, (LPCWSTR)buffer);
result = ::SendMessage(hCtl, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
if (result == 0)
{
WCHAR errorTitle[] = L"LastError";
LPVOID lpMsgBuf;
DWORD error = ::GetLastError();
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
::MessageBox(NULL, (LPCTSTR)lpMsgBuf, (LPCWSTR)errorTitle, MB_OK | MB_ICONINFORMATION);
::LocalFree(lpMsgBuf);
}
}
return (INT_PTR)TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
}
break;
case WM_CLOSE:
EndDialog(hDlg, message);
return TRUE;
#ifdef _DEVICE_RESOLUTION_AWARE
case WM_SIZE:
{
DRA::RelayoutDialog
(
GetInstance(),
hDlg,
DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_SETUP_WIDE) : MAKEINTRESOURCE(IDD_SETUP)
);
}
break;
#endif
}
return (INT_PTR)FALSE;
}
Hi levenum,
Thanks for the reply. Where to start?
Firstly I tend to use the scope resolution operator wherever possible. In this case ::SendMessage (for example), is meant to be a clear message to the reader that these functions are not member functions of the class, but instead exist in the global namespace. I have tried removing them and there is no difference.
You also asked if the code was in a class member function. Well, yes. It is a static member function of a specialization of a generic dialog class. Both the about box dialog and this setup dialog specialize this generic dialog class. Each has their own static dialog message processing function.
The code is in the part that handles the WM_INITDIALOG message. This is where I would normally (ie in Win32 on good ol' PC type windows) initialize controls before the dialog box is displayed. I have shown the dialog message function, and it is almost identical to the one for the about box that is generated when you create a Win32 project in the wizard.
One other point is that the GetLastError call and the format call are exactly out of the MSDN. If you look up the FormatMessage function, there is example code to translate the error code returned by GetLastError. That's exactly what I have here, and the message it gives is about not being in Win32 mode. So now I'm curious, how do you arrive at the 'This function is not supported on this system' comment. I looked for error and 120, and the only thing I could find was something about ARM messages "improper line syntax; wrong use of local label".
By the way, the SetWindowText function (commented out) gives exactly the same error code. As you say, surely both of these are allowed on this system.
I also appreciate you comment about not having heard of a Win32 mode.
But you have got me wondering if I can simplify the problem further. I will try the initial small project you get generated from the wizard, and in the about box dialog message processing function I will try to set the text in one of the two static controls on the about box.
Thanks again,
Peter
Code:
// Message handler for the setup dalog.
INT_PTR CALLBACK
DialogSetup::DialogSetupDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
// Create a Done button and size it.
SHINITDLGINFO shidi;
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_EMPTYMENU;
shidi.hDlg = hDlg;
SHInitDialog(&shidi);
// Set up strings
//LRESULT result = ::SendDlgItemMessage(hDlg, IDC_TITLE, WM_SETTEXT, 0, (LPARAM)"Setup");
WCHAR buffer[100];
HWND hCtl = ::GetDlgItem(hDlg, IDC_TITLE);
LRESULT result = ::SendMessage(hCtl, WM_GETTEXT, (WPARAM)80, (LPARAM)buffer);
buffer[0] = WCHAR('A');
//BOOL textResult = ::SetWindowText(hCtl, (LPCWSTR)buffer);
result = ::SendMessage(hCtl, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
if (result == 0)
{
WCHAR errorTitle[] = L"LastError";
LPVOID lpMsgBuf;
DWORD error = ::GetLastError();
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
::MessageBox(NULL, (LPCTSTR)lpMsgBuf, (LPCWSTR)errorTitle, MB_OK | MB_ICONINFORMATION);
::LocalFree(lpMsgBuf);
}
}
return (INT_PTR)TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
}
break;
case WM_CLOSE:
EndDialog(hDlg, message);
return TRUE;
#ifdef _DEVICE_RESOLUTION_AWARE
case WM_SIZE:
{
DRA::RelayoutDialog
(
GetInstance(),
hDlg,
DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_SETUP_WIDE) : MAKEINTRESOURCE(IDD_SETUP)
);
}
break;
#endif
}
return (INT_PTR)FALSE;
}
That error message comes from the free evc compilers. In the tool "error lookup" and in the help, it gives that mesage to correspond to that number.
I have just tested everthing you did. My dialog also uses a class with static methods for its routine. I used your exact code in the initial dialog handler and experimented with the origional contents of the controll. I tested on 2002 2003 2005 devices and can't make it fail. The worst i can get to happen is if there is no text to start with, just a square character displays after the A.
the only thing different is that you say two dialogs use that routine, but I am guessing that you are not doing bothe at once at this time.
Guys, thanks again for anything you can give me.
Lets see, I don't have the situation where two dialogs are using the same function. They both use a different message handling function (different name).
As I said in my last post (sorry I seem to have posted it twice), I was going to simplify the example. I've done that and I get the same problem.
I created another project with the same settings I described above, called "TestSetText". I made a change in only one place. In the function called "About", the message handling function for the about box dialog, I have inserted my example code to get and set the text for one of the static controls called IDC_STATIC_2. I have made no other changes to the code. So the modified About function is as below, and I have commented the section I have added:
Code:
// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
// Create a Done button and size it.
SHINITDLGINFO shidi;
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_EMPTYMENU;
shidi.hDlg = hDlg;
SHInitDialog(&shidi);
// Code to check setting text - only change
//LRESULT result = SendDlgItemMessage(hDlg, IDC_STATIC_2, WM_SETTEXT, 0, L"Example");
WCHAR buffer[100];
HWND hCtl = GetDlgItem(hDlg, IDC_STATIC_2);
LRESULT result = SendMessage(hCtl, WM_GETTEXT, (WPARAM)80, (LPARAM)buffer);
MessageBox(NULL, (LPCTSTR)buffer, (LPCWSTR)L"Text from control", MB_OK | MB_ICONINFORMATION);
// Modify the extracted text
buffer[0] = L'A';
//BOOL textResult = SetWindowText(hCtl, (LPCWSTR)buffer);
result = SendMessage(hCtl, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
if (result == 0)
{
WCHAR errorTitle[] = L"LastError";
LPVOID lpMsgBuf;
DWORD error = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
MessageBox(NULL, (LPCTSTR)lpMsgBuf, (LPCWSTR)errorTitle, MB_OK | MB_ICONINFORMATION);
LocalFree(lpMsgBuf);
}
// End of my change
}
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
case WM_CLOSE:
EndDialog(hDlg, message);
return TRUE;
#ifdef _DEVICE_RESOLUTION_AWARE
case WM_SIZE:
{
DRA::RelayoutDialog(
g_hInst,
hDlg,
DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_ABOUTBOX_WIDE) : MAKEINTRESOURCE(IDD_ABOUTBOX));
}
break;
#endif
}
return (INT_PTR)FALSE;
}
So now there are no double colons, no second dialog, no base class, nothing else to confuse the issue. When the app starts all I have to do is invoke the Help|About menu.
When the WM_GETTEXT message is complete, buffer contains exactly the text I would have expected "TestSetText Version 1.0", and this is what is displayed in the message box. So in principle the SendMessage function works and the control handle (hCtl) is correct. This leads me to suspect that all necessary controls are created by the time the WM_INITDIALOG message is processed, and SHOULD be a good place to modify the controls prior to displaying the dialog box.
Modifying the first character in the buffer (setting it to 'A') succeeds as I can see in the debugger.
The attempt to send the WM_SETTEXT message fails (ie result == 0) and GetLastError returns 120 again. The code as I have it there translates this to "This function is only valid in Win32 mode." And this is displayed in the next message box.
When you see the about box, the first character in the IDC_STATIC_2 control has not been changed.
I've also tried using the SetWindowText call which returns non zero (a failure), and the same thing happens (GetLastError returns 120).
One final comment is that if you look up in the MSDN the FormatMessage function, it gives you code (that I have copied) to translate the GetLastError into a string. This gives the Win32 mode message above.
On the other hand, I have found the 120 error in the section "System Errors - Numerical Order" and 120 is listed there as "This function is not valid on this platform." which both of you guys have mentioned.
Ok, two different error messages. The Win32 mode error I don't understand. The not valid error is much more understandable, but how could these functions not be valid?
If you have stayed with me this far then you have a lot of patience.
Thanks
Peter
perhaps you could work around this. Define a value to use as your own message like #define MY_SETUP_MESSAGE ...some value.
Then do nothing in the handler for WM_INITDIALOG except post your own setup message. Do all your normal stuff there. If that succeeds then take a closer look at the timing of WM_INITDIALOG, else there is something waky going on.
Hang on a second, you wrote:
I've also tried using the SetWindowText call which returns non zero (a failure), and the same thing happens (GetLastError returns 120).
Click to expand...
Click to collapse
Is that correct or is it a typo? According to MSDN non zero return for SetWindowText means success, not failure.
One thing you should try is calling SetLastError(0) before calling SetWindowText. Last error is no automatically reset in any way, so it is possible that error 120 is a result of a previous function. Although that still wouldn't account for not seeing the change text in the control.
In any case this is strange. I always initialize controls in WM_INITDIALOG handler and it never failed before.
Ah, you're right. Sorry, I screwed that up. I misread the MSDN there and did a GetLastError anyway, which returned 120.
SetWindowText returns a value of 1, which implies success, but it wasn't successful in the sense of setting the text, when you see the about box it is unchanged.
I also did a SetLastError to zero before the call, and did a GetLastError after it (even though the return code said success), and it was zero. So by all accounts (return code and GetLastError) it should have worked but didn't. The about box is unchanged.
I have also SetLastError to zero before the SendMessage to set the text. That returns zero, and I am sure that the MSDN says should be TRUE if the text is set, so an error. Trouble is, GetLastError then gives zero implying that there was no failure. When you see the about box, the text is not changed so it did fail.
I will have to experiment some more. Maybe I can't set text in a static for some reason. Do I need to call InitCommonControls for that or something (which I haven't done)?
I will also have to try setting text in an edit control.
I used the format message and got the same win32 mode stuff now. However, the text was modified to the new value. I think the win32 mode error message is a bug. Put the same code into the emulator and the error returned is invalid handle. At least invalid handle is something more definite. In both cases, emulator and real device, even though the returned value is 0 for WM_SETTEXT, and the error message is there, I do not think there is an error. Have you just tried it without any error checking?
Are you creating the dialog using creatdialog/dialogbox?
Hi OdeeanRDeathshead, thanks for the reply.
I don't think the invalid handle error is right here because I have used the same control window handle (hCtl) a couple of statements before to retrieve the text and that worked. I guess what I haven't checked is whether the control window handle is changed somehow as a result of the first call, but that would be really weird.
You said that even though SendMessage/WM_SETTEXT returned 0, you thought it probably wasn't an error. Well, there is support for that in that when I SetLastError to zero just prior to calling it, and call GetLastError just after, the error code was zero, thus no error. But the reason I think that there WAS an error is that it did not modify the static control. This is what I get if I effectively don't do any error checking.
As for how I am creating the dialog, the only code I have modified from the original project created from the application wizard is in the WM_INITDIALOG section of the About function that I showed you above. The dialog is created in the WndProc message handling function for the main window, part of which is below. If it is the IDM_HELP_ABOUT command, from the menu, it calls DialogBox specifying the dialog message processing function 'About' where my modified code is.
The code below is produced by the application wizard.
Code:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static SHACTIVATEINFO s_sai;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
[b]case IDM_HELP_ABOUT:
DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About);
break;[/b]
case IDM_OK:
SendMessage (hWnd, WM_CLOSE, 0, 0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
etc
I think I am going to have to experiment some more on the weekend. Try some other controls etc.
By the way I meant to mention that exactly the same thing happens in both the emulator as well as my Atom. So far, in all of the combinations of code, I have not been able to programmatically change the text content of a static control on a dialog.
And I've just noticed that my attempt to highlight (bold) the relevent part of the code above didn't work.
D'oh!
Actually I have just thought of something that may be relevent.
The emulator and SDK that came by default with VisualStudio2005 is WindowsCE 2003. When I first tried my code in the emulator, it worked. I could not only set text in a static control, I was also successfully manipulating a date/time picker in a separate dialog. I did lots of GDI rendering in the main window as well. And this code also worked on a friend's WindowsCE2003 PDA.
Things looked good until I tried it on my Atom which is WindowsMobile 5.
None of the above worked (except the GDI rendering). I thought it may have been a problem with the development environment. So I downloaded the WindowsMobile 5 SDK which includes a WM5 emulator. I thought this is bound to fix the problem, ie generate the code with the WM5 SDK.
All of my problems above are with WM5 project and emulator. And I said I was using this way back in the first post.
OdeeanRDeathshead, I had a quick look at your profile and you seem to have some earlier XDA machines. Are you using Windows Mobile 5?
If the problem does turn out to be Windows Mobile 5 related, then that says something very bad about backwards compatibility for that platform. Could it also be a WM5 bug? Surely not something so fundamental as this?
I use evc++3 for a compiler, mainly because I am the kind of person who thinks - if its not broaken why change. I have an Atom and do use it to run code on. I have all os, ie 2002,2002pe,2003,2003se,2005, so I don't think this problem is with the device. It may be vis studio 2005, but others have said it works OK.
PPC operating systems have a nasty history of backwards compatibility issues. I could not say that this is the issue here, but it is definately one reason I stick to a lowest common denominator approach. Why not just get evc3 or evc4 and give them a try. They are free.
I guess I was hoping to do it with Visual Studio 2005 because that is what I use at work. These days I mainly program in C#/.NET.
I kind of miss the low level stuff that I used to do on windows a long time ago. But I reminisce.
I'm assuming that evc++ is embedded visual c++? It sounds like really good advice, I'll look for it and it sounds like it will fix all my problems. Especially if as you say, it works for WindowsMobile 5. Can you tell me if you are supposed to use the WindowsMobile 5 SDK with it?
So OdeeanRDeathshead and levenum, thanks a lot for your help guys.
Peter

volume setting

I am trying to set the volume to my needs then put it back after. I have use the code from ppc developer network and when that did not set the correct volume I also did the registry as well. Don't worry about "reg", its my registry class and it works fine.
DWORD oldReg=0;
oldReg=reg->readDWORDfromReg(name,path);
reg->saveDWORDtoRegistry(name,path,0xffffffff);
WAVEFORMATEX wf;
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 1;
wf.nSamplesPerSec = 8000 * 1000;
wf.wBitsPerSample = 8;
wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
wf.cbSize = 0;
HWAVEOUT hwo;
DWORD dwVolume=0xffffffff;
DWORD oldVolume=0;
int waveDevice=-1;
UINT numberOfDevices=waveOutGetNumDevs();
for(UINT id=0;id<numberOfDevices;id++)
{
if (waveOutOpen(&hwo,id,&wf,0,0,CALLBACK_NULL)==MMSYSERR_NOERROR)
{
waveDevice=id;
waveOutGetVolume(hwo,&oldVolume);
waveOutSetVolume(hwo,dwVolume);
waveOutClose(hwo);
break;
}
}
.........playing sound here all ok....
//put the volume back
if(waveDevice!=-1)
{
if (waveOutOpen(&hwo, waveDevice, &wf, 0, 0, CALLBACK_NULL) == MMSYSERR_NOERROR)
{
waveOutSetVolume(hwo, oldVolume);
waveOutClose(hwo);
}
}
reg->saveDWORDtoRegistry(name,path,oldReg);
I can set the volume to any value below the origional volume but any attempt to set a volume higher just dose nothing. There are no errors (checking left out here), just the same level. I did not seriously expect the registry part to work as I guess there is some event to trigger that change, but others seem to get results from waveOutSetVolume.
Well, I never tried changing volume by code, but I know TCPMP player does it well and it's open source so might be worth taking a look at.
Thanks levenum, I will give it a look.
Before I got a chance to look at that code I got a result. I have been using PlaySound to play a resource with no volume change working. When I use waveOutWrite to play a buffer containing the same data I can get the volume change I am after. There is still something wrong with my code because the sound gets garbled but I think I will figure that part out. I also want to next test playsound with a file instead of a resource.
<edit>
using playsound with the same file plays clear sound but the volume change is not working. Its a pity because to get the waveoutwrite to work properly i had to fill in the WAVEFORMATEX with the CORRECT values. This means that if I am allowing the user to specify files to play I will have to find out the samples per second and bits per sample info before I can use the file.

[QUESTION] HTCColdBoot.exe

Can anyone tell me what "exactly" HTCColdBoot.exe does on a cold boot? Copies files? Runs provxml's? I'm trying to troubleshoot a homescreen layout issue that only occurs after HTCColdBoot.exe runs on my Cavalier.
Thanks in advance.
This is the best explanation I have seen floating around. It is here in one of the threads, but this excerpt is taken from Willem Jan Hengeveld aka Itsme.
this is a description of all the files which are relevant to coldbooting a windows ce device.
databases, filesystem, and registry are initialized by filesys.exe based on the following config files
default.fdf
this is the registry information, as generated by regcomp.exe from the platform builder.
struct header {
DWORD signature; // 0x1d8374b2
DWORD size; // size of entire file
struct entry entry[];
};
struct entry {
WORD entrysize;
WORD entrytype; // 1 = path, 2 = key,value pair
union {
struct pathentry;
struct keyvalentry;
};
};
struct pathentry {
WORD hive; // 0 = HKCR, 1 = HKCU, 2 = HKLM
WORD pathlen; // in nr of wchars
WORD zero; // always 0 !!! this field is not present in wince4.x
WCHAR path[];
};
struct keyvalentry {
WORD valuetype; // 1 = string, 2 = empty, 3 = binary, 4 = dword, 7 = wbinary
WORD keysize; // in nr of wchars
WORD valuesize; // in bytes
WCHAR key[];
BYTE value[];
};
key/path size is including terminating NUL
the key 'Default' is the '@' default key.
initdb.ini
this initializes all databases
initobj.dat
this initializes the filesystem
calibrate + cut-paste tutorial
the program that does this is 'welcome.exe'.
initobj.dat contains a line that links 'welcome.lnk' into the startup folder. causing it to run as soon as the shell starts up.
welcome.exe deletes this link when it is finished
welcome.lnk contains 'MSWELCOME', which refers to the 'HKLM\SOFTWARE\Microsoft\Shell\Rai\:MSWELCOME' key in the registry, which points to "\Windows\Welcome.exe"
other things that welcome.exe does:
ImmDisableIME(0)
InitRichInkDLL
RegisterWindowMessage("SHWMappNotify")
ShowWindow("Taskbar", 0)
make \My Documents\Templates\*.psi, *.psw, *.xlt, *.pxt ro_hidden
for all in Comm\DefaultConnections, set ras some params
do more stuff to device.
pass 'defaultconfig.xml' to configmanager.dll
call method that does something with 'voicemail.lnk'
SHSipPreference(6)
load imgdecmp.dll
fload, coredll:2043
SHSipPreference(2)
ShowWindow(?, 1)
TouchCalibrate
ClockDll ...
run 'clocknot.exe' at later time.
deletelink
oeminfo.xml
contains public keys for HTC, and microsoft
.rgu files
since pocketpc 2003, many registry settings have moved from default.fdf to .rgu files. these files are processed by regupdater.exe, but I have not yet researched how and when exactly.
AutoConfig.exe
AutoConfig is loaded via a 'startup' item set by initobj.dat.
it locates the operator rom data, and presents a list of supported configurations found in the customtab.dat file.
Click to expand...
Click to collapse
GSLEON3 said:
This is the best explanation I have seen floating around. It is here in one of the threads, but this excerpt is taken from Willem Jan Hengeveld aka Itsme.
Click to expand...
Click to collapse
It's too bad that information (while good!) doesn't help him at all as it has nothing to do with htccoldboot.exe.. Notice the HTC in the file name ?
Htccoldboot.exe processes all provxml's among other things. So you assumed right You could try trimming them one by one, until your issue goes away...
NRGZ28 said:
It's too bad that information (while goog!) doesn't help him at all as it has nothing to do with htccoldboot.exe.. Notice the HTC in the file name ?
Htccoldboot.exe processes all provxml's among other things. So you assumed right You could try trimming them one by one, until your issue goes away...
Click to expand...
Click to collapse
Thats what I figured. Thanks. The main issue is that after about 10 minutes of "idle", you go back to the home screen and it's white saying "The layout cannot be loaded". Sometimes the Start menu will work so I can get back into Settings\Home Screen and change it. When I do, it comes back.
Any idea what can be affecting that? Happens with HTC Sliding Panels, regular Sliding Panels, and both CPR's. Also, regardless of what color "scheme" I choose. It's like there is some background service that times it out!?
Any ideas?

[SOLVED] How do I restart manila in C# or C++?

Hi.
Can someone tell me how to restart manila programatically? I'm writing an app that requires it to restart in order to show some changes and am struggling with this.
I thought it would be a simple case of getting a handle, closing the process and then running manila.exe again, but this doesn't want to work.
Any advice would be appreciated.
Solved!
See this post...
http://forum.xda-developers.com/showpost.php?p=5627550&postcount=13
Hi
You can try TFDetacher :
http://www.codeplex.com/TFDetacher
Sorry if I don't understand your question, I'm french
Good Luck
You could use MichaRefresh too.
http://forum.xda-developers.com/showthread.php?t=583034
simply mortscript
Code:
regWriteDword HKLM, Software\Microsoft\Today\Items\HTC Sense, Enabled, 0
RedrawToday
whatever
regWriteDword HKLM, Software\Microsoft\Today\Items\HTC Sense, Enabled, 1
RedrawToday
Thanks for the answers guys, but I'm trying to do this in an app that I'm writing, so the suggestions for apps are unfortunately no good for me.
bgumble - the registry entry changes are fine, but I don't know what MortScript actually does when you use the "RedrawToday" command. I won't be using MortScript (my app is being developed in C#), so I'm 1/2 way there now, thanks
Can anyone point me in the right direction with this?
johncmolyneux said:
Thanks for the answers guys, but I'm trying to do this in an app that I'm writing, so the suggestions for apps are unfortunately no good for me.
bgumble - the registry entry changes are fine, but I don't know what MortScript actually does when you use the "RedrawToday" command. I won't be using MortScript (my app is being developed in C#), so I'm 1/2 way there now, thanks
Can anyone point me in the right direction with this?
Click to expand...
Click to collapse
..how about kill manila.exe?
cyron_at said:
..how about kill manila.exe?
Click to expand...
Click to collapse
That was my first thought, and it seemed like the most likely thing, but it doesn't work. First off, I couldn't terminate the process in C#, so I tried it with dotfred's task manager. It doesn't seem to want to terminate at all. It still appears to be running, but then the desktop is screwed, as if it's not being redrawn. Running manila.exe afterwards just doesn't help and you need to restart the device.
Any advice?
Might be some goodies here, don't have time to test I'm afraid : http://msdn.microsoft.com/en-us/library/bb416484.aspx
Dave
if you have mortscript use this
DaveShaw said:
Might be some goodies here, don't have time to test I'm afraid : http://msdn.microsoft.com/en-us/library/bb416484.aspx
Dave
Click to expand...
Click to collapse
Thanks Dave. It doesn't help, but it's an interesting read nonetheless
bnm7bnm said:
if you have mortscript use this
Click to expand...
Click to collapse
Thanks, but I'm doing this in C# and don't want to require the end user to have any extra software installed.
bgumble said:
simply mortscript
Code:
regWriteDword HKLM, Software\Microsoft\Today\Items\HTC Sense, Enabled, 0
RedrawToday
whatever
regWriteDword HKLM, Software\Microsoft\Today\Items\HTC Sense, Enabled, 1
RedrawToday
Click to expand...
Click to collapse
I haven't tested this with Manila but instead of RedrawToday the following call might be good:
PostMessage:GetDesktopWindow(), WM_WININICHANGE, 0xF2, 0);
RAMMANN said:
I haven't tested this with Manila but instead of RedrawToday the following call might be good:
PostMessage:GetDesktopWindow(), WM_WININICHANGE, 0xF2, 0);
Click to expand...
Click to collapse
Thanks RAMMANN - I'll give that a try and let you know.
BIG THANKS to bgumble, RAMMANN and MichelDiamond. I'm putting the code here for both my future reference and for anyone who stumbles across this whilst looking for the same solution...
Code:
using Microsoft.Win32;
using System.Runtime.InteropServices;
public const int HWND_BROADCAST = 0xffff;
public const int WM_WININICHANGE = 0x001A;
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("coredll.dll", SetLastError = true)]
static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private static void RestartManila()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey
("Software\\Microsoft\\Today\\Items\\HTC Sense", true);
key.SetValue("Enabled", 0);
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, (IntPtr)0xF2, (IntPtr)0);
// This is required or manila is enabled before it's fully disabled,
// so doesn't restart
System.Threading.Thread.Sleep(1000);
key.SetValue("Enabled", 1);
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, (IntPtr)0xF2, (IntPtr)0);
}
johncmolyneux said:
BIG THANKS to bgumble, RAMMANN and MichelDiamond. I'm putting the code here for both my future reference and for anyone who stumbles across this whilst looking for the same solution...
Code:
using Microsoft.Win32;
using System.Runtime.InteropServices;
public const int HWND_BROADCAST = 0xffff;
public const int WM_WININICHANGE = 0x001A;
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
private static void RestartManila()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(
"Software\\Microsoft\\Today\\Items\\HTC Sense", true);
key.SetValue("Enabled", 0);
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
// This is required or manila is enabled before it's fully disabled,
// so doesn't restart
System.Threading.Thread.Sleep(1000);
key.SetValue("Enabled", 1);
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
Click to expand...
Click to collapse
I'd reccommend using PostMessage instead of SendMessage.
I wrote the WeatherCityEditor that is used for Sense 2.1 and Sense 2.5.
Joe Wilcox sent me code very similar to this to Stop and Start Touch Flo 3D. He wrote the app that was used with Manila 2.0 and earlier.
When Sense came along, I tried just changing the TouchFLO 3D part to HTC Sense like what is posted.
Sometimes, it workded great, but some users reported hangs on start. I did not reproduce immediately, but eventually it started happening for me too. Very rarely right after a soft reset, but after leaving the phone alone for hours.
When it would hang, it might hang for up to 5 minutes.
Switching to Post message, and adding a 1 or 2 second delay took care of it.
SendMessage waits for things to be processed. PostMessage does not wait.
JVH3 said:
Sometimes, it workded great, but some users reported hangs on start. I did not reproduce immediately, but eventually it started happening for me too. Very rarely right after a soft reset, but after leaving the phone alone for hours.
When it would hang, it might hang for up to 5 minutes.
Switching to Post message, and adding a 1 or 2 second delay took care of it.
SendMessage waits for things to be processed. PostMessage does not wait.
Click to expand...
Click to collapse
Thanks for the advice mate. I was aware of the difference between the 2 methods but didn't realise that it could cause a problem. I chose to use SendMessage because it waits for a response, thinking that it may negate the need for the sleep inbetween the 2 calls, but if you've experienced it causing problems as you described then I'll definitely use PostMessage instead!
Thanks mate

Categories

Resources