Solved

Watcom c++ 10.6

Posted on 1997-04-07
7
371 Views
Last Modified: 2013-12-03
I don´t understand how to make my first program with
watcom c++ 10.6 for windows. How can i make "hello world!" window + when i push some key on keyboard it ends, so how im going to do that with watcom?!? is there anymore void main (void).. or something like that.. what is the basic form to code with watcom under windows?
0
Comment
Question by:mov
  • 4
  • 2
7 Comments
 
LVL 5

Expert Comment

by:yonat
ID: 1334442
C++ answer:

#include <iostream.h>

int main()
{
    cout << "hello world!";
    return 0;
}


C answer:

#include <stdio.h>

int main(void)
{
    printf("hello world!");
    return 0;
}

0
 

Author Comment

by:mov
ID: 1334443
I didn't get any window that shows me "Hello world!".
0
 

Expert Comment

by:kw040597
ID: 1334444
The above code from yonat should be OK, if you you have set the program type to Win32 console and run it under Windows95/NT. For creating a real GUI Windows app, you should include <windows.h> and use WinMain() as your startup function. There should be a lot of examples around. Go to any book store you'll find one.

0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:mov
ID: 1334445
Edited text of question
0
 

Author Comment

by:mov
ID: 1334446
Ok, i changed the question to more understand form. i meant that it works with windows 95. And still when im running that program it doesnt show me anything. So i want that hello world!
in my screen.
0
 

Accepted Solution

by:
kw040597 earned 50 total points
ID: 1334447
#include <windows.h>

LRESULT APIENTRY WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    const char sz[] = "Hello World!";

    PAINTSTRUCT ps;

    switch (uMsg) {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    case WM_PAINT:
        BeginPaint(hwnd, &ps);
        SetTextColor(ps.hdc, GetSysColor(COLOR_WINDOWTEXT));
        SetBkColor(ps.hdc, GetSysColor(COLOR_WINDOW));
        TextOut(ps.hdc, 0, 0, sz, strlen(sz));
        EndPaint(hwnd, &ps);
        break;
    }

    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    HWND hwnd;
    WNDCLASS wc;
    MSG msg;

    wc.style = CS_DBLCLKS;
    wc.lpfnWndProc = (WNDPROC)WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = NULL;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = "Hello World Window Class";

    if ( !RegisterClass(&wc) )
        return 0;

    hwnd = CreateWindow(
        wc.lpszClassName,
        "Hello World!",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, 0,
        200, 200,
        NULL,
        NULL,
        hInstance,
        NULL);

    if ( !hwnd )
        return 0;

    ShowWindow(hwnd, nCmdShow);

    while ( GetMessage(&msg, NULL, 0, 0) ) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam ;
}

0
 

Author Comment

by:mov
ID: 1334448
i grade KW's answer good, because for an excellent there should be comments what some of those lines do in code?

like :

PAINTSTRUCT ps;  // this is xxxx.

but that example did work, and im very pleased.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now