如何使用代码:blocks在win32 API中创建搜索栏 [英] How do I create a search bar in win32 API using code:blocks

查看:114
本文介绍了如何使用代码:blocks在win32 API中创建搜索栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用win32 API中的一个项目。在这里,我希望用户在搜索栏中键入文本,并弹出第一个相应的单词。当用户完成输入或选择单词时,单击处理按钮应显示另一个消息框。





当用户点击处理按钮时,我希望每个单词显示不同的消息框。这意味着,应用程序必须能够存储数据以便可以检索它。到目前为止,我有这个代码可以存储数据并被检索。



I am working on one project in win32 API. Here, I want the user to type a text in a search bar and the first corresponding words should pop-up. When the user is done with the typing or selects the word, clicking on the 'Process' button should display another message box.


I want each word to display a different message box when the user clicks on the 'Process' button. Implying that, the application must be able to store data such that it can be retrieved. So far, I have this code which can store data and be retrieved.

HWND hWndComboBox = CreateWindow (TEXT("COMBOBOX"), TEXT (""),
           CBS_DROPDOWN| CBS_HASSTRINGS | WS_VSCROLL| WS_VISIBLE |WS_CHILD ,
            100, 20, 200, 70,
            hwnd ,(HMENU) NULL, NULL, NULL);

CreateWindow (TEXT("BUTTON"), TEXT ("Process "),
            WS_VISIBLE | WS_CHILD ,
            200, 100, 70, 20,
            hwnd,(HMENU) NULL, NULL, NULL);

SendMessage  (
    hWndComboBox  ,
    (UINT) CB_ADDSTRING,
    (WPARAM) 0, (LPARAM) TEXT ("Apple"));

SendMessage  (
    hWndComboBox ,
    (UINT) CB_ADDSTRING,
    (WPARAM) 0, (LPARAM) TEXT ("Apple juice"));

    SendMessage (hWndComboBox , CB_GETCURSEL , (WPARAM) 0, (LPARAM) 0);









在这里,我不能做的是没有像搜索水果这样的默认单词,当用户开始输入时,它会清除。此外,当用户选择Apple并单击处理按钮时,不会显示任何对话框。我不知道如何根据用户输入调用消息框进行响应。此外,搜索框右侧的小搜索图标。



请问我该怎么办?我使用的是win32 API代码:Blocks。任何进一步澄清的问题都是值得欢迎的。任何链接或答案都是最受欢迎的。谢谢大家。



我尝试了什么:



我有搜索谷歌的解决方案,但无济于事。我自己也设置了一些代码。





Here, what I cannot do is that there is no default word like "Search Fruits" which clears when the user begins to type. Moreover, when the user selects 'Apple' and clicks on the 'Process' button, no dialog box is displayed. I do not know how to call the message box to respond depending on the user inputs. And also, the small search icon on the right of the search box.

Please what should I do? I am using win32 API Code:Blocks. Any further question for clarification is welcome. Any link or answer is most welcome. Thank you all.

What I have tried:

I have searched Google for solutions but to no avail. I have setup some codes myself too.

推荐答案

我认为这就是你要找的东西



Win32 SDK C自动完成Combobox轻松 [ ^ ]



I think that this is what you are looking for

Win32 SDK C Autocomplete Combobox Made Easy[^]

引用:

我不能做的是没有像搜索这样的默认词水果当用户开始输入时会清除。

what I cannot do is that there is no default word like "Search Fruits" which clears when the user begins to type.





一旦你掌握了组合框的编辑控件,就可以发送 EM_SETCUEBANNER消息(Windows) [ ^ ]到它需要最低限度的Windows Vista(以及常用的控件清单)



Once you got the handle of combobox's edit control you can send a EM_SETCUEBANNER message (Windows)[^] to it

but this requires minimum Windows Vista (and a common controls manifest )


这篇关于如何使用代码:blocks在win32 API中创建搜索栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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