adamstemper
Programmer
I have an ActiveX HTML Object as defined here:
<object id="HSMBTPrintX1" width="350" height="350" classid="CLSID:68d05400-18a6-4b39-b3ff-a17d77c1eddf" codebase=".\HSMBTPrintX.ocx">
------------------------------------------------------------
And a button:
<input type="button" name="Print" value="Print" onclick="PassParameter()" />
------------------------------------------------------------
This button calls some javascript defined above the button and control:
<script language="javascript" type="text/javascript"> function PassParameter() {
if (StringInput.value != " ") {
alert('1 - ' + HSMBTPrintX1);
HSMBTPrintX1.InputParameter = StringInput.value;
alert('2 - ' + StringInput.value);
var temp = HSMBTPrintX1.PrintLabel();
alert('3 -' + temp);
}
}
</script>
------------------------------------------------------------
My PrintLabel C++ code method, here:
char* CHSMBTPrintXCtrl:rintLabel(void)
{
return "temp";
//AFX_MANAGE_STATE(AfxGetStaticModuleState());
// TODO: Add your dispatch handler code here
TCHAR g_szComPort[16];
char szout[512];
HANDLE hCom;
TCHAR comPort[16];
unsigned long bytesWritten;
int counter;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if (!FindBluetoothPort(g_szComPort))
return "minus two";
hCom = CreateFile(comPort,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);
if (hCom == NULL)
return "minus one";
CStringA charstr(m_InputParameter);
// Create text to send to printer
strcpy(szout, "^XA\n");
strcat(szout, "^PRC ^LH0,0 ^LL203 ^PW406 ^MD5 ^MFF,F ^MMT ^MNM ^CF0,20,12 ^XB\n");
strcat(szout, "^FO20,05 ^AFN ^FV MASTER PACK ^FS\n");
strcat(szout, "^XZ");
// Write file to Bluetooth COM port
if(WriteFile(hCom,szout,256,&bytesWritten,NULL)==0)
{
return "one";
}
return "two";
FireLabelPrinted();
}
------------------------------------------------------------
And as you can see, (just for testing), as soon as the function is called it returns some text. I attempt to output this text in a javascript alert.
The issue is, the "temp" javascript variable outputs as "undefined"... so i'm assuming the PrintLabel function never even gets called.
For some background information (which may or may not help in a conclusion), i am using VS2008, creating a Visual C++ Smart Device project. The solution also has a Smart Device CAB Project added on. The entire solution is then built; I copy the .CAB, .INF, .OCX and .HTML files to a single folder on a handheld device running Windows CE.
Additionally, I am not very familiar with C++... nor ActiveX. Any help is appreciated!!
If i need to provide more information, just point me in a direction.
Thanks!
<object id="HSMBTPrintX1" width="350" height="350" classid="CLSID:68d05400-18a6-4b39-b3ff-a17d77c1eddf" codebase=".\HSMBTPrintX.ocx">
------------------------------------------------------------
And a button:
<input type="button" name="Print" value="Print" onclick="PassParameter()" />
------------------------------------------------------------
This button calls some javascript defined above the button and control:
<script language="javascript" type="text/javascript"> function PassParameter() {
if (StringInput.value != " ") {
alert('1 - ' + HSMBTPrintX1);
HSMBTPrintX1.InputParameter = StringInput.value;
alert('2 - ' + StringInput.value);
var temp = HSMBTPrintX1.PrintLabel();
alert('3 -' + temp);
}
}
</script>
------------------------------------------------------------
My PrintLabel C++ code method, here:
char* CHSMBTPrintXCtrl:rintLabel(void)
{
return "temp";
//AFX_MANAGE_STATE(AfxGetStaticModuleState());
// TODO: Add your dispatch handler code here
TCHAR g_szComPort[16];
char szout[512];
HANDLE hCom;
TCHAR comPort[16];
unsigned long bytesWritten;
int counter;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if (!FindBluetoothPort(g_szComPort))
return "minus two";
hCom = CreateFile(comPort,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);
if (hCom == NULL)
return "minus one";
CStringA charstr(m_InputParameter);
// Create text to send to printer
strcpy(szout, "^XA\n");
strcat(szout, "^PRC ^LH0,0 ^LL203 ^PW406 ^MD5 ^MFF,F ^MMT ^MNM ^CF0,20,12 ^XB\n");
strcat(szout, "^FO20,05 ^AFN ^FV MASTER PACK ^FS\n");
strcat(szout, "^XZ");
// Write file to Bluetooth COM port
if(WriteFile(hCom,szout,256,&bytesWritten,NULL)==0)
{
return "one";
}
return "two";
FireLabelPrinted();
}
------------------------------------------------------------
And as you can see, (just for testing), as soon as the function is called it returns some text. I attempt to output this text in a javascript alert.
The issue is, the "temp" javascript variable outputs as "undefined"... so i'm assuming the PrintLabel function never even gets called.
For some background information (which may or may not help in a conclusion), i am using VS2008, creating a Visual C++ Smart Device project. The solution also has a Smart Device CAB Project added on. The entire solution is then built; I copy the .CAB, .INF, .OCX and .HTML files to a single folder on a handheld device running Windows CE.
Additionally, I am not very familiar with C++... nor ActiveX. Any help is appreciated!!
If i need to provide more information, just point me in a direction.
Thanks!