|
As Esc/P is an older technology only supported by a few printers, have you considered using PCL instead?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I did try to use PCL6 but fail.
I send the PCL command by calling WritePrinter API.
I do not know if I need to call another Win32 Printing API to send the PCL command.
The PCL command is arranged in an array of bytes. But, no response from the printer.
Any code sample to send PCL command, please?
Thank you.
Sandford
|
|
|
|
|
|
Hi Gerry,
Thanks. I will try.
Sandford
|
|
|
|
|
Just a suggestion if you get really desperate; If the printer has a hex dump mode feature you can enable it and print out exactly what's being sent to the printer. Another way is to set the printer driver to 'Print to File' and your job will print to a file. Then if you are familiar with the printer language, you can examine the data to see if something has been added or missing in the printer data stream.
Good luck
|
|
|
|
|
|
I found some old code that I wrote some time ago but never tested. I did a quick test with it and found that when I printed to my hp laserjet that I was only getting 1/2 of the data. After a little investigating I found that i didn't adjust for unicode data so using "RAW" mode passing 2 * datasize to
WritePrinter((void*)data, 2*datasize, &dwBytesWritten)
seem to fix the problem. However, as I said, this code is not fully tested so don't know if this is a real fix or if it has anything to do with your problem. I have problem using "TEXT" mode also but don't feel like investigating. The documentation just says "size of the array". Doesn't mention anything about unicode.
Test data _T("abcd")
Sending a size of 4 resulted in "ab" printing out.
Sending a size of 8 resulted in "abcd" printing out.
Also, if your printer data escape sequence as nul values in it, you may have to adjust it for unicode; ie. double nul.
_T("escN") + nul + nul
Best regards.
-- modified 1-Oct-20 8:17am.
|
|
|
|
|
|
Hi~
I wrote the following function to copy the selected part of NotePad.
( Sending Control+C Message )
However, it does not work!
Only 'C' is printed in NotePad.
Does anyone know why?
>> OS : Windows10
>> Compiler : VisualStudio 2010
Send_KeyBoard_Control_C()
{
HWND notepad = ::FindWindow(__T("NotePad"), NULL );
if (notepad == NULL) {
return;
}
if (!::SetForegroundWindow(notepad)) {
return;
}
int sendCount = 0;
INPUT input;
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wVk = VK_CONTROL;
input.ki.wScan = 0;
input.ki.dwFlags = 0;
sendCount += SendInput(1, &input, sizeof(INPUT));
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wScan = 'C';
input.ki.dwFlags = KEYEVENTF_UNICODE;
sendCount += SendInput(1, &input, sizeof(INPUT));
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wScan = 'C';
input.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
sendCount += SendInput(1, &input, sizeof(INPUT));
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wVk = VK_CONTROL;
input.ki.wScan = 0;
input.ki.dwFlags = KEYEVENTF_KEYUP;
sendCount += SendInput(1, &input, sizeof(INPUT));
if ( sendCount != 4 ) {
TRACE("fail\n");
}
}
modified 30-Sep-20 6:56am.
|
|
|
|
|
Why are you using KEYEVENTF_UNICODE flag?
|
|
|
|
|
Thanks a lot!
I fixed it thanks to you.
void Send_KeyBoard_Control_C()
{
HWND notepad = ::FindWindow(__T("NotePad"), NULL );
if (notepad == NULL) {
return;
}
if (!::SetForegroundWindow(notepad)) {
return;
}
int sendCount = 0;
INPUT input;
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wVk = VK_CONTROL;
sendCount += SendInput(1, &input, sizeof(INPUT));
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wVk = 'C';
sendCount += SendInput(1, &input, sizeof(INPUT));
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wVk = 'C';
input.ki.dwFlags = KEYEVENTF_KEYUP;
sendCount += SendInput(1, &input, sizeof(INPUT));
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wVk = VK_CONTROL;
input.ki.dwFlags = KEYEVENTF_KEYUP;
sendCount += SendInput(1, &input, sizeof(INPUT));
if ( sendCount != 4 ) {
TRACE("fail\n");
}
}
|
|
|
|
|
|
I am writing code for an ARM processor and compiling with GCC inside Eclipse IDE. When the application wants something to get done, it needs to create a task and queue it:
typedef uint32_t (*task_t)(uint8_t* data, uint16_t dataSizeBytes);
void queueTask(task_t task, uint8_t* data, uint16_t dataSizeBytes); Now I want to be able to queue C++ tasks inside the same task queue:
#include <functional>
using namespace std;
using taskCpp_t = function <uint32_t(uint8_t* dataPtr, uint16_t dataSizeBytes)>;
void queueTaskCpp(taskCpp_t task, uint8_t* data, uint16_t dataSizeBytes); The compiler complains when I simply try to cast my C++ function pointer into a C function pointer:
void queueTaskCpp(taskCpp_t task, uint8_t* data, uint16_t dataSizeBytes) {
queueTask((task_t)task, NULL, 0); } Does anybody know what I can do to be able to queue taskCpp_t tasks into the same queue as the task_t are queued into?
|
|
|
|
|
I don't think you can. A C++ object cannot be used as a simple pointer as the two are totally different.
|
|
|
|
|
You may use a C++ static function as task. That would be equivalent to a standard C function.
|
|
|
|
|
I'm hoping to be able to use the function like this:
queueTaskCpp([](uint8_t* data, uint16_t dataSizeBytes) {
}, NULL, 0); I would assume the above function implementation would become static, right? God forbid if the function gets implemented on the stack, obviously that would mean I can't use this concept at all since the function implementation on the stack will most likely be corrupt when it's time to execute the queued function. I'm not planning to use any classes or object orientedness, I'm only using C++ to be able to pass anonymous functions like this.
|
|
|
|
|
To show how different the two things are try this:
int main ()
{
taskCpp_t t;
cout << "taskCpp_t size: " << sizeof (taskCpp_t) << '\n';
cout << "task_t size: " << sizeof (task_t) << '\n';
}
I get:
taskCpp_t size: 64
task_t size: 8
but it is up the compiler what a function object should contain.
Mircea
|
|
|
|
|
write an 8051 embedded c program in which after every 200 ms the leds connected to port 2 are turned on or off. assume xtal 11.0592mhz. use timer 0 in mode 1.
|
|
|
|
|
I can't be bothered. You do it.
|
|
|
|
|
|
Start reading the 8051 datasheet (that you may find easily online) and your C compiler documentation (because you probably have to implement the timer 0 interrupt servicing routine).
|
|
|
|
|
It seems to be a good idea. Good luck!
|
|
|
|
|
|
I feel I'm turning slightly mad. In my mind the two variants below should give the same output:
class A {
public:
A () { cout << "A created" << endl; }
};
class B {
public:
B () { cout << "Default B constructor" << endl; }
B (A oa) { cout << "B created from A" << endl; }
B (const B& other) { cout << "B copy constructor" << endl; }
};
int main()
{
A aobj;
B* bptr = new B (B (aobj));
cout << "--------" << endl;
B bobj (aobj);
B* bbptr = new B (bobj);
}
After A is created, I create a B from A and then I copy the B using the copy constructor. At least that's my intention.
However the output I get is:
A created
B created from A
--------
B created from A
B copy constructor
What am I missing here?
Mircea
|
|
|
|
|
I might be wrong, but
B (aobj) from
new B (B (aobj)) should call move constructor, not copy constructor ...
P.S.
B (B (aobj)) would call a copy constructor only if what is inside of first brackets would be an already created B object, a l value, so, since
B (aobj) is an anonymous object, move construct would be called.
P.P.S. I added move constructor to B
B(B&& rhs) { std::cout << "B move constructor" << std::endl; }
and is never called either.
modified 23-Sep-20 6:34am.
|
|
|
|