Solved

Watcom c++ 10.6

Posted on 1997-04-07
7
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

 

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

627 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