如何从多个编辑控件复制文本? [英] How do I copy text from multiple edit controls?

查看:80
本文介绍了如何从多个编辑控件复制文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译器:Visual C ++标准版4.0

语言:C

项目类型:Win32



问题:我创建了6个编辑控件和一个按钮。我按照这个顺序创建了它们

:4个编辑控件,按钮,2个编辑控件(只读)。

它们都正常运行但是我只能复制文本第3和

第4个编辑框。缓冲区在声明时初始化,第一个和第二个缓冲区用空格写入。我正在使用Edit_GetText来获取文本的
。正在编写该程序以进行计算。

中的数据前4个编辑框将用于计算和答案

将显示在最后2个编辑框中。按钮是Calc按钮。

所以,我在前4个框中输入文本,点击calc按钮,然后作为

a test我使用TextOut显示文本只显示3号和4号文本

。用于数字1和2的行是空白的。这些不是
对话框,只是编辑控件。我已经做了很多研究并尝试了不同的东西,但没有解决问题。我非常感谢

非常感谢。谢谢,John

Compiler: Visual C++ Standard Edition 4.0
Language: C
Project type: Win32

Problem: I have created 6 edit controls and one pushbutton. I created them
in this order: 4 edit controls, pushbutton, 2 edit controls(read only).
They all function properly BUT I can copy the text from only the 3rd and
4th edit boxes. The buffers were initialized when declared and the 1st and
2nd buffers get over written with spaces. I am using Edit_GetText to get
the text. This program is being written to make a calculation. The data in
the first 4 edit boxes will be used to make the calculation and the answers
will be displayed in the last 2 edit boxes. The pushbutton is the Calc button.
So, I enter the text in the first 4 boxes, hit the calc button, and then as
a test I display the text using TextOut and only the text from number 3 and 4
are displayed. The lines used for number 1 and 2 are blank. These are not
dialog boxes, just edit controls. I have done a lot of research and tried
different things but have not solved the problem. I would appreciate some
help very much. Thanks, John

推荐答案

我终于发现了这个问题。如上所述,我使用了六个编辑控件,两个

是只读的。我为输入控件声明了一个四元素数组,并为输出控件声明了一个两元素数组:hEditIN [4]和hEditOut [2]。然后我用
用于循环来创建它们;循环遍历数组以及它们的ID和屏幕位置。好吧,我今天发现在循环中只读控件我使用了hEditIN而不是hEditOut !!!!!!由于此时我没有注意只读控件,所以我没有发现错误。

点击Calc按钮后,WM_COMMAND捕获它,然后循环浏览

hEditIN数组,并为每个元素调用Edit_GetText,此时

在父窗口中显示结果。伙计,多么有经验!现在我可以继续了!
I finally discovered the problem. As stated I'm using six edit controls, two of
which are read only. I declared a four element array for the input controls and
a two element array for the output controls: hEditIN[4] and hEditOut[2]. Then I
used for loops to create them; looping through the arrays as well as their IDs and screen positions. Well, I discovered today that in the loop for the read only controls I used hEditIN instead of hEditOut!!!!!! Since I wasn't paying any attention to the read only controls at this point I didn't catch the error.
Now after the Calc button is clicked WM_COMMAND catches it and I loop through
the hEditIN array and call Edit_GetText for each element and at this point
display the results in the parent window. Man, what an experience! Now I can get on with it!


这篇关于如何从多个编辑控件复制文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