Windows NT?

This is a discussion on Windows NT? within the C++ Programming forums, part of the General Programming Boards category; I'm using the book "Programming Windows Fifth edition and it uses windows NT c++ windows language. How can i edit ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    9

    Windows NT?

    I'm using the book "Programming Windows Fifth edition and it uses windows NT c++ windows language. How can i edit this code to make it run on windows XP.

    Code:
    #include <windows.h>
    #include <math.h>
    
    #define NUM 1000
    #define TWOPI (2*3.14159)
    
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
    {
    static TCHAR szAppName[] = TEXT("Sine Wave");
    HWND         hwnd;
    MSG          msg;
    WNDCLASS     wndclass;
    
    wndclass.style = CS_HREDRAW|CS_VREDRAW;
    wndclass.lpfnWndProc = WndProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
    wndclass.hbrBackground = (HBUSH) GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName = NULL;
    wndclass.lpszClassName = szAppName;
    
    if(!RegisterClass(&wndclass))
    {
    MessageBox(NULL, TEXT("Program requires Windows NT!"),szAppName, MB_ICONERROR);
    return 0;
    }
    
    hwnd = CreateWindow(szAppName, TEXT("Sine Wave Using Polyline"),
    WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,
    CW_USEDEFAULT, NULL, NULL,hInstance, NULL);
    
    ShowWindow(hwnd, iCmdShow);
    UpdateWindow(hwnd);
    
    while(GetMessage(&msg,NULL,0,0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return msg.wParam;
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    static int cxClient, cyClient;
    HDC hdc;
    int i;
    PAINTSTRUCT ps;
    POINT apt[NUM];
    
    switch(message)
    {
    case WM_SIZE:
         cxClient = LOWORD(lParam);
         cyClient = HIWORD(lParam);
         return 0;
    case WM_PAINT:
    hdc= BeginPaint(hwnd,&ps);
    
    MoveToEx(hdc, 0, cyClient / 2, NULL);
    LineTo(hdc, cxClient, cyClient/2);
    
    for(i=0;i<NUM;i++)
    {
    apt[i].x = i*cxClient/NUM;
    apt[i].y = (int)(cyClient/2*(1-sin(TWOPI*i/NUM)));
    }
    
    PolyLine(hdc,apt,NUM);
    return 0;
    
    case WM_DESTROY:
         PostQuitMessage(0);
         return 0;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
    }

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    you probably don't have to do anything to the code. It should run on Windows 2000 or XP.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Windows XP==Windows NT 5.1

  4. #4
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    :1,$:s/NT/XP/g

    assuming you're using VI for an editor.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Perfect number and divisors
    By Lissa in forum C Programming
    Replies: 31
    Last Post: 10-24-2008, 01:36 PM
  2. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  3. getting to true DOS with windows NT
    By major_small in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 11-05-2003, 04:23 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. Dos differences in Windows NT and Windows XP
    By Ruchikar in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 09-17-2003, 11:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21