****关于几个SDK的问题???
我用CreateWindow每生成一个窗口后,在桌面的任务栏上就会显示一个按钮,
如何实现无论生成多少个窗口,在任务栏上都不会显示仍会按钮!!
还有几个关于编辑框的问题
对于一个多行编辑框,
1.如何得到编辑框有多少行?
2.如何得知当前光标在第几行?
3.如何在编辑框里移动光标?
4.如何改变编辑框的字体,字体颜色和背景色?
问题点数:40、回复次数:12Top
1 楼SKJG(司空见惯)回复于 2003-12-03 17:51:19 得分 0
还有
如何用代码把编辑框设置为只读和非只读?????Top
2 楼3jaja(缘来如此)回复于 2003-12-03 18:04:50 得分 0
用 SendMessage()函数Top
3 楼SKJG(司空见惯)回复于 2003-12-03 18:37:15 得分 0
大虾们,最好给出具体的代码??
小弟是初入们的
Top
4 楼kingcom_xu(冷羽)回复于 2003-12-03 18:48:24 得分 15
http://www.csdn.net/develop/Read_Article.asp?Id=17482
编辑框前3条请看msdn中关于Edit的参考.
第四个可在该编辑框的父窗口的wm_ctlcolor中处理.具体看msdn中wm_ctlcolor消息的说明.Top
5 楼SKJG(司空见惯)回复于 2003-12-03 21:35:04 得分 0
小弟我用SDK生成了一个窗口,上面有一个多行的EDIT
窗口HWND为hWin
EDIT的HWND为hEdit
我想知道一些对EDIT的控制的方法
1.1.如何得到EDIT有多少行?
2.如何得知当前光标在第几行?
3.如何在EDIT里移动光标?
4.如何改变EDIT的背景色?
5.如何改变EDIT的字体和字体颜色?
6.如何用代码把编辑框设置为只读和非只读?
很急
请真正的大虾给出具体的代码!!!!!!!!!!
Top
6 楼laiyx()回复于 2003-12-03 22:47:49 得分 5
可以查阅msdn中关于EM_GETLINECOUNT的描述,以及相关消息的用法。
如得到EDIT有多少行,可用下面代码:
int nAllLines=::SendMessage(hEdit,EM_GETLINECOUNT,0L,0L);
有关光标的操作,首先要取得光标的位置(GetCursor()),然后用EM_CHARFROMPOS消息(用法同上)获得光标所在行数和具体位置。
设置光标用SetCursor()即可,改变颜色和字体用WM_CTLCOLOREDIT 消息,即在父窗口中编制处理WM_CTLCOLOREDIT 消息的函数,系统要重画edit框时,会自动调用消息处理函数,你在函数中设置好你想用的颜色和字体即可;
改变只读非只读属性用EM_SETREADONLY消息:设成只读::SendMessage(hEdit,EM_SETREADONLY,1,0);设成非只读为::SendMessage(hEdit,EM_SETREADONLY,0,0).Top
7 楼SKJG(司空见惯)回复于 2003-12-04 09:04:39 得分 0
我用::SendMessage(hEdit,EM_SETREADONLY,0,0)把EDIT设为只读
但是EDIT的背景色变了,如何实现在EDIT处于只读模式的时候,背景
色不变?Top
8 楼wangweixing2000(星(inspiration(灵感)))回复于 2003-12-04 10:04:01 得分 0
查阅msdnTop
9 楼SKJG(司空见惯)回复于 2003-12-04 11:03:56 得分 0
如何得知EDIT的光标的的位置的改变???Top
10 楼SKJG(司空见惯)回复于 2003-12-04 11:09:20 得分 0
以下是MSDN中关于EM_SETREADONLY的信息,
请教wangweixing2000,我从那里找答案????!!!!
Platform SDK: Windows User Interface
EM_SETREADONLY
The EM_SETREADONLY message sets or removes the read-only style (ES_READONLY) of an edit control. You can send this message to either an edit control or a rich edit control.
To send this message, call the SendMessage function with the following parameters.
SendMessage(
(HWND) hWnd, // handle to destination window
EM_SETREADONLY, // message to send
(WPARAM) wParam, // read-only option
(LPARAM) lParam // not used; must be zero
);
Parameters
wParam
Specifies whether to set or remove the ES_READONLY style. A value of TRUE sets the ES_READONLY style; a value of FALSE removes the ES_READONLY style.
lParam
This parameter is not used.
Return Values
If the operation succeeds, the return value is nonzero.
If the operation fails, the return value is zero.
Remarks
When an edit control has the ES_READONLY style, the user cannot change the text within the edit control.
To determine whether an edit control has the ES_READONLY style, use the GetWindowLong function with the GWL_STYLE flag.
Rich Edit: For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Version: Requires Rich Edit 1.0 or later.
Header: Declared in Winuser.h; include Windows.h.
See Also
Edit Controls Overview, Edit Control Messages, GetWindowLong
Built on Thursday, May 11, 2000Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Version: Requires Rich Edit 1.0 or later.
Header: Declared in Winuser.h; include Windows.h.
See Also
Edit Controls Overview, Edit Control Messages, GetWindowLong
Top
11 楼SKJG(司空见惯)回复于 2003-12-04 11:23:57 得分 0
我用以下的代码来取得EDIT的光标在第几行,
POINT point;
GetCursorPos(&point);
long CurLine=SendMessage(hEdit,0L,(LPARAM)(&point));
DWORD dwError=GetLastError();
结果是
CurLine总是等于-1
dwError总是等于0
为什么?????
Top
12 楼eejeff(nana)回复于 2004-03-26 16:21:18 得分 20
去CodeProject,CodeGuru看看
或许可以找到答案
再不行就得啃MSDN Platform SDK 中关于EDIT控件得参考了
中文MSDN就要推出了,看看Top




