|
guy i need to make a list box so when i type in a word to search definition, i still can see the word tat previously input and its output. i dunno how so plz help for ur kindness. Below is my code.
#include <windows.h> #include <string.h> #include "resource.h"
// global variables declarations HWND hwnd; HINSTANCE hInst;
//functions prototyping LRESULT CALLBACK DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam); void dict(char *english, char *malay); void initstr(char *str,int n); // end of functions prototyping
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC) DlgProc);
hInst = hInstance;
return 0; }
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) {
HWND hwndText, hwndquestion, hwndanswer;
hwndquestion = GetDlgItem(hWndDlg, IDC_QUESTION); hwndanswer = GetDlgItem(hWndDlg, IDC_ANSWER); switch(Msg) { case WM_INITDIALOG: SetWindowText(hwndquestion, ""); SetWindowText(hwndanswer, ""); return TRUE;
case WM_COMMAND: switch(wParam) { case IDOK: char question[240], answer[240]; initstr(question,240); initstr(answer,240); GetWindowText(hwndquestion,question,40); dict(question,answer); SetWindowText(hwndanswer, answer); return TRUE; break;
case IDCANCEL: EndDialog(hWndDlg, 0); return TRUE; } break; } return FALSE; }
void initstr(char *str,int n) { int i; for (i=0;i<n;i++) *(str+i)=0; }
void dict(char * question, char *answer) { if(strstr(question,"transistor")) strcpy(answer,"Transistor is a semiconductor device which applify current.");
if(strstr(question,"computer")) strcpy(answer,"Computer is .......that can help a lot.");
}
|