Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,210 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 918 people online right now. Registration is fast and FREE... Join Now!




C++ dictionary program help

 
Reply to this topicStart new topic

C++ dictionary program help, making list box to see the recent input and output

jkkt87
post 12 Mar, 2008 - 06:28 AM
Post #1


New D.I.C Head

*
Joined: 11 Mar, 2008
Posts: 3

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.");

}
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/21/08 08:03PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month