BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: Dynamic switching of resource DLLs

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internationalization
View previous topic :: View next topic  
Author Message
Dennis Jones
Guest





PostPosted: Tue Aug 19, 2003 3:53 pm    Post subject: Re: Dynamic switching of resource DLLs Reply with quote




"BMacF" <bruce (AT) cidif (DOT) org> wrote

Quote:
HELP!!! I am trying to switch resource DLLs so I can switch my
application
from English to French simply by clicking a button. I was told to follow
the RichEdit example that ships with Delphi, but it still doesn't seem to
work.

const
FRENCH = (SUBLANG_FRENCH shl 10) or LANG_FRENCH;
if LoadNewResourceModule(FRENCH) <> 0 then
ReinitializeForms;

After following the debugger through this code, it seems that
ReinitializeForms never gets called. If I change the '<>' to '=', then it
is called.

Can somebody please explain to me what exactly the above code does and why
it doesn't work in my code?
I was also told to Release the Form and then Recreate it after the
ReinitializeForms call. Is this correct, because it doesn't work any
better.

I've never been very impressed with ReInit. It was intended to be an
example, and that's exactly the way I treated it (like an example) and
actually ended up re-writing it. What you might want to do is, step through
ReInit to see what it is doing, and exactly where it is failing.

My guess is, it is failing the LoadLibararyEx call, meaning that ReInit
can't find your .FRA or .FR resource file. Make sure it is either in your
path, or in the same directory as your EXE.

Note that LoadNewResourceModule returns 0 if it fails, or the handle to the
resource module if it succeeds. Therefore, the code you have above is
correct -- you only want to call ReinitializeForms() if
LoadNewResourceModule() succeeds (returns non-zero).

Note also that ReInit will not work for your application if you have forms
in DLL's. Only forms in the EXE will get handled (that's another reason I
re-wrote ReInit -- I needed to translate a huge application with forms in
many DLL's).

- Dennis



Back to top
Dennis Jones
Guest





PostPosted: Tue Aug 19, 2003 4:05 pm    Post subject: Re: Dynamic switching of resource DLLs Reply with quote




"BMacF" <bruce (AT) cidif (DOT) org> wrote


Quote:
I was also told to Release the Form and then Recreate it after the
ReinitializeForms call. Is this correct, because it doesn't work any
better.

It is not necessary to release the form. But I would recommend hiding the
form before you translate, and showing it afterward. Otherwise, if you have
lots of forms in memory that get translated, you will get a lot of flicker
on the main form, and it will take a lot longer:

// hide the main form
Hide();

// translate the application, loading the new forms
LoadNewResourceModule( ... );

// show the main form
Show();

- Dennis



Back to top
BMacF
Guest





PostPosted: Thu Aug 21, 2003 2:17 pm    Post subject: Re: Dynamic switching of resource DLLs Reply with quote



My sample application still doesn't work as it should. I am trying to
switch resource languages but the text on my Main Form is always displayed
in english. If I use the code written below, as explained in the RichEdit
example shipped with Delphi, it still seems as if ReinitializeForms is never
called. If I force the ReinitializeForms call, the components texts on the
from change but not for english or french, but for the components
identifier. I don't know what to do and I feel like I'm using precious time
trying to figure this one out. If anyone could help me so I can move on to
bigger problems, I would be very greatful. If I must send you my code, let
me know.
My patience is growing thin,
BMacF


"Dennis Jones" <djones (AT) nospam (DOT) com> wrote

Quote:

"BMacF" <bruce (AT) cidif (DOT) org> wrote in message
news:3f4236ee$1 (AT) newsgroups (DOT) borland.com...
HELP!!! I am trying to switch resource DLLs so I can switch my
application
from English to French simply by clicking a button. I was told to
follow
the RichEdit example that ships with Delphi, but it still doesn't seem
to
work.

const
FRENCH = (SUBLANG_FRENCH shl 10) or LANG_FRENCH;
if LoadNewResourceModule(FRENCH) <> 0 then
ReinitializeForms;

After following the debugger through this code, it seems that
ReinitializeForms never gets called. If I change the '<>' to '=', then
it
is called.

Can somebody please explain to me what exactly the above code does and
why
it doesn't work in my code?
I was also told to Release the Form and then Recreate it after the
ReinitializeForms call. Is this correct, because it doesn't work any
better.

I've never been very impressed with ReInit. It was intended to be an
example, and that's exactly the way I treated it (like an example) and
actually ended up re-writing it. What you might want to do is, step
through
ReInit to see what it is doing, and exactly where it is failing.

My guess is, it is failing the LoadLibararyEx call, meaning that ReInit
can't find your .FRA or .FR resource file. Make sure it is either in your
path, or in the same directory as your EXE.

Note that LoadNewResourceModule returns 0 if it fails, or the handle to
the
resource module if it succeeds. Therefore, the code you have above is
correct -- you only want to call ReinitializeForms() if
LoadNewResourceModule() succeeds (returns non-zero).

Note also that ReInit will not work for your application if you have forms
in DLL's. Only forms in the EXE will get handled (that's another reason
I
re-wrote ReInit -- I needed to translate a huge application with forms in
many DLL's).

- Dennis





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internationalization All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.