|
Tarek Jabri wrote: ...i need to know how can i run the registered web browser...
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I create a windows form application named p2pport.
and I want to use the Message Map of MFC.
so I use MFC with shared DLL and include afxwin.h.
But When I compile it, it says that
Debug Assertion Failed
File : dbgheap.c
line 144
Expression : _CrtIsValidHeapPointer(pUserData)
I find it is because of the afxwin.h.
I google it and found that it is a bug that was reported to MSDN.
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99715[^]
I use that method to replace the main function and put #include <afxwin.h> in stdfax.h file.
My original code is
#include "stdafx.h"<br />
#include "Dlg.h"<br />
<br />
using namespace p2pport;<br />
[STAThreadAttribute]<br />
<br />
int main(void)
{<br />
Application::EnableVisualStyles();<br />
Application::SetCompatibleTextRenderingDefault(false); <br />
<br />
Application::Run(gcnew Dlg());<br />
CMFCApp k;<br />
return 0;<br />
}
And I modify it.
#include "stdafx.h"<br />
#include "Dlg.h"<br />
<br />
using namespace p2pport;<br />
<br />
[STAThreadAttribute]<br />
class CMFCApp : public CWinApp<br />
{<br />
public:<br />
virtual BOOL InitInstance()<br />
{<br />
Application::EnableVisualStyles();<br />
Application::SetCompatibleTextRenderingDefault(false);<br />
return FALSE;<br />
}<br />
}theApp;
But it comes the error.
error C3115: 'System::STAThreadAttribute': this attribute is not allowed on 'theApp'
I delete the [STAThreadAttribute] .
It comes another two errors.
error LNK2001: unresolved external symbol _main
fatal error LNK1120: 1 unresolved externals
I dont know how to solve it. I stuck it all day.
Can anybody help me to solve the problem.
Appreciate for ur reply
Thx.
Jane
|
|
|
|
|
|
Hello everyone,
Could dumpbin be used to check whether an executable or a DLL (written in Visual Studio C/C++ native unmanaged) is debug version or release version? I use /headers option but can not see any differences.
If dumpbin can not be used to check debug or release, any other tool could be used?
thanks in advance,
George
|
|
|
|
|
Hi Luc,
Here is my test result, and debug version/release version are of different size.
1. I have dumped debug and release version, the both of them has only one existence of word *debug*, here it is
24000 [ 1C] RVA [size] of Debug Directory
2. See (1);
3. What do you mean *the presence of the PDB file name at the end of the exe*, could you show more information please?
regards,
George
|
|
|
|
|
Hi George,
my hex viewer shows this as the very last few bytes in a debug exe:
01EFF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
01F000 4E 42 31 30 00 00 00 00 53 3D A9 3F 03 00 00 00 "NB10....S=.?...."
01F010 48 3A 5C 4C 50 5F 70 72 6F 6A 65 63 74 73 5C 5F "H:\LP_projects\_"
01F020 70 75 7A 7A 6C 65 73 5C 62 65 65 6C 64 7A 6F 65 "puzzles\beeldzoe"
01F030 6B 65 72 5C 44 65 62 75 67 5C 62 65 65 6C 64 7A "ker\Debug\beeldz"
01F040 6F 65 6B 65 72 2E 70 64 62 00 "oeker.pdb. "
so what I am suggesting is you either use such tool to look, or you programmatically
verify the file ends on "2E 70 64 62 00"
BTW: I am not sure this ".PDB == debug build" relation always holds true
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks Luc,
Both of the binaries contains the word PDB. It is so strange. But the size is different and the bigger one (debug version) is debuggable, and the smaller one (release version) is not debuggable (when pressing F5 in Visual Studio 2005, all the break points set before will become invalid).
Any comments or ideas?
regards,
George
|
|
|
|
|
Hi George, I have one comment: the debug/release divide is not very strict, there are several
compiler and linker switches you can set/clear/specify influencing the kind of code
generated, and the amount of metadata present in the DLL/EXE file.
Visual Studio comes with two predefined configurations, aptly called "Debug" and "Release",
with different switch settings. But you can alter those settings, and you can define
additional configurations.
What is it exactly you hope to achieve?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks Luc,
I agree with your points. My purpose is to debug the application, i.e. when using F5 in Visual Studio 2005 to execute the debug, the application can stop at break points. But currently, when using F5, all the break points will become invalid.
I am wondering why and suspecting some important options (either compile option or link option is missing) which causes this issue.
Any comments or ideas are welcome.
regards,
George
|
|
|
|
|
Thanks Luc!
Sorry that I may not make myself undertood. I am using embedded VC++ 4.0 to develop. Now I installed Visual Studio 2005 and migrate the project files generated by embedded VC++ 4.0 to Visual Studio 2005 using the IDE. But now in Visual Studio 2005 I can not debug it. So, I am confused that there must be some wrong settings which blocks me from debugging in Visual Studio 2005 -- maybe there is something wrong in the migration process or something wrong in the Visual Studio 2005 settings.
regards,
George
|
|
|
|
|
Try Luc's suggestion - create a dmnmy project in VS2005 and then compare the settings between the debug version in that one and your migrated project. I'm sure the problem is in the settings since the eVC uses a subset of VS. Also, make sure your settings for the target windows version are also correct to now target a desktop versus a mobile.
Judy
|
|
|
|
|
Thanks Judy,
Previously, I think the differences between debug and release version is whether the macro DEBUG and _DEBUG are defined. I think I am wrong. There should be more differences -- i.e. simply adding DEBUG and _DEBUG macros to release version project can not produce debug version project.
Do you have any experiences and knowledge to share what is the settings (e.g. compile options, linker options, etc.) which makes debug and relase version different please?
regards,
George
|
|
|
|
|
George_George wrote: Previously, I think the differences between debug and release version is whether the macro DEBUG and _DEBUG are defined. I think I am wrong
Yes, you are wrong. The differences have always been more than just that define. Things like optimizations (/O), information to include in the output file (/Z), which runtime to include (/MT /MD /L) and more.
George_George wrote: Do you have any experiences and knowledge to share what is the settings (e.g. compile options, linker options, etc.) which makes debug and relase version different please?
I've never memorized them. Whenever I've wanted to compare, I create a dummy project and then open it in two different instances of VS, one showing release and the other showing debug and compare them. Or just open up the .dsp file in text mode and compare the two sets of options directly. There are too many to know them all. Take my approach and compare them yourself then look them up in the help and see what each one does to really understand why a given setting is appropriate for which mode.
Judy
|
|
|
|
|
Hi Judy,
Great reply. I think all the configurations which matter is stored in .vcproj file, right (so I only need to compare with two .vcproj file to see any differences)? The .dsp file you mentioned should be some redundancy information of .vcproj file? Right?
I asked this question is because I am wondering if I only compare the two .vcproj files, whether I will miss some important settings which matter.
regards,
George
|
|
|
|
|
.dsp is the project file for VS6 and .vcproj is used for VS2005. I thought you were using 6, my mistake. You're not comparing two different vcproj files, you're comparing two different sections of the same vcproj from your sample project. If you look inside it, you'll find multiple "configuration" sections and within each section, all the different settings.
Judy
|
|
|
|
|
Thanks Judy!
regards,
George
|
|
|
|
|
I put some CEdit to the dialog, use the same function OnChangeEdit1, when the context of edit box is changed,
such as,
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit1)
ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit1)
the problem is, I can not decide which edit box has called the function, How can I get the ID for it?
|
|
|
|
|
Does this code helpful?
void CdddDlg::OnEnChangeEdit1()
{
if(GetFocus()==GetDlgItem(IDC_EDIT1))
MessageBox(_T("editbox1"));
if(GetFocus()==GetDlgItem(IDC_EDIT2))
MessageBox(_T("editbox2"));
}
|
|
|
|
|
...and for a syntactical point of view, you should always put curved braces for if statements, even it then contains only one instruction...
|
|
|
|
|
toxcct wrote: ...and for a syntactical point of view, you should always put curved braces for if statements, even it then contains only one instruction...
I always put curly braces for if statements, even if it would only be a one-liner. About a month ago, however, I started doing one-liners without the braces. I ran into so many problems from doing this. It took me quite a while to get re-accustomed to my old ways. It's funny, you would think it wouldn't cause any problems, but it did for me.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Thank you for your advice.;)
|
|
|
|
|
Step 1. Ensure that IDC_EDIT1,IDC_EDIT2,IDC_EDIT3 are consecutive ID's ie 1001,1002,1003
Step 2. instead of 3 separate ON_EN_CHANGE's inside the ClassWizard part of the MESSAGE_MAP use on ON_CONTROL_RANGE outside of the ClassWizard part of the MESSAGE_MAP
ON_CONTROL_RANGE(EN_CHANGE, IDC_EDIT1, IDC_EDIT3, OnChangeEdit1)
Step 3. change the declaration of OnChangeEdit1 to
void YourClass::OnChangeEdit1(UINT nIDCtl)
see ON_CONTROL_RANGE[^]
|
|
|
|
|
<br />
SqlCmd.Format("SELECT TOP %u * FROM \<br />
(SELECT TOP %u * FROM %s ORDER BY time DESC) as t1 \<br />
WHERE time not in (SELECT TOP %u time FROM %s ORDER BY time DESC) as t2 \<br />
ORDER BY time", \<br />
m_RcPerGrp,m_CntDispRc,m_TableName,tmp,m_TableName);<br />
If I take off
<br />
WHERE time not in (SELECT TOP %u time FROM %s ORDER BY time DESC) as t2<br />
there is no runtime error.
What's wrong?
|
|
|
|
|
the problem is not the SQL command but how you build the string...
you cannot write like you did, but change to this:
SqlCmd.Format("SELECT TOP %u * FROM <code>"</code>
<code>"</code>(SELECT TOP %u * FROM %s ORDER BY time DESC) as t1 <code>"</code>
<code>"</code>WHERE time not in (SELECT TOP %u time FROM %s ORDER BY time DESC) as <code>"</code>
<code>"</code>ORDER BY time",
m_RcPerGrp, m_CntDispRc, m_TableName, tmp, m_TableName);
moreover, you should use parametrized query objects to add some parameters to your query, rather than build a CString yourself...
for your query, i suggest you this optimization:
SELECT TOP :1 *
FROM
(SELECT TOP :2 * FROM :3 ORDER BY time DESC) as t1
WHERE
t1.time NOT IN
(SELECT TOP :4 time FROM :5 ORDER BY time DESC)
ORDER BY t1.time
-- modified at 11:08 Sunday 11th November, 2007
|
|
|
|
|
Thanks very much.
I've never used parametrized query objects.
If it is not difficult, I should follow you suggestion.
Maybe I should find some sample code.
|
|
|
|