Author | Message | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ![]() I need to convert a null-terminated string pointer (4 byte integer if i remember correctly) into a WORD (2 byte integer) in this function: HWND hEdit = GetDlgItem(gui_plist_dialog, IDC_LIST1); // IDC_LIST1 is the list control within the dialog. const char * name = character->name.c_str(); SendMessage(hEdit, LB_ADDSTRING, NULL, MAKELPARAM(&name, 0)); I'm wondering just how the hell I would even do such. o_o I don't see how a pointer could even be 2 bytes on a 32 bit system. So I guess the real question is, what am I misunderstanding about this function. .-. The function is basically supposed to add strings to a list control on a gui I'm working on.
|
| ![]() hmm post more code, or at-least explain --- Remember when is not an organization nor a fucking group , it's simply an idea that we believe in and live for. The priority of Remember when should come before oxygen , as oxygen is cosmetic even life itself is cosmetic,that's why offer our worthless lives to The "Remember when"
|
| ![]() weedindeed posted: (8th Jun 2013, 07:55 am) #define IDC_LIST1 9052 HWND gui_plist_dialog; IDC_LIST1 is a reference to the list control within the dialog. Every gui entity needs an id so defines make it easier to organize instead of remembering the number. And gui_plist_dialog is like a pointer to the window/dialog if i recall correctly. I figured out that it needs to actually be an LPARAM and I finally got it compiling, but it's not showing on the list. That might be because I forgot to update the window after though. I'll check and see.
|
| ![]() std::string str=character->name; char * writable = new char[str.size() + 1]; std::copy(str.begin(), str.end(), writable); writable[str.size()] = '\0'; delete[] writable; //after you finish using it --- Remember when is not an organization nor a fucking group , it's simply an idea that we believe in and live for. The priority of Remember when should come before oxygen , as oxygen is cosmetic even life itself is cosmetic,that's why offer our worthless lives to The "Remember when"
|
| ![]() I just used c_str() to convert it to null terminated o.o I figured out the part I posted, now i'm not sure why it's not showing. T_T Thanks for the help though.
|
| ![]() I got it working TCHAR szBuf[]="Charname"; //const TCHAR szBuf[] =character->name.c_str(); LONG lResult; lResult = SendMessage( hwndEdit, LB_ADDSTRING, sizeof( szBuf ) / sizeof( szBuf[0] ), (LPARAM)szBuf ); --- Remember when is not an organization nor a fucking group , it's simply an idea that we believe in and live for. The priority of Remember when should come before oxygen , as oxygen is cosmetic even life itself is cosmetic,that's why offer our worthless lives to The "Remember when"
|
| ![]() I already got it working a few days back, now I just can't seem to keep the HWND handler to the dialog box holding the list to keep from going null. It's a global variable, so it shouldn't be going null after the scope ends. I don't know why it's doing this. .-. These are the files that contain all the gui operations:
|
| ![]() So what you're saying is that when the window is created and the player list is updated for the first time after that you can't use the update function because the handler turns null.
--- Remember when is not an organization nor a fucking group , it's simply an idea that we believe in and live for. The priority of Remember when should come before oxygen , as oxygen is cosmetic even life itself is cosmetic,that's why offer our worthless lives to The "Remember when"
|
| ![]() If I declare in the header, I will get a multiple definition error since my header is used in multiple files. I also want to make it in win32 for the learning experience. I've tried delclaring it with extern in other source files though, and there was no change. This is such a strange bug. @_@ Edit: Ah, crap I know why now. http://msdn.microsoft.com/en-us/library/windows/desktop/ms632619(v=vs.85).aspx I was calling it in wm_create and that runs when the window is requested and before it's created. Using WM_NCCREATE seemed to keep it from returning null, but it's still not showing anything in the dialog box. |