FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Windows Toast notifications - second try
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Windows Toast notifications - second try
Posted: Sun Apr 17, 2016 06:41 PM
Silvio,

combase.dll. What is it?
The combase.dll is a Microsoft COM for Windows.
This file is part of Microsoft庐 Windows庐 Operating System.
Combase.dll is developed by Microsoft Corporation.
It鈥檚 a system and hidden file.
Combase.dll is usually located in the %SYSTEM% folder and its usual size is 1,219,072 bytes.

Recommendation
The combase.dll process is safe and disabling it can be dangerous,
because programs on your computer need it to work correctly.

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Windows Toast notifications - second try
Posted: Sun Apr 17, 2016 10:04 PM

here give me an error error loading combase.dll

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Windows Toast notifications - second try
Posted: Sun Apr 17, 2016 10:16 PM

Silvio,

What Windows version are you using ?

You have to use Windows 10

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Windows Toast notifications - second try
Posted: Mon Apr 18, 2016 04:25 PM
Borland Windows 10 Toasts support is (slowly) moving forward...

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

聽 聽local pString, cIID, pFactory
聽 聽local pXml, pNodeList, pNode

聽 聽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, @pFactory )
聽 聽WindowsDeleteString( pString );

聽 聽// pFactory->GetTemplateContent( ... )
聽 聽WinRTMethod( pFactory, 9, 3, @pXml ) // 9: Ninth method, 3: fourth template

聽 聽pString = WinRTString( "text" )
聽 聽// pXML->GetElementsByTagName( ... )
聽 聽WinRTMethod( pXml, 17, pString, @pNodeList )
聽 聽WindowsDeleteString( pString )

聽 聽// pNodeList->Item( ... )
聽 聽WinRTMethod( pNodeList, 8, 0, @pNode )

聽 聽MsgInfo( pNode )

聽 聽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>

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:
聽 聽 聽 聽 聽hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, &pReturn ) );
聽 聽 聽 聽 聽break;

聽 聽 聽 case 4:
聽 聽 聽 聽 聽hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), &pReturn ) );
聽 聽 聽 聽 聽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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Windows Toast notifications - second try
Posted: Mon Apr 18, 2016 08:46 PM
Windows 10 Notifications working with Borland! :-)

Important: In order to test it, a shortcut to the EXE must be created in the start menu

toastb.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

聽 聽local pString, cIID, pToastFactory
聽 聽local pXml, pNodeList, pNode
聽 聽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 );

聽 聽// pFactory->GetTemplateContent( ... )
聽 聽WinRTMethod( pToastFactory, 9, 3, @pXml ) // 9: Ninth method, 3: fourth template

聽 聽pString = WinRTString( "text" )
聽 聽// pXML->GetElementsByTagName( ... )
聽 聽WinRTMethod( pXml, 17, pString, @pNodeList )
聽 聽WindowsDeleteString( pString )

聽 聽// pNodeList->Item( ... )
聽 聽WinRTMethod( pNodeList, 8, 0, @pNode )

聽 聽// 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 )

聽 聽// factory->CreateToastNotification( ... );
聽 聽WinRTMethod( pNotificationFactory, 7, pXML, @pNotification )

聽 聽pString = WinRTString( "FiveTech" )
聽 聽// toastStatics->CreateToastNotifierWithId( ... );
聽 聽WinRTMethod( pToastFactory, 8, pString, @pNotifier )
聽 聽WindowsDeleteString( pString )

聽 聽// notifier->Show( ... );
聽 聽WinRTMethod( pNotifier, 7, 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>

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


A shortcut to the EXE in the start menu must be created:







regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 12:01 AM

Antonio,

Wow, color me impressed!

I'm going to try it out.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 12:17 AM
Antonio,

I am getting errors. Any ideas?

James

Code (fw): Select all Collapse
Generating C source output to 'Toasts1.c'...
Done.

Lines 91, Functions/Procedures 7, pCodes 567
The system cannot find the file specified.
Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
Toasts1.c:
Error E2451 Toasts1.prg 110: Undefined symbol 'HB_LONGLONG' in function HB_FUN_WINRTMETHOD
Error E2451 Toasts1.prg 124: Undefined symbol 'HB_LONGLONG' in function HB_FUN_WINRTMETHOD
Error E2121 Toasts1.prg 124: Function call missing ) in function HB_FUN_WINRTMETHOD
Error E2121 Toasts1.prg 127: Function call missing ) in function HB_FUN_WINRTMETHOD
Warning W8004 Toasts1.prg 128: 'pMethod' is assigned a value that is never used in function HB_FUN_WINRTMETHOD
*** 4 errors in Compile ***
* Linking errors *

