📄 bcjq102.txt
字号:
C++ Builder开发者:程序员之家
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
首页
| 控件天堂 | 控件使用
| 编程技巧
| 源代码 | 编程工具 |
系统补丁 | 电子书籍 | 技术论坛
| 相关链接
if (ad==1) {document.write(''+'');}
if (ad==2) {document.write(''+'');}
if (ad==3) {document.write(''+'');}
var marqueecontents=''+scroll_text+''
if (document.all)
document.write(''+marqueecontents+'')
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
setTimeout("window.onresize=regenerate",450)
intializemarquee()
}
}
function intializemarquee(){
document.cmarquee01.document.cmarquee02.document.write(marqueecontents)
document.cmarquee01.document.cmarquee02.document.close()
thelength=document.cmarquee01.document.cmarquee02.document.height
scrollit()
}
function scrollit(){
if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){
document.cmarquee01.document.cmarquee02.top-=speed
setTimeout("scrollit()",100)
}
else{
document.cmarquee01.document.cmarquee02.top=marqueeheight
scrollit()
}
}
window.onload=regenerate2
当前位置
:
编程技巧
用C++
Builder创建组合框
本文介绍了在Win
98环境下,如何利用C++ Builder和Windows的Api函数创建满足用户特定需求的Combo框,并且通过Api函数扩充了C++
Builer标准组件的功能。
在C++ Builder 下,其所带的Combo控件当内容发生变化时将调用OnChange的Combo1Change事件句柄。这时事件句柄将向系统发送一条基于Combo的CB—FINDSTRING消息,在消息中传递编辑字符串内容。该消息的SendMessage返回值是下拉框中第一个匹配条目的Index值,如果在下拉列表框中找到相匹配的条目,Comobo1Change句柄将发送一条基于Combo的CB—SETEDITSEL消息,该消息的参数确定从插入点到字符串结尾的部分将被选择。结果是被选中的部分是作为消息搜索结果显示在Combo的Text值中。
具体实现:
1、在进入C++ Builder 4.0以后,在窗体上画一个CmoboBox1,在Items中输入anlantic
faloncs、China、Japanese、Amercia等字符串。
2、创建ComboBox1的OnChange句柄,并填入如下代码:
void —fastcall
TForm1::ComboBox1Change(TObject *Sender)
{
String value = ComboBox1-〉Text ;
if (lastkey == ′\b′ || lastkey == VK—DELETE)//
如果用户输入的是Delete键或是Tab键,搜索不进行//
{
lastkey = 0 ;
return ;
}
lastkey = 0 ;
if (ComboBox1-〉SelStart != value.Length
())//如果用户的光标在输入字符串的中间,搜索不进行//
return ;
int index = SendMessage (ComboBox1-〉Handle,
CB—FINDSTRING, -1, (LPARAM) value.c—str ()) ;
//在下来列表框寻找与用户输入字符串相匹配的字符串的索引值//
if (index 〉= 0)//如果索引值〉0//
{
ComboBox1-〉ItemIndex = index ;
SendMessage (ComboBox1-〉Handle, CB—SETEDITSEL,
0, MAKELPARAM (value.Length (), -1)) ;
//发送CB_SETEDITSEL消息//
}
}
3、创建ComboBox1的KeyDown句柄,并填入如下代码:
void —fastcall
TForm1::ComboBox1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
lastkey = Key ;//保存最后的键//
}
4、在头文件中增加如下变量:
Private:WORD LastKey;
5、编译运行。当用户输入在输入框中输入Chi时,便出现China整个字符串。
以上方法在Pwin 98和C++Builder 4.0
Enterprise版中实现。
有时想让控件实现一些不大可能的功能,试试Windows的Api
函数,或许它可以让你梦想成真。
作者:孙航东
if (ad==1) {document.write(''+'');}
if (ad==2) {document.write(''+'');}
if (ad==3) {document.write(''+'');}
C++ Builder开发者®
2000年06月01日 站长:唐朝