Personal tools
Document Actions

lesson6b.cpp

by aullmj — last modified 2009-02-10 11:21

Initial cpp file for lesson 6b

Click here to get the file

Size 2.6 kB - File type text/x-c++src

File contents

#include <windows.h>
#include "resource.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT OnTimer( HWND hDlg );

//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: Entry point for the application.  Since we use a simple dialog for 
//       user interaction we don't need to pump messages.
//-----------------------------------------------------------------------------
int APIENTRY WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int )
{
    // Display the main dialog box.
    DialogBox( hInst, MAKEINTRESOURCE( IDD_DIALOG1 ), NULL, MainDlgProc );
    return 0;
}

//-----------------------------------------------------------------------------
// Name: MainDialogProc
// Desc: Handles dialog messages
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
    UNREFERENCED_PARAMETER( lParam );

    switch( msg )
    {
        case WM_INITDIALOG:
            // Set a timer to go off 30 times a second. At every timer message
            // the input device will be read
            SetTimer( hDlg, 0, 2000 , NULL );
            return TRUE;

        case WM_TIMER:
            // Update the input device every timer message
            //OnTimer( hDlg );
            return TRUE;

        case WM_COMMAND:
            switch( LOWORD( wParam ) )
            {
                case IDC_BUTTON1:
                    MessageBoxA(hDlg,"world","hello",MB_OK);
                    return TRUE;
                case IDCANCEL:
                    EndDialog( hDlg, 0 );
					KillTimer( hDlg, 0 );
                    return TRUE;
                case IDOK:
                    EndDialog( hDlg, 0 );
					KillTimer( hDlg, 0 );
                    return TRUE;
            }

        case WM_DESTROY:
            // Cleanup everything
            KillTimer( hDlg, 0 );
            return TRUE;
    }

    return FALSE; // Message not handled 
}

//-----------------------------------------------------------------------------
// Name: UpdateInputState()
// Desc: Get the input device's state and display it.
//-----------------------------------------------------------------------------
HRESULT OnTimer( HWND hDlg )
{
	MessageBoxA(NULL,"world","hello",MB_OK);
    return S_OK;
}