win api question

Started by
5 comments, last by Muzlack 21 years, 9 months ago
I''m totally unfamiliar with the win api except to get a window up and running for my directX game. I want to ask the user for a map making program i''m making a file they would like to open up. Is there a way that I can make a simple dialog box (it doesn''t even need to have text on it) that has a text box for the user to type in a filename? or, a way to make my own scanf command? Sponge Factory --Muzlack
--Muzlack
Advertisement
Well, about the simplest you''re gonna get is to make a dialog box template in the resource editor and then call the DialogBox function.

Then, handle the OK click and grab the text with GetDlgItem (or GetDialogItem, dun remember) and GetWindowText

daerid@gmail.com
quote:Original post by daerid
Then, handle the OK click and grab the text with GetDlgItem (or GetDialogItem, dun remember) and GetWindowText


GetDlgItem() + GetWindowText() = GetDlgItemText() =)

Anyway, if you just want the dialog box for the simple purpose of collecting a string and then it goes away then using a dialog resource is very easy and time saving. Winprog has some tutorials on dialog boxes and basic Win32 API.


I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm
what should the second argument of getdlgitem be?
--Muzlack
quote:Original post by Muzlack
what should the second argument of getdlgitem be?

The item identifier as specified in resource.h. While in your resource editor, be sure to alias the control (button, textbox, whatever) with an ID (something like IDC_USERNAME). MSVC will define this as being equivalent to a particular integer and you can use that symbol (IDC_blah) in your dialog code after including resource.h.
The id of your control. Frequently dialog items are given id's like ID_STATIC1 or ID_MYBUTTON etc. That is the id you are supposed to use.

*Bah! Beaten!


I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader's Realm

[edited by - Invader X on July 1, 2002 1:02:01 AM]
Also, when you create a resource in VC++, it automatically creates a file "resource.h" in your project space. Each control on your dialog is given a unique ID and inside resource.h are the name of those controls and their IDs. Add

#include "resource.h"

to your main program file, and you can then use those controls by name instead of ID #.

Sorry, I just restated what Olu said

http://roninmagus.hopto.org

[edited by - Ronin Magus on July 1, 2002 11:13:30 AM]

This topic is closed to new replies.

Advertisement