Click here to Skip to main content
15,922,584 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: About "Ctrl + ALT + DEL" Pin
29-Oct-01 22:22
suss29-Oct-01 22:22 
GeneralRe: About "Ctrl + ALT + DEL" Pin
2-Nov-01 14:01
suss2-Nov-01 14:01 
GeneralRe: About "Ctrl + ALT + DEL" Pin
Deepak Khajuria29-Oct-01 22:03
Deepak Khajuria29-Oct-01 22:03 
GeneralText To Speech Control...... Pin
29-Oct-01 18:31
suss29-Oct-01 18:31 
GeneralRe: Text To Speech Control...... Pin
Michael P Butler30-Oct-01 2:30
Michael P Butler30-Oct-01 2:30 
GeneralMake/Compile file problem Pin
29-Oct-01 16:02
suss29-Oct-01 16:02 
GeneralScrollbar question with RichEditControl Pin
gordingin29-Oct-01 15:10
gordingin29-Oct-01 15:10 
GeneralCListCtrl question (custom) Pin
29-Oct-01 14:39
suss29-Oct-01 14:39 
Hi all,

Like everyone who has done any CListCtrl work, I want to make some changes (sub-item editing and the like). Easy enough to do, done it already with a CListView. To save myself from having to make the same change over and over I thought it would be nice to make a proper CListViewEx style class derived from CCtrlView. I'm sure everyone who's tried this knows the problem, silly GetListCtrl() casts a pointer to itself Frown | :-( Anyway, I reckon I have a cunning solution (someone please stop me if this won't work!) I'm going to derive a new CListCtrl (called CListCtrlEx) add the changes to it (I've actually already done this) and it works via subclassing (i.e. create a ListCtrl with the dialog editor and select the subclass to be ListCtrlEx).
Now in order to do the cunning bit with the CCtrlView I need to register this new class with Windows, no problem, stole some code from a tutorial on this site and all works well, the class registers. However, and here's the problem (at last), if I create a custom control with the dialog editor, set the class accordingly and do all the necessary member modifications (i.e. add DDX stuff), the app. compiles fine, but nothing appears on my little test dialog, anyone know why? I've included the code below, it's so simple and I can't see why the ListCtrl won't paint, unless I can get the registered control to draw itself my cunning plan is going to fail Frown | :-(

Here's the whole thing (bar the dialog bits):
CListCtrlEx::CListCtrlEx()
{
TRACE("CListCtrlEx() is constructing....\n");
if(RegisterWindowClass()) TRACE("CListCtrlEx() - Class registered.\n");
}

CListCtrlEx::~CListCtrlEx()
{
TRACE("CListCtrlEx() is destructing....\n");
}

bool CListCtrlEx::RegisterWindowClass()
{
WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle();
bool status = false;

if(!(::GetClassInfo(hInst, _T("CListCtrlEx"), &wndcls)))
{
// otherwise we need to register a new class
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = (HBRUSH) COLOR_BTNSHADOW;
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = _T("CListCtrlEx");

if(!AfxRegisterClass(&wndcls))
{
AfxThrowResourceException();
status = false;
}
else status = true;
}
else TRACE("CListCtrlEx()::RegisterWindowClass() - Class already registered.\n");

return(status);
}

BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl)
//{{AFX_MSG_MAP(CListCtrlEx)
ON_NOTIFY_REFLECT(NM_CLICK, OnClick)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListCtrlEx message handlers

void CListCtrlEx::OnClick(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLISTVIEW *lv = (NMLISTVIEW *)pNMHDR;

TRACE("CListCtrlEx::OnClick() - Got a click (at %02d,%02d)\n",lv->ptAction.x,lv->ptAction.y);
*pResult = 0;
}

void CListCtrlEx::PreSubclassWindow()
{
TRACE("CListCtrlEx::PreSubclassWindow() - Running....\n");
CListCtrl::PreSubclassWindow();
}

GeneralRe: CListCtrl question (custom) Pin
Tomasz Sowinski30-Oct-01 0:48
Tomasz Sowinski30-Oct-01 0:48 
QuestionWindow minumim width ? Pin
Christian Graus29-Oct-01 13:15
protectorChristian Graus29-Oct-01 13:15 
AnswerRe: Window minumim width ? Pin
29-Oct-01 13:24
suss29-Oct-01 13:24 
GeneralRe: Window minumim width ? Pin
Christian Graus29-Oct-01 13:50
protectorChristian Graus29-Oct-01 13:50 
GeneralWindows API issue Pin
29-Oct-01 13:14
suss29-Oct-01 13:14 
GeneralRe: Windows API issue Pin
Christian Graus29-Oct-01 13:16
protectorChristian Graus29-Oct-01 13:16 
GeneralRe: Windows API issue Pin
Nish Nishant29-Oct-01 13:56
sitebuilderNish Nishant29-Oct-01 13:56 
GeneralRe: Windows API issue Pin
Nish Nishant29-Oct-01 13:54
sitebuilderNish Nishant29-Oct-01 13:54 
GeneralWindow's API problems Pin
29-Oct-01 13:08
suss29-Oct-01 13:08 
GeneralRe: Window's API problems Pin
Christian Graus29-Oct-01 13:13
protectorChristian Graus29-Oct-01 13:13 
Generalsimple real audio making Pin
lo29-Oct-01 12:40
lo29-Oct-01 12:40 
QuestionDrawing a RoundRect and add an action handler? Pin
29-Oct-01 12:06
suss29-Oct-01 12:06 
AnswerRe: Drawing a RoundRect and add an action handler? Pin
Rassman30-Oct-01 2:53
Rassman30-Oct-01 2:53 
GeneralRe: Drawing a RoundRect and add an action handler? Pin
30-Oct-01 5:12
suss30-Oct-01 5:12 
GeneralRe: Drawing a RoundRect and add an action handler? Pin
Rassman30-Oct-01 23:40
Rassman30-Oct-01 23:40 
GeneralWin32 -- RtlAllocateHeap Pin
Peter Weyzen29-Oct-01 11:55
Peter Weyzen29-Oct-01 11:55 
GeneralRe: Win32 -- RtlAllocateHeap Pin
29-Oct-01 13:19
suss29-Oct-01 13:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.