Solved

Watcom c++ 10.6

Posted on 1997-04-07
7
377 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA Error Since Excel 2016 x64 5 142
Using MS Code on my Mac 6 72
Visual Studio: built-in keystroke automation 2 82
What .NET URL re-routing tool did I use? 2 84
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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