Click here to Skip to main content
15,902,634 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: regards avtivex control Pin
ThatsAlok1-Apr-07 21:11
ThatsAlok1-Apr-07 21:11 
QuestionDyanmic tab Pin
deeps_cute30-Mar-07 18:18
deeps_cute30-Mar-07 18:18 
AnswerRe: Dyanmic tab Pin
Naveen30-Mar-07 18:45
Naveen30-Mar-07 18:45 
GeneralRe: Dyanmic tab Pin
deeps_cute30-Mar-07 22:46
deeps_cute30-Mar-07 22:46 
GeneralRe: Dyanmic tab Pin
Naveen30-Mar-07 22:50
Naveen30-Mar-07 22:50 
GeneralRe: Dyanmic tab Pin
prathuraj31-Mar-07 1:54
prathuraj31-Mar-07 1:54 
GeneralRe: Dyanmic tab Pin
Naveen1-Apr-07 17:09
Naveen1-Apr-07 17:09 
QuestionProblem with Pointers Pin
CoffeeAddict1930-Mar-07 13:35
CoffeeAddict1930-Mar-07 13:35 
This problem cropped up after I converted the dialog from modal to non-modal, so that might have something to do with it. The question: why should I have to call GetDlgItem to get a pointer to a dialog box control in every function instead of just once in OnInitDialog?

I've got these pointers in my modeless dialog box header file:

CListBox* ExpressionsListBoxPtr;
CListBox* FiltersListBoxPtr;
CListBox* TargetsListBoxPtr;


All were initialized to null by the constructor. In OnInitDialog() I put this (I checked to make shure OnInitDialog got called, and that the pointers were not null afterwords):

ExpressionsListBoxPtr = (CListBox*)(GetDlgItem(IDC_DLGS_EXPRESSIONLISTBOX));
FiltersListBoxPtr = (CListBox*)(GetDlgItem(IDC_DLGS_FILTERLISTBOX));
TargetsListBoxPtr = (CListBox*)(GetDlgItem(IDC_DLGS_TARGETLISTBOX));


The issue is that when I execute this fuction I get a debug assertation error and I've determined that the class level pointers are the source of the problem. I have worked around it by calling GetDlgItem in the function itself instead of just in OnInitDialog:

afx_msg void CRatiosNewSearchDialog::OnAddFilter()
{
	CListBox* TempListBoxPtr = (CListBox*)(GetDlgItem(IDC_DLGS_EXPRESSIONLISTBOX));
	//int CurrentSelection = ExpressionsListBoxPtr->GetCurSel();
	int CurrentSelection = TempListBoxPtr->GetCurSel();
	
	int Pos = 0;
	CString Expression = "";

	if(CurrentSelection == LB_ERR)
		MessageBox("You must select an expression before you can add a filter. LB_ERR.", "User Error", MB_ICONHAND);
	else //everything is cool, add the expression to the filter list box
	{
		ExpressionsListBoxPtr->GetText(CurrentSelection, Expression);
		Pos = Expression.Find(" - ", 0);
		Expression.Delete(0, Pos + 3);
		Pos = FiltersListBoxPtr->AddString(Expression);
		ResetListboxScrollbar(FiltersListBoxPtr);
		FiltersListBoxPtr->SetCurSel(Pos);
	}
}


Can anyone tell me why it is not letting me just call GetDlgItem once when the dialog pops up instead of making me call it every time I want to use a control?
AnswerRe: Problem with Pointers Pin
cp987630-Mar-07 13:49
cp987630-Mar-07 13:49 
GeneralRe: Problem with Pointers Pin
CoffeeAddict1931-Mar-07 19:17
CoffeeAddict1931-Mar-07 19:17 
GeneralRe: Problem with Pointers Pin
cp987631-Mar-07 20:42
cp987631-Mar-07 20:42 
QuestionDoes VS 2005 Standard Edition support services Pin
dburns30-Mar-07 10:36
dburns30-Mar-07 10:36 
AnswerRe: Does VS 2005 Standard Edition support services Pin
George L. Jackson30-Mar-07 11:26
George L. Jackson30-Mar-07 11:26 
GeneralRe: Does VS 2005 Standard Edition support services Pin
dburns30-Mar-07 11:55
dburns30-Mar-07 11:55 
QuestionWhy? Pin
_808630-Mar-07 6:35
_808630-Mar-07 6:35 
AnswerRe: Why? Pin
jeron130-Mar-07 6:52
jeron130-Mar-07 6:52 
AnswerRe: Why? Pin
Mark Salsbery30-Mar-07 6:54
Mark Salsbery30-Mar-07 6:54 
GeneralRe: Why? Pin
_808630-Mar-07 22:02
_808630-Mar-07 22:02 
AnswerRe: Why Not? Pin
led mike30-Mar-07 8:53
led mike30-Mar-07 8:53 
Questioncompiling linux programs on windows xp Pin
shiraztk30-Mar-07 5:33
shiraztk30-Mar-07 5:33 
AnswerRe: compiling linux programs on windows xp Pin
shiraztk30-Mar-07 5:42
shiraztk30-Mar-07 5:42 
GeneralRe: compiling linux programs on windows xp Pin
Chris Losinger30-Mar-07 10:07
professionalChris Losinger30-Mar-07 10:07 
AnswerRe: compiling linux programs on windows xp Pin
Cedric Moonen30-Mar-07 7:19
Cedric Moonen30-Mar-07 7:19 
AnswerRe: compiling linux programs on windows xp Pin
led mike30-Mar-07 8:56
led mike30-Mar-07 8:56 
GeneralRe: compiling linux programs on windows xp Pin
Mark Salsbery30-Mar-07 15:07
Mark Salsbery30-Mar-07 15:07 

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.