Process completed, Exit Code 0.
Execution time: 00:03.389
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 12:51 AM

Antonio,

I am using xHarbour: xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603)

I cannot find HB_LONGLONG defined in any of the include files for this verson. Perhaps you are using Harbour instead?

These are the other two lines causing this error:

Error E2121 Toasts1.prg 124: Function call missing ) in function HB_FUN_WINRTMETHOD

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

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

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 03:12 AM
James,

Please add these lines to have support for xHarbour:

#pragma BEGINDUMP

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

#ifndef HB_LONGLONG
#define HB_LONGLONG long
#define hb_storvnll hb_stornl
#endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 03:52 AM

Antonio,

Well I don't understand, but I am getting the same errors with the new #DEFINE's.

I even looked in the PPO file and HB_LONGLONG still remains unchanged.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 06:23 AM
James,

Please use this version:

toastb.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local pString, cIID, pToastFactory
   local pXml, pNodeList, pNode
   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 );

   // pFactory->GetTemplateContent( ... )
   WinRTMethod( pToastFactory, 9, 3, @pXml ) // 9: Ninth method, 3: fourth template

   pString = WinRTString( "text" )
   // pXML->GetElementsByTagName( ... )
   WinRTMethod( pXml, 17, pString, @pNodeList )
   WindowsDeleteString( pString )

   // pNodeList->Item( ... )
   WinRTMethod( pNodeList, 8, 0, @pNode )

   // 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 )

   // factory->CreateToastNotification( ... );
   WinRTMethod( pNotificationFactory, 7, pXML, @pNotification )

   pString = WinRTString( "FiveTech" )
   // toastStatics->CreateToastNotifierWithId( ... );
   WinRTMethod( pToastFactory, 8, pString, @pNotifier )
   WindowsDeleteString( pString )

   // notifier->Show( ... );
   WinRTMethod( pNotifier, 7, 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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 06:50 AM

Antonio :shock: lo conseguiste :D .
Lo he mirado ayer y el c贸digo no estaba al alcance para mi . :(

Aprobecho el post para preguntar ? en la busqueda de entender el codigo he llegado aqui https://msdn.microsoft.com/es-es/librar ... s/mt186421
驴 como queda realmente WinRt con la salida del api UWP de microsoft ?
Gracias y perdonar que no escriba en ingles ( mi ingles es mas que pesimo :( )

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 07:28 AM

Manuel,

Te digo cual ha sido la secuencia para poder programarlo:

  1. Pruebo el ejemplo en C++ proporcionado por Microsoft y compruebo que funciona
  2. Ese c贸digo s贸lo funciona con VSC2015 (no funciona con otros compiladores de C)
  3. Buscando ejemplos en google encuentro un ejemplo programado en HSP (un lenguaje de programaci贸n japones)
    que usa un sistema muy diferente e intento comprender como lo hacen:

viewtopic.php?p=189293#p189293

  1. Consigo implementar la funci贸n WinRTMethod() que estoy convencido que es el sistema usado por HSP
  2. Migro el c贸digo de Microsoft en C++ a la funci贸n WinRTMethod()
  3. Milagrosamente funciona :-)

Ni idea del api UWP. De hecho, WinRT me parece una locura por su complejidad :-)

me queda por solucionar esta l铆nea:
inputText.As( &inputTextNode );

viewtopic.php?p=189283#p189283

parece un casting de tipos: que un objeto IXmlText pase a ser un objeto IXmlNode. A煤n no se c贸mo implementarlo.

Se agradecen sugerencias. En el siguiente post tienes la versi贸n m谩s actual.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 07:29 AM
Works fine with Harbour and xHarbour:

Important: In order to test it, a shortcut to the EXE must be created in the start menu

toastb.prg
Code (fw): Select all Collapse
#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( "Hello world" )

return nil

function Toast( cFirstLine )

聽 聽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, 3, @pXml ) // 3: fourth template

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

聽 聽WinRTMethod( pNodeList, Item, 0, @pXmlNode )
聽 聽pString = WinRTString( "First line" )
聽 聽WinRTMethod( pXml, CreateTextNode, pString, @pXmlText )
聽 聽// pXmlText.As( ... );
聽 聽// WinRTMethod( pXmlText, 8, @pXmlNode )
聽 聽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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Windows Toast notifications - second try
Posted: Tue Apr 19, 2016 07:42 AM

Antonio lo digo porque por lo leido el api UWP es mucho mas facil que winrt y ademas parece que es su sustituto ( eso entiendo ) , ha sido introducido en win10 y me da que le da un tiro en la cabeza al winrt. Poca vida le han dado ...

http://stackoverflow.com/questions/3198 ... nd-windows