Can console commands like cin, cout, getch, etc be used in windows apps?

  • Context: Comp Sci 
  • Thread starter Thread starter Pipsqueakalchemist
  • Start date Start date
Click For Summary
SUMMARY

Using console commands such as cin, cout, and getch in Windows applications leads to blocking the event loop, which is a common issue not encountered in console applications. These commands are designed for console input and do not integrate well with event-driven GUI frameworks. To effectively manage user input in Windows applications, developers should utilize GUI elements like buttons and text fields instead of blocking I/O operations. Understanding the principles of Windows GUI programming is essential for structuring applications to avoid these pitfalls.

PREREQUISITES
  • Basic understanding of C++ programming
  • Familiarity with Windows GUI frameworks
  • Knowledge of event-driven programming concepts
  • Experience with console application development
NEXT STEPS
  • Research Windows GUI programming fundamentals
  • Learn about event-driven programming patterns
  • Explore alternatives to blocking I/O in GUI applications
  • Study user input handling in frameworks like Win32 or Qt
USEFUL FOR

Developers transitioning from console applications to Windows GUI applications, software engineers looking to improve their understanding of event-driven programming, and anyone encountering input handling issues in GUI environments.

Pipsqueakalchemist
Messages
138
Reaction score
20
Homework Statement
can I used console commands in windows application?
Relevant Equations
C++, visual studio
So I started working in a windows application. But i started having issues with blocking the event loop when using while loops that i never encountered before when using while loops in console application.

My theory is that I used commands like getch or cin to exit the loop in the window application and that those commands work fine in console but not in windows and that's why I can't exit my while loops and my event loop is blocked

Is this the case because if it's not then I'm at a complete loss because I've never encountered these issues before when coding in console.
 
Physics news on Phys.org
You kind of let your other thread with this question just hang there.

But to repeat some from that thread: as a rule of thumb you cannot in general expect that blocking I/O and event driven applications mix well. Waiting for user input using cin in GUI application seems particularly weird and pointless since the GUI is there to handle user input with framework elements like buttons and text fields/areas. Perhaps you can describe what kind of problem you are trying to solve and what makes you want to mix console and GUI functions?

It will probably also be a good idea you learn the basics of (Windows) GUI programming and how to structure such an application to solve "standard problems".
 
  • Like
Likes   Reactions: Tom.G and Mark44

Similar threads

Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
8
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
8K