Learn to program Tic Tac Toe Game in Visual C++ on Windows

Build a complete Tic Tac Toe Game as Windows application with Visual studio 2015 / Visual C++ and Windows API
4.4 (192 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
9,064 students enrolled
Start Learning Now
  • Lectures 15
  • Length 3 hours
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 2/2016 English

Course Description


Do you want to learn how to build Windows applications using C++ and Windows API? Do you want to build a native Windows application in C++ and have it run on any version of Windows including Windows 7, Windows 8, Windows 8.1 and Windows 10?

Do you want to learn some cool techniques for handling arrays in C/C++? Are you curious to learn what it takes to build a game with Visual C++ on Windows?

If you say yes to any of these questions, then you should consider taking this course today!


  • The basic concepts, tools and functions you need to build a complete Tic Tac Toe game with Visual C++ on Windows
  • The building blocks of a Windows GUI application including Windows, Menus, Texts, Shapes and Icons
  • How to prompt the user for messages and how to use MessageBox API
  • What is GDI and how to use it to draw texts, shapes and icons
  • How to handle Windows messages and how to center elements inside your window
  • And more tips and tricks of the trade!

This course is 100% free, so there is nothing to lose! I made my best efforts to provide high quality content and to make this both useful and fun to watch.

Let’s get started today! Enroll now!


  • Over 15 lectures and 3 hours of video content
  • Code Tic-Tac-Toe in C/C++ on Windows
  • Understand how to write efficient C++ for Windows
  • Learn how Windows applications work
  • Understand how painting works on Windows and how to utilize it for your apps
  • Build a complete tic-tac-toe game by following this course
  • Learn how to add menus, messages and how to draw inside your application with GDI


  • Basic knowledge of C/C++ like loops, functions, variables and if conditions
  • Basic understanding of pointers and structs in C/C++
  • Windows 7 or newer
  • Visual Studio installation – Visual Studio 2015 Community Edition (Recommended)
  • Developers who want to learn how to program on Windows with C++
  • Anyone who wants to learn how to use Visual C++ and Windows API


 In this course I try to cover basic understanding of Windows programming as well as the functions we use. However, it requires a lot of time and effort to cover Windows programming and Windows APIs from scratch, which is outside the scope of this course.




What are the requirements?

  • Installation of Visual Studio 2015 Community Edition (Free)
  • Understanding of Windows environment and applications
  • Basic knowledge of C/C++ like writing functions, if conditions and loops
  • Familiarity with C/C++ structures and pointers

What am I going to get from this course?

  • Learn the basic concepts, tools and functions you need to build a complete Tic Tac Toe game with Visual C++ on Windows
  • Build a fully functional Tic Tac To Game as a Windows Application
  • Create Native Windows Applications with Menus, Messages, Text and Icons

Who is the target audience?

  • This course is a quick overview and an introduction to anyone interested in learning building Windows Applications and Programming Windows API using C/C++
  • You must have some basic knowledge of Programming in C/C++ to be able to understand the concepts mentioned here

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Learn to program Tic Tac Toe in Visual C++ on Windows

In this video we will take a quick look at the application we're going to build together during this tutorial!

I hope you enjoy it and find it useful!


In this video I will walk you through the process to create a new Windows application using Visual Studio 2015 and briefly go over the generated code together to understand the components of the Win32 applications that we will use for our Tic Tac Toe game.

Please make sure to download and install Visual Studio Community Edition (Free) from Microsoft.


In this video we discuss some Windows API to draw the rectangle for our Tic Tac Toe game board. We also learn how to make it always centered and also learn how to prevent the user from re-sizing the window smaller than the size of the game board itself.


In this lecture, we learn how to change background color of our application window and also learn different ways to slice and dice our game board into individual cells.


In this lecture, we learn how to detect mouse clicks by handling WM_LBUTTONDOWN message and then we learn how to write a function together in C/C++ to determine the rectangular area of the cell clicked by the user


In this lecture we learn how to implement GetCellRect function to calculate the dimensions of a given cell at index location (0 to 8) and return that as a RECT structure


In this part, we continue to explore how to use solid brushes for players. We will create a red brush and a blue brush and see how we can alternate between the two using some code logic.


In this lecture, we learn how to best store player moves in memory using 1-dimensional array (vector) so that we track player moves and also to redraw everything whenever we receive a WM_PAINT message


In this lecture we learn how to implement GetWinner function and learn how to display messages to the players using MessageBox and also we will learn how to efficiently manipulate arrays and avoid writing too many if conditional statements


In this lecture, we learn how to modify resource files to add menu items. We will also learn how to prompt user for YES/NO and how to reset the game and start a new game


In this lecture, we learn how to draw out some text inside the main window using GDI and also learn about setting text foreground and background colors


In this part, we see how to implement a function called ShowTurn that helps us show turn messages as well as other messages in the main window as the players take turns


In this lecture, we learn how to draw images using icons instead of the red & blue colors.


In this part we continue to make further enhancements to the code and also learn how to highlight the three cells that contain the winning move using colors


In this lecture, I close the course with some final ideas on how to improve this further and expand on it and also I would like to hear feedback and comments for better courses and projects in the near future...

Also, please find the source code attached to this lecture and thanks for watching!

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Moe Mohammad El-Haj, Senior Software Design Engineer / Manager / Consultant

Hi there!

My name is Mohammad and I have a degree in computer sciences and have been working as a professional software engineer since 1995. I wrote my first program in GW-BASIC when I was 14 years old and since then I knew that I wanna grow up to become a programmer as it is the love and passion of my life!

I also started teaching Visual C/C++ and Visual Basic back in 1997 and that is when I learned how much I enjoy teaching and helping others!

I lived in Seattle for 17 years to work for Microsoft so I can learn from the best in the industry!  I spent 9 years at Microsoft as a senior software engineer and then became curious to try out other companies in USA so I can keep on growing and learning...

Over 20 years of my career, I worked with many companies from startups to medium size companies like Citrix and to big companies like Microsoft. During that time, I learned so many languages and technologies from Visual Basic, C/C++, Win32, ATL, COM, Python, Java, Javascript, C# and .NET and many more. I built Windows applications, mobile applications, built some websites and built games using Unity and many other tools. I like to share my experience and help others become professional developers as well.

I mentored, lead and managed many developers in my career and successfully helped ship many products including V 1.0 products like Microsoft Office Communicator ( aka Lync or Skype for Business). When I found out about Udemy, I was immediately hooked as a student, but I also wanted to pursue my passion as an instructor as I know that I enjoy teaching and helping others and I think I can make the learning experience fun and easy :)

As of 2017, I moved to live in the Silicon Valley and decided to be working full-time on creating courses as well as building some cool apps and games in my free time!

Looking forward to getting to e-meet and know everyone on Udemy!



Ready to start learning?
Start Learning Now