Skip to main content
gamedev.net
🔒 Locked

Programming Classes

Started by AMoronThatWantsToProgram 4 replies 500+ views
Original Post
AMoronThatWantsToProgram
AMoronThatWantsToProgram
This is kind of an obscure question. It might even be a dumb question but anyway. I was wondering why almost ever programming class that is available always teaches in DOS instead of windows. Now from what I see DOS in incredibly dead. Wouldnt it be better to just learn windows the first time instead of dos?
Null and Void
Null and Void
I''ll put it this way:

Basic DOS program in C/C++:
    
#include <stdio.h>

int main(void) {
printf("Hello");
return 0;
}
[/SOURCE]

Basic Windows program in C/C++:
[SOURCE]
#include <windows.h>

LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);

char szWinName[] = "MyWin";
HINSTANCE hInst;

int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
LPSTR lpszArgs, int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
/* Define a window class. */
wcl.hInstance = hThisInst; /* handle to this instance */
wcl.lpszClassName = szWinName; /* window class name */
wcl.lpfnWndProc = WindowFunc; /* window function */
wcl.style = 0; /* default style */

wcl.cbSize = sizeof(WNDCLASSEX); /* set size of WNDCLASSES */

wcl.hIcon = LoadIcon(hThisInst, MAKEINTRESOURCE(MY_ICON)); /* large icon */
wcl.hIconSm = LoadIcon(hThisInst, MAKEINTRESOURCE(MY_ICON)); /* small icon */

wcl.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor style */
wcl.lpszMenuName = NULL; /* no menu */

wcl.cbClsExtra = 0; /* no extra */
wcl.cbWndExtra = 0; /* information needed */

/* Make the window background light gray. */
wcl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);

/* Register the window class. */

if(!RegisterClassEx(&wcl)) return 0;

hwnd = CreateWindow(szWinName, "Messenger",
(WS_SYSMENU | WS_MINIMIZEBOX | WS_OVERLAPPED),
CW_USEDEFAULT, CW_USEDEFAULT,
600, 325, HWND_DESKTOP, NULL, hThisInst, NULL);

hInst = hThisInst;
ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);

while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}


I think it is much easier to use the first format to learn the logical patterns of programming. All of the code that is needed to work in Windows is just going to confuse people
Null and Void
Null and Void
My posting has a slight error. All of the Windows and DOS code was combined into the same box =P

Oh well, you can figure it out.
Martee
Martee
Hehehehe, now that was a good explanation of why programming classes start in DOS .
Mr. Annonymous: use
[ source ]
.
.
.
[ /source ]
Without the spaces.

Martee
Magnum Games
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.