Home > Archive > Smartphone Developer Forum > January 2005 > CeGetUserNotificationPreferences
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
CeGetUserNotificationPreferences
|
|
| yufufi 2005-01-23, 8:59 pm |
| I'm trying to write an application which adds notifications and removes the
ones belong to it. all the notifications added by my application has the
same title. so what I want to do is to get all notifications and check their
titles, and then delete if it is created by my application..
there are some imported functions at this page
http://samples.gotdotnet.com/quicks...fications.aspx.
I used them without any problem. For example with CeSetUserNotificationEx I
added some notifications and they worked fine. The problem occurs when I try
to query notifications and find the ones which belong to my application.
[DllImport("coredll.dll",SetLastError=true)]
internal static extern bool CeGetUserNotificationHandles (
int []rghNotifications,
int cHandles,
out int pcHandlesNeeded);
I use this function to query notifications which seems to be working
properly. (Actually I'm not sure!)
[DllImport("coredll.dll",SetLastError=true)]
internal static extern bool CeGetUserNotificationPreferences(
int handle,
out CE_USER_NOTIFICATION lpNotification );
I use this function to query notification preferences.
CE_USER_NOTIFICATION is defined in the web page I mentioned above:
internal struct CE_USER_NOTIFICATION: IDisposable
{
public ActionFlags actionFlags;
public SmartString pwszDialogTitle;
public SmartString pwszDialogText;
public SmartString pwszSound;
public uint dwMaxSound;
public uint dwReserved;
public CE_USER_NOTIFICATION( string title, string text )
{
actionFlags = ActionFlags.PUN_DIALOG;
pwszDialogTitle = new SmartString( title );
pwszDialogText = new SmartString( text );
pwszSound = new SmartString( null );
dwMaxSound = 0;
dwReserved = 0;
}
public void Dispose()
{
pwszDialogTitle.Dispose();
pwszDialogText.Dispose();
pwszSound.Dispose();
}
}
internal struct SmartString: IDisposable
{
public IntPtr szString;
public SmartString( string s )
{
szString = StringToHLocal( s );
}
public void Dispose()
{
FreeHLocal( szString );
}
}
So in theory when I query notifications , it should be possible to check
their title through returned CE_USER_NOTIFICATION with lpNotification
..pwszDialogTitle.szString. But it seems szString is not filled with
something. I set lpNotification.pwszDialogTitle.szString to some temp value
before passing to CeGetUserNotificationPreferences as a ref. It returned
with the same values. So noone seems to be changing them ??
I tried to go 'unsafe' and used char * instead of smartstring which didn't
changed anything at all.
thanx in advance,
yufufi
| |
| Peter Foot [MVP] 2005-01-24, 8:58 am |
| CeGetUserNotificationPreferences does just that, it returns the default
preferences the user has set for notfications. the idea of this function is
you fill the structure with the default values, then add your own specific
data in (text title etc) then set the notification.
If you want to query an existing notification you must use
CeGetUserNotificationHandles and then use these handle values with
CeGetUserNotification.
Peter
--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org
"yufufi" <yufufi@ttnet.net.tr> wrote in message
news:es5DosZAFHA.3840@tk2msftngp13.phx.gbl...
> I'm trying to write an application which adds notifications and removes
> the ones belong to it. all the notifications added by my application has
> the same title. so what I want to do is to get all notifications and check
> their titles, and then delete if it is created by my application..
>
> there are some imported functions at this page
> http://samples.gotdotnet.com/quicks...fications.aspx.
>
> I used them without any problem. For example with CeSetUserNotificationEx
> I added some notifications and they worked fine. The problem occurs when I
> try to query notifications and find the ones which belong to my
> application.
>
> [DllImport("coredll.dll",SetLastError=true)]
> internal static extern bool CeGetUserNotificationHandles (
> int []rghNotifications,
> int cHandles,
> out int pcHandlesNeeded);
> I use this function to query notifications which seems to be working
> properly. (Actually I'm not sure!)
> [DllImport("coredll.dll",SetLastError=true)]
> internal static extern bool CeGetUserNotificationPreferences(
> int handle,
> out CE_USER_NOTIFICATION lpNotification );
> I use this function to query notification preferences.
> CE_USER_NOTIFICATION is defined in the web page I mentioned above:
> internal struct CE_USER_NOTIFICATION: IDisposable
> {
> public ActionFlags actionFlags;
> public SmartString pwszDialogTitle;
> public SmartString pwszDialogText;
> public SmartString pwszSound;
> public uint dwMaxSound;
> public uint dwReserved;
> public CE_USER_NOTIFICATION( string title, string text )
> {
> actionFlags = ActionFlags.PUN_DIALOG;
> pwszDialogTitle = new SmartString( title );
> pwszDialogText = new SmartString( text );
> pwszSound = new SmartString( null );
> dwMaxSound = 0;
> dwReserved = 0;
> }
> public void Dispose()
> {
> pwszDialogTitle.Dispose();
> pwszDialogText.Dispose();
> pwszSound.Dispose();
> }
> }
> internal struct SmartString: IDisposable
> {
> public IntPtr szString;
> public SmartString( string s )
> {
> szString = StringToHLocal( s );
> }
> public void Dispose()
> {
> FreeHLocal( szString );
> }
> }
> So in theory when I query notifications , it should be possible to check
> their title through returned CE_USER_NOTIFICATION with lpNotification
> .pwszDialogTitle.szString. But it seems szString is not filled with
> something. I set lpNotification.pwszDialogTitle.szString to some temp
> value before passing to CeGetUserNotificationPreferences as a ref. It
> returned with the same values. So noone seems to be changing them ??
> I tried to go 'unsafe' and used char * instead of smartstring which didn't
> changed anything at all.
> thanx in advance,
> yufufi
>
|
|
|
|
|