Windows Toast notifications - second try

Re: Windows Toast notifications - second try

Postby thefull » Tue Apr 19, 2016 9:32 am

Brutal Antonio, con un xHarbour viejo , bcc 5.5 , con Windows 10 funciona perfecto!
Saludos
Rafa Carmona ( rafa.thefullARROBAgmail.com___quitalineas__)
User avatar
thefull
 
Posts: 731
Joined: Fri Oct 07, 2005 7:42 am
Location: Barcelona

Re: Windows Toast notifications - second try

Postby Silvio.Falconi » Tue Apr 19, 2016 10:34 am

Antonio,
I mean for the sample for borland you linked me http://forums.fivetechsupport.com/viewtopic.php?p=189308#p189308
I tried that test on win7 and it ask me the dll
perhaps it not possible into windows seven but I see alert message from google or another application into w7 ...
I think it can be run also on win 7
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7063
Joined: Thu Oct 18, 2012 7:17 pm

Re: Windows Toast notifications - second try

Postby Baxajaun » Tue Apr 19, 2016 12:59 pm

Silvio,

you must use Windows 10.

Best regards,
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: Windows Toast notifications - second try

Postby James Bott » Tue Apr 19, 2016 2:06 pm

Antonio,

Well the new version works great! Its magic. I didn't even need the link to Start, it just worked.

I haven't yet tried the second Harbour/xHarbour version yet, as I just woke up. But I will give it a try soon.

I assume that you will be wrapping the whole thing in a FW class later?

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Windows Toast notifications - second try

Postby James Bott » Tue Apr 19, 2016 3:27 pm

Antonio,

I tried the 2nd Borland version (for Harbour and xHarbour) and it works great too. Also, it did not require being pinned to the Start menu--it just ran.

Great work.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Windows Toast notifications - second try

Postby Antonio Linares » Tue Apr 19, 2016 5:02 pm

James, Rafa,

many thanks for your feedback.

Good to know that we don't need the shortcut :-)

I have to complete its implementation to set the desired toast texts and image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows Toast notifications - second try

Postby Antonio Linares » Tue Apr 19, 2016 7:08 pm

Enhanced example:

Image

https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.toasttemplatetype

toastb.prg
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

#define Show                       7
#define CreateToastNotification    7
#define CreateToastNotifierWithId  8
#define Item                       8
#define GetTemplateContent         9
#define CreateTextNode            12
#define GetElementsByTagName      17
#define AppendChild               23

function Main()

   Toast( "FiveWin", "support for Windows 10", "standard toast notifications" )

return nil

