|
Solved by myself!
In OnPaint() I changed the positions of the CStaticControls.
Of course this is causing "recursive" WM_PAINT calls.
I moved this code to other functions (OnSize, OnTimer,...), now it works!
|
|
|
|
|
I have a CListCtrl in my MFC dialog application.
I enabled the HDS_FILTERBAR for List control the by the following code.
CHeaderCtrl* pHeaderCtrl = m_myListCtrl.GetHeaderCtrl();
pHeaderCtrl->SetDlgCtrlID( IDC_LIST1 );
HDITEM hdItem;
ZeroMemory( &hdItem, sizeof( HDITEM ));
hdItem.mask = ( HDI_FILTER );
pHeaderCtrl->ModifyStyle( 0, HDS_FILTERBAR );
hdItem.type = HDFT_ISSTRING;
The filter is displayed.
However I would like to change the background color and font of the Edit control and button in the filter section.
How can I achieve it.
aks
|
|
|
|
|
The CEdit class inherits from CWnd so you can use SetFont to change the font. You can probably set the background colour by subclassing the window. Changing the colour and image in a button can be done in similar ways. Google should find you some samples.
|
|
|
|
|
Thank you for the comment.
I tried by subclassing the Header control.
But I could not find any options to get the edit control and button from the CHeaderCtrl.
aks
|
|
|
|
|
aks. wrote: I could not find any options to get the edit control and button So who put them in the header in the first place?
|
|
|
|
|
Ok. I got it, I used FindWindoEx to find the WC_EDIT in the header.
I think the filter button is not exactly a button. Its a bitmap.
aks
|
|
|
|
|
I don't think that is the best way. You put the items in the header so you should be able to get their handles quite easily using the methods of the CHeaderCtl object.
|
|
|
|
|
I could only find it by using FindWondow API in class derived from CHeaderCtrl.
Ans I customized the edit control from OnCustomDraw().
aks
|
|
|
|
|
I have a dialog of radio buttons, 100 of them
I use this to select type of material product is made from so I can select correct ink for printing. Selections are everything from alumininum, plastics to wood.
I would like to select 1 radio button and have it return
the int of that selection without having to add an event handler for each and everyone of the radio buttons
Is there a routine that can handle any check on any button?
If(any button is checked) return(int # of the button)
Using visual studio c++ 2008
Peter Boyko
modified 8-Sep-15 10:23am.
|
|
|
|
|
You can hook up the same event for each button. The sender can be identified by the sender parameter of the event. It contains a reference to the button, and thus, its name.
--sorry, thought this was the C# forum. Doesn't MFC have something similar?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
if it does, I'm not able to find it. Could be I'm looking at the wrong pages.
Peter Boyko
|
|
|
|
|
golfbird wrote: I have a dialog of radio buttons, 100 of them That is a really bad idea. Use a ListBox, or preferably more than 1 to allow simple selection of items.
|
|
|
|
|
thanks
you have busted my bubble.
To me, it seemed easier to look at a dialog page
with radio buttons rather than search a listing
especially for my printers who may not have to learn how
to use drop down list boxes
Seems to me that the program knows when a radio button
is selected and then marks is as such and turns off all others in the group..
I was hoping I could intercept the routine and just
add my own function to it.
Peter Boyko
|
|
|
|
|
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 ?
|
|
|
|