Need Help! How to add two buttons to C code Magbox!


Results 1 to 7 of 7

Thread: How to add two buttons to C code Magbox!

  1. #1
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    208
    Downloads
    0
    Uploads
    0

    Default How to add two buttons to C code Magbox!

    I want to have two click buttons in a message box prompt in my too change C Code, one to proceed with the change and one to abort the start of the tool change operation. Anyone know how to do that?
    Thanks, Dan

    Similar Threads:


  2. #2
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2998
    Downloads
    0
    Uploads
    0

    Default Re: How to add two buttons to C code Magbox!

    Hi Dan,

    You might see the MessageBox.c example:

    Code:
    #include "KMotionDef.h"
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    main()
    {
        int Answer;
    
        Answer = MsgBox("Hello World",MB_YESNO|MB_ICONEXCLAMATION);
        if (Answer == IDYES)
            printf("Answer is Yes\n");
        else
            printf("Answer is No\n");
        
    }
    It includes a Yes and No button. Using MB_OKCANCEL that includes OK and Cancel might be more appropriate. See KMotionDef.h for other options.

    Regards



  3. #3
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    208
    Downloads
    0
    Uploads
    0

    Default Re: How to add two buttons to C code Magbox!

    Quote Originally Posted by TomKerekes View Post
    Hi Dan,

    You might see the MessageBox.c example:

    Code:
    #include "KMotionDef.h"
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    main()
    {
        int Answer;
    
        Answer = MsgBox("Hello World",MB_YESNO|MB_ICONEXCLAMATION);
        if (Answer == IDYES)
            printf("Answer is Yes\n");
        else
            printf("Answer is No\n");
        
    }
    It includes a Yes and No button. Using MB_OKCANCEL that includes OK and Cancel might be more appropriate. See KMotionDef.h for other options.

    Regards
    Thanks Tom,

    I can't seem to get it to work. I want it to continue with the code if "OK" (return 1) is clicked and exit the tool change sequence if "cancel" is clicked (return 0). But i keep getting a C code error when i try to compile. I seem to be a lot better with examples of code then without lol



  4. #4
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2998
    Downloads
    0
    Uploads
    0

    Default Re: How to add two buttons to C code Magbox!

    Hi Dan,

    I don't quite understand what you mean. Do you want to make a function that returns 1 or 0 depending on the answer? Post your code and the error and we can check it.

    Regards



  5. #5
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    208
    Downloads
    0
    Uploads
    0

    Default Re: How to add two buttons to C code Magbox!

    Here it is, I've modified the Automatic Tool change to allow for manual installation of 5 tools Tool 101-105 and the selection of Laser as tool 77, Drill is tool 99 and Laser cross hairs as tool 88. It's gotten alot more complicated since the initial version


    It's a work in progress so the formatting sucks. But basically it all works currently. The current code has a message box prompt that says your about to initiate a manual tool change and you click ok and it continues with the tool change. I would like to make is a OK/Cancel option box to abort the tool change entirely if it was incorrectly selected for some reason. It's near the start of the code i made square marker of a bunch of ////// to show where. Once i get this cleaned up i'll share with the dynomotion forum and make a better video.

    Thanks,
    Dan

    Attached Files Attached Files


  6. #6
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2998
    Downloads
    0
    Uploads
    0

    Default Re: How to add two buttons to C code Magbox!

    Hi Dan,

    Try changing:

    MsgBox(s, MB_ICONHAND | MB_OK);

    To

    if (MsgBox(s, MB_ICONHAND | MB_OKCANCEL)==IDCANCEL) return 1;

    Regards



  7. #7
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    208
    Downloads
    0
    Uploads
    0

    Default Re: How to add two buttons to C code Magbox!

    Thanks Tom, We ran out of time Sunday to test this out. Next time I'm back in town we will test it and let you know how it went.

    -Dan



Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

How to add two buttons to C code Magbox!

How to add two buttons to C code Magbox!