回复 2楼 ab1034982749
#include "stdafx.h"
#include <windows.h>
#include <windowsx.h>
#include "resource.h"
#include "MainDlg.h"
BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);
HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);
}
return FALSE;
}
BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
return TRUE;
}
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDC_BUTTONADD:
TCHAR INPUT1[ 256 ];
HWND hwndcombo = GetDlgItem( hwnd, IDC_COMBOINF );
GetDlgItemText( hwnd, IDC_EDITADD, INPUT1, sizeof( INPUT1 ) );
ComboBox_InsertString( hwndcombo, -1, INPUT1 );
break;
case IDC_BUTTONDEL:
HWND hwndcombo = GetDlgItem( hwnd, IDC_COMBOINF );
int index = ComboBox_GetCurSel( hwndcombo );
ComboBox_DeleteString( hwndcombo, index );
break;
case IDC_BUTTONSEARCH:
TCHAR INPUT2[ 256 ];
HWND hwndcombo = GetDlgItem( hwnd, IDC_COMBOINF );
GetDlgItemText( hwnd, IDC_EDITSEARCH, INPUT2, sizeof( INPUT2 ) );
int search = ComboBox_FindStringExact( hwndcombo, -1, INPUT2 );
ComboBox_SetCurSel( hwndcombo, search );
break;
default:
break;
}
}
void Main_OnClose(HWND hwnd)
{
EndDialog(hwnd, 0);
}