C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-31-2002, 02:12 PM   #1
Registered User
 
marcusbankuti's Avatar
 
Join Date: Mar 2002
Posts: 32
Programs run in dos. Why not windows?

Right now my programs run in msdos prompt. How do I make them run in Windows?
marcusbankuti is offline   Reply With Quote
Old 03-31-2002, 02:17 PM   #2
Registered User
 
xlnk's Avatar
 
Join Date: Mar 2002
Posts: 186
well you have dos programming and windows programming. Theres a forum here for window programming, and heres some tutorials:

http://www.relisoft.com/win32/index.htm
http://www.mindlessdrone.com/tutoria.../windows.shtml
http://www.winprog.org/tutorial/

make sure you have a firm knowledge of c/c++ before hand.
__________________
the best things in life are simple.
xlnk is offline   Reply With Quote
Old 03-31-2002, 04:12 PM   #3
Banned
 
frenchfry164's Avatar
 
Join Date: Oct 2001
Posts: 1,552
DOS is how you learn

Windows is how you earn!
frenchfry164 is offline   Reply With Quote
Old 03-31-2002, 09:18 PM   #4
Registered User
 
marcusbankuti's Avatar
 
Join Date: Mar 2002
Posts: 32
Well, I have the code to make a window

#include <windows.h>

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)

{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */

/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);

/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use light-gray as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);

/* Register the window class, if fail quit the program */
if(!RegisterClassEx(&wincl)) return 0;

/* The class is registered, let's create the program*/
hwnd = CreateWindowEx(
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

/* Make the window visible on the screen */
ShowWindow(hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage( ) returns 0 */
while(GetMessage(&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}

/* The program return-value is 0 - The value that PostQuitMessage( ) gave */
return messages.wParam;
}

/* This function is called by the Windows function DispatchMessage( ) */
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}

But how do I then put my dos program code into it.
marcusbankuti is offline   Reply With Quote
Old 03-31-2002, 09:24 PM   #5
Registered User
 
xlnk's Avatar
 
Join Date: Mar 2002
Posts: 186
you can't just straight out stick in DOS code. did you go here? http://www.winprog.org/tutorial/
__________________
the best things in life are simple.
xlnk is offline   Reply With Quote
Old 03-31-2002, 09:29 PM   #6
Registered User
 
marcusbankuti's Avatar
 
Join Date: Mar 2002
Posts: 32
c++ is c++ isn't it? Is there different variations for windows and dos?
marcusbankuti is offline   Reply With Quote
Old 03-31-2002, 11:41 PM   #7
Registered User
 
Dual-Catfish's Avatar
 
Join Date: Sep 2001
Posts: 802
Yes, C++ is C++.
Dual-Catfish is offline   Reply With Quote
Old 05-15-2002, 11:54 AM   #8
Evil Member
 
Join Date: Jan 2002
Posts: 638
Actually c++ is not c++.

Here, try it:

[code]
#include <iostream>

using std::cout;

int main () {
int c = true;
if (c++==c++) cout << "C++ is C++";
if (c++!=c++) cout << "C++ is not C++";
return 0;
}
[/ODE]
Imperito is offline   Reply With Quote
Old 05-15-2002, 12:11 PM   #9
Registered User
 
Mario's Avatar
 
Join Date: May 2002
Posts: 317
Quote:
Originally posted by Imperito
Actually c++ is not c++.

Here, try it:

Code:
#include <iostream>

using std::cout;

int main () {
int c = true;
if (c++==c++) cout << "C++ is C++";
if (c++!=c++) cout << "C++ is not C++";
return 0;
}
LOL!

But c++ can be c++:
Code:
if (c++==c++) cout << "C++ is not C++";
if (c++!=c++) cout << "C++ is C++";
Programmers have the power!
__________________
Regards,
Mario Figueiredo
Using Borland C++ Builder 5

Read the Tao of Programming
This advise was brought to you by the Comitee for a Service Packless World
Mario is offline   Reply With Quote
Old 05-15-2002, 12:17 PM   #10
Evil Member
 
Join Date: Jan 2002
Posts: 638
Yeah well in my example, the strings came from the logic. I could just as easily do this:

Code:
{
int a = 5;
int b = 7;
int c = b - 2;
if (a == c) cout << "Pi is just three\n"; 
if (b != a) cout << "This is not actually a computer, it is a pencil with a piece of lettuce on it\n";
}
Imperito is offline   Reply With Quote
Old 05-15-2002, 12:28 PM   #11
Registered User
 
Join Date: Apr 2002
Posts: 249
C++ is the best...

As I always say: C++ is the best.

but C++ is not C++ this is up to the programmer.

for your question...
and if you have C++ compiler under windows, please open your file, and write your code again and thin compile it.
and if you have any problem ... just write your error with your code, and I will be glad to help you.

but still C++ is the best.
__________________
C++
The best
NANO is offline   Reply With Quote
Old 05-15-2002, 01:27 PM   #12
Pygmy Monkey
 
ErionD's Avatar
 
Join Date: Feb 2002
Posts: 408
If you actually took time to read what he said you would understand that he wasnt having errors. He was wondering how to make windows and then how to get his DOS program into the window.
ErionD is offline   Reply With Quote
Old 05-15-2002, 01:29 PM   #13
Registered User
 
Join Date: Apr 2002
Posts: 249
hmmmmmm

I got it now...
__________________
C++
The best
NANO is offline   Reply With Quote
Old 05-15-2002, 02:06 PM   #14
Registered User
 
Liam Battle's Avatar
 
Join Date: Jan 2002
Posts: 114
Well bud before you do anything learn how to code a win32 GUI... pure DOS applications (not win32 bit console applications) are written in 16bit code. now, when translating them into a win32 gui, you will loose percision and have errors.

So the fact is learn how to write win32bit GUI applications, with the WINAPI or MFC, then rewrite your DOS code in the new program.

its that simple..

the DOS GUI and the WIN GUI, are just front end code...
so what ever DOS GUI you did is now garbage.

your back end code should be very easibly ported for the WIN32 environment.

Im guessing you are new to C++ on a windows system?
__________________
LB0: * Life once school is done
LB1: N <- WakeUp;
LB2: N <- C++_Code;
LB3: N >= Tired : N <- Sleep;
LB4: JMP*-3;

Last edited by Liam Battle; 05-15-2002 at 02:10 PM.
Liam Battle is offline   Reply With Quote
Old 08-11-2002, 06:52 PM   #15
marcusbankuti
Guest
 
Posts: n/a
Well, I'm back.

After my brief time of studying windows programming, I gave up.

Now though, I want to program for the Pocket PC, and it's between C++ and Visual Basic. I think I'll choose c++.

Anyway, I'll look at some of the tutorials you mentioned, as knowing Windows Programming is needed to program for the Pocket PC.

Anybody here program for mobile devices?
  Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help getting a program to run command prompt and a windows app together Crazy Glue C# Programming 2 12-22-2006 08:45 PM
Codec Bitrates? gvector1 C# Programming 2 06-16-2003 08:39 AM
POSIX/DOS programs? nickname_changed C++ Programming 1 02-28-2003 05:42 AM
IE 6 status bar DavidP Tech Board 15 10-23-2002 05:31 PM
Shut off DOS screen automatically to Windows Unregistered A Brief History of Cprogramming.com 2 11-08-2001 07:14 PM


All times are GMT -6. The time now is 04:02 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22