function Toast( cFirstLine, cSecondLine, cThirdLine )

   local pString, cIID, pToastFactory
   local pXml, pNodeList, pXmlNode, pXmlText, pXmlNodeChild
   local pNotification, pNotificationFactory, pNotifier

   RoInitialize( 1 )

   pString = WinRTString( "Windows.UI.Notifications.ToastNotificationManager" )

   // "50AC103F-D235-4598-BBEF-98FE4D1A3AD4"
   cIID = Chr( 0x3F ) + Chr( 0x10 ) + Chr( 0xAC ) + Chr( 0x50 ) + ;
          Chr( 0x35 ) + Chr( 0xD2 ) + Chr( 0x98 ) + Chr( 0x45 ) + ;
          Chr( 0xBB ) + Chr( 0xEF ) + Chr( 0x98 ) + Chr( 0xFE ) + ;
          Chr( 0x4D ) + Chr( 0x1A ) + Chr( 0x3A ) + Chr( 0xD4 )

   RoGetActivationFactory( pString, cIID, @pToastFactory )
   WindowsDeleteString( pString );

   WinRTMethod( pToastFactory, GetTemplateContent, 7, @pXml )

   pString = WinRTString( "image" )
   WinRTMethod( pXml, GetElementsByTagName, pString, @pNodeList )
   WindowsDeleteString( pString )

   pString = WinRTString( "text" )
   WinRTMethod( pXml, GetElementsByTagName, pString, @pNodeList )
   WindowsDeleteString( pString )

   WinRTMethod( pNodeList, Item, 0, @pXmlNode )
   pString = WinRTString( cFirstLine )
   WinRTMethod( pXml, CreateTextNode, pString, @pXmlText )
   WindowsDeleteString( pString )
   WinRTMethod( pXmlNode, AppendChild, pXmlText, @pXmlNodeChild )

   WinRTMethod( pNodeList, Item, 1, @pXmlNode )
   pString = WinRTString( cSecondLine )
   WinRTMethod( pXml, CreateTextNode, pString, @pXmlText )
   WindowsDeleteString( pString )
   WinRTMethod( pXmlNode, AppendChild, pXmlText, @pXmlNodeChild )

   WinRTMethod( pNodeList, Item, 2, @pXmlNode )
   pString = WinRTString( cThirdLine )
   WinRTMethod( pXml, CreateTextNode, pString, @pXmlText )
   WindowsDeleteString( pString )
   WinRTMethod( pXmlNode, AppendChild, pXmlText, @pXmlNodeChild )

   // 04124B20-82C6-4229-B109-FD9ED4662B53
   cIID = Chr( 0x20 ) + Chr( 0x4B ) + Chr( 0x12 ) + Chr( 0x04 ) + ;
          Chr( 0xC6 ) + Chr( 0x82 ) + Chr( 0x29 ) + Chr( 0x42 ) + ;
          Chr( 0xB1 ) + Chr( 0x09 ) + Chr( 0xFD ) + Chr( 0x9E ) + ;
          Chr( 0xD4 ) + Chr( 0x66 ) + Chr( 0x2B ) + Chr( 0x53 )

   pString = WinRTString( "Windows.UI.Notifications.ToastNotification" )
   RoGetActivationFactory( pString, cIID, @pNotificationFactory )
   WindowsDeleteString( pString )

   WinRTMethod( pNotificationFactory, CreateToastNotification, pXML, @pNotification )

   pString = WinRTString( cFirstLine )
   WinRTMethod( pToastFactory, CreateToastNotifierWithId, pString, @pNotifier )
   WindowsDeleteString( pString )

   WinRTMethod( pNotifier, Show, pNotification )

   RoUninitialize()

return nil

function WinRTString( cText )

   local pString
   
   WindowsCreateString( AnsiToWide( cText ), Len( cText ), @pString )

return pString

DLL FUNCTION RoInitialize( nType AS LONG ) AS LONG PASCAL LIB "combase.dll"

DLL FUNCTION RoUninitialize() AS VOID PASCAL LIB "combase.dll"

DLL FUNCTION WindowsCreateString( cWideText AS LPSTR, nLength AS LONG, @pString AS PTR ) ;
   AS LONG PASCAL LIB "combase.dll"
   
DLL FUNCTION WindowsDeleteString( pString AS PTR ) AS LONG PASCAL LIB "combase.dll"

DLL FUNCTION RoGetActivationFactory( pString AS PTR, REFIID AS LPSTR, @pFactory AS PTR ) ;
   AS LONG PASCAL LIB "combase.dll"

#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

#ifndef HB_LONGLONG
   #define HB_LONGLONG long
   #define hb_storvnll hb_stornl
#endif

typedef void * ( __stdcall * PMETHOD0 )( void * );
typedef void * ( __stdcall * PMETHOD1 )( void *, void * );
typedef void * ( __stdcall * PMETHOD2 )( void *, void *, void * );

