Jump to content
  • Advertisement
Sign in to follow this  
dhulli

Simple Win32 Programming help

This topic is 3800 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm building a map editor where I'm using a 2d engine as a child window to show the map. I have enough basic Windows programming knowledge that I built a modeless dialog box,menu etc. Now, I can get information from menu item clicks and button clicks on dialog boxes but little else. Searching through books is tiresome (i tried through petzold). Anyways, I need a little help. Simple examples would be best. (note all controls are in a modeless dialog box) -Getting the text from an editbox -Setting the text of such an edit box. -Adding values to a list box. -Getting the selected value from a listbox Thanks a lot

Share this post


Link to post
Share on other sites
Advertisement
You can find this information by going to the MSDN page for Windows Controls and clicking on the particular control you need to work with. Nearly all controls work by using messages to access or set data, so usually the "messages" section is a good place to look (typically each control will also show you common tasks in the "Using" section, which will link to the documentation for the messages.) So for example if you go to the "using" section for the Edit Control, it tells you to use the WM_GETTEXT message to retrieve text, and the WM_SETTEXT message to set the text.

Also many controls have macros defined that simply the process of using messages to retrieve and set data. For example the Edit Control has the Edit_GetText macro you can use.

Share this post


Link to post
Share on other sites
Like I said, I'm not that experienced in DirectX.
I understand the SendDlgItemMessage function and the WM_GETTEXT message. But how do I get a string out of the parameters? or put a string in the case of WM_SETTEXT?

Share this post


Link to post
Share on other sites
You are not going to want to hear this but here goes. . .

Petzold covers everything you just asked for with source code examples and explanations.

The book is meant more as a tutorial and a reference. You don't have to read all of it at once.

Look up the sections on what you want and just read those.

Share this post


Link to post
Share on other sites
Like the documentation for WM_GETTEXT says, the lParam parameter should be a pointer to a buffer where the string will be stored. WM_SETTEXT works exactly the same way.


// Getting text
std::wstring text;
WCHAR buffer [256];
SendMessage(editHandle, WM_GETTEXT, 256, reinterpret_cast<LPARAM>(buffer));
text = buffer;

// Setting text
std::wstring text = "Booga!";
SendMessage(editHandle. WM_SETTEXT, text.length(), reinterpret_cast<LPARAM>(text.c_str()));
);




You can also use the GetWindowText and SetWindowText functions if you want, which will handle sending the message for you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!