6 Replies - 11602 Views - Last Post: 07 February 2010 - 12:08 PM Rate Topic: -----

#1 ptm82379  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 30-December 09

input box?

Posted 06 February 2010 - 12:41 PM

In VB back when i knew it a little there was an input box feature.
Is there anything similar in C++

I need to ask the user a question record and store the answer then use it in the main code.

Something like this " what is the movie name?"
then the user types in "WHATEVER"
and the program stores it as a variable for later use....
Is This A Good Question/Topic? 0
  • +

Replies To: input box?

#2 no2pencil  Icon User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6560
  • View blog
  • Posts: 30,699
  • Joined: 10-May 07

Re: input box?

Posted 06 February 2010 - 12:42 PM

You can collect a return value from a MessageBox in the Windows API. But it's a little more complicated than that.
Was This Post Helpful? 1
  • +
  • -

#3 ptm82379  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 30-December 09

Re: input box?

Posted 07 February 2010 - 08:16 AM

How would I do this?
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: input box?

Posted 07 February 2010 - 08:19 AM

Start with this tutorial.
Was This Post Helpful? 1
  • +
  • -

#5 mentallybroken  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 82
  • Joined: 03-October 07

Re: input box?

Posted 07 February 2010 - 08:34 AM

this is the reason why c++ is never the best tool for windows gui programming . even though c++ can do it doesn't mean its the best tool for the job . i suggest try learning C#.net, win32 is just too painful

This post has been edited by mentallybroken: 07 February 2010 - 08:36 AM

Was This Post Helpful? 0
  • +
  • -

#6 ptm82379  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 30-December 09

Re: input box?

Posted 07 February 2010 - 08:34 AM

View PostJackOfAllTrades, on 07 February 2010 - 07:19 AM, said:

Start with this tutorial.


This is waaaayy over my head....This is my second program...I think my teacher is a bit overambitious..This is ridiculous
Was This Post Helpful? 0
  • +
  • -

#7 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 617
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: input box?

Posted 07 February 2010 - 12:08 PM

Using C++, you can access the Windows API (Application Programming Interface). The Windows API gives you access to alot of native Windows functions (and features) like dialog boxes for example, which is what you are looking for.
In VB, all you need to do is something like "input("input box)", using the windows API, its more like this.

DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DEBUGGER),
hWnd, (DLGPROC)aboutProc, 0);


And you will need a message loop

//--------------------------------------------------------------------------
// Name: aboutProc
// Desc: About dlg proc
//--------------------------------------------------------------------------
LRESULT CALLBACK aboutProc(HWND hDlg, UINT msg,	WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK)		
			{
				EndDialog(hDlg, LOWORD(wParam));
				return (INT_PTR)TRUE;
			}
    	break;
    }
	return 0;
}

Here is an example of a how to use the open file name dialog box in windows api

HRESULT PromptForFileOpen()
{
	OPENFILENAME ofn;
	char buf[260];


	ZeroMemory(&ofn, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = hWnd;
	ofn.lpstrFile = (LPSTR)buf;
	ofn.lpstrFile[0] = '\0';
	ofn.nMaxFile = sizeof(buf);
	ofn.lpstrFilter = "All Files\0*.*\0";
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = NULL;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

	if (GetOpenFileName(&ofn) != 0)
	{
		// buf now conatains the file path
	}

	return TRUE;
} 


You may think this is over yoru head at the moment but when you break it down, it isnt that bad really. Belive me, its just practice, that is all. Good luck , dont give up!

This post has been edited by Aphex19: 07 February 2010 - 12:11 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1