|
Ok, it's the m_vszIPAddr variable I'm suspicious about, or rather its container since the variable itself is not a pointer.
The reason why I think this is suspicious is you get an access violation, which usually means a pointer referencing out-of-bounds memory e.g. a very low address.
Since you get the assertion inside the std::vector::size() function, which only operates on internal operators that doesn't reference memory outside the vector elements if initialized properly, my guess is that somehow the vector has not been initialized properly.
As the vector itself is not a pointer, it should be initialized when its container is created and that's why I'm curious about the container.
In your CAlinksRemoteControl::ScanForUnits() you must access the vector in some way, probably calling push_back() to add a new "unit".
I would also like to see the code for allocating memory for a new "unit", how data is assigned to it and how it is inserted into the vector.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
One thing I have tried is moving the WSAStartup to the main initDialog function and the app goes through. Any ideas????
jim
|
|
|
|
|
jimjim733 wrote: Any ideas?
Nope.
I suggest you follow the call chain into ScanForUnits() from OnInitDialog() in debug mode. Verify that all objects operated on are created properly.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi,
I am using tab control in my dialog application. I need to change the background color for the tabs. I wrote DrawItem metho in CTabCtrl derived class. But the tab color is not changing. Please help me.
|
|
|
|
|
do you well defined the code snippet? what programming language is that?
|
|
|
|
|
Maito Gai wrote: what programming language is that?
C++/MFC
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
aaaaaaoooooooouuuuccccchhhhh there's so many forums I've replied to some tips here.... from diff sections and I've forgot it is in C++/MFC section
|
|
|
|
|
Maito Gai wrote: so many forums
which forums!
Maito Gai wrote: from diff sections and I've forgot it is in C++/MFC section
A title is present at the top of the page for every forum, please do read it next time onwards. and the number of messages posted by you reads 9 in ur profile out of which 2 belong to this thread
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Maybe... I'm blind now with C# and C++
|
|
|
|
|
I guess we are on the c++ forum and I think hari said CTabCtrl,can you need to more help.
|
|
|
|
|
|
Hi all,
In my application i m taking help of this article.
http://www.codeproject.com/KB/tree/CFolderTreeCtrl.aspx?msg=2674697#xx2674697xx[^]
Here no coding done for KeyDownFunction.
I want to perform same action as of LButtonDown of this project.
i m try my lavel best but i m not succeed so please help me for this.
And tell how can i perform same action on Space key down same as LButton down.
I m already ask this question to author of this article.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Can you use SendMessage API with WM_LBUTTONDOWN when the space key is pressed?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
No sir,
PLease tell me how can i do this
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
And the reason for not being able to do so is...?
Is capturing a key down event a problem or sending the message?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote: And the reason for not being able to do so is...?
...too lazy ; or not smart enough
|
|
|
|
|
Hi all,
I've got a problem which I can't seem to solve on my own...
My programm is dialog based and multi-threaded and I create a new dialog with
m_pPlainText->Create (IDD_PLAINTEXT_DLG);
m_pPlainText->SetIcon (AfxGetApp ()->LoadIcon (IDR_MAINFRAME), FALSE);
m_pPlainText->ShowWindow (SW_SHOWMAXIMIZED);
The first time I open this dialog it works fine, but when I try to open it for again I get the error: "Debug Assertion Failed" in file "f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\winocc.cpp"
The problem was followed back to this line of code in dlgcore.cpp
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);
If the error is ignored the dialog is built correctly. I have no idea what the problem could be, the only thing I could find in the internet concerning this message was about custom controls, but I don't have one in my dialog.
I'd really appreciate any help that could lead me the right way.
|
|
|
|
|
What's the code at the point the assertion fails?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
sorry for answering so late, but I waited for the mail that someone posted an answer and just found it in my spam folder...
The assertion fails in the following line
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);
I can still get into the function where it returns the pParentWnd->GetSafeHwnd() and when it returns to the line posted obove it fails on the next step. That is the strange thing. Sorry if I can't explain it so detailed but I hope you can understand what I mean.
Greetings
|
|
|
|
|
There's no ASSERT macros on that line.
I meant the actual line of code with the statement
with the assertion.
Without it, it's really hard to guess
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Stupid me, I finally found the ASSERT.
BOOL CWnd::SetWindowPos(const CWnd* pWndInsertAfter, int x, int y, int cx,
int cy, UINT nFlags)
{
ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
if (m_pCtrlSite == NULL)
return ::SetWindowPos(m_hWnd, pWndInsertAfter->GetSafeHwnd(),
x, y, cx, cy, nFlags);
else
return m_pCtrlSite->SetWindowPos(pWndInsertAfter, x, y, cx, cy, nFlags);
}
m_hWnd is NULL... Do you know what the reason could be?
Sorry for anwering so late again... Took some time to figure that out and I can't just keep on just looking for that thing all the time.
Greetings from Germany,
Armin
|
|
|
|
|
Member 3554668 wrote: Do you know what the reason could be?
The HWND associated with the CWnd-based object hasn't
been successfully created.
You could put a breakpoint at the Create() call and step into
the MFC code to see where it fails. For a dialog, it typically fails
if the dialog resource isn't found.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Now, that is what I did before, isn't it? I put a breakpoint at the Create function and ended at the lines i posted before. I can't get any deeper. If I make the next step the assertion already failed and visual studio sets a breakpoint at the assert.
I must admit that I don't yet understand all this HWND and CWnd stuff.
The strange thing is, that if I press ignore when the assertion failed the window is build just like the way it should and in release mode everything works perfectly. But I don't dare to just ignore the problem and keep on building my programm.
Armin
|
|
|
|
|
Member 3554668 wrote: Now, that is what I did before, isn't it?
Maybe, but now you're showing the assertion in SetWindowPos(), which
shouldn't be called until AFTER the window is created.
What does the call stack look like where the assertion
fails in CWnd::SetWindowPos()? i.e. Who's calling
SetWindowPos() before the HWND is valid?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey Mark,
very good hint to look in the call stack window. Good news is, I know now where the problem is, bad news is that I don't have a clue yet how to solve it.
I overwrote the function OnSize to adjust the size of the rich edit controls on my dialog.
void CPlainText::OnSize(UINT nType, int cx, int cy)
{
static BOOL bResize = FALSE;
CResizingDialog::OnSize(nType, cx, cy);
RECT rectDlg;
GetClientRect(&rectDlg);
if (bResize)
{
if (m_bSynchronize)
{
m_ctlPlainText.SetWindowPos(NULL, 10, 140, (rectDlg.right/2)-20, rectDlg.bottom-180, SWP_NOZORDER );
m_ctlPlainText2.SetWindowPos(NULL, (rectDlg.right/2), 140, (rectDlg.right/2)-10, rectDlg.bottom-180,SWP_NOZORDER | SWP_SHOWWINDOW);
}
else
{
m_ctlPlainText.SetWindowPos(NULL, 10, 140, rectDlg.right-20, rectDlg.bottom-180, SWP_NOZORDER | SWP_SHOWWINDOW);
}
}
bResize = TRUE;
}
I noticed that the OnSize function gets called before the dialog is completly created and causes an causes this ASSERT to fail so I tried to solve it with the little workaround with the BOOL bResize. I don't know how I could forget that. I didn't think about that the static variable is still initialised after the dialog has been closed... Do you know a more elegant solution?
Thanks for all your help so far!
|
|
|
|