Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Resource Dll in Borland

Posted on 2000-03-02
14
Medium Priority
?
294 Views
Last Modified: 2013-12-03
When working with several languages (using resource dll
for each) how can I set one of them in run time ?
0
Comment
Question by:gilad111397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 4
  • +1
14 Comments
 
LVL 15

Expert Comment

by:NickRepin
ID: 2578388
If you use the separate DLLs for each language, call GetUserDefaultLangID() to obtain the user language, then LoadLibrary("Appropriate name").

If you placed all languages into the same dll, the Windows must choose appropriate resources itself.
Alternatively, you can use FindResourceEx/LoadResource/LockResource to select different language resources.
0
 
LVL 2

Expert Comment

by:DarrinE
ID: 2581911
Borland is not really "resource dll" friendly - one of the primary reasons I moved to VC++ about a year ago.

If you have VC++ you can place all resources into one DLL and make it work - with BC++ you must have several DLL's - one for each language

The following function allocates a resource buffer - then retrieves the string associated with the value passed

//=========================================================================
// Name:    GetBuff                                                        
// Purpose: This is the buffer allocator.  Each time it's called, it returns
//                  a pointer to a 256-byte temporary buffer.  As a convenience to
//                  the caller, the first byte of the buffer is set to zero.
//=========================================================================

LPSTR PASCAL GetBuff (void)
{
    typedef char Buffer [MAXSTRSIZE];      // define our string buffer

    LPSTR p;
    HANDLE hBuff;
    static int BufNum = 0;
    static Buffer far * szBuffer = NULL;

    // If this is the first call, then allocate the buffer

    if (szBuffer == NULL)
    {
      hBuff = GlobalAlloc (GHND, sizeof (Buffer) * NUMBUFFERS);
      if (hBuff == NULL);  // Now's the time to panic !
      szBuffer = (Buffer far *) GlobalLock (hBuff);
    }

    p = szBuffer [BufNum++];
    if (BufNum >= NUMBUFFERS) BufNum = 0;
    *p = '\0';
    return p;
}


//=========================================================================
// Name:    GetResStr
// Purpose: This new version of GetResStr uses GetBuff to get a temporary
//          buffer for holding the returned string.
//=========================================================================

LPSTR PASCAL GetResStr (WORD id)
{
    LPSTR p;
    LoadString (hInstance, id, p = GetBuff(), MAXSTRSIZE - 1);
    return p;
}

Example :
/* Set the WIndow Title */
SetWindowText(hDlg, GetResStr (IDS_LD_TITLE));

Let me know if you need more

Darrin
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2581975
>>Borland is not really "resource dll" >>friendly

I shouldn't say that.
I have not met any such problem when I used the Borland compiler before.
I moved to VCC by another reasons.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 2

Expert Comment

by:DarrinE
ID: 2581987
What I really meant to say was that in  VC++ you can add strings which are only loaded dependant upon the country setting you choose - in BC++ (5.01) you cant do this - BC++ wont compile several different languages in the same resource file.

DarrinE
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2582238
No problem, at least with my Borland 5.02

LANGUAGE LANG_GERMAN, LANG_NEUTRAL
STRINGTABLE
{
 1,"Ya"
}
LANGUAGE LANG_ENGLISH, LANG_NEUTRAL
STRINGTABLE
{
 1,"Yes"
}
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2582651
And no problem with my Borland 5.01
 

0
 

Author Comment

by:gilad111397
ID: 2584560
In VC++ you use afxSetResourceHandler with the HANDLE you got from the LoadLibrary and everything is ok. Is there an equivavlent api to that in Borland ?
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2586273
NickRepin changed the proposed answer to a comment
0
 

Author Comment

by:gilad111397
ID: 2586595
send the close form.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2588069
I am not good expert in MFC , but seems
me that TModule class make all functions,
as afxSetResourceHandler :
example from my project:
TModule  resModule = new TModule(szNameDll);
....
      cdBitmap[nIcon1].hGraph = resModule->LoadBitmap(IDB_SHPS + ind);
...
Or
  return resModule->LoadString(code,buff, 80) - 1;
....
Class TModule encapsuleted all Functions
for work with Resoureces. See BC Doc and
BorlandC examples for more Information.
Alex


0
 

Author Comment

by:gilad111397
ID: 2588503
You should have explained about the resource wizard and the richedit sample that the help reference to.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2590340
Gilad, may be i don't understand something? You ask about Api/Class for
working with Resource Dll, right?
Now you ask something other.
Roule of  EE: only one question in you Q! And, sorry, what wrong in my reply?
TModule does not works? Or something
else?
0
 

Author Comment

by:gilad111397
ID: 2590580
It was the same question. I didn't check your sujestion, cause I read about the other idea (with the wizard), but I guess you may be right and since you may be right I assume you deserve the points so send the form again.

0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 200 total points
ID: 2591729
Ok, i risk to reply again.
About wisard: in BC you can use AppExpert: in File|New|Project|AppExpert
You can make good project, but it is not the wisard, as in VC, as i know.
Simple you have sceleton with some functions(you chouse them) and after that you insert manually you functionality.For example, TModule for
working with Resource Dll.
Alex  
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question