|
golfbird wrote: I was hoping I could intercept the routine and justadd my own function to
it. You can, see Davids reply. You'll need an ON_BN_CLICKED() entry for every radio button, but the function that gets called can be the same. Though for a 100 buttons I imagine it gets unwieldy.
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
ON_BN_CLICKED(IDC_RADIO_1, OnRadioClick)
ON_BN_CLICKED(IDC_RADIO_2, OnRadioClick)
ON_BN_CLICKED(IDC_RADIO_3, OnRadioClick)
END_MESSAGE_MAP()
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
This looks like what I was looking for.
Appreciate it, will give it a test
thank you
Peter Boyko
|
|
|
|
|
|
golfbird wrote: I have a dialog of radio buttons, 100 of them Very unfriendly UI.
The second parameter to the ON_BN_CLICKED() macro can point to the same handler function.
"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
|
|
|
|
|
Thanks.. I have to believe the objective I'm trying to reach
is beyond me. Thank You all again.
Peter Boyko
|
|
|
|
|
Which are the way to copy a CBitmap to another CBitmap, but have both of them ? In fact, I want to create a CBitmap from another CBitmap ... could you help me ? Thank you.
|
|
|
|
|
|
Thank you, I have succeeded ! 
|
|
|
|
|
I have 3 functions that do sorting on a CArray.
CArrays are declared in header file:
CArray<int*, int*>m_Integer;
CArray<string*, string*>m_String;
CArray<double*, double*>m_Double;
void sortIntegers()
{
// Do sorting for m_Integer here
}
void sortStrings()
{
// DO sorting for m_String
}
void sortDouble()
{
// Do sorting for m_Double
}
Now what i want to do is, have one generic function and then pass the CArray to that.
So far what i did is,
in Header file:
void sortAll(CArray<void*, void*> m_Array);
in CPP file:
void sortAll(CArray<void*, void*> m_Array)
{
int size = m_Array.GetSize();
............
............
............
m_Array.GetAt(0); // Error here
................
................
}
The error is that, it needs a class type and not a void type.
I am not sure how to proceed with writing a generic function to handle all different data types in one.
Any help is welcome!
|
|
|
|
|
|
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.
|
|
|
|
|
|