Thread: How do you make your program appear in windows instead of DOS?

  1. #1
    Registered User
    Join Date
    Dec 2001

    How do you make your program appear in windows instead of DOS?

    First I want to say that i actually DID search for a thread which could have an answer to my question as I thought, and still think,
    that many are sharing this problem with me:

    I want to make my program appear in a "normal window" instead
    of an MS DOS window when I've compiled it. Is it the compiler which decides, are there codes for this in the language of C++ or do you have to combine it with another language, like visual basic?

    I haven't got a clue so please help me.

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    I dont think there's a way to code this without using OWL or OCF or some big library. If you mean MS-DOS inside a Windows window, you can adjust it by using the options menu in Windows, it'll be under properties somewhere. If you mean a Windows window with a windows program, Windows compilers will do that for you when you compile.

  3. #3
    Registered User
    Join Date
    Sep 2001

    #include <windows.h>

    Windows programmign is alot different to DOS programming. First you have to get a compiler that will compile windows programs, like Borland c++ 5.5 or Dev C++ - both r free. I dont know the addresses of them so just do a search. Win Progamming does use the same language (c/c++) but you will normally have to compile it differently eg, borland: bcc32 -W prog.cpp
    the -W means for windows. This is the code you need to just create your window, it may seem like alot comapred to the Dos one but almost all of it is necacary to create the Window:
    #include <windows.h>

    /* Declare Windows procedure */
    /* 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 */ = 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 */
    /* Send message to WindowProcedure */

    /* 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 */
    default: /* for messages that we don't deal with */
    return DefWindowProc(hwnd, message, wParam, lParam);
    return 0;


    That will just create a simple window- 77 lines. It helps to read a few tutorials about window programming. below are some good beginer ones:

    Hope that helped - Jamazon

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 02:05 AM
  2. how do you make a program send data to the printer?
    By Sintu in forum C++ Programming
    Replies: 19
    Last Post: 10-20-2005, 07:22 PM
  3. Simple Windows Program - text?
    By Doagie in forum Windows Programming
    Replies: 1
    Last Post: 11-27-2004, 02:21 AM
  4. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM