PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

numeric keyboard

hi all,
i trie to make a calculator like.

any one can help me how to strore the numbers pressed wit my
(keyboard) , i tried to use TCHAR and _sprintf but not find the whay.

thanks.
I am not really sure that I understand what you want to accomplish. Are you using GapiDraw? What keyboard do you use?
On phones you can know that numeric key pressed by charcode, example: '5' - key 5... It work at stationary PC( not NumPad)
Or what u want?
well sorry for my english :)

try to explain whit a example of my newbie code:

Code:
HRESULT CMyApplication::StylusDown(POINT p)
{
if (AxeY >222 && AxeY < 251)
{ if (AxeX >50 && AxeX < 69)
_stprintf(m_Saisie,"1"); //button 1


if (AxeX >76 && AxeX < 95)
_stprintf(m_Saisie, "2"); //buton 2
}

return S_OK;
}


in my ProcessNextFrame:


Code:
TCHAR strSaisie[16];

_stprintf(strSaisie, TEXT("SAISIE [%c ]"),*m_Saisie);
pBackBuffer->DrawText(dwXCenter, (dwYCenter-10), strSaisie, pSystemFont, GDDRAWTEXT_CENTER, NULL, 0, NULL);


if i press 1 after 2 thats work but the 1 is ramplaced by 2 and i want to ((add)) this to make 12

in cstring is something like :

m_Saisie=m_Saisie+"1";

can i use cstring in gapidraw app ??

thanks.
by using printf, you're replacing everything in the character string, which is why the 1 is being replaced by 2.

I haven't tried CString myself in any of my PPC apps, but if it works, that would probably be easiest.

Otherwise, you can try concatenation (strcat) (not sure what the unicode version is).

Or, you could use a temporary character string and do your own concatenation:
_stprintf(sTemp, "%s2", m_Saisie);
_stprintf(m_Saisie, "%s", sTemp);

-John
thanks :)
but d'ont work, any sugestions ?
You're saying this doesn't work?
Code:
HRESULT CMyApplication::StylusDown(POINT p)
{
TCHAR sTemp[16];

if (AxeY >222 && AxeY < 251)
{ if (AxeX >50 && AxeX < 69)
_stprintf(sTemp,"%s1", m_Saisie); //button 1


else if (AxeX >76 && AxeX < 95)
_stprintf(sTemp, "%s2", m_Saisie); //buton 2

else _stprintf(sTemp, "%s", m_Saisie);

_stprintf(m_Saisie, "%s", sTemp);
}

return S_OK;
}
You should replace those last two _stprintf lines with the unicode version of strcpy, but regardless that should work.

After looking at your sample, I found another problem... You don't see what's wrong with this line?
Code:
_stprintf(strSaisie, TEXT("SAISIE [%c ]"),*m_Saisie);

%c means a character, not a string.
Using the asterisk in front of the string just gives you the first character.

It should be:
Code:
_stprintf(strSaisie, TEXT("SAISIE [%s ]"), m_Saisie);

However, if your definition of m_Saisie is the same as strSaisie, you should get rid of strSaisie altogether.

-John
After looking at your sample, I found another problem... You don't see what's wrong with this line?

Code:
_stprintf(strSaisie, TEXT("SAISIE [%c ]"),*m_Saisie);



i ave see 8) .

i ave say thats dont work because en i (push the button) my program craches ,i ave finaly found i ave put on InitInstance :
_stprintf(m_Saisie,"");

many thanks for your help :D :D