Solved

Watcom c++ 10.6

Posted on 1997-04-07
7
379 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Event ID 10010 3 80
Strange - Deleted Resource Info appears in Azure Portal 6 98
What .NET website keeps me current? 9 80
MDT Create a bootable media for BIOS 2 25
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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