Hi I got a problem with converting from LPARAM to std::string.
What I do is getting the selected object from a Listbox, the example I found on how to do this is to convert the object to LPARAM.
Now I want to convert this LPARAM to std::string and I've tried three different ways, can't remember which three.
But havent fully worked. How can I do it?

Recommended Answers

All 2 Replies

Show what you are doing. There are too many factors here to say without seeing your code.

case ID_LISTBOX:
                    SendMessageW(Screen.ListBox, LB_GETTEXT,0,(LPARAM)listBoxStr);

                    print("called");

                    callamount = callamount + 1;

                    if (called == false)
                    {

                        called = true;

                        std::string filepath = "../objects/";
                        std::string filename = LPCTSTRTOstring((LPCTSTR)listBoxStr);
                        std::string fullfilepath = filepath + filename;
                        print_str(fullfilepath);

                        char *cstr = new char[fullfilepath.length() + 1];
                        strcpy(cstr, fullfilepath.c_str());

                        entities[currententity].EnableEditing(true);
                        entities[currententity].OpenEntity(cstr);
                        toolData.SelectedModelPath = entities[currententity].GetEntryValue("(MPath)", 1);
                        print(toolData.SelectedModelPath);

                        currententity = currententity + 1;

                        delete [] cstr;

                    }

                    if (callamount == 3)
                        called = false;

                break;

this works 99% but it comes with an error once I close the program

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.