|
Hi all,
I have a weird problem with stl !
I need to work with callback functions between different classes. With VS2010 I have done this already different times without any problem.
With VS2015 I cannot compile such code!
Example:
in Header in Class Declaration:
#include <functional>
...
bool ProvideItemData(int nItem, int nSubItem);
in .cpp:
{
m_ListCtrl.SetOwnerData(std::bind(&CBlockEditView::ProvideItemData, this, std::placeholders::_1));
}
declaration in called class:
bool SetOwnerData(std::function <bool(int nItem,int nSubItem)> callback);
When compiling in VS2010, I get weird error messages:
c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1501): error C2440: 'return': cannot convert from 'std::_Unforced' to 'bool'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1501): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\functional(210): note: see reference to function template instantiation '_Rx std::_Invoke_ret<_Rx,_Callable&,_Ty,_Ty>(std::_Forced<_Rx,false>,_Callable &,_Ty &&,_Ty &&)' being compiled
1> with
1> [
1> _Rx=bool,
1> _Callable=_Decayed,
1> _Ty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\functional(208): note: while compiling class template member function 'bool std::_Func_impl<_Decayed,_Alloc,_Ret,int,int>::_Do_call(int &&,int &&)'
1> with
1> [
1> _Alloc=std::allocator<int>,
1> _Ret=bool
1> ]
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\functional(136): note: see reference to class template instantiation 'std::_Func_impl<_Decayed,_Alloc,_Ret,int,int>' being compiled
1> with
1> [
1> _Alloc=std::allocator<int>,
1> _Ret=bool
1> ]
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\functional(339): note: see reference to class template instantiation 'std::_Is_large<_Myimpl>' being compiled
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\functional(318): note: see reference to function template instantiation 'void std::_Func_class<_Ret,int,int>::_Reset_alloc<_Ty,std::allocator<int>>(_Fx &&,const _Alloc &)' being compiled
1> with
I do not find any solution. So at the moment I do not have any idea, how to solve this issue!
Please help!
|
|
|
|
|
I have following code:
CFileDialog fileDlg(TRUE, _T("*"), NULL, OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT, _T("All files (*.*)|*.*||"), NULL);
if(IDOK == fileDlg.DoModal())
TRACE(">>>%s\n", fileDlg.GetFileName());
and when I select a file, no mater what kind of file, I get:
>>>D
that is all ... why ? What I have done wrong here ?
|
|
|
|
|
You are passing an ANSI string to the TRACE macro. Therefore, an ANSI string is expected for the %s parameter but you have a Unicode build and fileDlg.GetFileName() returns a wide string.
So you should use the _T() macro also for the TRACE argument:
TRACE(_T(">>>%s\n"), fileDlg.GetFileName());
See also the examples at MFC Debugging Techniques[^].
|
|
|
|
|
Thank you. That was the problem.
|
|
|
|
|
1. I set tab order for control in a MFC dialog.
2. Started the application.
3. Clicked a button in dialog, whose tab order is 3.
4. A modal dialog displayed.
5. Closed the modal dialog.
Now the focus automatically moved to the control having tab order 0.
Since the focus was on the button just before the click, I would like to retain the selection on the same button.
aks
|
|
|
|
|
aks. wrote: 3. Clicked a button in dialog, whose tab order is 3. But did this button actually have the focus at this point?
|
|
|
|
|
Yes.
Before button click, even if the last focus is on another control( say tab order 2 ), after closing the Modal dialog the focus move to control having Tab order 0.
aks
|
|
|
|
|
I have a similar application (Win32 rather than MFC), but the focus stays in the correct place on return from the second dialog. I can only suggest you do some debugging to try to see what is happening under the covers.
|
|
|
|
|
aks. wrote: Now the focus automatically moved to the control having tab order 0. How are you verifying this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Yes. I think the default MFC application created using the VS2010 wizard has this behavior.
aks
|
|
|
|
|
There is a world of difference between thinking something and actually checking it. If this was the default behaviour it is likely that many programs would not work.
|
|
|
|
|
Nice quote
Could you please suggest a solution!
aks
|
|
|
|
|
Solution to what? We have no idea what your code is doing, or what you are doing when you run it, beyond your belief that the focus moves after you run some dialog. The only way to move forward with this is to write a very simple test program to demonstrate the problem and run some tests until you can isolate exactly what is happening.
|
|
|
|
|
|
|
The onus is on you to narrow the problem down to just the relevant code. Sane folks aren't going to chase links around and pull unrelated code from a project.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I did not done any specific code for the setting the focus. I just shared the framework generated code for easily reproducing the issue, so that you can understand the issue clearly.
aks
|
|
|
|
|
|
I want to create an IDE which should have similar look and feel like Visual Studio itself.
For this I created a "Visual Studio Style" Project by usage of AppWizard.
Now I am wondering, how to implement "Windows Float" functionality?
What I mean exactely? e.g. when you look at Visual Studio's Solution Explorer window, there is a small down arrow in the title bar. When you click on it, a menue opens and you can change the window style to "float".
This feature I want to use instead of a non modal dialog, becaue this would be much more flexible.
Has anybody an idea, how to implement. Maybe it is also implement in the IDE Framework of the MFC, but I do not know how to activate??
Any ideas?
Many thanks
|
|
|
|
|
How to use C to make a Mathematical / Statistical compiler for my final year project. i need help. Need someone that will put me through all the steps to achieve this project of mine. i havent actually seen any recent work on it. Thanks
|
|
|
|
|
|
Member 11942996 wrote: How to use C to make a Mathematical / Statistical compiler for my final year project. So what in the world have you been doing prior to this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
0
down vote
favorite I have seen CPU scheduling algorithms (Rate monolithic - Real time CPU scheduling) or priority scheduling using array data structure
http://c-programmingguide.blogspot.in/2012/09/c-program-for-rate-monotonic-scheduling.html
But I would like to know if this is the preferred data structure if yes why OR if any data struture is preferred for RMS then which one is better and why
any suggestions would be appreciated
Thanks in advance
|
|
|
|
|
Hello Everybody,
We have an application which is created in VC++ 6.0 version, in that we are displaying some colors (Pantone color) reading the colors from text file and displaying.
When I use the same text file (with same color details), in Visual Studio 2008 or higher, the application is displaying different color (actual color is this)
For example,
Original RGB is 198, 93, 82
Using color picker, for old application, its giving RGB as 120, 27, 20 and in the new application it shows 198, 93 and 82.
Will there be any color variation between old and new applications (visual studios)?
Thanks in advance,
A. Gopinath.
|
|
|
|
|
Howdy, I'm not so sure I understand your question.
rgb(198,93,82) looks like This , while rgb(120,27,20) looks like This
Obviously, these 2 colours are not only very different in terms of their RGB values and their HSL values for that matter, but they also appear very different to anyone not unfortunate enough to be hit with R-G colour blindness. Aren't you actually telling us yourself that the colours appear differently?
Their pantone numbers are also very different, 180 U vs 1815 C
I can't help but wondering 3 things:
1) What is the format of the input in the text-file and the exact input that produces these colours?
2) How is this being transformed into a colour by your application?
3) What difference did you find when you stepped through the conversion process in your debugger in each of the versions of the application?
I'm not familiar with the conversion process between rgb <--> pantone to know if a small difference in precision could produce such a wildly different result, or if it's an integer-only process that could suffer from a signed/unsigned error. Showing the input and the way it results in a final colour could well help, though it may not.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|