我想在一个编辑框(IDC_EDIT1)中,输入一段文字,怎么办?

lizsss 2002-10-27 11:13:04
已知:窗口的HWND指针,不知道编辑框的ID
...全文
122 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
lizsss 2002-10-30
  • 打赏
  • 举报
回复
ok.
我的问题用别的方法也能解决。

大家是否希望继续讨论???
lizsss 2002-10-27
  • 打赏
  • 举报
回复
可不可以先获得id,然后不需要焦点就能输入。
ThinkX 2002-10-27
  • 打赏
  • 举报
回复
SetWindowText(HWND hwnd, LPCTSTR lpString)
mynameis007 2002-10-27
  • 打赏
  • 举报
回复
IDC_EDIT1:BCB中好像不是这样表示控件的ID的...在SDK中在头文件中有如下
的申明:
#define IDC_EDITX 200//300,400.
在BCB中不能直接用IDC_Edit1.
mynameis007 2002-10-27
  • 打赏
  • 举报
回复
如果你找不到的话是因为你没有装Win32Help.如下:
he GetWindowLong function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window.

LONG GetWindowLong(

HWND hWnd, // handle of window
int nIndex // offset of value to retrieve
);


Parameters

hWnd

Identifies the window and, indirectly, the class to which the window belongs.

nIndex

Specifies the zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus four; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32-bit integer. To retrieve any other value, specify one of the following values:

Value Action
GWL_EXSTYLE Retrieves the extended window styles.
GWL_STYLE Retrieves the window styles.
GWL_WNDPROC Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure.
GWL_HINSTANCE Retrieves the handle of the application instance.
GWL_HWNDPARENT Retrieves the handle of the parent window, if any.
GWL_ID Retrieves the identifier of the window.
GWL_USERDATA Retrieves the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window.


The following values are also available when the hWnd parameter identifies a dialog box:

Value Action
DWL_DLGPROC Retrieves the address of the dialog box procedure, or a handle representing the address of the dialog box procedure. You must use the CallWindowProc function to call the dialog box procedure.
DWL_MSGRESULT Retrieves the return value of a message processed in the dialog box procedure.
DWL_USER Retrieves extra information private to the application, such as handles or pointers.


Return Values

If the function succeeds, the return value is the requested 32-bit value.
mynameis007 2002-10-27
  • 打赏
  • 举报
回复
GetWindowLong和SetWindowLong两个的API的参数比较多而且杂,建议你看一下帮助...上面都有的..
lizsss 2002-10-27
  • 打赏
  • 举报
回复
我找不到GetWindowLong()的函数声明。
季世平老大,再解释一下可以吗?
还有,哪个GWL_ID是什么???
jishiping 2002-10-27
  • 打赏
  • 举报
回复
已知窗口句柄(包括控件的句柄),用下面的方法得到窗口的ID:
UINT ID = GetWindowLong(hWnd, GWL_ID);

已知父窗口和控件的ID,用下面的方法得到控件的窗口句柄:
HWND hWnd = GetDlgItem(hParent, ChildID);

知道了控件Edit的句柄,就可以用SetWindowText来设定Edit的文字了。
大大怪老张 2002-10-27
  • 打赏
  • 举报
回复
行不行试试就知道了...

得到句柄后,二楼给了你方法...
lizsss 2002-10-27
  • 打赏
  • 举报
回复
请问用那一条函数来获得对话框中的edit的id
GetDlgItemID()行不??
获得句柄又咋办???
jishiping 2002-10-27
  • 打赏
  • 举报
回复
你必须要先得到Edit的窗口句柄或者ID才行。对不同的程序,这需要区别对
待。对于采用Dialog资源的对话框,每个Edit有固定的ID,这可以先用其它
的工具得到Edit的ID;如果Edit没有固定的ID,需要根据其它的条件来得到
Edit的窗口句柄。

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