HB_FUNC( WINRTMETHOD ) // pInspectable, nMethod, params...
{
   IUnknown * unknown = ( IUnknown * ) hb_parnll( 1 );
   void * pMethod = ( ( void ** ) unknown->lpVtbl )[ hb_parnl( 2 ) - 1 ];
   IUnknown * pReturn;

   switch( hb_pcount() )
   {
      case 3:
         if( HB_ISBYREF( 3 ) )
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, &pReturn ) );
         else
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, ( IUnknown * ) hb_parnll( 3 ) ) );
         break;

      case 4:
         if( HB_ISBYREF( 4 ) )
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), &pReturn ) );
         else
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), ( IUnknown * ) hb_parnll( 4 ) ) );
         break;
   }

   if( HB_ISBYREF( 3 ) )
      hb_storvnll( ( HB_LONGLONG ) pReturn, 3 );

   if( HB_ISBYREF( 4 ) )
      hb_storvnll( ( HB_LONGLONG ) pReturn, 4 );
}  

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows Toast notifications - second try

Postby James Bott » Tue Apr 19, 2016 10:34 pm

Antonio,

Two findings:

1) Using the code in your previous post, I notice that if I call the toast from:

ACTIVATE WINDOW oWnd ON INIT Toast()

The toast displays but doesn't show up in the Activity Center. (It does show when you just call it without the window).

2) Also you cannot click on the toast message to open the app (with or without the shortcut). Maybe you have to define an ON CLICK action somewhere?

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Windows Toast notifications - second try

Postby Antonio Linares » Wed Apr 20, 2016 6:58 am

James,

I just tested this and it properly appeared in the action center:

Code: Select all  Expand view  RUN
function Main()

   local oWnd

   DEFINE WINDOW oWnd

   ACTIVATE WINDOW oWnd ;
      ON INIT Toast( "FiveWin", "support for Windows 10", "standard toast notifications" )

return nil


Regarding the detection of the click on the toast, it can be done in VSC2015 C++, not sure if we will be able to have it with Borland:

https://code.msdn.microsoft.com/windowsdesktop/sending-toast-notifications-71e230a2/

https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/DesktopToasts/cpp
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows Toast notifications - second try

Postby mastintin » Wed Apr 20, 2016 9:09 am

First prototype class :)

Code: Select all  Expand view  RUN




#define IdShow                     7
#define CreateToastNotification    7
#define CreateToastNotifierWithId  8
#define Item                       8
#define GetTemplateContent         9
#define CreateTextNode            12
#define GetElementsByTagName      17
#define AppendChild               23

#define TemplateToastImageAndText01  0  // A large image and a single string wrapped across three lines of text.

#define TemplateToastImageAndText02  1  // A large image,
                                                // one string of bold text on the first line,
                                                // one string of regular text wrapped across the second and third lines.
                               
#define TemplateToastImageAndText03  2  // A large image, one string of bold text wrapped across the first two lines,
                                                                              // one string of regular text on the third line.
                                                             
#define TemplateToastImageAndText04  3  // A large image, one string of bold text on the first line,
                                                                              // one string of regular text on the second line,
                                                                              // one string of regular text on the third line.


#define TemplateToastText01          4  // A single string wrapped across three lines of text.
 
#define TemplateToastText02          5  // One string of bold text on the first line,
                                                                              // one string of regular text wrapped across the second and third lines.

#define TemplateToastText03          6  // One string of bold text wrapped across the first and second lines,
                                                                            // one string of regular text on the third line.

#define TemplateToastText04          7  // One string of bold text on the first line,
                                                                              // one string of regular text on the second line,
                                                                              // one string of regular text on the third line.


function Main()

   Toast( "FiveWin", "support for Windows 10", "standard toast notifications", " Hello word" )

return nil


function Toast( cFirstLine, cSecondLine, cThirdLine , cTextNotifier )


   local pXmlItem
   local oToast:= TToast():new()


   //   oToast:CreateTemplate( TemplateToastImageAndText04 )

      oToast:CreateTemplate( TemplateToastText04 )
      oToast:CreateNodeList( "image" )
      oToast:CreateNodeList( "text" )
     
        oToast:AppendNode(1)
      oToast:CreateNodeText( @pXmlItem, cFirstLine )
      oToast:AppendItemNode( pXmlItem )
     
      oToast:AppendNode(2)
      oToast:CreateNodeText( @pXmlItem, cSecondLine )
      oToast:AppendItemNode( pXmlItem )

      oToast:AppendNode(3)
      oToast:CreateNodeText( @pXmlItem, cThirdLine )
      oToast:AppendItemNode(  pXmlItem )

      oToast:CreateNotification()
      oToast:CreateNotifier( cTextNotifier )

      oToast:Show()
     
      oToast:End()

