-
I keep getting pretty bad errors on this...like protection faults.
here is the code in my button:
PHP Code:
int thenumber;
char * pc;
itoa(thenumber, pc, thenumber);
srand(time(NULL));
num1 = 1 + rand() % 3;
num2 = 1 + rand() % 3;
num3 = 1 + rand() % 3;
SendMessage(ghWnd_Slot1, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(num1, pc, 10));
SendMessage(ghWnd_Slot2, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(num2, pc, 10));
SendMessage(ghWnd_Slot3, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(num3, pc, 10));
-
It's the way you used itoa. You need to have a buffer of a sufficient size - I normally use 40 characters:
Code:
char buf[40];
int x = 5;
itoa(x, buf, 10); // 10 is the radix (number base)
Also, don't use LPCTSTR unless you're willing to use Unicode :(. Just use plain LPCSTR. And since casting just converts it around you don't need it and can stay with LPARAM.
-
1 Attachment(s)
Thanks
As usual, it works after help from parksie :D
thanks again
and for anyone that's interrested, I attached what I made. :)
-
Oh by the way, I meant to ask you something. I noticed that it doesn't change the numbers sometimes, but the cash does change (I think you'll have to download the attachment to know what I'm talking about)....its in the button named ghWnd_Pull