Click here to Skip to main content
16,010,523 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMetafile Header Pin
Anthony98873-Jan-03 18:40
Anthony98873-Jan-03 18:40 
QuestionBizarre...help please anyone? Pin
Brian Tietz3-Jan-03 17:21
Brian Tietz3-Jan-03 17:21 
AnswerRe: Bizarre...help please anyone? Pin
Michael Dunn3-Jan-03 20:15
sitebuilderMichael Dunn3-Jan-03 20:15 
GeneralRe: Bizarre...help please anyone? Pin
Brian Tietz4-Jan-03 5:33
Brian Tietz4-Jan-03 5:33 
GeneralDirectX ActiveX Control Pin
IMMASARA3-Jan-03 17:10
IMMASARA3-Jan-03 17:10 
QuestionSave into directory using what class? Pin
brandon18793-Jan-03 17:05
brandon18793-Jan-03 17:05 
AnswerRe: Save into directory using what class? Pin
xxhimanshu3-Jan-03 17:23
xxhimanshu3-Jan-03 17:23 
GeneralSTL List Problem Pin
Mark_Vandeberg3-Jan-03 16:28
Mark_Vandeberg3-Jan-03 16:28 
Can anyone Help
I am having problems adding a filter to my STL List the problem is in the function
AddFilter.
The char string FilterName is not being added correctly in the statement mfilter.push_back(FilterName);
by replacing the variable FilterName for literals there is no problem.
When debuging the previus is always the current FilterName it appears the reference the same location.

The code below shows what i have implemented please take a look and let me know where I mest up.

Any Help would be appreciated
Thanks

//----------------------------------------------------------------------------
// Mesage handler for Filter box.
//----------------------------------------------------------------------------
LRESULT CALLBACK Filter(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
HWND hwndList;
int iSel;
int cIndex;
int success;

switch (message)
{
case WM_INITDIALOG:
hwndList = GetDlgItem(hDlg, IDC_FILTERLIST);
if(nFilters > 0)
{
char tmp[MAX_FILTER_LENGTH];
for(FilterIterator = mfilter.begin();
FilterIterator != mfilter.end();
FilterIterator++)
{
strcpy(tmp, *FilterIterator);

iSel = (INT)SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)tmp);
SendMessage(hwndList, IDC_FILTERLIST, iSel, (LPARAM)tmp);
}
}
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
success = FALSE;
switch (wmId)
{
case IDOK:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
break;
case IDCANCEL:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
break;
case IDC_ADD_STRING:
char tmpfilter[MAX_FILTER_LENGTH];
GetDlgItemText(hDlg, IDC_NEWFILTER, (LPTSTR)tmpfilter, strlen(tmpfilter));
success = AddFilter(tmpfilter);
if (success == TRUE)
{
hwndList = GetDlgItem(hDlg, IDC_FILTERLIST);
iSel = (INT)SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)tmpfilter);
SendMessage(hwndList, IDC_FILTERLIST, iSel, (LPARAM)tmpfilter);
SetDlgItemText(hDlg, IDC_NEWFILTER, "");
}
break;
case IDC_FILTERLIST:
if (wmEvent == LBN_DBLCLK)
{
MessageBox(hDlg, "ListBox", "LISTBOX", MB_OK);
hwndList = GetDlgItem(hDlg, IDC_FILTERLIST);
cIndex = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
FilterIterator = mfilter.begin();
advance(FilterIterator, cIndex);
mfilter.remove(*FilterIterator);
SendMessage(hwndList, LB_DELETESTRING, cIndex, 0);
}
break;
}
}
return FALSE;
}
//----------------------------------------------------------------------------
// Function AddFilter
//----------------------------------------------------------------------------

BOOL AddFilter(char* FilterName)
{
bool RetCode;
// abort if too many filters
if( nFilters >= MAX_FILTERS )
{
RetCode = FALSE;
}
else
{
int fSize = strlen(FilterName);
if( fSize >= 1)
{

// This is the code which fails
mfilter.push_back(FilterName);

// This section proves the data is written to the list and is diplayed correctly when the
//filter dialog is opened calling Filter(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)

if(nFilters == 0)
mfilter.push_back("One");
else if(nFilters == 1)
mfilter.push_back("Two");
else if(nFilters == 2)
mfilter.push_back("Three");
else
mfilter.push_back("Else");
//
nFilters++;
RetCode = TRUE;
}
}
return RetCode;
}
GeneralRe: STL List Problem Pin
Anonymous3-Jan-03 22:40
Anonymous3-Jan-03 22:40 
GeneralRe: STL List Problem Pin
Mark_Vandeberg4-Jan-03 4:13
Mark_Vandeberg4-Jan-03 4:13 
GeneralWindow style problem Pin
IGx893-Jan-03 15:31
IGx893-Jan-03 15:31 
QuestionHow to replace the ScrollBar on a List & Combo Box Pin
MaTrIX2k23-Jan-03 13:01
MaTrIX2k23-Jan-03 13:01 
AnswerRe: How to replace the ScrollBar on a List & Combo Box Pin
Gary R. Wheeler4-Jan-03 3:12
Gary R. Wheeler4-Jan-03 3:12 
GeneralRe: How to replace the ScrollBar on a List & Combo Box Pin
MaTrIX2k24-Jan-03 12:45
MaTrIX2k24-Jan-03 12:45 
GeneralRe: How to replace the ScrollBar on a List & Combo Box Pin
Gary R. Wheeler5-Jan-03 2:08
Gary R. Wheeler5-Jan-03 2:08 
QuestionPhotoshop and Alias/Handle/FSSpec ?? Pin
Anonymous3-Jan-03 12:54
Anonymous3-Jan-03 12:54 
Generaltime mesure Pin
aguest3-Jan-03 11:25
aguest3-Jan-03 11:25 
GeneralRe: time mesure Pin
Hesham Amin3-Jan-03 21:33
Hesham Amin3-Jan-03 21:33 
GeneralRe: time mesure Pin
Anonymous4-Jan-03 12:09
Anonymous4-Jan-03 12:09 
Questionincreasing InfoTip duration ? Pin
scott sanders3-Jan-03 11:03
scott sanders3-Jan-03 11:03 
AnswerRe: increasing InfoTip duration ? Pin
Ravi Bhavnani4-Jan-03 11:01
professionalRavi Bhavnani4-Jan-03 11:01 
GeneralGetting text from user Pin
Anonymous3-Jan-03 10:45
Anonymous3-Jan-03 10:45 
GeneralRe: Getting text from user Pin
David Salter3-Jan-03 10:53
David Salter3-Jan-03 10:53 
GeneralRe: Getting text from user Pin
Anonymous3-Jan-03 11:42
Anonymous3-Jan-03 11:42 
GeneralRe: Getting text from user Pin
IGx893-Jan-03 16:40
IGx893-Jan-03 16:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.