Simple Win32 Programming help
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
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.
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.
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?
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?
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.
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.
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.
You can also use the GetWindowText and SetWindowText functions if you want, which will handle sending the message for you.
// Getting textstd::wstring text;WCHAR buffer [256];SendMessage(editHandle, WM_GETTEXT, 256, reinterpret_cast<LPARAM>(buffer));text = buffer;// Setting textstd::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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement