|
Now my programs is acting really weird. What worked before now displays a "User breakpoint" error when i move my mouse over the "open file" dialog. Here's my browse dialog which worked fine before:
void OnBrowse()
{
OPENFILENAME ofn;
char szFileName[MAX_PATH+1];
const char szFilter[] = "All Files (*.*)\0" "*.*\0";
szFileName[0] = '\0';
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = ghMainWnd;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = (LPSTR)NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = sizeof(szFileName);
ofn.lpstrFileTitle = NULL;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = (LPSTR)NULL;
ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = "";
if (GetOpenFileName(&ofn))
SetDlgItemText(ghMainWnd, IDC_SOURCEFILE, szFileName);
}
It worked fine before, but now when i have added a new function which should execute after the OnBrowse function is done, i get a "User breakpoint" message when i move my mouse over the dialog:
Unhandled exception at 0x77f767cd in MP3.exe: User breakpoint.
Here's the contents of the Call Stack when the erros appears:
ntdll.dll!77f767cd() <- stops here
ntdll.dll!77fa2f17()
ntdll.dll!77f842f4()
ntdll.dll!77f635c7()
msms001.vwp!017b7b68()
msms001.vwp!017b7539()
msms001.vwp!017afcf7()
vct3216.dll!00c34326()
And this appears in the Output pane:
HEAP[MP3.exe]: Invalid Address specified to RtlFreeHeap( 01810000, 01814270 )
Unhandled exception at 0x77f767cd in MP3.exe: User breakpoint.
All help is appreciated.
-Rune Svendsen
|
|
|
|
|
You actually should be thankful for the user-breakpoint: it is called by the debug-version of your program, because an assert failed. RtlFreeHeap even tells you why it failed: you're trying to free a memory-block that either has been damaged or was never allocated. RtlFreeHeap knows this because it puts a signature before and after each allocated block and the signatures before the block you're trying to free don't match.
Figure out which variable is being mishandled, and your program will stop acting weird.
When you say it 'worked before', you're probably saying it worked in release-build: no assertions are being performed, and the RT will be happy to free anything you ask it to, even things that were never allocated.
|
|
|
|
|
Thanks for your help. But how is it possible to find out what variable is being mishandled when the error happens when i move my mouse over the dialog created by the GetOpenFileName API?
Thanks
|
|
|
|
|
Hi all,
I need to compare 2 strings,one is a simple character string and the other is a LPWSTR value.How can I do it.Is there any type conversion available.
Thanks
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
You will need to convert one of the strings into the same format as the other. Which one you choose does not matter.
Use one of these functions:
MultiByteToWideChar
WideCharToMultiByte
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Isn't it best to convert the single-byte to wide-format? If conversion from wide- to single-byte format looses information (because some widechars are not representable), the strings might match after conversion, even if they don't actually match... No?
|
|
|
|
|
example:
USES_CONVERSION;
LPCSTR s1 = "Hello World!";
LPCWSTR s2 = L"Hello World!";
int i = _tcscmp(A2CT(s1), W2CT(s2));
There is other ways, but more complicated.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Good day all
I was wondering if someone could help with this. I need to find a way of checking to see that if my application that I built is currently running? Any information would be a great help.
Thanks.
|
|
|
|
|
Just use the prevInstance member value of the App object.
If (App.prevInstance) Then
MsgBox "This is the second instance of your app"
End If
When you run your program, the first time, nothing will happen, the second time you will get a message box indicating that there is a previous instance of your app running.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I wanna find my articles which I wrote in this fourm some days ago ,how could I do that?thx
YES, I am here.
|
|
|
|
|
You mean old forum posts?
Look at the top of the page on the left, under the Options it should display your username. Click on that to get to your profile page.
From there, click the "Messages Posted" link, and it'll show all the posts you've made
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
u can try to search for it, using the search in the top of the thread page on the right if u know ur name is enough!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
It seems that I could not find with set my name as the keyword in this fourm.
YES, I am here.
|
|
|
|
|
My custom database class has this destructor:
~DbClass()
{
Close();
m_pConn.Release();
m_pConn = NULL;
m_strConnection = _T("");
<code> if(m_pConnPhoto )
{
if(m_pConnPhoto->GetState() != ADO::adStateClosed)
m_pConnPhoto->Close();
}
m_pConnPhoto.Release();
m_pConnPhoto = NULL;
m_strConnection1 = _T("");</code>
::CoUninitialize();
}
I added the stuff in red to a preexisting sample, so I'm not sure if it looks okay.
Anyways I made a MyDBClass m_db variable in the doc of my mfc mdi app. So far I havent deleted (??) it anywhere. Not even sure if I need to destroy or delete it, or take care of it somehow...
What do you think?
Thanks,
ns
|
|
|
|
|
for every new there's a delete somewhere...else there's no need I feel. If you need a delete put it in the CMyAppDoc::OnCloseDocument() override.
|
|
|
|
|
Hi all,
I want to use IDiskQuotaControl interface to set per user quota on a network shared volume. But I need include the lib into my project which implement the interface.
Which lib is that?
Thanks for your answer.
Laura
|
|
|
|
|
You don't need a specific lib, CoCreateInstance with CLSID CLSID_DiskQuotaControl should work.
Look! They have the Internet on computers now! (Homer J. Simpson)
|
|
|
|
|
I tried, but always got link error 2001:
Execution.obj : error LNK2001: unresolved external symbol _CLSID_DiskQuotaControl
Execution.obj : error LNK2001: unresolved external symbol _IID_IDiskQuotaControl
|
|
|
|
|
try __uuidof(DiskQuotaControl) and __uuidof(IDiskQuotaControl) instead.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Yes I find a sample code for this.
just add #define INITGUIDS
(like _uuid())
Thanks you all.
|
|
|
|
|
Hello there,
How can i make a Right aligned RichEdit box, programically ??
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi,
I have some problem with this query i execute under visual C++6.0
"SELECT Nom, CodePostal, Sum(Montant) AS MontantRemb, DateTraitement <br />
FROM TClient GROUP BY Nom, CodePostal, Montant,DateTraitement <br />
HAVING (((DateTraitement)=#09/05/2002#));"
In Microsoft Access interface it work well but if i execute it via ODBC like this :
retcode = SQLExecDirect(m_hstmt,(SQLCHAR*)strSQL, SQL_NTS);
this isntruction work also but i have a problem with SQL Fetch:
while (( retcode = SQLFetch(m_hstmt))!= SQL_NO_DATA)<br />
{ <br />
SQLGetData(m_hstmt, 1, SQL_C_CHAR, szNomClient, 25, &cbName);<br />
SQLGetData(m_hstmt, 2, SQL_C_CHAR, szCodePostal, 6, &cbName);<br />
SQLGetData(m_hstmt, 3, SQL_C_CHAR, szMontant, 16, &cbName);<br />
SQLGetData(m_hstmt, 4, SQL_C_CHAR, szDateTraitement, 11, &cbName);<br />
} Here retcode return 100 and i can't obtain my data
Thanks in advance for any help
|
|
|
|
|
Are you sure your datatypes in the calls to SQLGetData() are correct? Your select statement has column #3 as Sum(Montant). Without knowing your table structure, I'm guessing Montant is a numeric field, in which case you'll want to use something like SQL_C_ULONG with a size of 4 bytes. Your date field, the 4th column, would also have a problem. That should go with SQL_C_TYPE_TIMESTAMP, assuming it's stored as a date field in your table and not a string. SQL_C_CHAR is only used for character (string) columns.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Hello,
I am trying to pass a file through a Socket plus I would like to send the name of the file also.. Here is my source for sending the file. (I'll tell you my problem at the end)
void CClientDlg::OnBAttach()
{
CSocket* cSocket = new CSocket();
cSocket->Create();
cSocket->Connect((LPCTSTR(m_strServerIP)),m_iFtPort);
static char BASED_CODE szFilter[] = "All Files (*.*)|*.*||";
CString strPath;
CFileDialog m_ldFile(TRUE,".*",strPath,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);
m_ldFile.m_ofn.lpstrInitialDir = _T("C:\\");
if (m_ldFile.DoModal() == IDOK)
{
strPath = m_ldFile.GetPathName();
CFile myFile;
myFile.Open(strPath, CFile::modeRead | CFile::typeBinary);
long nRead;
do
{
byte* data = new byte[4096];
nRead = myFile.Read(data, 4096);
cSocket->Send(data, nRead);
delete data;
}
while (nRead > 0);
myFile.Close();
}
cSocket->Close();
delete cSocket;
}
And for my Receive function on the "Server" side
long nRead;
do
{
byte* data = new byte[4096];
nRead = pSocket->Receive(data, 4096);
m_destFile.Write(data, nRead);
delete data;
}
while (nRead > 0);
I can't figure out a good way to get the file name, plus when I receive the file like this, sometimes the file ends up a few bytes longer than the source(sending) file and sometimes the file comes across perfect..
On my accept function I create a pre defined file for receiving and I open it for reading.. then in my receive I start writing to the file. When the client disconnects I close the file.. This just doesn't seem like a good way to pass files through a socket.. anyone have any better ways of doing this. I have been beating my head against the wall for days. I can't find any examples on MSDN and I found only 1 example at codeguru.com
Thanks for any suggestions.
Rob
|
|
|
|
|
To send across the file name, you could prepend the file's data with the file's name in a header struct, which appears to be what you were starting to do. Your receive code would have to be more intelligent in this case... instead of just dumping whatever it receives over the socket into a file, you'd have to look for the header first and then continue on.
It's important that your receive code only pulls in the header initially, and that it doesn't spill over into the file data. That's what
nRead = pSocket->Receive( byBuffer + nPos, sizeof( FileHeader ) - nPos );
nPos += nRead;
</code>
is doing in the following pseudo code. It will only read at a maximum sizeof( FileHeader ) bytes. You can't assume that you'll get all of those bytes in one pass, however, which is why you still have to put it in a do..while.
typedef struct
{
char szFileName[_MAX_PATH];
} FILE_HEADER, *LPFILE_HEADER;
send_code()
{
... Get the file name
#define BUFFER_SIZE 4096
long nRead = 0;
BYTE byBuffer[BUFFER_SIZE];
FILE_HEADER FileHeader;
strcpy( FileHeader.szFileName, myFile.GetFileName() );
cSocket->Send( dynamic_cast< LPVOID >( &FileHeader ), sizeof( FileHeader ));
do
{
nRead = myFile.Read( byBuffer, BUFFER_SIZE );
cSocket->Send( byBuffer, nRead );
} while( nRead > 0 );
... clean up
}
receive_code()
{
long nRead = 0;
long nPos = 0;
BYTE byBuffer[BUFFER_SIZE];
FILE_HEADER FileHeader;
do
{
nRead = pSocket->Receive( byBuffer + nPos, sizeof( FileHeader ) - nPos );
nPos += nRead;
} while( (nPos < sizeof( FileHeader )) && (nRead > 0) );
if( nPos != sizeof( FileHeader ) )
{
return;
}
... create file with FileHeader.szFileName
do
{
nRead = pSocket->Receive( byBuffer, BUFFER_SIZE );
destFile.write( byBuffer, nRead );
} while( nRead > 0 );
}
</code>
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|