|
By default, clicking on the item text in a listcontrol with extended style checkboxes, does not set the check in the checkbox. How do I make it so that when I click on the name, the check is set and the app responds as if to an actual direct check in the checkbox?
Thank you.
ns
|
|
|
|
|
You can't make the list control do that automatically (there's no style bit or extended style bit to do it) so you'll have to add some code.
You need a notify handler for NM_CLICK. If the user left clicks on the icon or the first column label, the NMITEMACTIVATE.iItem member will contain the index of the item clicked on, so you can then set the check state of the item.
In MFC, your code will look something like this, assuming you're handling the notification in the parent window of the list control:
ON_NOTIFY(NM_CLICK, ID_YOUR_LIST_CONTROL, OnClickYourListControl)
...
void OnClickYourListControl(NMHDR* pNMHDR, LRESULT* pResult)
{
NMITEMACTIVATE* pItem = (NMITEMACTIVATE*)pNMHDR;
if (pItem->iItem > -1)
{
CListCtrl* pList = (CListCtrl*)CWnd::FromHandle( (pItem->hdr).hwndFrom );
ASSERT(pList!=NULL);
pList->SetCheck( pItem->iItem, !pList->GetCheck(pItem->iItem) );
}
*pResult=0;
}
If you're handling the notification in the list control itself, you'll need to use the reflected message instead, via the ON_NOTIFY_REFLECT macro.
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Thanks so much for the direction. I am trying it out. For the checkboxes I have:
m_list3.SetExtendedStyle(LVS_EX_CHECKBOXES);
where m_list3 is a listcontrol.
Thanks a million again,
ns
|
|
|
|
|
Hi,
I need to have the MDI MFC app start with two different views already populated with data. I only have one document. How do I code my app so that when it starts, both the views will be instantiated?
Thank you.
|
|
|
|
|
How can I make a CWnd-descended child window which has a Z-order placing it beneath its CWnd-descended parent window?
|
|
|
|
|
Have you already tried something with SetWindowPos() (Throw an eye in the MSDN for further infos) ?
~RaGE();
|
|
|
|
|
Yes, I looked into SetWindowPos(). The problem is that when SetWindowPos() changes the Z-order of a window, it automatically changes the Z-order of any windows owned by that window. So if I tell it to put my main window in front of a child, it does it and then puts the child in front of the main window again.
|
|
|
|
|
Hi all,
Is there any class to list all my Directories,Folders and the files in that folders and Network mapped drives in a drop down combo box?.Kindly help me.
With regards
Shibu K.V.
Senior Research Associate.
VLSI ASIC Hardware Design Group
Electronics R&D Centre,Trivandrum
India
|
|
|
|
|
There is no.
It's better way to invoke standard Open Dialog by GetOpenFileName().
|
|
|
|
|
Hi all,
How can i get the back ground colour of a dialog?
With regards
Shibu K.V.
Senior Research Associate.
VLSI ASIC Hardware Design Group
Electronics R&D Centre,Trivandrum
India
|
|
|
|
|
COLORREF rgbBackground = GetSysColor(COLOR_WINDOW);
|
|
|
|
|
Try to declare a template class as below, But it can't pass the compiling.
(Using MS VC++ 6.0)
template < class ClassType, typename DataType > class MyContainer :
public ClassType < DataType >
{
...
}
only while I change it to something like this, it works.
template < typename DataType > class MyContainer :
public vector < DataType >
{
...
}
But my purpose is to support vector, list, queue and deque in a single
template class. Does anyone know how to make it?
Any commment greatly appreciated!
Wayne King
10 Jul 2002
|
|
|
|
|
In the example that doesn't work, you are using a template parameters ClassType as a name of a class as well. There are going to be some problems with trying to create a template this way. For instance the ClassType template parameter also needs a parameter to it as well. The only way I could get it to work is as follows:
template< class T, class D>
class MyContainer
{
public:
MyContainer() : T<d>
{}
virtual ~MyContainer() {}
};
typedef MyContainer<vector<int>, int> MyIntContainer;
|
|
|
|
|
Hi Terry Denham,
Soory I didn't get you. Is your messgae intact?
Could you please reply again?
Wayne King
10 Jul 2002
|
|
|
|
|
I want to change the scroll lines number in Windows98(system wide).
But it does not work. Could you please give me a hand ?
Below is my code:
int num = 10;
SystemParameterInfo(SPI_SETWHEELSCROLLLINES, num, NULL, NULL);
The same code works in WinMe, Win2000 and WinXP.
Could you please give me your ideas?
Thanks for your help.
|
|
|
|
|
i am having problem in loading a bitmap in a rectangle contained in a dialogbox. anybody having idea what to do or any sample code
|
|
|
|
|
I generally make a CStatic box with a border and then create a new class which is a child of CStatic. For example, class CBitmapViewBox : public CStatic
I add a member variable of type CBitmapViewBox to my main dialog and, in the OnInitDialog() event, I do this...
<br />
m_BitmapViewBox.SubclassDlgItem(IDC_SBITMAPDISPLAY, this);<br />
m_BitmapViewBox.Init();<br />
To load and display the bitmap, I do this...
<br />
void CBitmapViewBox::OnPaint() <br />
{<br />
CPaintDC dc(this);
CMainViewDlg *pWnd = (CMainViewDlg *)GetParent();<br />
<br />
if(pWnd != NULL)<br />
{<br />
if(m_bValid)<br />
{<br />
CRect lRect;<br />
GetClientRect(lRect);<br />
lRect.NormalizeRect();<br />
<br />
BITMAP bm;<br />
m_BMP.GetBitmap(&bm);<br />
CBitmap *pOldBitmap = dcMem.SelectObject(&m_BMP);<br />
<br />
dc.BitBlt(0, 0, lRect.Width(), lRect.Height(), &dcMem, 0, 0, SRCCOPY);<br />
<br />
dc.SelectObject(pOldBitmap);<br />
}<br />
else<br />
{<br />
dc.DrawText("Not a valid BMP file", -1, lRect, DT_CENTER | DT_VCENTER | DT_WORDBREAK);<br />
}<br />
}<br />
<br />
CStatic::OnPaint();<br />
}<br />
<br />
BOOL CBitmapViewBox::UpdateBMP(LPCTSTR lpszName)<br />
{<br />
CMainViewDlg *pFrameWnd = (CMainViewDlg *)GetParent();<br />
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), lpszName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);<br />
<br />
m_bValid = TRUE;<br />
<br />
if(m_BMP.DeleteObject())<br />
m_BMP.Detach();<br />
<br />
if(!hBitmap)<br />
{<br />
m_bValid = FALSE;<br />
UpdateSize(m_iMaxWidth, m_iMaxHeight);<br />
Invalidate(TRUE);<br />
return FALSE;<br />
}<br />
<br />
m_bValid = TRUE;<br />
<br />
m_BMP.Attach(hBitmap);<br />
}<br />
|
|
|
|
|
Is there a good book on this planet about the core WINApi, how it works, and how I can work with it. I have to use the ol' famous help or MSDN, but I'm wasting paper on it (Printing), and it's not always that clear (No samples, etc...)
Sjoerd
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
there is a good book in the market its something like Win32API programing with visual basic and does have samples
live and let them live
|
|
|
|
|
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
I bought Petzold after I found some PDFs. I ordered and got suprised how big it is, recommended if you need old school WinAPI.
|
|
|
|
|
At Amazon?
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
please google your question:
http://www.google.de/search?q=petzold
|
|
|
|
|
how to pass a memDC from view class to an activeX controls method which is created dynamically in the view
|
|
|
|
|
i have form view with size larger than that of a screen size with scrollbars. i am creating ActiveX components dynamically at runtime on this view. i want to extract all these components in to a bitmap for printing. but when i am trying to do so my bitmap is having only the components which are present in the visible client area of the form view. is there any way to get the drawing of the componets that are present in the not visible area of the view or is there any other method to print my form view with activeX components that donot completely fit into the visible client area.
|
|
|
|