home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / DATEFI20 / SAMPLE.C < prev    next >
C/C++ Source or Header  |  1995-01-24  |  2KB  |  78 lines

  1. #include <windows.h>
  2.  
  3. LPSTR    AppName            = "SAMPLE";
  4. #define    AM_DROP_OK        15669
  5. #define AM_DROP_DATE    16763
  6.  
  7. LRESULT CALLBACK _export MainWndProc( HWND, unsigned, WORD, LONG );
  8.  
  9. int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance,
  10.                     LPSTR lpszCmdLine, int nCmdShow )
  11. {
  12.     HWND hWnd;
  13.     MSG msg;
  14.     WNDCLASS wndClass;
  15.  
  16.     if( !hPrevInstance ) {
  17.         wndClass.style = CS_HREDRAW | CS_VREDRAW;
  18.         (FARPROC)wndClass.lpfnWndProc = (FARPROC)MainWndProc;
  19.         wndClass.cbClsExtra = 0;
  20.         wndClass.cbWndExtra = 0;
  21.         wndClass.hInstance = hInstance;
  22.         wndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
  23.         wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
  24.         wndClass.hbrBackground = COLOR_WINDOW + 1;
  25.         wndClass.lpszMenuName = NULL;
  26.         wndClass.lpszClassName = AppName;
  27.  
  28.         RegisterClass( &wndClass );
  29.     }
  30.     
  31.     hWnd = CreateWindow( AppName, AppName, WS_OVERLAPPEDWINDOW,  CW_USEDEFAULT,
  32.                 CW_USEDEFAULT, 270, 120, NULL, NULL, hInstance, NULL );
  33.  
  34.  
  35.     ShowWindow(hWnd,nCmdShow);
  36.     UpdateWindow(hWnd);
  37.  
  38.     while ( GetMessage( &msg, NULL, 0, 0 ) ){
  39.             TranslateMessage( &msg );
  40.             DispatchMessage( &msg );
  41.     }
  42.  
  43.     return msg.wParam;
  44. }
  45.  
  46. LRESULT CALLBACK _export MainWndProc( HWND hWnd, unsigned iMessage,
  47.                                      WORD wParam, LONG lParam )
  48. {
  49.     static HINSTANCE hInstance;
  50.     static HWND hWndEdit;
  51.     
  52.     switch( iMessage )
  53.     {
  54.         case WM_CREATE:
  55.             hInstance = ( (LPCREATESTRUCT) lParam ) -> hInstance;
  56.             hWndEdit = CreateWindow( "EDIT", "", 
  57.             WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL, 
  58.                 10, 65, 250, 25, hWnd, 100, hInstance, NULL );
  59.             CreateWindow( "STATIC", (LPSTR) "Drag the date from the "
  60.                 "DateFind window and drop into the field below:", WS_CHILD | 
  61.                 WS_VISIBLE , 10, 10, 250, 50, hWnd, 0, hInstance, NULL );
  62.             return 0;                  
  63.         case AM_DROP_OK:
  64.             if( wParam == hWndEdit )
  65.                 return TRUE;
  66.             return FALSE;
  67.         case AM_DROP_DATE:
  68.             if( wParam == hWndEdit )
  69.                 SetWindowText( hWndEdit, (LPSTR) lParam );
  70.             return TRUE;
  71.         case WM_DESTROY:
  72.             PostQuitMessage( 0 );
  73.             return 0;
  74.     }
  75.     
  76.     return DefWindowProc( hWnd, iMessage, wParam, lParam );
  77. }
  78.