|
Frankesk wrote:
Lately I have installed and removed MySQL, MSDE, various ServicePacks, maybe something has been wrong and I didn't notice.
Maybe one of the MFC DLL's has gone back to an old version. About now I'd suggest re-installing VC++.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
I have reinstalled, now all works...
Thanks for your time
|
|
|
|
|
Memory in debug mode is buffered so that memory overflow conditions that can crash in release mode can work fine in debug mode. My first guess is that 'result' does not point to a block of memory of the size you are expecting. Are you sure you allocated sufficient memory for the trailing null character? result will need to point to at least 16 bytes of memory for this code to work properly ( "anything" = 9 s1 = 6 NULL char = 1.)
"There's a slew of slip 'twixt cup and lip"
|
|
|
|
|
Yes it was large enough, 255 chars. The problem is that doesnt crash, but display a string contained in another char-vector, as if they did overlapped, I don't know.
I thought of a NULL terminating that I could have missed so that the string 1 could extend to string 2 that was declared just after, but it's not the case. Turing Optimizations to Default fixes this bug on my machine, while in other pcs runs fine without altering this setting
|
|
|
|
|
Sorry, I did not read the last line in your original post, so I misunderstood the nature of the bug. It sounds to me as though you have a damaged stack. The issue is *still* one of debug mode buffering memory more generously than release mode. You are going to need to trace back through the call stack to figure out where the problem is. Stack overflow bugs can cause all kinds of bizarre issue like this. Good hunting.
"There's a slew of slip 'twixt cup and lip"
|
|
|
|
|
Which SP are you running for VC6? Either SP5 or SP6 is the latest.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
|
i need to trap double click of a list control thats in my dialog based application ( min my dialog box). I have a list control class that handles messages. So i handled NM_DBLCLK message and i type casted NMHDR* to NM_LISTVIEW* to the item on which user made dbl clk. this didnt work ( i got iItem = -1 ). So i type casted NMHDR* to NMITEMACTIVATE* and tried getting iItem. I still got -1. So how can i get the item in which dbl clk is made. thanks.
ps:i am running windows2000 and VC++6.0
|
|
|
|
|
Anonymous wrote:
i need to trap double click of a list control
Here's how I handled that situation - I wanted to double click on a list control item and pop it up in a message box. Sorry about the lack of formatting, I'm sure there's a way to do that but...
First, handled NM_DBLCLK,
ON_NOTIFY(NM_DBLCLK, IDC_MSG, OnDblclkMsg)
then,
void CTestAppDlg::OnDblclkMsg(NMHDR* pNMHDR, LRESULT* pResult)
{
// m_lcMsg is the list control
POSITION pos = m_lcMsg.GetFirstSelectedItemPosition();
if (pos) {
int iItem = m_lcMsg.GetNextSelectedItem(pos);
if (-1 != iItem) {
// this is just data that I associated when I added the item
MsgData* pData = (MsgData*)m_lcMsg.GetItemData(iItem);
if (GOOD_PTR(pData, MsgData)) {
MessageBox(pData->strFullMsg);
}
}
}
*pResult = 0;
}
One thing you need to be aware of is that unless you set a flag for selecting the entire row, you must double click on the first column or the click is ignored. You can do that with a call in OnInitDialog() like this:
m_lcMsg.SetExtendedStyle(m_lcMsg.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
Hope this helps...
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|
Rather than using NM_DBLCLK you might need to handle LVN_ITEMACTIVE notification instead. Then you can cast the NMHDR * to a NMITEMACTIVE * without any problems.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
When I play a wav file as a resource, the wav won't play or it will stop play after a VEEEEEERY short time..... Is slow to play as resource or can I put the wavs in a DLL to get it to work??
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Hi, I read the MSDN online and get the following sample of using AfxBeginThread:
UINT MyThreadProc( LPVOID pParam )
{
CMyObject* pObject = (CMyObject*)pParam;
if (pObject == NULL ||
!pObject->IsKindOf(RUNTIME_CLASS(CMyObject)))
return 1; // if pObject is not valid
// do something with 'pObject'
return 0; // thread completed successfully
}
// inside a different function in the program
.
.
.
pNewObject = new CMyObject;
AfxBeginThread(MyThreadProc, pNewObject);
.
.
.
I understand that.....but :
1. if I want to create 50 threads that doing the stuff in MyThreadProc(), how can i do it? Add a for loop to create 50 times???
2. If I want to suspend 10th thread, how can i identify the 10th thread and suspend it?
3. Same as 2....to do resume and kill the thread.
Thank you very much !!!
|
|
|
|
|
ChiYung wrote:
1. if I want to create 50 threads that doing the stuff in MyThreadProc(), how can i do it? Add a for loop to create 50 times???
I think you can create 50 seprate thread instead of creating one and doing 50 thread in it,then when you want to suspend 10th of them,it is so easy.Another easy way is set timer and make it work for example for each 1 second for 50 seconds.Hope that help.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Thanks for your reply!
Yes....I need to create 50 separate threads (liked 50 different transactions). Since my program is going to simulate the DBMS behavior, in the MyThreadProc() there should be some algorithm to choose whether the current operation of this transaction is READ or WRITE. In this case, all 50 threads will use the same MyThreadProc() and i don't need to make 50 different MyThreadProc(). My question is,
1. Can i create these thread by:
for (i=0; i<50; i++)
{
pNewObject = new CMyObject;
AfxBeginThread(MyThreadProc, pNewObject);
}
2. How to identify Xth thread after creating 50 threads?
3. What parameter I need to put in order to suspend/resume/kill the 10th (or Xth) Thread? Because let say, one thread A (transaction) is READING a data object, and another thread B wants to WRITE the same data object. In this case, thread B needs to wait until thread A finish. So I have to suspend thread B......and wait....then resume.
So, should I call AfxGetThread()???? SuspendThread()??? ResumeThread()????
Thanks!!!!
|
|
|
|
|
ChiYung wrote:
How to identify Xth thread after creating 50 threads?
AfxBeginThread will return the CWinThread* for the thread started. That will identify each thread. You can have an array of CWinThread*s
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
Hi,
I need examples..... please..help......
Thank you!!!!!
ChiYung
|
|
|
|
|
How does it works?
Can I use CAsyncSocket and just make a simple C/S app????
How?
I want to make a Client/Server either by using MFC or Win32 API
And it going to work over the internet!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
The machine running the server must be accesible from the internet. Other than that there is not much difference.
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
So you mean, that example application from "Sams Teach Yourself VC++ in 21 days" will work if I put the server on a computer with Internet acces and then call the server with the IP and bla bla....???? Perhaps you don't know how that example works?
But I don't need to set a specific flag to the Create or something?
You article for example... Can I use it over the Internet?
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Rickard Andersson wrote:
You article for example... Can I use it over the Internet?
Yes. You can.
Rickard Andersson wrote:
So you mean, that example application from "Sams Teach Yourself VC++ in 21 days" will work if I put the server on a computer with Internet acces
I never saw that book, but I expect it to work
Nish
p.s. I am surprised that a 21 day VC++ book has a chapter on winsock!!! or were they teaching CSocket stuff?
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
Nish [BusterBoy] wrote:
p.s. I am surprised that a 21 day VC++ book has a chapter on winsock!!! or were they teaching CSocket stuff?
Well, it talks about CAsyncSocket class and how to create a simple Client/Server app to send messages etc.......
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
I have created a simple MDI application with the MFC class wizard. At the moment I have only one view and one document. The view has CListView as a base class. I have disabled the new file option on startup by using
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
The user can either call a add menu option that displays a dialog box with which they can add data to the database, or they can pick a view menu option which will allow them to view all the data added on that particular day. My problem is calling the view from the mainframe menu option. I have read several articles but they all deal with adding documents and views and then swopping between them. I know I'm probably being very dense but have tried the whole of yesterday with no success. .
This is the code I'm using to initialize the List view in myView::OnInitialUpdate.
DWORD dwExStyle;
CRepPartDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//CActionsApp *pApp = (CActionsApp*)AfxGetApp();
CListCtrl& m_List = GetListCtrl();
dwExStyle = m_List.GetExStyle();
dwExStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES;
m_List.SetExtendedStyle(dwExStyle);
m_List.SetBkColor(RGB(255, 255, 255));
ASSERT(m_List.GetBkColor() == RGB(255, 255, 255));
m_List.InsertColumn(0,_T("Share"),LVCFMT_LEFT,160);
m_List.InsertColumn(1,_T("Status"),LVCFMT_LEFT,90);
m_List.InsertColumn(2,_T("Action Date"),LVCFMT_LEFT,90);
m_List.InsertColumn(3,_T("Book Date"),LVCFMT_LEFT,90);
m_List.InsertColumn(4,_T("Comment"),LVCFMT_LEFT,160);
Someone has suggested calling OnFileNew() from my menu handler but no success. Please help! Any suggestions will be more than I have already!
Grasp it but you cannot get it!
It's name is memory..
|
|
|
|
|
Who has used the regexp object in system32\vbscipt.dll to parse the text string. I have tried it and make it work!
But i don't know why i can get only one match(that is the matches.GetCount()==1), even there are many exist. The next is my code:
void CInetSessionDlg::ParsePage(CString szPattern, CString szContent){
try{
if(m_regExp.CreateDispatch(__uuidof(RegExp)) == FALSE)
{
AfxMessageBox("CreateDispatch Failed!");
return;
}
m_regExp.SetIgnoreCase(TRUE);
m_regExp.SetPattern(LPCTSTR(szPattern));
if(m_regExp.Test(LPCSTR(szContent)))
{
ISubMatches matches = m_regExp.Execute(szContent);
for(long i = 0; i < matches.GetCount(); i++)
{
IMatch2 match = matches.GetItem(i);
CString strLink = match.GetValue();
m_cbHref.AddString(strLink); }
}
}
catch(_com_error& e)
{
AfxMessageBox("Com Error occurred!" + e.Description());
return;
}
}
in this implementation file's header file:
i defined the RegExp(copied from the file RegExp.tlh got from vbscript.dll)
struct __declspec(uuid("3f4daca4-160d-11d2-a8e9-00104b365c9f"))RegExp; // [ default ] interface IRegExp2
Why? Who can tell me how to use vbscript.dll in VC++ 6.0
thanks a lot!
Sincerely, Davidlou
davidlou68@hotmail.com
|
|
|
|
|
Please use the <pre> tags
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
Who has used the regexp object in system32\vbscipt.dll to parse the text string. I have tried it and make it work!
But i don't know why i can get only one match(that is the matches.GetCount()==1), even there are many exist. The next is my code:
void CInetSessionDlg::ParsePage(CString szPattern, CString szContent){
try{
if(m_regExp.CreateDispatch(__uuidof(RegExp)) == FALSE)
{
AfxMessageBox("CreateDispatch Failed!");
return;
}
m_regExp.SetIgnoreCase(TRUE);
m_regExp.SetPattern(LPCTSTR(szPattern));
if(m_regExp.Test(LPCSTR(szContent)))
{
ISubMatches matches = m_regExp.Execute(szContent);
for(long i = 0; i < matches.GetCount(); i++) {
IMatch2 match = matches.GetItem(i);
CString strLink = match.GetValue();
m_cbHref.AddString(strLink);
}
}
}
catch(_com_error& e)
{
AfxMessageBox("Com Error occurred!" + e.Description());
return;
}
}
in this implementation file's header file:
i defined the RegExp(copied from the file RegExp.tlh got from vbscript.dll)
struct __declspec(uuid("3f4daca4-160d-11d2-a8e9-00104b365c9f"))RegExp; // [ default ] interface IRegExp2
Why? Who can tell me how to use vbscript.dll in VC++ 6.0
This time, i have tried to use
and hope it will work.
Thank u two friends!
Sincerely, Davidlou
davidlou68@hotmail.com
|
|
|
|