|
Sorry, i read wrong, my mistake
I think you should override the OnOK function of the dialog, do not call CDialog::OnOK() in it.
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Compared to your data set, practicaly none and you'll need every bit of that. In Widows x64 it will depend on the compiler you are using, if you are still using a compiler for x32 then it will add no additional overhead. If you change to a compler for x64 then all your int variable sizes will become 64 bit variables (doubles your sets memory size and should double the amount of data vector can handle).
If you don't use vector (or possibly CArray), then you will have to write your own code to handle the array and that may add more overhead than using vector.
The actual overhead in bytes depends on what functions you need to call. When a C++ compiler generates code (well VC6 anyway), I beleive it does not generate code (for templates) that does not get called (a little built in optimization).
If you where writing it in standard C, you would normaly get every function in every staticaly linked library include in your program, whether you called them or not.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
It really depends on how you are using std::vector. If you don't use reserve and then just push_back each entry, then the vector will grow using a simple doubling algorithm.
For example, push_pack one item and the new size is 1 elements used, 1 element allocated (1U/1A). If you push back another, vector needs to resize the memory so it doubles the size resulting in 2U/2A. On the next push_back it doubles again resulting in 3U/4A. Next push back doesn't require a reallocate, 4U/4A. The next one doubles again, 5U/8A.
Now, given you need to store 100,000,000, the doubling algorithm would result in 134,217,728 elements allocated. This is a waste of a lot of memory.
But that is only half the problem. Everytime that memory is reallocated, it runs the risk of fragmenting your memory. When you are talking about a few KB here and there, it isn't a problem. When you start talking about MB blocks of memory, you will end up with a lot of "free" memory that was once allocated but isn't being used since the bigger allocation can't fit into that block. So you could easily be wasting another 400MB of memory.
BUT, this isn't a problem with vector, it would be a problem with how you are using it. Use reserve to pre-allocate the vector size. Once that is done, what the other guy said would be true.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thank you for the information, it has been the most helpful.
I use this array to sort data in for stress testing memory. So I needed to know the exact size of memory used. I should write a custom made class
|
|
|
|
|
I'm building an opengl "spy" utility to capture opengl calls. I compiled my own DLL and called it opengl32.dll. The DLL exports entrypoints for most of the OpenGL calls as follows:
typedef void (*glEnable_TYPE)(int cap);
void glEnable(int cap)
{
glEnable_TYPE GL_glEnable;
// returns a handle to the DLL, otherwise NULL
hMod = LoadLibrary("C:/windows/system32/opengl32.DLL");
// returns the address of the DLL function, otherwise NULL
GL_glEnable = (glEnable_TYPE) GetProcAddress(hMod, "glEnable");
GL_glEnable(cap);
}
The problem is, I cannot get the wgl entrypoints (wglMakeCurrent, etc.) to work. Either I include these in my opengl, in which case visual c++ reports:
error C2491: 'wglMakeCurrent' : definition of dllimport function not allowed
Or, if I do not include a definition of these functions, I get:
error LNK2001: unresolved external symbol wglMakeCurrent
Debug/opengl32.lib : fatal error LNK1120: 1 unresolved externals
LINK : fatal error LNK1141: failure during build of exports file
What can I do?
|
|
|
|
|
:(Hi All!
I am getting debug assertion error exactly at the fourth time i open Webbrowser Control, consistently, everytime. CAN ANYONE HELP?
Any help on this regards will be appreciated !
I have two components, one is a MFC Application and the other is a Dll. I have a Webbrowser control in the dll, that is accessed by the MFC App. The following code calls the Webbrowsercontrol, which is in the dll, by the foll code:
"CWebDialog* wb;
wb = new CWebDialog();
wb->DoModal(); "
This code calls the Webbrowser control cpp, in the dll, whose Initdialog has the foll:
BOOL CWebDialog::OnInitDialog()
{
USES_CONVERSION;
CoInitialize(NULL);
try
{
hf_WriteLog("ONINITDLGWEB");
COleVariant vaURL(m_strURL);
((CWebBrowser2*)GetDlgItem(IDC_EXPLORER1))->Navigate2(vaURL, NULL, NULL, NULL, NULL);
hf_WriteLog("NAVIGATED");
VariantClear(&vaURL);
CoUninitialize();
CDialog::OnInitDialog();
}
This throws an exception, every fourth time. Is that a problem with the memory allocation of the dll.. or anything, someone could help????????
Regards
angello6
Regds
Angello
|
|
|
|
|
I do not know, but even in a try block you have to check return values to make sure the functions have succeded.
CoInitialize(0) should be called at program startup and CoUninitialize() should be called at program shutdown, not every time you call OnInitDialog(). May be that is the problem. If you told the application wizard (when generating project) that you were going to use COM objects, then it has already inserted code for those 2 functions. The problem can also be in the DLL.
Good Luck and Good Night!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Try to move CDialog::OnInitDialog to the first line of your CWebDialog::OnInitDialog function
Between the great things we cannot do and the small things we will not do, the danger is that we shall do nothing
|
|
|
|
|
"CoInitialize(0) should be called at program startup and CoUninitialize() should be called at program shutdown, not every time you call OnInitDialog()"
Thats not true. CoInitialize should be called at least once per thread; and every CoInitialize should have a corresponding CoUninitialize().
Furthemore, CoInitialize is deprecated, and you ought to be using CoInitializeEx instead.
using System.Beer;
|
|
|
|
|
True, calling the CoInitialize(0) followed by a call to CoUnitialize() should not cause a problem. A dialog window, like probably every other window, is in the applications thread, so if you call CoInitialize(0) at app-startup and CoUnitialize() at app-shutdown, then any other call will be redundant (unless called in a new thread).
Once the programmer has implimented proper error checking and makes sure any resources used are proberly released, the problem should go away.
Jon Hulatt wrote:
you ought to be using CoInitializeEx instead
TRUE
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
"I am getting debug assertion error exactly at the fourth time"
"This throws an exception, every fourth time"
so which is it? an assertation? or an exception?
Did you try stepping through the code to see which line causes the problem?
using System.Beer;
|
|
|
|
|
I just want to know if the two binary files is same. if i compare them byte by byte , it'll cost a lot of time. is there some good method?
|
|
|
|
|
No, this is the fastest way. The speed will depend on realization. while (*p1++==*p2++); will be slower than memcmp, fully loaded files are a bit faster then mapped files, etc.
The only alternative is some crc generation, but it will be faster only when comparing one file to many.
Igor Green
http://www.grigsoft.com
Compare It! + Synchronize It! : Files and folders comparison never was easier!
|
|
|
|
|
BAsicly yes.
If you want some example source code, search for "diff", which is a unix utility that does what you want. (and many other things)
|
|
|
|
|
Henry miller wrote:
If you want some example source code, search for "diff", which is a unix utility that does what you want. (and many other things)
Good idea. However, "diff" is for text files. If you want to compare binary files, try the unix utility "cmp"
If you don't have the source to the unix utilities, try looking at cygwin, a Unix-on-DOS implementation:
http://www.cygwin.com[^]
|
|
|
|
|
A simple check on length would be a quick way to say they are different.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
hi all,
I want to add check Boxes to every Column Field data in a List Control..How do I do that?.
Thanks in advance..
|
|
|
|
|
I've used this control for just such a problem.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
can anyone here tell me functions that handle Windows MIDI driver(usb)?
new to this stuff
tahnx in advance
|
|
|
|
|
Hi,
In my program I have huge data sets(about 100,000,000 integers) and I was wondering how much memory overhead it has?
For a 32bit integer array of size 100,000,000 x 4bytes = 400MB memory is just needed for the data set. How much std::vector in Windows would add to that? How about in Windows for x64?
Thanks!
Rob
|
|
|
|
|
hey,
I have a child window with Flat scroll bars. The scrolling is handled in OnVScroll and OnHScroll. I need to implement the scrolling in mouse wheel operations too. How can I Implement it?
Thanks in Advance.
shijuck
|
|
|
|
|
OnMouseWhell(): generated by the class wizard when you select to handle WM_MOUSEWHEEL.
Example:
BOOL CSMyScrollView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
return CScrollView::OnMouseWheel(nFlags, zDelta, pt);
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
How to get Dialog Handle?
On Visual C++ 6.0, how to I identify a user who is having what kind of privileges? (i.e admin privilege, etc)
|
|
|
|
|
max_gundam15 wrote:
How to get Dialog Handle?
What do you need this handle for (i.e., what problem are you addressing)?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Interface expert wanted!
Has anyone ever seen this? Can anyone help?
I have built a VC dll to be accessed by a vb app. I am a so-called professional
programmer who has done this plenty of times before and know my way well around both
languages (at least I thought I did)
My C code consists of just 4 entry points from which I then call lots of internal code
The whole thing works great if I build it in VC.net and use it in a vb.net app
(one odd thing though, I always thought that you defined a function as __stdcall
rather than __cdecl - I can only make the dll work in vb.net if I DO declare the funtions
as __cdecl !)
When I go over to windows apps and build the dll in vc6 and use it in vb6 I get
"bad calling convention" (I did use __stdcall this time and expected no problems)
I have tried everything I can think of, a ".def" file, "__declspec(dllexport)" defining,
you name it. I have even run diagnostics: bindump.exe and depends.exe and can
visibly see the entry points apparantly correctly set up by vb6
I have spent much time browsing the web trying different suggestions. None have helped.
I am quite familiar with the differences between calling sequences. Recalling previous
problems experienced with mismatching parameters I even added a special void function
with no parameters (__stdcall) - I can't even call that, same "bad calling" message
Do I have a bad install (?!) - has anyone been through this? I am losing my confidence
and may be applying for a different job real soon!
|
|
|
|
|