Results 1 to 4 of 4

Thread: SendMessage(error with integers)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    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(thenumberpcthenumber);
                    
                    
    srand(time(NULL));
                    
    num1 rand() % 3;
                    
    num2 rand() % 3;
                    
    num3 rand() % 3;
                    
                    
    SendMessage(ghWnd_Slot1WM_SETTEXT0, (LPARAM) (LPCTSTRitoa(num1pc10));
                    
    SendMessage(ghWnd_Slot2WM_SETTEXT0, (LPARAM) (LPCTSTRitoa(num2pc10));
                    
    SendMessage(ghWnd_Slot3WM_SETTEXT0, (LPARAM) (LPCTSTRitoa(num3pc10)); 

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Thanks

    As usual, it works after help from parksie

    thanks again




    and for anyone that's interrested, I attached what I made.
    Attached Files Attached Files

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width