return nil


CLASS TToast

   DATA pTFactory
   DATA pXml
   DATA pNodeList
   DATA pXmlNode
   DATA pXmlNodeChild
   
   DATA pNotification
   DATA pNotifier
   
   METHOD New( )
   METHOD CreateTemplate( nTemplateToast ) INLINE WinRTMethod( @::pTFactory, GetTemplateContent, nTemplateToast, @::pXml )
   METHOD CreateNodeList( cType )
   METHOD CreateNodeText( pXmlText, cTexto )
   METHOD AppendNode(nItem) INLINE WinRTMethod( ::pNodeList, Item, nItem-1 , @::pXmlNode )
   METHOD AppendItemNode( pXmlItem )
   METHOD CreateNotification()
   METHOD CreateNotifier( cText )
   METHOD Show() INLINE  WinRTMethod( ::pNotifier, IdShow, ::pNotification )
 
             
   METHOD End()
   
ENDCLASS

//----------------------------------------------------------------------------//

METHOD New() CLASS TToast

local pString
local cIID

   RoInitialize( 1 )

   pString = WinRTString( "Windows.UI.Notifications.ToastNotificationManager" )

   // "50AC103F-D235-4598-BBEF-98FE4D1A3AD4"
   cIID = Chr( 0x3F ) + Chr( 0x10 ) + Chr( 0xAC ) + Chr( 0x50 ) + ;
          Chr( 0x35 ) + Chr( 0xD2 ) + Chr( 0x98 ) + Chr( 0x45 ) + ;
          Chr( 0xBB ) + Chr( 0xEF ) + Chr( 0x98 ) + Chr( 0xFE ) + ;
          Chr( 0x4D ) + Chr( 0x1A ) + Chr( 0x3A ) + Chr( 0xD4 )

   RoGetActivationFactory( pString, cIID, @::pTFactory )
   WindowsDeleteString( pString )

return Self

//----------------------------------------------------------------------------//

 METHOD CreateNodeList( cType ) CLASS TToast // cType -> "image","text"

local pString := WinRTString( cType )
   WinRTMethod( ::pXml, GetElementsByTagName, pString, @::pNodeList )
   WindowsDeleteString( pString )
Return nil

//----------------------------------------------------------------------------//

METHOD CreateNodeText( pXmlText, cTexto ) CLASS TToast
local pString
   pString = WinRTString( cTexto )
   WinRTMethod( ::pXml, CreateTextNode, pString, @pXmlText )
   WindowsDeleteString( pString )

Return nil

//---------------------------------------------------------------------

METHOD AppendItemNode( pXmlItem ) CLASS TToast
 WinRTMethod( ::pXmlNode, AppendChild, pXmlItem, @::pXmlNodeChild )
Return nil

//---------------------------------------------------------------------

METHOD CreateNotification() CLASS TToast
local cIID
local pString
local pNotificationFactory

   // 04124B20-82C6-4229-B109-FD9ED4662B53
   cIID = Chr( 0x20 ) + Chr( 0x4B ) + Chr( 0x12 ) + Chr( 0x04 ) + ;
          Chr( 0xC6 ) + Chr( 0x82 ) + Chr( 0x29 ) + Chr( 0x42 ) + ;
          Chr( 0xB1 ) + Chr( 0x09 ) + Chr( 0xFD ) + Chr( 0x9E ) + ;
          Chr( 0xD4 ) + Chr( 0x66 ) + Chr( 0x2B ) + Chr( 0x53 )

   pString = WinRTString( "Windows.UI.Notifications.ToastNotification" )
   
   RoGetActivationFactory( pString, cIID, @pNotificationFactory )
   WindowsDeleteString( pString )
   WinRTMethod( pNotificationFactory, CreateToastNotification, ::pXML, @::pNotification )
   
