Pages

Friday, 9 February 2018

Write a program that prints the value of hInstance in a message box. Write a program that displays three buttons ‘Yes’, ‘No’ ‘Cancel’ in the message box. Write a program that receives a number as a command line argument and prints its factorial value in a message box. Write a program that displays command line arguments including file name in a message box.



Write a program that prints the value of hInstance in a
message box.
Write a program that displays three buttons ‘Yes’, ‘No’
‘Cancel’ in the message box.
Write a program that receives a number as a command line
argument and prints its factorial value in a message box.
Write a program that displays command line arguments
including file name in a message box.

#include <windows.h>
#include "Resource.h"

//---------------------------------------------------------------------------
HWND hWnd;
LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
//---------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                                                                   LPSTR lpCmdLine, int nCmdShow)
{
                DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGFIRST),
                          hWnd, reinterpret_cast<DLGPROC>(DlgProc));

                return FALSE;
}
//---------------------------------------------------------------------------
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
                switch(Msg)
                {
                case WM_INITDIALOG:
                                return TRUE;

                case WM_COMMAND:
                                switch(wParam)
                                {
                                case IDOK:
                                                EndDialog(hWndDlg, 0);
                                                return TRUE;
                                }
                                break;
                }

                return FALSE;
}