用ComboBox和SendMessage结合,如何自动出现List?

XIAYINAMY 2004-06-12 05:09:25
希望在向组合框中输入时,会自动展开List,将如下语句放在KeyPress中之后,不能使List不能自动展开,但文本已经匹配成功
lRet = SendMessage(cmbValue(6).hwnd, CB_SHOWDROPDOWN, True, 0)
...全文
128 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2004-06-14
  • 打赏
  • 举报
回复
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub Combo1_Change()
Dim iStart As Integer
Dim sString As String
Static iLeftOff As Integer

iStart = 1
iStart = Combo1.SelStart

If iLeftOff <> 0 Then Combo1.SelStart = iLeftOff: iStart = iLeftOff

sString = CStr(Left(Combo1.Text, iStart))
Combo1.ListIndex = SendMessage(Combo1.hwnd, &H14C, -1, ByVal CStr(Left(Combo1.Text, iStart)))

If Combo1.ListIndex = -1 Then iLeftOff = Len(sString): Combo1.Text = sString
If Combo1.Text <> "" Then SendMessage Combo1.hwnd, &H14F, True, 0

Combo1.SelStart = iStart
Combo1.SelLength = 0
iLeftOff = 0

End Sub
Private Sub Form_Load()
Dim i As Long
For i = 1 To 500
Randomize
Combo1.AddItem Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97)
Next
Combo1.Text = ""
End Sub