Return nil

//---------------------------------------------------------------------

METHOD CreateNotifier( cText ) CLASS TToast

local pString := WinRTString( cText )

   WinRTMethod( ::pTFactory, CreateToastNotifierWithId, pString, @::pNotifier )
   WindowsDeleteString( pString )
   
Return nil



//---------------------------------------------------------------------

METHOD End() CLASS TToast
  RoUninitialize()
Return nil


//---------------------------------------------------------------------

function WinRTString( cText )

   local pString
   
   WindowsCreateString( AnsiToWide( cText ), Len( cText ), @pString )

return pString

//---------------------------------------------------------------------

DLL FUNCTION RoInitialize( nType AS LONG ) AS LONG PASCAL LIB "combase.dll"

DLL FUNCTION RoUninitialize() AS VOID PASCAL LIB "combase.dll"

DLL FUNCTION WindowsCreateString( cWideText AS LPSTR, nLength AS LONG, @pString AS PTR ) ;
   AS LONG PASCAL LIB "combase.dll"
   
DLL FUNCTION WindowsDeleteString( pString AS PTR ) AS LONG PASCAL LIB "combase.dll"

DLL FUNCTION RoGetActivationFactory( pString AS PTR, REFIID AS LPSTR, @pFactory AS PTR ) ;
   AS LONG PASCAL LIB "combase.dll"

//---------------------------------------------------------------------
#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

#ifndef HB_LONGLONG
   #define HB_LONGLONG long
   #define hb_storvnll hb_stornl
#endif

typedef void * ( __stdcall * PMETHOD0 )( void * );
typedef void * ( __stdcall * PMETHOD1 )( void *, void * );
typedef void * ( __stdcall * PMETHOD2 )( void *, void *, void * );

HB_FUNC( WINRTMETHOD ) // pInspectable, nMethod, params...
{
   IUnknown * unknown = ( IUnknown * ) hb_parnll( 1 );
   void * pMethod = ( ( void ** ) unknown->lpVtbl )[ hb_parnl( 2 ) - 1 ];
   IUnknown * pReturn;

   switch( hb_pcount() )
   {
      case 3:
         if( HB_ISBYREF( 3 ) )
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, &pReturn ) );
         else
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, ( IUnknown * ) hb_parnll( 3 ) ) );
         break;

      case 4:
         if( HB_ISBYREF( 4 ) )
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), &pReturn ) );
         else
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), ( IUnknown * ) hb_parnll( 4 ) ) );
         break;
   }

   if( HB_ISBYREF( 3 ) )
      hb_storvnll( ( HB_LONGLONG ) pReturn, 3 );

   if( HB_ISBYREF( 4 ) )
      hb_storvnll( ( HB_LONGLONG ) pReturn, 4 );
}  

#pragma ENDDUMP

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Windows Toast notifications - second try

Postby richard-service » Wed Apr 20, 2016 9:09 am

Hi Antonio,

I got shout down. OS-win10

Code: Select all  Expand view  RUN

#include "FiveWin.ch"

#define Show                       7
#define CreateToastNotification    7
#define CreateToastNotifierWithId  8
#define Item                       8
#define GetTemplateContent         9
#define CreateTextNode            12
#define GetElementsByTagName      17
#define AppendChild               23

function Main()

   local oWnd

   DEFINE WINDOW oWnd

   ACTIVATE WINDOW oWnd ;
      ON INIT Toast( "FiveWin", "support for Windows 10", "standard toast notifications" )

return nil

