Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++ 2005
|
Visual C++ 2005 For discussion of Visual C++ 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2010, 03:53 AM
Registered User
 
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question C++ program console to win32 how to do code?

Good Morning to every body! I am a hobby programmer and join in this forum today. I have code a program of stop watch in c++ and compiled and run well.but I want to see the Win32 application istead of console appln. Please anybody can help how to code for win32? The source code of console appln for stop watch as given below.

code
// example2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{int ms=0,s=0,m=0;
char stop;
cout << endl << "Hello ! This is a Stopwatch application programmed by T.Kannan" << endl;
cout << endl << " Press Q to Quit else any Charactor followed by enter Key to start STOP WATCH" << endl;
cin >> stop;
while(stop != 'Q')
{
do
{
for(ms=1; ms<=100; ms++)
{
cout << " Minutes : Seconds : Milliseconds";
s=s+(ms/100);
m=m+(s/60);
cout << endl << endl << " " << m << " : " << s << " : " << ms << endl;
if(s==60)s=0;
printf("\nBY");
printf("\n");
printf("\nT.KANNAN");
system ("CLS");
}
}while(m<1);
ms=0;
s=0;
cout << endl;
cout << endl << "Hello ! 1 Minute duration gone programmed by T.Kannan" << endl << endl;
cout << "M: " << m;
cout << " S: " << s;
cout << " MS: " << ms << endl << endl;
m=0;
cout << " Press Q to Quit else any Charactor followed by enter Key " << endl;
cin >> stop;
}

return 0;
}
/code
 
Old September 7th, 2010, 03:34 AM
Authorized User
 
Join Date: Nov 2009
Posts: 26
Thanks: 1
Thanked 1 Time in 1 Post
Post

My best recommendation is to take a look at this book :

MS Press - Programmming WindowsBy Charles Petzold

This book goes through win32 API programming quickly and very efficiently using C language.I couldn't find any better source for win32 except this one.

Best luck
 
Old March 30th, 2011, 07:17 AM
Registered User
 
Join Date: Dec 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

download vc++ from microsoft and use it's help or msdn.
 
Old April 1st, 2011, 01:15 AM
Registered User
 
Join Date: Dec 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by dreamboy View Post
Good Morning to every body! I am a hobby programmer and join in this forum today. I have code a program of stop watch in c++ and compiled and run well.but I want to see the Win32 application istead of console appln. Please anybody can help how to code for win32? The source code of console appln for stop watch as given below.

code
// example2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{int ms=0,s=0,m=0;
char stop;
cout << endl << "Hello ! This is a Stopwatch application programmed by T.Kannan" << endl;
cout << endl << " Press Q to Quit else any Charactor followed by enter Key to start STOP WATCH" << endl;
cin >> stop;
while(stop != 'Q')
{
do
{
for(ms=1; ms<=100; ms++)
{
cout << " Minutes : Seconds : Milliseconds";
s=s+(ms/100);
m=m+(s/60);
cout << endl << endl << " " << m << " : " << s << " : " << ms << endl;
if(s==60)s=0;
printf("\nBY");
printf("\n");
printf("\nT.KANNAN");
system ("CLS");
}
}while(m<1);
ms=0;
s=0;
cout << endl;
cout << endl << "Hello ! 1 Minute duration gone programmed by T.Kannan" << endl << endl;
cout << "M: " << m;
cout << " S: " << s;
cout << " MS: " << ms << endl << endl;
m=0;
cout << " Press Q to Quit else any Charactor followed by enter Key " << endl;
cin >> stop;
}

return 0;
}
/code
Other then your name what you actually wrote in this code?
Your code remindes me 286, 386 era when I started learning C language.
It's printf() for screen output and system() for calling DOS commands or any executable eg .exe,. com, .bat etc.
Anyway code is not good.
Run and check how many minutes it takes to show 1 minutes on different PCs with processors of different speed.
It is not stop watch. It runs for so called 1 minute under all cercumtences.
There was no need of clearing screen in inner loop that also using system("CLS"). Use gotoxy() instead and over wright new time over old time..

Anyway from where ever you start keep trying.
It is good to search and read code on net.
Not only try them also try to modify them. This way you will learn.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Win32 Console Apllication with a winform raghaw WinForms/Console Application Design 0 October 7th, 2008 07:34 AM
take arguments when running program in console iulian C++ Programming 8 January 16th, 2007 09:17 AM
Pls Help Me Check This Code - Win32 ck C++ Programming 4 January 13th, 2005 12:14 AM
Pls Help Me Check This Code - Win32 ck Visual C++ 0 December 29th, 2004 12:50 PM
Need help in writing a C program using win32 API rameshbabumv C++ Programming 0 March 10th, 2004 05:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.