CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2017
    Posts
    1

    absolute visual newbie

    Hi
    I have programmed in C and am reasonably proficient. but oop is not something I have learned or want to learn for the purpose of this excersize
    I have built a Lego EV3 computer robot which can play connect 4 / four in a row written in robot c. It has motors and sensors and places the pieces for you in a real board.
    I have developed it to a point where it can play reasonably well, but I have to upload every code change to the EV3 reload all the counters etc. to test it.
    My idea was to write a quick and simple form based visual c app to refine the playing strategy quickly and easily on screen and then move the code back to the robot.

    I have my code up and running error free in a cpp file
    I have a form with buttons on a 7x6 grid to represent the playing board and 7 buttons at the top to select the row where you want to drop your counter
    the idea is you press one of the 7 buttons at the top to select where you want to drop your counter (my code kicks in) and providing everything is ok then change the background colour
    of the buttons on the 7x6 board to represent the counters being placed.

    the problem is as an old C programmer I am struggling.

    I have the full C program conect4.cpp and in main() was a while(moved==false) loop which would sense a light change to indicate the player had moved then progress.

    now I have a board myform.h[design] and a myform.h with the c code for the form. I have 7 buttons on and I do not know how to:

    in the cpp file main() wait for a button to be pressed and the syntax to to write a loop which will pretty much just while(moved==false) wait and when one is pressed break the loop by setting moved to true and returning an integer from the relevant button from 1 to 7 so I know which button was pressed.

    hope this makes sense.

    any help appreciated

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: absolute visual newbie

    You have to write a windows app with winmain rather than a console app with main.

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

Featured