function Toast( cFirstLine, cSecondLine, cThirdLine )

   local pString, cIID, pToastFactory
   local pXml, pNodeList, pXmlNode, pXmlText, pXmlNodeChild
   local pNotification, pNotificationFactory, pNotifier

   RoInitialize( 1 )

   pString = WinRTString( "Windows.UI.Notifications.ToastNotificationManager" )

   // "50AC103F-D235-4598-BBEF-98FE4D1A3AD4"
   cIID = Chr( 0x3F ) + Chr( 0x10 ) + Chr( 0xAC ) + Chr( 0x50 ) + ;
          Chr( 0x35 ) + Chr( 0xD2 ) + Chr( 0x98 ) + Chr( 0x45 ) + ;
          Chr( 0xBB ) + Chr( 0xEF ) + Chr( 0x98 ) + Chr( 0xFE ) + ;
          Chr( 0x4D ) + Chr( 0x1A ) + Chr( 0x3A ) + Chr( 0xD4 )

   RoGetActivationFactory( pString, cIID, @pToastFactory )
   WindowsDeleteString( pString );

   WinRTMethod( pToastFactory, GetTemplateContent, 7, @pXml )

   pString = WinRTString( "image" )
   WinRTMethod( pXml, GetElementsByTagName, pString, @pNodeList )
   WindowsDeleteString( pString )

   pString = WinRTString( "text" )
   WinRTMethod( pXml, GetElementsByTagName, pString, @pNodeList )
   WindowsDeleteString( pString )

   WinRTMethod( pNodeList, Item, 0, @pXmlNode )
   pString = WinRTString( cFirstLine )
   WinRTMethod( pXml, CreateTextNode, pString, @pXmlText )
   WindowsDeleteString( pString )
   WinRTMethod( pXmlNode, AppendChild, pXmlText, @pXmlNodeChild )

   WinRTMethod( pNodeList, Item, 1, @pXmlNode )
   pString = WinRTString( cSecondLine )
   WinRTMethod( pXml, CreateTextNode, pString, @pXmlText )
   WindowsDeleteString( pString )
   WinRTMethod( pXmlNode, AppendChild, pXmlText, @pXmlNodeChild )

   WinRTMethod( pNodeList, Item, 2, @pXmlNode )
   pString = WinRTString( cThirdLine )
   WinRTMethod( pXml, CreateTextNode, pString, @pXmlText )
   WindowsDeleteString( pString )
   WinRTMethod( pXmlNode, AppendChild, pXmlText, @pXmlNodeChild )

   // 04124B20-82C6-4229-B109-FD9ED4662B53
   cIID = Chr( 0x20 ) + Chr( 0x4B ) + Chr( 0x12 ) + Chr( 0x04 ) + ;
          Chr( 0xC6 ) + Chr( 0x82 ) + Chr( 0x29 ) + Chr( 0x42 ) + ;
          Chr( 0xB1 ) + Chr( 0x09 ) + Chr( 0xFD ) + Chr( 0x9E ) + ;
          Chr( 0xD4 ) + Chr( 0x66 ) + Chr( 0x2B ) + Chr( 0x53 )

   pString = WinRTString( "Windows.UI.Notifications.ToastNotification" )
   RoGetActivationFactory( pString, cIID, @pNotificationFactory )
   WindowsDeleteString( pString )

   WinRTMethod( pNotificationFactory, CreateToastNotification, pXML, @pNotification )

   pString = WinRTString( cFirstLine )
   WinRTMethod( pToastFactory, CreateToastNotifierWithId, pString, @pNotifier )
   WindowsDeleteString( pString )

   WinRTMethod( pNotifier, Show, pNotification )

   RoUninitialize()

return nil

function WinRTString( cText )

   local pString
   
   WindowsCreateString( AnsiToWide( cText ), Len( cText ), @pString )

return pString

DLL FUNCTION RoInitialize( nType AS LONG ) AS LONG PASCAL LIB "combase.dll"

DLL FUNCTION RoUninitialize() AS VOID PASCAL LIB "combase.dll"

DLL FUNCTION WindowsCreateString( cWideText AS LPSTR, nLength AS LONG, @pString AS PTR ) ;
   AS LONG PASCAL LIB "combase.dll"
   
DLL FUNCTION WindowsDeleteString( pString AS PTR ) AS LONG PASCAL LIB "combase.dll"

