home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 6.ddi / OWLDEMOS.ZIP / USECDLL2.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.2 KB  |  84 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <windows.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include "cdlgdll.h"
  7. #include "usecdll.h"
  8.  
  9. LRESULT FAR PASCAL _export WndProc (HWND, UINT, WPARAM, LPARAM);
  10.  
  11. char appName[] = "DLL Test (non-OWL app)";
  12.  
  13. int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR,
  14.   int nCmdShow )
  15. {
  16.   WNDCLASS wndClass;
  17.   MSG  msg;
  18.   HWND hWnd;
  19.  
  20.   if ( !hPrevInstance )
  21.   {
  22.     wndClass.style        = CS_HREDRAW | CS_VREDRAW;
  23.     wndClass.lpfnWndProc    = WndProc;
  24.     wndClass.cbClsExtra        = 0;
  25.     wndClass.cbWndExtra        = 0;
  26.     wndClass.hInstance         = hInstance;
  27.     wndClass.hIcon        = LoadIcon( 0, IDI_APPLICATION );
  28.     wndClass.hCursor        = LoadCursor( 0, IDC_ARROW );
  29.     wndClass.hbrBackground  = (HBRUSH)GetStockObject( WHITE_BRUSH );
  30.     wndClass.lpszMenuName   = "COMMANDS";
  31.     wndClass.lpszClassName  = appName;
  32.  
  33.     if ( !RegisterClass( &wndClass ) )
  34.       return FALSE;
  35.   }
  36.  
  37.   hWnd = CreateWindow(appName, appName, WS_OVERLAPPEDWINDOW,
  38.     CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInstance, NULL);
  39.  
  40.   ShowWindow( hWnd, nCmdShow );
  41.  
  42.   while ( GetMessage( &msg, 0, 0, 0 ) )
  43.   {
  44.     TranslateMessage( &msg );
  45.     DispatchMessage( &msg );
  46.   }
  47.  
  48.   return msg.wParam;
  49. }
  50.  
  51. LRESULT FAR PASCAL _export WndProc (HWND hWnd, UINT Message, WPARAM wParam,
  52.   LPARAM lParam)
  53. {
  54.   switch(Message)
  55.   {
  56.     case WM_DESTROY:
  57.       PostQuitMessage(0);
  58.       break;
  59.  
  60.     case WM_COMMAND:
  61.       if ( (LOWORD(lParam) == 0) && (wParam == CM_COLOR) )
  62.       {
  63.         COLORREF TheColor;
  64.         char MsgStr[128];
  65.  
  66.         TheColor = RGB(0x00, 0x00, 0x00);
  67.         if ( GetColor(hWnd, TheColor) )
  68.           sprintf(MsgStr,
  69.            "RGB intensities: \r\n\r\n Red - %d \r\n Green - %d \r\n Blue - %d",
  70.             GetRValue(TheColor), GetGValue(TheColor), GetBValue(TheColor));
  71.         else
  72.           strcpy(MsgStr, "Cancelled");
  73.         MessageBox(hWnd, MsgStr, appName, MB_OK);
  74.       }
  75.       else
  76.         return DefWindowProc(hWnd, Message, wParam, lParam);
  77.       break;
  78.  
  79.     default:
  80.       return DefWindowProc(hWnd, Message, wParam, lParam);
  81.   }
  82.   return 0L;
  83. }
  84.