|
Hi there,
I want to add a feature in my program that user can change the language …
For example in a OS, I installed 3 languages like English U.S and Farsi and Russia.
I want to change the active language (English U.S) to other language (Farsi), programically …
How can I do that ?
Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
1) DLLs with resources (1 language/1 dll) - used in WndTabs - You can download its sources to see.
2) Text files with localized texts - used in Windows Commander - advantage is, the users can localize it themselfs, complications with dialogs, localized bitmaps imposible.
3) You can have multi-language resources in your aplication - the language is then selected by the OS according to local settings.
Sonork 100.15206;PavelK
|
|
|
|
|
It is relatively simple to start your app in one or another language (depending for instance on some registry value). MSDN article HOWTO: Create Localized Resource DLLs for MFC Application explains the procedure. For the language change to take effect while the program is running things are a lot messier: probably you're better off relaunching the app after setting the new language (you can even do this programmatically from the exiting instance so that the user has the illusion of having the change set on-the-fly).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
you can even do this programmatically from the exiting instance so that the user has the illusion of having the change set on-the-fly
are you saying there's a way for an app to restart itself? i've been looking for that for years...
-c
For men use, if they have an evil turn, to write it in marble:
and whoso doth us a good turn we write it in dust.
-- Sir Thomas More
|
|
|
|
|
Pardon me? Maybe we're not talking about the same issue, cause the restarting stuff is almost trivial: Get a grip to the program own name with GetModuleFileName(NULL,...) and realunch it at the end of InitInstance with, for instance, CreateProcess .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
yeah. slightly different. i need a way to relaunch after the app is really shut down (as opposed to almost shut down).
-c
For men use, if they have an evil turn, to write it in marble:
and whoso doth us a good turn we write it in dust.
-- Sir Thomas More
|
|
|
|
|
This can be done, too. At the beginning of InitInstance insert the following
HANDLE mutex=CreateMutex(NULL,FALSE,"SOME_LONGISH_AND_ALMOST_SURELY_UNIQUE_NAME_11D2_8FC2_0000E5140DA0_");
WaitForSingleObject(mutex,INFINITE);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
I am working on a winsock program that supports multiple connections simultaneously. For example, the user could connection to more than one server at any given time. The design works, but it fails if the user cancels. In other words, if the user lets the program finish doing work no matter how many connections the user has selected, then the program works. However, if the user cancels via cancel button that sets a status variable in the program to false, then the program begin closing all connections and closing all worker threads.
I am still trying to fingure out what causes the program to crash. Visual C++ outputs this error.
-----
Unhandled exception at 0x77f5111b in myProgram.exe: 0xC0000008: An invalid HANDLE was specified.
-----
Does anyone know what is a good place to start debugging this kind of error? I check all thread handle via WaitForSingleObject() before closing. I use a linked list to store the threads handles.
Thanks,
Kuphryn
|
|
|
|
|
It's a good idea to check your pointers, handles, etc for validity before using them. Check all parameters that are pointers or handles before you use them. Similarly check all returned pointers or handles from functions.
Look for the line number where the error happens, and then place a break point there or step through your code and see what exactly is happening. Or you could start TRACE ing and write the output to a file. Or write automated tests that will dump the variables, thread data, etc to a file whenever an error occurs. This last approach, though painful and time consuming in the beginning, is the best in the long run, as it saves a lot of time and misery.
Regards,
Rohit Sinha
|
|
|
|
|
Most likely you're using a HANDLE that was previously closed during the cleanup process. Usually, in debug mode you just can jump right into the offending piece of code and figure out which call is causing the exception. If for some reason this is not available to you, I'd suggest you try the following: After closing a handle, set it to NULL ; then, before attempting any operation on a given handle, check for it not to be NULL : if it is, then you've spotted an error.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay. Thanks everyone. I know the problem and has implemented a working solution.
Joaquín M López Muñoz was right on the right track about the threads closing simultaneously. I did in fact set all threads to INVALID_HANDLE_VALUE and checked them all using WaitForSingleObject().
The problem has to do with collapsing all sockets and threads as the user cancels a process. A solution I now use is to close each socket which means all their worker threads after their threads ends and sends a messages to main frame for closing. In other words, instead of stepping through all sockets in the linked list and closing them and their worker threads, now the program waits for them to end since I am using a boolean variable to indicate cancelation. This solution works flawlessly.
Kuphryn
|
|
|
|
|
what's the difference between:
1. MBCS (Multi Byte Character Set)
2. DBCS (Double Byte Character Set - it's a subset of MBCS right?)
3. Unicode (I though Unicode IS DBCS)
any idea?
Unicode compatible API all starts with "_w"?
example:
_wXXXX(..)
thanx!
norm
|
|
|
|
|
MBCS will have either one or two bytes represent a character. When you are dealing with a MBCS you will want to be careful to use the mbc version of the c runtime functions in order to perform string operations like strlen and strncpy because you are not copying a specific number of bytes rather than characters.
DBCS uses two bytes to represent each character. That simple.
UNICODE is a DBCS, but IBM uses that term all over the place, when they refer to MBCS as well. Therefore when Microsoft refers to UNICODE as a type of character set, they use Wide Character Set (WCS).
I hope that clears things up.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
thanx, loud and clear, just one last thing:
Unicode compatible API all (or most) starts with "_w"?
example:
_wXXXX(..)
norm
|
|
|
|
|
You're a bit off with your MBCS and DBCS definitions. An MBCS uses variable numbers of bytes per character. Some will have one, some two, some three, etc. A DBCS (double-byte char set) is an MBCS with a max character length of 2 bytes.
Unicode is technically not an MBCS because all characters are the same length, 2 bytes. It is a wide character set.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
can someone please tell me
how to add external dependencies folder to the project?
and How to add .h files to that external dependencies folder?
thanks
|
|
|
|
|
The Visual Studio IDE will automatically do that for you in your project if it detects these other dependencies.
That folder is really just there for your reference. If you are going to add files to your project I would suggest you do it through the source files, or add the files that you want to compile in the "source Files" folder.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
No.. external dependencies folder didn't get created..
would it be becase of win32 console application w/o MFC support???
I understand.. but i cannot include in my program.. even i include it i got error. saying
error LNK2001: unresolved external symbol _functionName_
so i was thinking may be it needs external dependencies folder.. which might be wrong.
|
|
|
|
|
I think it may only get created after the first successful build where a non-project include file is used - I've just tried the project type you've got (console app, no MFC) and that's the behaviour I saw...
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
as far as i have been able to tell, 'external dependencies' is a visual studio managed folder that lists all files included manually (via #include) that have not explicitly been added into the .h files.
try #including a header file not already in the project and rebuilding - it should then appear in the ext dep folder
|
|
|
|
|
Is there a way to accomplish this?
I get an error the way it is now
error C2440: 'initializing' : cannot convert from 'const int' to 'int *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
int counts[] doesn't work either
warning C4200: nonstandard extension used : zero-sized array in struct/union
error C2233: '<unknown>' : arrays of objects containing zero-size arrays are illegal
typedef struct
{
int id;
int numCounts;
int *counts;
} Counts;
Counts counts[] =
{
{1, 0, 0},
{2, 10, {100, 101, 102, 103, 104, 105, 106, 107, 108, 109}},
{3, 0, 0},
{4, 0, 0},
{5, 8, {209, 208, 207, 206, 205, 204, 203, 202}},
{6, 5, {300, 301, 302, 303, 304}},
};
int numCounts = sizeof(counts) / sizeof(Counts);
void main()
{
return;
}
Todd Smith
|
|
|
|
|
You can't initialize pointer as an array like this:
int *a;
a = {10,20,30};
You can use only type identifier[] = { /*...*/ }
Pointers should be initialized like this:
int *a;
a = new int[10];
a[0] = 15;
a[]1 = 16;
I suggest you to create a more complex type.
Ñ There is only one MP Ð
|
|
|
|
|
This worked
typedef struct
{
int id;
int numCounts;
int *counts;
} Counts;
int items1[] = {100, 101, 102, 103, 104, 105, 106, 107, 108, 109};
int items2[] = {209, 208, 207, 206, 205, 204, 203, 202};
int items3[] = {300, 301, 302, 303, 304};
Counts counts[] =
{
{1, 0, 0},
{2, 10, items1},
{3, 0, 0},
{4, 0, 0},
{5, 8, items2},
{6, 5, items3},
};
void main()
{
return;
}
Todd Smith
|
|
|
|
|
No! This code doesn't work well! It compiles with no errors, but int *counts; is still just a pointer and it can points only at the *first* element in an array!
Example:
int items1[] = {100, 101, 102, 103, 104, 105, 106, 107, 108, 109};
int* p = items1
in debugger:
Name: value: type:
p 0x0054H1 int*
|- 100 int
You can get access to the second element in an array like this: p++, but if you want to get access to the 11th element, you will get Access Violation and your program will crash!
Ñ There is only one MP Ð
|
|
|
|
|
Maciej Pirog wrote:
You can get access to the second element in an array like this: p++, but if you want to get access to the 11th element, you will get Access Violation and your program will crash!
These are the ways of C++ Arrays. They *ARE* just pointer to some memory.
Maybe the STL std::vector is what you want?
|
|
|
|
|