Skip to main content
GameDev.net gamedev.net
🔒 Locked

LoadString () to get dialog text.

Started by programmer_tom Dec 20, 2005 at 4:03 PM 7 replies 1.1k views
Original Post
programmer_tom
programmer_tom
hey all. not sure if i'm even on the right track with what i want to do here, but here's what i got: i want to use the resource editor to maks simple dialogs, then retrieve the text from them elsewhere in my program. i've been told using LoadString() can get this done, but i can't get it to work. char TCHAR[10000]; LoadString ( GetModuleHandle ( NULL ), // Hinstance IDD_DIALOG, // Dialog ID sz, // string (out) 10000 * sizeof(TCHAR) ); // max bytes any ideas? thanks -programmer_tom
SiCrane
SiCrane
Moved to General Programming.
jflanglois
jflanglois
Well, what errors are you getting? If I were to just guess, I might say that TCHAR is already defined and may not be a good name for your character buffer, or that your compiler is defaulting to Unicode and there are conversion problems.

More details would help us help you.

[edit] Also, when specifying the size, you do not want to multiply by the size of the buffer's type (although that would more likely cause errors down the line if your strings are longer than 10000 characters -- and your character's size is bigger than one times char, which is not the case here).


jfl.
Anon Mike
Anon Mike
LoadString loads string from string resources. If you're creating these resources in VS they'll begin with IDS_ unless you go out of your way to change it.

Getting random strings from dialog controls is something else entirely. How you would go about it depends on exactly what you're trying to do.
-Mike
programmer_tom
programmer_tom
sry, made a type on the last entry....doing it at te end of the day.
what i meant was:

TCHAR sz[10000];

LoadString ( GetModuleHandle ( NULL ), IDD_DIALOG, sz, 10000 );

Getting random strings from dialog controls is what i want to do. I guess I'm way off?

pretty much, i'm doing a custom GUI and would like the artists to be able to use the resource editor to design the GUI windows, so i want to be able to look through the dialog resources and pull data selectively. I just need to be able to get a the text.

thanks
-programmer_tom
tj963
tj963
The easiest way to do this would be to actually create the dialog, but don't have it's visible flag set in the resource so it won't actually show. Then you could do a GetDlgItemText to get the strings.

tj963
tj963
programmer_tom
programmer_tom
thanks man, but what i need is the data that looks like this in the rc file :


BEGIN
DEFPUSHBUTTON "Launch Flight",IDC_LAUNCH_MISSION,166,132,61,14
EDITTEXT IDC_STOP_AFTER_EDIT,68,40,30,12,ES_AUTOHSCROLL |
ES_READONLY | ES_NUMBER
CONTROL "",IDC_STOP_AFTER,"msctls_updown32",UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,86,41,10,
10
EDITTEXT IDC_STARTING_WAYPOINT_EDIT,68,25,30,12,ES_AUTOHSCROLL |
ES_READONLY | ES_NUMBER | NOT WS_TABSTOP


etc....
rmsimpson
rmsimpson
In your Visual Studio folder, find atlwin.h, and look for CAxDialogImpl<>. Find CreateActiveXControls() and then follow the code. It opens the dialog resource and iterates the dialog items looking for ActiveX controls. You can modify the code from there to retrieve the strings from dialog resources.

Robert
programmer_tom
programmer_tom
thanks man, i'll give it a shot soon.

-programmer_tom

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.