作为Microsoft 32位平台的应用程序编程接口,Win32 API是从事Windows应用程序开发所必备的。本书首先对Win32 API函数做完整的概述;然后收录五大类函数:窗口管理、图形设备接口、系统服务、国际特性以及网络服务;在附录部分,讲解如何在Visual Basic和Delphi中对其调用。 本书是从事Windows应用程序开发的软件工程师的必备参考手册。 Win32 API作为 Microsoft 32位平台(包括:Windows 9x,Windows NT3.1/4.0/5.0,WindowsCE)的应用程序编程接口,它是构筑所有32位Windows平台的基石,所有在Windows平台上运行的应用程序都可以调用这些函数。 从事Windows应用程序开发,离不开对Win32 API函数的调用。只有充分理解和利用API函数,才能深入到Windows的内部,充分挖掘系统提供的强大功能和灵活性。 近年来,随着Microsoft 32位平台的版本升级, Win32 API函数的构成、功能与调用方式都有很大的发展变化,然而,国内很少有相关的新版资料出版。为了满足广大开发人员的迫切需求,我们经过认真收集、整理素材,组织编写了这本与各种Microsoft 32位平台最新版本同步的Win32 API参考手册。 全书收录了五大类函数:窗口管理、图形设备接口、系统服务、国际特性以及网络服务。所有函数均附有功能说明、参数说明、返回值说明、备注以及引用说明。另外,在本书的第一章,我们对WiN32 API函数作了完整的概述;在附录部分,讲解了如何在Visual Basic和Delphi中对其调用。 由于篇幅较大,涉及技术内容广泛,加之时间仓促,书中难免存在不少错误或疏漏,希望广大读者给与批评指正。 在Windows程序设计领域处于发展初期时,Windows程序员可使用的编程工具唯有API函数。这些函数在程序员手中犹如"积木块"一样,可搭建出各种界面丰富、功能灵活的应用程序。不过,由于这些函数结构复杂,所以往往难以理解,而且容易误用。 随着软件技术的不断发展,在Windows平台上出现了很多优秀的可视化编程环境,程序员可以采用"所见即所得"的编程方式来开发具有精美用户界面和功能的应用程序。这些可视化编程环境操作简便、界面友好,比如:Visual C++,Delphi,Visual Basic等等。在这些工具中提供了大量的类库和各种控件,它们替代了API的神秘功能。事实上,这些类库和控件都是构筑在Windows API的基础上的,但它们使用方便,加速了Windows应用程序的开发,所以受到程序员的普遍采用。有了这些类库和控件,程序员们便可以把主要精力放在整体功能的设计上,而不必过于关注具体细节。不过,这也导致了非常多的程序员在类库面前"固步自封",对下层API函数的强大功能一无所知。 实际上。程序员要想开发出更灵活、更实用、更具效率的应用程序,必然要涉及到直接使用API函数。虽然类库和控件使应用程序的开发容易得多,但它们只提供Microsoft Windows的一般功能,对于一些比较复杂和特殊的功能来说,单使用类库和控件是难以实现的,必须直接使用API函数来编写。API函数是构筑整个Windows框架的基石,只有充分理解和利用API函数,才能深入到Windows的内部,充分发挥各种32位平台的强大功能和灵活性,才能成功地扩展和突破类库、控件和可视开发环境的限制。 Win32 API即为Microsoft 32位平台的应用程序编程接口(Application Programming Interface)。所有在Win32平台上运行的应用程序都可以调用这些函数。 使用Win32 API,应用程序可以充分挖掘Windows的32位操作系统的潜力。 Mircrosoft的所有32位平台都支持统一的API,包括函数、结构、消息、宏及接口。使用 Win32 API不但可以开发出在各种平台上都能成功运行的应用程序,而且也可以充分利用每个平台特有的功能和属性。 在具体编程时,程序实现方式的差异依赖于相应平台的底层功能的不同。最显著的差异是某些函数只能在更强大的平台上实现其功能。例如,安全函数只能在Windows NT操作系统下使用。另外一些主要差别就是系统限制,比如值的范围约束,或函数可管理的项目个数等等。 标准Win32 API函数可以分为以下几类: 窗口管理 窗口通用控制 Shell特性 图形设备接口 系统服务 国际特性 网络服务 在下面各节中,我们分别介绍这7种类型的API函数。 窗口管理函数向应用程序提供了一些创建和管理用户界面的方法。你可以使用窗口管理函数创建和使用窗口来显示输出、提示用户进行输入以及
6 , chunks.zip<br>This will open a file and read it in "Chunks" of a selected file.<END><br>7 , logging.zip<br>This is a bas that will log installation procedures so the file can be removed later.<END><br>8 , savetree.zip<br>This will save the info in a Tree View. "This technique allows a program to save hierarchical information like the data in a TreeView in a way that is easy to understand."<END><br>11 , OLE.zip<br>Demonstrates the use of OLE.<END><br>12 , gradtxt2.zip<br>"A program for drawing horizontal, rectangular or spherical gradient texts."<END><br>13 , sweepgl.zip<br>This example greatly demonstrates how to use OpenGL in Visual Basic.<END><br>15 , drawdemo.zip<br>This is an excellent example of how to make a paint program with a few extras.<END><br>16 , cube.zip<br>This example demonstrates how to rotate a cube in visual basic.<END><br>17 , sprite1.zip<br>This is an Excellent example on how to use sprites in your program.<END><br>18 , charcreate.zip<br>This is an example of how to assign "characters" to differant pictureboxes. This would be a good starting point for VB game developers.<END><br>19 , breakthrough.zip<br>This demonstrates a simple game in Visual Basic. An excellent example.<END><br>26 , openlib.zip<br>These are the type libs that go with OpenGL. This is used to make 3D text.<END><br>27 , basMath.zip<br>This module contains functions for various math equations. <END><br>28 , calc.zip<br>This is a basic calculator written in Visual Basic.<END><br>29 , stopwatch.zip<br>This shows how to count off time in a Stop Watch format.<END><br>31 , taskhide.zip<br>This will hide your application from the taskbar, Alt+Tab, and Alt+Ctrl+Del.<END><br>32 , newbie.zip<br>This is a nicely done help file for programmers that are new to Visual Basic.<END><br>33 , vbfaq.zip<br>This is AOL's PC Dev Visual Basic FAQ. This is an excellent starting point for begginners.<END><br>34 , Bas.zip<br>it is very good modual for activex<END><br>35, paraviasource.zip<br>This is
梯形图转换语句表,软件测试阶段 IMPLEMENT_DYNCREATE(VDisPlayView, CScrollView) VDisPlayView::VDisPlayView() { //P_LIST cDatList; EnableAutomation(); } VDisPlayView::~VDisPlayView() { } HFONT C_SetFont(UINT uFont) { HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if (hFont == NULL) hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); return hFont ; } void VDisPlayView::OnFinalRelease() { // When the last reference for an automation object is released // OnFinalRelease is called. The base class will automatically // deletes the object. Add additional cleanup required for your // object before calling the base class. CScrollView::OnFinalRelease(); } BEGIN_MESSAGE_MAP(VDisPlayView, CScrollView) ON_WM_CREATE() // ON_WM_MOUSEMOVE() ON_MESSAGE(WM_DRAWDATA, OnDrawData) // ON_WM_MOUSEHWHEEL() ON_WM_SIZE() // ON_WM_MOUSELEAVE() ON_WM_NCMOUSELEAVE() END_MESSAGE_MAP() BEGIN_DISPATCH_MAP(VDisPlayView, CScrollView) END_DISPATCH_MAP() // Note: we add support for IID_IViScroll to support typesafe binding // from VBA. This IID must match the GUID that is attached to the // dispinterface in the .IDL file. // {C1771C4B-2FF0-46ED-A4FE-D381086A49E4} static const IID IID_IViScroll = { 0xC1771C4B, 0x2FF0, 0x46ED, { 0xA4, 0xFE, 0xD3, 0x81, 0x8, 0x6A, 0x49, 0xE4 } }; BEGIN_INTERFACE_MAP(VDisPlayView, CScrollView) INTERFACE_PART(VDisPlayView, IID_IViScroll, Dispatch) END_INTERFACE_MAP() // VDisPlayView drawing void VDisPlayView::OnInitialUpdate() { //CScrollView::OnInitialUpdate(); //CSize sizeTotal; // TODO: calculate the total size of this view //sizeTotal.cx = sizeTotal.cy = 1000; // SetScrollSizes(MM_TEXT, sizeTotal); SetScrollSizes(MM_TEXT, CSize(VIEW_WIDTH,VIEW_HIGHT)); CScrollView::OnInitialUpdate(); } //void VDisPlayView::OnDraw(CDC* pDC) //{ // CDocument* pDoc = GetDocument(); // //CAutoPanDoc* pDoc = GetDocument(); // ASSERT_VALID(pDoc); // // // Get the invalidated rectangle of the view, or in the case // // of printing, the clipping region of the printer dc. // CRect rectClip; // CRect rectCloud; // pDC->GetClipBox(&rectClip;); // pDC->LPtoDP(&rectClip;); // rectClip.InflateRect(1, 1); // avoid rounding to nothing // // // Note: CScrollView::OnPaint() will have already adjusted the // // viewport origin before calling OnDraw(), to reflect the // // currently scrolled position. ///* for(int x=0; x<1600; x+=50) // { // for(int y=0; yFillSolidRect(rc, RGB(x,y,x*y)); // } // }*/ // // // // // TODO: add draw code here //} // VDisPlayView diagnostics #ifdef _DEBUG void VDisPlayView::AssertValid() const { CScrollView::AssertValid(); } #ifndef _WIN32_WCE void VDisPlayView::Dump(CDumpContext& dc) const { CScrollView::Dump(dc); } #endif #endif //_DEBUG // VDisPlayView message handlers int VDisPlayView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CScrollView::OnCreate(lpCreateStruct) == -1) return -1; m_pDC=new CClientDC(this); uRowNumber=10000;// uColNumber=4; /* UINT uRowNumber ,uColNumber, *uPerCol_Width,*uPerRow_height ,;*/ uPerCol_Width =new WORD[uColNumber]; uPerRow_height=new WORD[uRowNumber]; UINT i; for(i=0;iList; //LVS_EDITABELS 允许项文本能够适本地进行编辑。父窗口必须运行了LVN_ENDLABLEDIT //ListView_SetExtendedListViewStyle //cDatList.SetExtendedStyle(LVS_EX_GRIDLINES| LVS_EDITLABELS); /* LV_COLUMN lvcol; lvcol.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; lvcol.pszText = L"索引"; lvcol.iSubItem = 0; lvcol.cx = 130; cDatList.InsertColumn(0, &lvcol;); lvcol.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; lvcol.pszText = L"元件"; lvcol.iSubItem = 1; lvcol.cx = 130; cDatList.InsertColumn(1,&lvcol;); lvcol.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; lvcol.pszText = L"注释"; lvcol.iSubItem = 2; lvcol.cx = 130; cDatList.InsertColumn(2,&lvcol;); lvcol.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; lvcol.pszText = L"辅助标号"; lvcol.iSubItem = 3; lvcol.cx = 130; cDatList.InsertColumn(3,&lvcol;); */ // cDatList.InsertColumn(0, L"序号", LVCFMT_LEFT, 40); // cDatList.InsertColumn(1,L"地物名称", LVCFMT_LEFT, 80); // cDatList.InsertColumn(2,L"地物颜色", LVCFMT_LEFT, 120); // CString strName, strIndex; // int m; // for(int i=0; i<32; i++) // { // strIndex.Format(L"%d", i+1); // strName.Format(L"Class%d", i+1); // cDatList.InsertItem( i, strIndex); // cDatList.SetItemText(i, 1, strName); //cDatList.SetItemText(i, 1, strName); //cDatList.SetItemData(i, RGB(rand(), rand(), rand())); // } //cDatList.ApproximateViewRect(CSize(670,700),-1); //cDatList.SetRowHeigt(26); //cDatList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP); //cDatList.Create(_T("CONTROL"),(LPCWSTR) NULL,WS_CHILD|WS_VISIBLE,rect,this,ID_FUNCTION_INSERT); /* if (!cDatList.CreateEx(0L,_T("CSCROLLVIEW"),(LPCWSTR) NULL, WS_CHILD|WS_VISIBLE| ES_AUTOHSCROLL|
1 , docudel.zip
This example shows how to clear the document history on the start menu.
2 , BatteryAPIdemo.zip
This example demonstrates how to "To get information about the battery status with out having to use the SysInfo.ocx from MS"
3 , DisableXexam.zip
This example easily demonstrates how to remove the "X" from your forms.
4 , manc-sleep.zip
This example demonstrates how to pause for a specified duration in seconds using the 'Sleep' win32 API function.
5 , camp-api.zip
An example of editing the "win.ini" file to execute programs when Windows loads.
6 , win32api.exe
This will install the Win32API.txt on your system. This file holds all API declarations for Windows. Must 下载.
7 , transparentblt.zip
This demonstrates how to display an image transparently on the form. An excellent example.
8 , MessageBoxDemo.zip
Manipulate Message Boxes using API. These include a self-closing message box, and a form-centered message box.
9 , menucol.zip
This shows how to add "columns" to your menus. An excellent example.
10 , changeborder.zip
Have you ever wanted to change the border style during runtime? Now you can using SetWindowLong. This example demonstrates greatly how you can accomplish this.
11 , capmousedemo.zip
This example demonstrates how to Set capture on the mouse to detect when it enters and leaves a specific portion of your form.
12 , apilines.zip
This example demonstrates how to draw lines using API.
13 , killapp.zip
This is a bas file to close any window with just it's caption.
14 , combohgt.zip
This demonstrates how to change the height of a combobox's drop-down height using API.
15 , bat-os.zip
This demonstrates how to retrieve information about Battery Powered machines.
16 , display.zip
This will open the Screen Resolution Dialog so you can manipulate it.
17 , ciasystray.zip
This shows you how to add your icon to the system tray without any third-party controls.
18 , taskbar.zip
This demonstrates how to Hide and Show the taskbar.
19 , wpchanger.zip
This shows how to change Windows' Desktop Wallpaper
20 , discad.zip
This shows how to disable control alt and delete by tricking the computer into thinking that the screensaver is running.
21 , windowfrompoint.zip
Get a window's handle from the current cursor position.
22 , api.zip
api function collection
23 , benchmark.zip
This program is very usefull program which gets the details of your computer and have an ability of changing some system details.
24 , menustructure.zip
This program will retrieve the full menu structure of a Form, up to three levels, and allow the user to modify it.
25 , crackPassword.zip
This is a very unusual program which will let you read behind those ******* in password fields and recover captions from Dialogs, Labels, Command Buttons, TextBoxes...
26 , hotkey_source.zip
Hotkey Manager Beta Version: Manages and implements hotkey in Windows 95/98/NT.
27 , rjsoftapisamples.zip
The samples included in this project use the few API
28,sysmetrics.zip
This is a windows information viewer. You can use this sample to find or select an open window, and view information about the window, such as its hwnd, size, and parent window.
29,launcher.zip
This is an ActiveX DLL that causes a client app to wait for another app to finish. The library takes care of launching the new app and doing all of the synchronization. It also returns the exit code for the process.
30,servcont.zip
It enables you to start and stop NT Services through the Win32 API, change the startup type and the security account associated with it. Included is a test harness so that people can see how it works. The code has been tested under NT4 SP6a
31,passdemo.zip
This is a very good example of how to use the registry to save data. It shows how to create, store and save a password to the registry and also encrypts it to keep out prying eyes.
32,delay.zip
This is a rough translation of the GetTickCount API and includes three different ways to pause an application.
33,cdromsystray.zip
This excellent program which was sent to us annoymously adds an icon to the systray (bottom right on the start menu bar) and allows you to control the opening and closing of the CDROM.. Easily adaptable, and if you wrote this and want to be credited
34,rgbdemo.zip
Very small, very fast. Complete source included to demonstrate how to translate a long to red, green and blue values
35,sleep2.zip
This is a small project showing how to use the Sleep API call from within your program to pause for a set period of time. Its much better than looping round as it uses very little CPU time
36,threads.zip
This application is only used to show how a multithreaded program is structured through the 'eyes' of VB. If you follow the logic of the program it does teach a lot about multithreading and the necessary techniques to do this in a 'Thread Safe environmen
37,callback.zip
This small project is for the more advanced VB users and shows an undocumented VB function and an undocumented Win32 API function. Demonstrated in the project how to use these two functions in order to raise events in a class from a module
38,ctaskmanager.zip
This application contains the same basic functionality as the task manager in Windows. It allows you to see the loaded windows on your system as well as the class, position and process ID for each window. Remember that every process running on a system
39,cprocessfinished.zip
This little routine will test if a shelled process has finished executing and return true or false. Its bits of code like that we would like more of, so please send them.
40,apimsg.zip
API Message Box
41,freespc.zip
Get a Drive's Free Space
42,drvinfo.zip
Get Drive Information (S/N, Label, Format)
43,nodisk.zip
Show Message When There is No Disk in a Drive
44,fullpath.zip
Add Full Paths to a TreeView
45,disksrch.zip
Search for Disk in a Removable Drive
46,drvtype.zip
Determine Drive Type
47,findcd1.zip
Find the First CD-ROM
48,xxsShell32.zip
Shell32 functions and subs wrapper for VB developers.
49,api2.zip
This application is designed to help VB Developer to find Windows API Easely.
50,qsvb.zip
QuickSilver for Visual Basic, aims to provide a wrapper for all important Windows API functions by a simple class. All the operations are included as properties and methods that can used with the same ease as any other part of your dream project.
51,CPUInfo.zip
This code will quickly tell you a lot of your system information like computer name, IP address, OS, Service Pack, Processor Vendor, Processor Type, Processor Speed (Raw and Normal), RAM (Total and Available).
52,Callbacks.zip
It is nice little application, which demonstrates WinAPI Callbacks. It hides and restors all Yahoo chatting window in a single click.
53,ShellTrayIcon.zip
The CShellTrayIcon class allows your VB application to set, change and delete icons in the system's tray (note: the official term for the tray is the taskbar notification area). The class raises an event in your application when the user clicks an icon in the tray.
54,EventCtl.zip
This little control greatly simplifies the business of subclassing a form to get at the extra events that the Visual basic designers left out. i.e.:
55,EuroCalc2.zip
In place conversion between every one of the European Monetary Union member currencies and the Euro.
56,Edge.zip
In my program i have used few API functions to set 3D,Sunken,etched effects to the images of your image control.Another example shows how to change your label control to a 3D command button almost functionally.
57,Prjfloat.zip
I have used two APIFuctions 'Setwindowword' and 'Setparent' to make the child window float
freely and with in the parent window. Open with vb5 and vb6.
58,FilterTextBox.zip
This program shows how to filter out characters from TextBox control.Uses GetWindowLong and SetWindowLong APIs.
59,SysControl.zip
This is a program that will let you show, hide, alter text, capture a picture, change the parent, kill, close, enable, disable, get info on, minimize, maximize, restore, capture a picture of, make them stay-on-top, send a message to, edit the window style, and flash the title bar on almost any target!
60,LBApi.zip
This program uses Sendmessage API function for additem,removeitem,clear,selcount,listcount etc, with a horizontal scroll bar.(List/combo)
61,winnanny.zip
U can use Winnanny to restrict unauthorised people from running programs u don't want them to on your pc .It Uses simple api functions to do this.
62,ReadWriteIni.zip
Creates .ini file, writes to it and reads from it. Demo project shows how to write usernames and passwords. For clarity's sake I made it write user color preferences.
63,capture.zip
This program captures the active window and displays it to a Picture box.
64,TransIco.zip
An update to my previous code : Added a couple of features some ppl asked me for...like the ability to change the text colour of the icon and also keep the background transparent after a desktop refresh.
65,shutdown.zip
Shut Down Windows with Windows Shutdown Dialog.This is the real thing , not Kill , It is a real API Call, I hope you find it useful.
66,alarm.zip
A VB alarm clock.
67,clcViewWinInfo.zip
ViewWinInfo is a windows information viewer. You can use this sample to find or select an open window, and view information about the window, such as its hwnd, size, and parent window.
68,ptinrect.zip
Use the PtInRect API function to create an annoying program.
69,fliphorizvert.zip
Flips a picture using the StretchBlt API function.
70,animation.zip
Use BitBlt to crate flickerless animation

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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