Thread: Programs run in dos. Why not windows?

  1. #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?

  2. #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.

  3. #3
    DOS is how you learn

    Windows is how you earn!

  4. #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.

  5. #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.

  6. #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?

  7. #7
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Yes, C++ is C++.

  8. #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]

  9. #9
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    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

  10. #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";
    }

  11. #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

  12. #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.

  13. #13
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    hmmmmmm

    I got it now...
    C++
    The best

  14. #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?
    Last edited by Liam Battle; 05-15-2002 at 02:10 PM.
    LB0: * Life once school is done
    LB1: N <- WakeUp;
    LB2: N <- C++_Code;
    LB3: N >= Tired : N <- Sleep;
    LB4: JMP*-3;

  15. #15
    marcusbankuti
    Guest
    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?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-22-2006, 08:45 PM
  2. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  3. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  4. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM
  5. Shut off DOS screen automatically to Windows
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 07:14 PM