home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ For TASM / ALIASWIN.PAK / CPPUSER.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-21  |  2.6 KB  |  102 lines

  1. /*
  2.    cppuser.cpp
  3.  
  4.    Copyright (c) 1993 by Borland International, Inc.
  5.  
  6.    This module links with library.lib using mangled CPP names.
  7.  
  8.    Part of the aliaswin example.
  9.  
  10.    Build using the provided makefile using:
  11.      "make -B" or "make -B -DWIN16".
  12. */
  13.  
  14. #define  STRICT
  15. #include <windows.h>
  16.  
  17. /* Prototypes for functions in library.lib. These prototypes will be 
  18.    mangled and resolved through aliasing. */
  19.  
  20. extern void SetCoords( LPARAM lParam );
  21. extern void DrawHappyFace( HDC hdc );
  22. extern void PrintMessage( HDC hdc, PSTR WhoIsIt );
  23.  
  24. char szAppName[] = "CPP User Program";
  25.  
  26. LRESULT FAR PASCAL WndProc( HWND hWnd, UINT iMessage, WPARAM wParam,
  27.                             LPARAM lParam )
  28. {
  29.     HDC hdc;
  30.     PAINTSTRUCT ps;
  31.  
  32.     switch (iMessage)
  33.     {
  34.          case WM_SIZE:
  35.             SetCoords( lParam );              /* Call into library.lib */
  36.             return 0;
  37.  
  38.          case WM_PAINT:
  39.             hdc = BeginPaint( hWnd, &ps );
  40.  
  41.             DrawHappyFace( hdc );             /* Call into library.lib */
  42.             PrintMessage( hdc, "CPP User" );  /* Call into library.lib */
  43.  
  44.             EndPaint( hWnd, &ps );
  45.             return 0;
  46.  
  47.          case WM_DESTROY:
  48.             PostQuitMessage( 0 );
  49.             return 0;
  50.     }
  51.     return DefWindowProc( hWnd, iMessage, wParam, lParam );
  52. }
  53.  
  54. #pragma option -w-
  55.  
  56. int PASCAL WinMain( HINSTANCE hInstance,
  57.                     HINSTANCE hPrevInstance,
  58.                     LPSTR lpszCmdLine,
  59.                     int nCmdShow )
  60. {
  61.    WNDCLASS wndclass;
  62.    MSG msg;
  63.    HWND hWnd;
  64.  
  65.    if ( ! hPrevInstance ) {
  66.  
  67.         wndclass.style         = CS_HREDRAW | CS_VREDRAW;
  68.         wndclass.lpfnWndProc   = WndProc;
  69.         wndclass.cbClsExtra    = 0;
  70.         wndclass.cbWndExtra    = 0;
  71.         wndclass.hInstance     = hInstance;
  72.         wndclass.hIcon         = LoadIcon( NULL, IDI_APPLICATION );
  73.         wndclass.hCursor       = LoadCursor( NULL, IDC_ARROW );
  74.         wndclass.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
  75.         wndclass.lpszMenuName  = NULL;
  76.         wndclass.lpszClassName = szAppName;
  77.  
  78.         RegisterClass( &wndclass );
  79.    }
  80.    hWnd = CreateWindow( szAppName,
  81.        "CPP User",
  82.        WS_OVERLAPPEDWINDOW,
  83.        CW_USEDEFAULT,
  84.        CW_USEDEFAULT,
  85.        CW_USEDEFAULT,
  86.        CW_USEDEFAULT,
  87.        NULL,
  88.        NULL,
  89.        hInstance,
  90.        NULL );
  91.  
  92.    ShowWindow( hWnd, nCmdShow );
  93.    UpdateWindow( hWnd );
  94.  
  95.    while( GetMessage( &msg, NULL, 0, 0 ) )
  96.    {
  97.        TranslateMessage( &msg );
  98.        DispatchMessage( &msg );
  99.    }
  100.    return msg.wParam;
  101. }
  102.