home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / BCPPOWL1.ZIP / OWLDEMOS.ZIP / USECDLL2.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-28  |  2.1 KB  |  84 lines

  1. // ObjectWindows - (C) Copyright 1991 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. long FAR PASCAL _export WndProc (HWND, WORD, WORD, LONG) ;
  10.  
  11. char appName[] = "DLL Test (non-OWL app)";
  12.  
  13. int PASCAL WinMain( HANDLE hInstance, HANDLE 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  = 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. long FAR PASCAL _export WndProc (HWND hWnd, WORD Message, WORD wParam,
  52.   LONG lParam)
  53.   switch(Message)
  54.   {
  55.     case WM_DESTROY: 
  56.       PostQuitMessage(0);
  57.       break;
  58.  
  59.     case WM_COMMAND:
  60.       if ( (LOWORD(lParam) == 0) && (wParam == CM_COLOR) )
  61.       {
  62.         COLORREF TheColor;
  63.         char MsgStr[128];
  64.  
  65.         TheColor = RGB(0x00, 0x00, 0x00);
  66.         if ( GetColor(hWnd, TheColor) )
  67.           sprintf(MsgStr,
  68.            "RGB intensities: \r\n\r\n Red - %d \r\n Green - %d \r\n Blue - %d",
  69.             GetRValue(TheColor), GetGValue(TheColor), GetBValue(TheColor));
  70.         else
  71.           strcpy(MsgStr, "Cancelled");
  72.         MessageBox(hWnd, MsgStr, appName, MB_OK);
  73.       }
  74.       else
  75.         return DefWindowProc(hWnd, Message, wParam, lParam);
  76.       break; 
  77.  
  78.     default:
  79.       return DefWindowProc(hWnd, Message, wParam, lParam);
  80.   }
  81.   return 0L;
  82. }
  83.