65.9K
CodeProject is changing. Read more.
Home

InputBox using WinAPI

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.65/5 (17 votes)

Jun 13, 2002

viewsIcon

142489

downloadIcon

2993

InputBox using WinAPI.

Sample Image - InputBox.jpg

Introduction

Do you know VB's InputBox? Me too. =)

So, this class is for those people who need VB-like InputBox in VC++.

Usage

The usage of this class is very easy:

Add InputBox.h and InputBox.cpp into your project, include InputBox.h to the file where you suppose to use Inputbox and:

#include "InputBox.h"

...

CInputBox ibox(hWndParent);
if (ibox.DoModal("Caption", "Prompt")) 
  MessageBox(NULL, ibox.Text, "Title", MB_OK);

In the constructor, you have to provide a valid hwnd of the parent window. Function DoModal(...) returns TRUE if button OK is pressed and FALSE if button Cancel.

CInputBox doesn't need resource file. You can use it with MFC or without one.

That's all.