日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Win32程序中使用Combo box控件

發(fā)布時間:2024/4/18 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Win32程序中使用Combo box控件 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

第一次使用win32寫代碼,將代碼中對Combo box 控件的使用做個總結(jié):


1. ? 使用SendMessage向窗口發(fā)送消息,對Combo Box進行基本操作如添加數(shù)據(jù),刪除數(shù)據(jù),得到所選Item的值等,請參考:

? ? ???http://blog.csdn.net/qiurisuixiang/article/details/6746234


2. 使Combo box控件可見或不可見,需使用EnablkeWindow函數(shù):

? ? EnableWindow(hCombo,TRUE);

? ? EnableWindow(hCombo,FALSE);


3. 響應Combo box的Notification message,比如選擇Combo box中一個不同于當前的Item時,會響應CBN_SELCHANGE消息。

MSDN的解釋:

CBN_SELCHANGE Notification


The?CBN_SELCHANGE?notification message is sent when the user changes the current selection in the list box of a combo box. The user can change the selection by clicking in the list box or by using the arrow keys. The parent window of the combo box receives this notification in the form of aWM_COMMAND?message with?CBN_SELCHANGE?in the high-order word of the?wParam?parameter.

Syntax

CBN_SELCHANGEWPARAM wParamLPARAM lParam;

Parameters

wParam
The low-order word specifies the control identifier of the combo box.

The high-order word specifies the notification message.

lParam
Handle to the combo box.?



Process Message Code:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
????????? int wmId, wmEvent;

????????? switch (message)
????????? {
????????? case WM_COMMAND:

// low-order word specifies the control identifier of the combo box.

?????????????? wmId ? ?= LOWORD(wParam);??

//high-order word specifies the notification message.

?????????????? wmEvent = HIWORD(wParam);
????????????? // 分析菜單選擇:
????????????? switch (wmEvent)
???????????????{
?????????????? case CBN_SELCHANGE:
?????????????????????? if (wmId==IDC_COMBO_MODE) ? //判斷選中的是哪個Combo box
?????????????????????????{

????????????????? ???????????? . . . . . .

??????????????????????? }
?????????????????????? break;
???????????????}
????????????? break;
???????case WM_DESTROY:
??????????????PostQuitMessage(0);
??????????????break;

???????? ?//Although the dialog box procedure is similar to a window procedure,?

????????? //it must not call the?DefWindowProc?function to process unwanted messages
??????? //? default:
??????? //? return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}


總結(jié)

以上是生活随笔為你收集整理的Win32程序中使用Combo box控件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。