Subversion Repositories filter_foundry

Rev

Rev 496 | Rev 522 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 496 Rev 521
Line 19... Line 19...
19
*/
19
*/
20
 
20
 
21
#include "ff.h"
21
#include "ff.h"
22
 
22
 
23
void strcpy_advance_id(TCHAR** str, int msgid) {
23
void strcpy_advance_id(TCHAR** str, int msgid) {
24
    TCHAR tmp[1000];
24
    //TCHAR tmp[1000];
-
 
25
    int len;
-
 
26
 
-
 
27
    len = FF_GetMsg(*str, msgid);
25
 
28
 
-
 
29
    *str += len;
-
 
30
 
26
    FF_GetMsg(*str, msgid);
31
    //FF_GetMsg(&tmp[0], msgid);
-
 
32
    //len = xstrlen(&tmp[0]);
-
 
33
    if (len == 0) {
-
 
34
        simplealert(TEXT("strcpy_advance_id ist len=0!"));
-
 
35
    }
27
 
36
   
28
    FF_GetMsg(&tmp[0], msgid);
-
 
29
    *str += xstrlen(&tmp[0]);
-
 
30
}
37
}
31
 
38
 
32
// Attention: No bounds checking!
39
// Attention: No bounds checking!
33
void FF_GetMsg(TCHAR* ret, int MsgId) {
40
int FF_GetMsg(TCHAR* ret, int MsgId) {
34
#ifdef WIN_ENV
41
#ifdef WIN_ENV
-
 
42
 
-
 
43
#ifdef UNICODE
35
        TCHAR* szMsg;
44
    TCHAR* szMsg;
36
    int len;
45
    int len;
37
    len = LoadString(hDllInstance, MsgId, (LPTSTR)&szMsg, 0);
46
    len = LoadString(hDllInstance, MsgId, (LPTSTR)&szMsg, 0);
-
 
47
    if (len == 0) return 0; // resource not found
-
 
48
    if (ret != NULL) {
38
    LoadString(hDllInstance, MsgId, ret, len+1);
49
        LoadString(hDllInstance, MsgId, ret, len + 1);
-
 
50
    }
-
 
51
    return len;
-
 
52
#else
-
 
53
    // LoadStringA is either broken or badly documented!
-
 
54
    // The documentation says that you receive a read-only string reference as well as the length as return value if cchBufferMax==0.
-
 
55
    // Reality shows that return value is -1 if cchBufferMax==0.
-
 
56
    // https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/8d8c5382-1867-460a-a18f-70dc425ffe2f/loadstring-not-behaving-as-documented?forum=windowssdk
-
 
57
    // We cannot receive a read-only memory using LoadStringA, because the WinAPI needs to do a Unicode-to-ANSI convertion,
-
 
58
    // so we must define some max limit.
-
 
59
    TCHAR szMsg[4096];
-
 
60
    int len;
-
 
61
    len = LoadString(hDllInstance, MsgId, (LPTSTR)&szMsg, 4096);
-
 
62
    if (len == 0) return 0; // resource not found
-
 
63
    if (ret != NULL) {
-
 
64
        LoadString(hDllInstance, MsgId, ret, len + 1);
-
 
65
    }
-
 
66
    return len;
-
 
67
#endif
-
 
68
 
39
#else
69
#else
40
        Str255 msg;
70
        Str255 msg;
41
        GetIndString(msg, 1000, MsgId);
71
        GetIndString(msg, 1000, MsgId);
42
    myp2cstrcpy(ret, msg);
72
    myp2cstrcpy(ret, msg);
43
#endif
73
#endif
Line 47... Line 77...
47
TCHAR* FF_GetMsg_Cpy(int MsgId) {
77
TCHAR* FF_GetMsg_Cpy(int MsgId) {
48
#ifdef WIN_ENV
78
#ifdef WIN_ENV
49
    TCHAR* szMsg;
79
    TCHAR* szMsg;
50
    int len;
80
    int len;
51
    TCHAR* ret;
81
    TCHAR* ret;
52
    len = LoadString(hDllInstance, MsgId, (LPTSTR)&szMsg, 0);
82
    len = FF_GetMsg(NULL, MsgId);
-
 
83
    if (len == 0) return NULL; // resource not found
53
    ret = (TCHAR*)malloc((len+1) * sizeof(TCHAR));
84
    ret = (TCHAR*)malloc((len+1) * sizeof(TCHAR));
54
    if (ret == NULL) return NULL;
85
    if (ret == NULL) return NULL;
55
    LoadString(hDllInstance, MsgId, ret, len+1);
86
    LoadString(hDllInstance, MsgId, ret, len+1);
56
    return ret;
87
    return ret;
57
#else
88
#else