注:Prompt_ini是一个文件;请帮忙转为delphi代码,分贴给分。
typedef struct {
field screen;
field field_id;
field type;
field visible;
field label;
field label_x;
field label_y;
field text;
} SCREEN_OBJ;const int NUM_SCREEN_OBJ_FIELDS = 8;const int LABEL = 0;
const int LABELLED_FIELD = 1;extern int Prompt_size;
extern CString Prompt_ini; 
EditText **prompts_arr;
static int prompts_arr_count = 0;void GetPrompts(void)
{
// Allocate the array
prompts_arr = new EditText* [Prompt_size];

if (!prompts_arr)
{
cout << endl << "No memory for" << endl << "prompts table." << endl;
exit(1);
}

SCREEN_OBJ screen_obj;  // Structure to hold parsed screen object info

const int MAX_LINE_LEN = 256;
char line[MAX_LINE_LEN];
ifstream prompts_ini((char*)Prompt_ini);


int prompts_arr_index = 0; prompts_ini.getline(line, MAX_LINE_LEN);
while (!prompts_ini.rdstate() & ios::eofbit)
{
if (!is_empty(line) && !is_comment(line))
{ // If the current line is neither a comment nor a blank line
  // then it must be a prompt definition, so parse it, build an
  // EditText object and store it in the hash table. if (prompts_arr_index == Prompt_size)
{
cout << "No more room in table!!" << endl;
exit(1);
}
EditText *temp_et;

if (parse_fields((unsigned char *)line,HH_delimiter,NUM_SCREEN_OBJ_FIELDS,(char*)&screen_obj) == ERROR)
{
cout << endl << "Fatal Error in \n" << (char*)Prompt_ini << " file." << endl;
cout << "Line: " << line << endl;
exit(1);
}
else

CString a_key = (CString)(screen_obj.screen) + "." + (CString)(screen_obj.field_id);
a_key.ToLower();

int a_field_type = atoi(screen_obj.type);
int a_visible = atoi(screen_obj.visible);
CString a_label = screen_obj.label;
int a_label_x = atoi(screen_obj.label_x);
int a_label_y = atoi(screen_obj.label_y);
CString a_text = screen_obj.text;
temp_et = new EditText(a_label, a_label_x, a_label_y, a_key, a_text, a_deflt);

prompts_arr[prompts_arr_index++] = temp_et;
prompts_arr_count++;
}
} prompts_ini.getline(line, MAX_LINE_LEN);
}
}
EditText find_et(const char*key_str)
{
CString key(key_str);
key.ToLower();

EditText et(key,0,0,key,"Error!","Error!"); if (prompts_arr_count)
{

for (int i=0;i<prompts_arr_count;i++)
{
if (prompts_arr[i]->name() == key)
et = *(prompts_arr[i]);
}
}

return et;
}
void cleanup_prompts(void)
{
for (int i=0;i<prompts_arr_count;i++)
{
if (prompts_arr[i])
delete prompts_arr[i];
}

delete [] prompts_arr;
}

解决方案 »

  1.   

    楼上的,共三个方法:
    GetPrompts
    find_et
    cleanup_prompts主要功能是从一个文本文件里读取内容,有个类型EditText:这个是一个自定义的文本框主要的问题,有一行代码:
    EditText **prompts_arr;这个是指针的指针吧?delphi中怎么实现?
      

  2.   

    指针的指针在delphi中并不难:如
    type
      p=^char;  //char可为其它类型
      pp=^pp;  //指向char指针的指针
    问题是你的程序是VC写的,且用到了MFC,与其化功夫将它改为delphi的源码,不如用VC将它封装成一个dll,在delphi中调用就可以了