DLL FUNCTION RoGetActivationFactory( pString AS PTR, REFIID AS LPSTR, @pFactory AS PTR ) ;
   AS LONG PASCAL LIB "combase.dll"

#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

#ifndef HB_LONGLONG
   #define HB_LONGLONG long
   #define hb_storvnll hb_stornl
#endif

typedef void * ( __stdcall * PMETHOD0 )( void * );
typedef void * ( __stdcall * PMETHOD1 )( void *, void * );
typedef void * ( __stdcall * PMETHOD2 )( void *, void *, void * );

HB_FUNC( WINRTMETHOD ) // pInspectable, nMethod, params...
{
   IUnknown * unknown = ( IUnknown * ) hb_parnll( 1 );
   void * pMethod = ( ( void ** ) unknown->lpVtbl )[ hb_parnl( 2 ) - 1 ];
   IUnknown * pReturn;

   switch( hb_pcount() )
   {
      case 3:
         if( HB_ISBYREF( 3 ) )
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, &pReturn ) );
         else
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, ( IUnknown * ) hb_parnll( 3 ) ) );
         break;

      case 4:
         if( HB_ISBYREF( 4 ) )
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), &pReturn ) );
         else
            hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), ( IUnknown * ) hb_parnll( 4 ) ) );
         break;
   }

   if( HB_ISBYREF( 3 ) )
      hb_storvnll( ( HB_LONGLONG ) pReturn, 3 );

   if( HB_ISBYREF( 4 ) )
      hb_storvnll( ( HB_LONGLONG ) pReturn, 4 );
}  

#pragma ENDDUMP
 


矬闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡醴
?FWH 64 for Harbour 16.03 (MSVC++) Mar.2016 Harbour development power 喝
?(c) FiveTech 1993-2016 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8/10 喊
斂闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡闡囁?
'葔葔葔葔葔葔葔葔葔葔葔葔葔葔葔葔葔葔葔葔葔葔?' 不是內部或外部命令、可執行的程式或批次檔。
Compiling...
Harbour 3.2.0dev (r1603082110)
Copyright (c) 1999-2016, http://harbour-project.org/
Compiling 'toast.prg' and generating preprocessed output to 'toast.ppo'...
Lines 4684, Functions/Procedures 8
Generating C source output to 'toast.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

toast.c
toast.prg(136): warning C4311: 'type cast': pointer truncation from 'void *' to 'long'
toast.prg(138): warning C4311: 'type cast': pointer truncation from 'void *' to 'long'
toast.prg(143): warning C4311: 'type cast': pointer truncation from 'void *' to 'long'
toast.prg(145): warning C4311: 'type cast': pointer truncation from 'void *' to 'long'
toast.prg(150): warning C4311: 'type cast': pointer truncation from 'IUnknown *' to 'long'
toast.prg(153): warning C4311: 'type cast': pointer truncation from 'IUnknown *' to 'long'
* Application successfully built *
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 803
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: Windows Toast notifications - second try

Postby Antonio Linares » Wed Apr 20, 2016 9:18 am

Richard,

It is not ready for 64 bits yet
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows Toast notifications - second try

Postby Antonio Linares » Wed Apr 20, 2016 9:20 am

Manuel,

very good

I am focused now on implementing the toast events

Also we need to implement the code to display the image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows Toast notifications - second try

Postby richard-service » Wed Apr 20, 2016 9:23 am

Antonio Linares wrote:Richard,

It is not ready for 64 bits yet


I see, I hope hurry upgrade it.
32bit working now.
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 803
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: Windows Toast notifications - second try

Postby norberto » Wed Apr 20, 2016 12:31 pm

Antonio, works perfectly here in 1511 Windows version 10 pro 64, but we know that notifications on Windows 10 has several options, such as actions, scheduling, auto answer, it would be possible to implement this? Another suggestion: there would be the possibility to detect Windows 10 and just run the notification only in this version?

best regards.
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 22 guests