For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I have programmed a MFC utility with some radio buttons on the main window.
When I click on a radio button the BN_CLICKED message is captured by the handler and does some task.
I have seen an unexpected behaviour: when I open another window (hard disk explorer, control panel, speaker volume and also a generic folder) and then I close it, the radio button clicks even I haven't clicked the mouse on the radio button.
I suppose that this is caused by my program's window that get the focus when I close the other window.
How can I block this behaviour?
This behavior is, or at least used to be, by design. When [de]activating the window, the radio buttons do not know that. All they know is that they got focus, and the behavior for radio buttons is to auto-select on focus.
Does somebody have an idea why will the following happen:
printf("Min Value: %d\n", minValue(root));
printf("Max Value: %d\n", maxValue(root));
// not sure why line below throws segmentation core
//printf("Min Val: %d Max Val: %d\n", minValue(root), maxValue(root));
minValue and maxValue are recursive functions returning the min/max value of a binary tree, when called separately as in lines 1 & 2 they work fine, but when called from the same printf statement I get a segmenation fault in linux.
I have a namespace and class defined inside a cpp file (say x.cpp ). I want to declare this class as 'friend' inside another header (say y.h), but the header won't recognize the namespace.
Now, when I put the namespace in another header (x.h) and include it in y.h, I get a re-definition error ( also in x.cpp ). I can't remove the namespace definition from x.cpp, since it has been put together by a framework for me, and I won't be able to use the framework otherwise.
Does this mean I can't declare this class as friend of any other class ?
If I remember correctly you can (at least in VS 6.0) include .cpp files the same way you include header files. However it's not a very good practice.
You could consider defining some kind of helper class or interface class in z.h and include this file in both x.cpp and y.h. Then you could declare z a friend of y and "channel" the function calls from x through z. Alternatively you could even derive y from z and wouldn't need a friend declaration.
The good thing about pessimism is, that you are always either right or pleasently surprised.
I'm developing a wxWidgets 3.0 project using this Json_spirit library with boost 1_46_0 in Visual Studio 2008.
I Edited all the Additional directories and Additional Dependencies in the properties
After compiling the project I'm getting linkage error like
error LNK2019: unresolved external symbol "bool __cdecl json_spirit::read(class std::basic_istream<char,struct std::char_traits<char> > &,class json_spirit::Value_impl<struct json_spirit::Config_vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &)" (?J_read@json_spirit@@YA_NAEAV?$basic_istream@DU?$char_traits@D@std@@@std@@AEAV?$Value_impl@U?$Config_vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@json_spirit@@@1@@Z) referenced in function "private: class wxWindow * __cdecl HiFrame::ReadingJson(class wxWindow *,class wxString &,class wxString &)" (?ReadingJson@HiFrame@@AEAAPEAVwxWindow@@PEAV2@AEAVwxString@@1@Z) "
can anybody help me out to resolve this problem.??
Getting Linkage errors at Both Json_spirit::Read() and Json_spirit::Write() functions.
Just again i build the lib. now i'm getting error like
1>c:\documents and settings\administrator\my documents\downloads\boost_1_46_0\boost\function\function_base.hpp(408) : fatal error C1128: number of sections exceeded object file format limit : compile with /bigobj
i'm quite new to MFC programming and I would like if my software architecture can be simplified.
Let's suppose to have an MFC program where I put a member variable in CView class. This variable is set by a control put in a dialog window called by a menù.
I usually set a control variable in order to get the control value in order to avoid the GetdlgItem command.
The value of the control is used to set a member variable inside tha class of the dialog window and then when i close the dialog I copy the value of the dialog's variable into the main window variable
control variable -> member variable of the dialog window -> member variable of the main Cview window
With this scheme I Have to use 3 variables for each controls and this is quite expensive.
Can anyone suggest me a simpler way to get to synchronize the variable used by the main window with the value of a control inside a dialog window?
If you are worried about the memory needed to store several values twice, you could define a class or struct, create an object of it in your view class and pass the reference to this object to the dialog objects in their constructors. This way you only have 4 byte overhead per dialog.
The good thing about pessimism is, that you are always either right or pleasently surprised.
RedrawWindow(hwnd,&d,nullptr,RDW_UPDATENOW | RDW_INVALIDATE | RDW_ERASENOW);
but when, with animation\timer, the next image is drawed above the older one, instead clean all control and then redraw it.
(i need avoid the flicker and draw the control correctly and not 1 image above other)
can anyone advice me?
Does anyone know if the Visual Studio C++ compiler optimizes to eliminate calls to functions with empty definitions (nothing between the curly braces denoting the function's body)?
I am particularly interested in the 2010 and 2012 versions of the Visual Studio compiler.
It depends on whether the method is virtual. It would theoretically be possible to eliminate all calls to empty non-virtual methods. A virtual method may be overridden by a derived class, so the compiler must perform the virtual call.
(There may be some cases where the compiler can prove that the virtual call refers to the base class. In this case, the compiler could optimize the call away.)
As Richard suggests, the best way to check this is to write a short test program.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
I have an application which captures Lock, Unlock, Logoff and Logon events of Windows OS. I am able to get the notifications for Lock, Unlock and Logoff, but not getting any notification when user Logs on to the machine. I am using WTS_SESSION_LOGON event to capture the Log on event.
How to capture the event when user log on to the machine.
The following code is a basic algorithm for hamming distance calculation, but due to the design of my application, it requires many times to use this algorithm, in order to improve application efficiency, I want to improve the efficiency of this algorithm, is there any appropriate methods? Assembly language possible?
I don't see much optimisation options.
You are already using a lookup table and the code should not consume much time when dim is small. Rewriting it in assembler will be probably not faster because modern compilers will generate effective code (you may tell your compiler to generate an assembly output to check this).
When using the popcnt instruction and your data are always a multiple of 2 or 4 (or 8 with 64-bit builds), you can reduce the number of loop executions by performing the operation with 16/32/64 bits.
I wouldn't recommend assembly, unless platform portability is not a concern. A relatively easier option would be to apply a Duff's device to this loop. Unrolling the loop can provide performance boost. However, unless this is, say DSP code that has to run over and over again its probably not worthwhile and the effects wont be noticable.