Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Did someone can tell me how to use IClipboard ?
If someone knew, please give me a sample or some hints.

Any comments will be appreciated.

Robert :confused:

First you can enumerate the available clipboard data types using ICLIPBOARD_EnumInit() and ICLIPBOARD_EnumNext().
Then, pick a data type, and set the data on the clipboard using ICLIPBOARD_SetData().
Later, you can retreive it again using ICLIPBOARD_GetData().
It's all pretty straightforward. This API is really designed for passing data between applications. Within a single application, its not particularly useful.
Let me know if you have any more specific questions.

First you can enumerate the available clipboard data types using ICLIPBOARD_EnumInit() and ICLIPBOARD_EnumNext().
Then, pick a data type, and set the data on the clipboard using ICLIPBOARD_SetData().
Later, you can retreive it again using ICLIPBOARD_GetData().
It's all pretty straightforward. This API is really designed for passing data between applications. Within a single application, its not particularly useful.
Let me know if you have any more specific questions.

Hi Nathan,
Many thanks for your reply.
I have tried on your recommendation, and followings are my paragraph code,
-----------------------------------------------------------------------------------------
CBItemInfo *pci;
AECHAR sName[16];
AECHAR sReturn[32];
if ( ISHELL_CreateInstance(pme->m_pIShell, AEECLSID_CLIPBOARD, (void **)
&pme->m_pIClipboard)!=SUCCESS )
{
DBGPRINTF("[%s %d] Create Clipboard Failed", __FILE__, __LINE__, 0);
return FALSE;

// initialization
MEMSET( sReturn, 0, sizeof(sReturn) );
MEMSET( sName , 0, sizeof(sName ) );
pci = (CBItemInfo *)MALLOC( sizeof(CBItemInfo) );
pci->nNameLen = sizeof(pci->pszName)/sizeof(pci->pszName[0]);
if ( !ICLIPBOARD_EnumInit( pMe->m_pIClipboard ) )
{
DBGPRINTF("[%s %d] Clipboard enumeration Failed", __FILE__, __LINE__, 0);
return FALSE;

while ( ICLIPBOARD_EnumNext(pMe->m_pIClipboard, pci) )
{
STRTOWSTR( pci->pszName, sName, sizeof(sName) );
WSTRCAT ( sReturn, sName );

DBGPRINTF( "sReturn result: %s ", sReturn );
ITEXTCTL_SetText( pICurrentText, sReturn, sizeof(sReturn) );
FREEIF(pci);
-----------------------------------------------------------------------------------------
Above, I want to fetch all available clipboard data formats and display it on a text control, but I am failed on doing ICLIPBOARD_EnumNext().
Did something wrong I have made ??
Could you give me some comments ??
Thanks a lot.
Robert :)

Hi Nathan,
Many thanks for your reply.
I have tried on your recommendation, and followings are my paragraph code,
-----------------------------------------------------------------------------------------
CBItemInfo *pci;
AECHAR sName[16];
AECHAR sReturn[32];
if ( ISHELL_CreateInstance(pme->m_pIShell, AEECLSID_CLIPBOARD, (void **)
&pme->m_pIClipboard)!=SUCCESS )
{
DBGPRINTF("[%s %d] Create Clipboard Failed", __FILE__, __LINE__, 0);
return FALSE;

// initialization
MEMSET( sReturn, 0, sizeof(sReturn) );
MEMSET( sName , 0, sizeof(sName ) );
pci = (CBItemInfo *)MALLOC( sizeof(CBItemInfo) );
pci->nNameLen = sizeof(pci->pszName)/sizeof(pci->pszName[0]);
if ( !ICLIPBOARD_EnumInit( pMe->m_pIClipboard ) )
{
DBGPRINTF("[%s %d] Clipboard enumeration Failed", __FILE__, __LINE__, 0);
return FALSE;

while ( ICLIPBOARD_EnumNext(pMe->m_pIClipboard, pci) )
{
STRTOWSTR( pci->pszName, sName, sizeof(sName) );
WSTRCAT ( sReturn, sName );

DBGPRINTF( "sReturn result: %s ", sReturn );
ITEXTCTL_SetText( pICurrentText, sReturn, sizeof(sReturn) );
FREEIF(pci);
-----------------------------------------------------------------------------------------
Above, I want to fetch all available clipboard data formats and display it on a text control, but I am failed on doing ICLIPBOARD_EnumNext().
Did something wrong I have made ??
Could you give me some comments ??
Thanks a lot.
Robert :)

boolean cbtest_Copy(cbtest* pMe)
{
byte pSetData[11]={'a','b','c','d','e','f','g','h','i','j',0};
switch(ICLIPBOARD_SetData(pMe->m_pIClipboard, "FormatX", pSetData, 7))
{
case 0 :
// Data Copied
return TRUE;
break;
case EFAILED:
//Clipboard format not registered
case ENOMEMORY:
//Insufficient RAM
default:
return FALSE;
}
}
boolean cbtest_Paste(cbtest* pMe)
{
int nSize;
byte pGetData[32]={0};
byte pName[16]={0};
//Check Available Format
if(!ICLIPBOARD_EnumInit(pMe->m_pIClipboard))
{
return FALSE;
}
pMe->pci = (CBItemInfo *)MALLOC( sizeof(CBItemInfo) );
pMe->pci->pszName=pName;
pMe->pci->nNameLen=16;
if (ICLIPBOARD_EnumNext(pMe->m_pIClipboard, pMe->pci)==FALSE)
{
return FALSE;
}
// pMe->pci->pszName is Available Format
// pMe->pci->nNameLen
//Get Data
nSize=32;
switch(ICLIPBOARD_GetData(pMe->m_pIClipboard, pMe->pci->pszName, pGetData, &nSize))
{
case 0:
//SUCCESS
// Check pGetData
return TRUE;
break;
case EFAILED :
//Format is not supported
case EBADPARM:
//Invalid parameter
case ENOMEMORY:
//Insufficient buffer size passed to function
default:
return FALSE;
}
}
'Copy' and 'Paste' to be allow in different application so that they can pass data between applications
Any question will be welcome !!
Joyce

boolean cbtest_Copy(cbtest* pMe)
{
byte pSetData[11]={'a','b','c','d','e','f','g','h','i','j',0};
switch(ICLIPBOARD_SetData(pMe->m_pIClipboard, "FormatX", pSetData, 7))
{
case 0 :
// Data Copied
return TRUE;
break;
case EFAILED:
//Clipboard format not registered
case ENOMEMORY:
//Insufficient RAM
default:
return FALSE;
}
}
boolean cbtest_Paste(cbtest* pMe)
{
int nSize;
byte pGetData[32]={0};
byte pName[16]={0};
//Check Available Format
if(!ICLIPBOARD_EnumInit(pMe->m_pIClipboard))
{
return FALSE;
}
pMe->pci = (CBItemInfo *)MALLOC( sizeof(CBItemInfo) );
pMe->pci->pszName=pName;
pMe->pci->nNameLen=16;
if (ICLIPBOARD_EnumNext(pMe->m_pIClipboard, pMe->pci)==FALSE)
{
return FALSE;
}
// pMe->pci->pszName is Available Format
// pMe->pci->nNameLen
//Get Data
nSize=32;
switch(ICLIPBOARD_GetData(pMe->m_pIClipboard, pMe->pci->pszName, pGetData, &nSize))
{
case 0:
//SUCCESS
// Check pGetData
return TRUE;
break;
case EFAILED :
//Format is not supported
case EBADPARM:
//Invalid parameter
case ENOMEMORY:
//Insufficient buffer size passed to function
default:
return FALSE;
}
}
'Copy' and 'Paste' to be allow in different application so that they can pass data between applications
Any question will be welcome !!
Joyce

but why i can not use _GetData to get the data which other app set. my code is as :
in app A:
{
char p[]={'h','e','l','l','o','_','t','e','s','t',0x0};
IClipboard *pClipboard = NULL;
ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_CLIPBOARD,(void**)&pClipboard);
ICLIPBOARD_SetData(pClipboard,"test_data",(void*)p,11);
DBGPRINTF("set_data is hello_test");
ICLIPBOARD_Release(pClipboard);

in app B:
{
char receive_data[20] = {0};
uint8 size = 20;
IClipboard *pClipboard = NULL;
ISHELL_CreateInstance(pme->a.m_pIShell,AEECLSID_CLIPBOARD,(void**)&pClipboard);
ICLIPBOARD_GetData(pClipboard,"test_data",(void*)receive_data,&size);
DBGPRINTF("get_data is %s",receive_data);
ICLIPBOARD_Release(pClipboard);
}
then i debug them, app A run, and set the data, then A exit(or be suspend), then app B run, but i found that after ICLIPBOARD_GetData, the receive_data[] still is all zero. what is the matter?

but why i can not use _GetData to get the data which other app set. my code is as :
in app A:
{
char p[]={'h','e','l','l','o','_','t','e','s','t',0x0};
IClipboard *pClipboard = NULL;
ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_CLIPBOARD,(void**)&pClipboard);
ICLIPBOARD_SetData(pClipboard,"test_data",(void*)p,11);
DBGPRINTF("set_data is hello_test");
ICLIPBOARD_Release(pClipboard);

in app B:
{
char receive_data[20] = {0};
uint8 size = 20;
IClipboard *pClipboard = NULL;
ISHELL_CreateInstance(pme->a.m_pIShell,AEECLSID_CLIPBOARD,(void**)&pClipboard);
ICLIPBOARD_GetData(pClipboard,"test_data",(void*)receive_data,&size);
DBGPRINTF("get_data is %s",receive_data);
ICLIPBOARD_Release(pClipboard);
}
then i debug them, app A run, and set the data, then A exit(or be suspend), then app B run, but i found that after ICLIPBOARD_GetData, the receive_data[] still is all zero. what is the matter?

Hi,
I have a query here. Will this data(that we copy in clipboard from a BREW application) be available to native applications on hadset or just to other BREW applications?
Any fast reply will help me. Can you please reply fast if you have any idea about this?
Thanks in Advance!
nicefuture wrote:but why i can not use _GetData to get the data which other app set. my code is as :
in app A:
{
char p[]={'h','e','l','l','o','_','t','e','s','t',0x0};
IClipboard *pClipboard = NULL;
ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_CLIPBOARD,(void**)&pClipboard);
ICLIPBOARD_SetData(pClipboard,"test_data",(void*)p,11);
DBGPRINTF("set_data is hello_test");
ICLIPBOARD_Release(pClipboard);

in app B:
{
char receive_data[20] = {0};
uint8 size = 20;
IClipboard *pClipboard = NULL;
ISHELL_CreateInstance(pme->a.m_pIShell,AEECLSID_CLIPBOARD,(void**)&pClipboard);
ICLIPBOARD_GetData(pClipboard,"test_data",(void*)receive_data,&size);
DBGPRINTF("get_data is %s",receive_data);
ICLIPBOARD_Release(pClipboard);
}
then i debug them, app A run, and set the data, then A exit(or be suspend), then app B run, but i found that after ICLIPBOARD_GetData, the receive_data[] still is all zero. what is the matter?

Hi,
I have a query here. Will this data(that we copy in clipboard from a BREW application) be available to native applications on hadset or just to other BREW applications?
Any fast reply will help me. Can you please reply fast if you have any idea about this?
Thanks in Advance!
nicefuture wrote:but why i can not use _GetData to get the data which other app set. my code is as :
in app A:
{
char p[]={'h','e','l','l','o','_','t','e','s','t',0x0};
IClipboard *pClipboard = NULL;
ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_CLIPBOARD,(void**)&pClipboard);
ICLIPBOARD_SetData(pClipboard,"test_data",(void*)p,11);
DBGPRINTF("set_data is hello_test");
ICLIPBOARD_Release(pClipboard);

in app B:
{
char receive_data[20] = {0};
uint8 size = 20;
IClipboard *pClipboard = NULL;
ISHELL_CreateInstance(pme->a.m_pIShell,AEECLSID_CLIPBOARD,(void**)&pClipboard);
ICLIPBOARD_GetData(pClipboard,"test_data",(void*)receive_data,&size);
DBGPRINTF("get_data is %s",receive_data);
ICLIPBOARD_Release(pClipboard);
}
then i debug them, app A run, and set the data, then A exit(or be suspend), then app B run, but i found that after ICLIPBOARD_GetData, the receive_data[] still is all zero. what is the matter?

Hi All,
I have a query here. Will this data(that we copy in clipboard from a BREW application) be available to native applications on hadset or just to other BREW applications?
Any fast reply will help me. Can you please reply fast if you have any idea about this?
Thanks in Advance!

Hi All,
I have a query here. Will this data(that we copy in clipboard from a BREW application) be available to native applications on hadset or just to other BREW applications?
Any fast reply will help me. Can you please reply fast if you have any idea about this?
Thanks in Advance!

Here is my demo code, it's ok on brew 3.1.5
IClipboard* g_nfClp = NULL; // Global Clipboard pointer used to transfer data
CBItemInfo* g_nfPci = NULL;
//
//-------------------------------------------------------------------------------------
boolean NF_ClpNew( TBrowserApp *pMe )
{
int nErr = 0;
nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_CLIPBOARD, (void **)&g_nfClp );
if (nErr != SUCCESS || g_nfClp == NULL)
{
g_nfClp = NULL;
return FALSE;
}
return TRUE;

//
//-------------------------------------------------------------------------------------
void NF_ClpCleanup( TBrowserApp *pMe )
{
if( NULL != g_nfPci )
{
FREEIF( g_nfPci );
g_nfPci = NULL;
}
if( NULL != g_nfClp )
{
ICLIPBOARD_Release( g_nfClp );
g_nfClp = NULL;
}

//
//-------------------------------------------------------------------------------------
boolean NF_ClpCopy( TBrowserApp *pMe )
{
int nErr = 0;
void *input_data = NULL;
int inlen = 0;
char chTmp[120] = { 0 };
if( g_nfClp != NULL )
{
input_data = (void*) MALLOC( 100 );
STRCPY( (char*)chTmp, (const char*)"1234567890ABCDEFGHIJKLMN" );
inlen = strlen((const char*)chTmp);
memcpy( (void*)input_data, (const void*)chTmp, (size_t)(inlen+1) );
if( ICLIPBOARD_SetData( g_nfClp, "NFClpData", (void*)input_data, inlen ) != 0 )
{
FREEIF( input_data );
NF_ClpCleanup( pMe );
return FALSE;
}
}
FREEIF( input_data );
return TRUE;

//-------------------------------------------------------------------------------------
boolean NF_ClpPatse( TBrowserApp *pMe )
{
int nErr = 0;
void *out_data = NULL;
int outLen = 0;
uint8 pName[16]={ 0 };
if( g_nfClp != NULL )
{
//Check Available Format
if( !ICLIPBOARD_EnumInit( g_nfClp ) )
{
return FALSE;
}
g_nfPci = (CBItemInfo *)MALLOC( sizeof(CBItemInfo) );
g_nfPci->pszName = pName;
g_nfPci->nNameLen = 16;
if( !ICLIPBOARD_EnumNext( g_nfClp, g_nfPci ) )
{
return FALSE;
}
//Get Data
outLen = 32;
out_data = (void*) MALLOC( 100 );
if( ICLIPBOARD_GetData( g_nfClp, g_nfPci->pszName, (void*)out_data, &outLen ) != 0 )
{
return FALSE;
}
}
FREEIF( out_data );
return TRUE;

//-------------------------------------------------------------------------------------
boolean NF_ClipboardC( TBrowserApp *pMe )
{
NF_ClpNew( pMe );
NF_ClpCopy( pMe );
return TRUE;

//-------------------------------------------------------------------------------------
boolean NF_ClipboardP( TBrowserApp *pMe )
{
NF_ClpPatse( pMe );
NF_ClpCleanup( pMe );
return TRUE;

Here is my demo code, it's ok on brew 3.1.5
IClipboard* g_nfClp = NULL; // Global Clipboard pointer used to transfer data
CBItemInfo* g_nfPci = NULL;
//
//-------------------------------------------------------------------------------------
boolean NF_ClpNew( TBrowserApp *pMe )
{
int nErr = 0;
nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_CLIPBOARD, (void **)&g_nfClp );
if (nErr != SUCCESS || g_nfClp == NULL)
{
g_nfClp = NULL;
return FALSE;
}
return TRUE;

//
//-------------------------------------------------------------------------------------
void NF_ClpCleanup( TBrowserApp *pMe )
{
if( NULL != g_nfPci )
{
FREEIF( g_nfPci );
g_nfPci = NULL;
}
if( NULL != g_nfClp )
{
ICLIPBOARD_Release( g_nfClp );
g_nfClp = NULL;
}

//
//-------------------------------------------------------------------------------------
boolean NF_ClpCopy( TBrowserApp *pMe )
{
int nErr = 0;
void *input_data = NULL;
int inlen = 0;
char chTmp[120] = { 0 };
if( g_nfClp != NULL )
{
input_data = (void*) MALLOC( 100 );
STRCPY( (char*)chTmp, (const char*)"1234567890ABCDEFGHIJKLMN" );
inlen = strlen((const char*)chTmp);
memcpy( (void*)input_data, (const void*)chTmp, (size_t)(inlen+1) );
if( ICLIPBOARD_SetData( g_nfClp, "NFClpData", (void*)input_data, inlen ) != 0 )
{
FREEIF( input_data );
NF_ClpCleanup( pMe );
return FALSE;
}
}
FREEIF( input_data );
return TRUE;

//-------------------------------------------------------------------------------------
boolean NF_ClpPatse( TBrowserApp *pMe )
{
int nErr = 0;
void *out_data = NULL;
int outLen = 0;
uint8 pName[16]={ 0 };
if( g_nfClp != NULL )
{
//Check Available Format
if( !ICLIPBOARD_EnumInit( g_nfClp ) )
{
return FALSE;
}
g_nfPci = (CBItemInfo *)MALLOC( sizeof(CBItemInfo) );
g_nfPci->pszName = pName;
g_nfPci->nNameLen = 16;
if( !ICLIPBOARD_EnumNext( g_nfClp, g_nfPci ) )
{
return FALSE;
}
//Get Data
outLen = 32;
out_data = (void*) MALLOC( 100 );
if( ICLIPBOARD_GetData( g_nfClp, g_nfPci->pszName, (void*)out_data, &outLen ) != 0 )
{
return FALSE;
}
}
FREEIF( out_data );
return TRUE;

//-------------------------------------------------------------------------------------
boolean NF_ClipboardC( TBrowserApp *pMe )
{
NF_ClpNew( pMe );
NF_ClpCopy( pMe );
return TRUE;

//-------------------------------------------------------------------------------------
boolean NF_ClipboardP( TBrowserApp *pMe )
{
NF_ClpPatse( pMe );
NF_ClpCleanup( pMe );
return TRUE;