Click here to Skip to main content
15,914,208 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to remove menu bar Pin
shoma17-Mar-04 20:33
shoma17-Mar-04 20:33 
AnswerRe: How to remove menu bar Pin
Prakash Nadar17-Mar-04 21:12
Prakash Nadar17-Mar-04 21:12 
GeneralRe: How to remove menu bar Pin
Balkrishna Talele17-Mar-04 22:10
Balkrishna Talele17-Mar-04 22:10 
AnswerRe: How to remove menu bar Pin
Prakash Nadar17-Mar-04 22:28
Prakash Nadar17-Mar-04 22:28 
AnswerRe: How to remove menu bar Pin
Balkrishna Talele17-Mar-04 23:24
Balkrishna Talele17-Mar-04 23:24 
GeneralRe: How to remove menu bar Pin
Prakash Nadar17-Mar-04 23:48
Prakash Nadar17-Mar-04 23:48 
Generalaccessing control from generic class Pin
Roj17-Mar-04 19:59
Roj17-Mar-04 19:59 
GeneralRe: accessing control from generic class Pin
Antti Keskinen17-Mar-04 21:44
Antti Keskinen17-Mar-04 21:44 
MFC creates automatic class hiearchies, and has a set of functions that allow you to traverse and manipuate the hiearchy.

Consider the following example:
1. An application object is created
2. The application object creates and initializes it's main window (usually a frame window), and saves this into m_pMainWnd pointer on the CWinApp-class
3. The frame window, if it is an SDI frame, first creates a set of possible bars (toolbar, statusbar, menubar, rebar etc). Then it creates the view context, and places itself as a parent of the view.

This having said, you can find the form view class object by asking the frame window to enumerate through it's child windows. Alternatively, you can use GetDlgCtrl with the ID of the child window (by default, AFX_IDW_PANE_FIRST, unless you have given it a different ID while creating it). Here is what MSDN says about the function call:

You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes. As long as the hDlg parameter specifies a parent window and the child window has a unique identifier (as specified by the hMenu parameter in the CreateWindow or CreateWindowEx function that created the child window), GetDlgItem returns a valid handle to the child window

As you can see, the MFC implementation of this function always returns a CWnd* to the requested object. Now, when you ask for the view class pointer, you can cast it down from CWnd* to CFormView*. Again, by using this pointer, you can use GetDlgCtrl to request for a pointer into the CListCtrl object.

The reason why your code call fails is that although the form view is a child of the frame window, the list box control is NOT. It is the child of the form view. You need to use a pointer to the form view class instance if you wish to request for the listbox.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: accessing control from generic class Pin
Roj20-Mar-04 10:43
Roj20-Mar-04 10:43 
GeneralHello Help on CView !!! Pin
itmpras17-Mar-04 18:41
itmpras17-Mar-04 18:41 
GeneralRe: Hello Help on CView !!! Pin
Antti Keskinen17-Mar-04 21:31
Antti Keskinen17-Mar-04 21:31 
GeneralRe: Hello Help on CView !!! Pin
itmpras17-Mar-04 22:38
itmpras17-Mar-04 22:38 
GeneralSendMessag/Post Message Pin
AnnJS17-Mar-04 18:18
AnnJS17-Mar-04 18:18 
GeneralRe: SendMessag/Post Message Pin
tcss17-Mar-04 20:25
tcss17-Mar-04 20:25 
GeneralRe: SendMessag/Post Message Pin
Balkrishna Talele17-Mar-04 22:37
Balkrishna Talele17-Mar-04 22:37 
GeneralRe: SendMessag/Post Message Pin
David Crow18-Mar-04 3:17
David Crow18-Mar-04 3:17 
QuestionHow to insert icon into a toolbar? Pin
P_JAYAPRAKASH17-Mar-04 17:39
P_JAYAPRAKASH17-Mar-04 17:39 
AnswerRe: How to insert icon into a toolbar? Pin
Prakash Nadar17-Mar-04 19:48
Prakash Nadar17-Mar-04 19:48 
AnswerRe: How to insert icon into a toolbar? Pin
Balkrishna Talele17-Mar-04 22:14
Balkrishna Talele17-Mar-04 22:14 
Generalaccess violation 0xC0000005 when calling func in dll Pin
suninwater17-Mar-04 15:36
suninwater17-Mar-04 15:36 
GeneralRe: access violation 0xC0000005 when calling func in dll Pin
ian mariano17-Mar-04 17:26
ian mariano17-Mar-04 17:26 
GeneralSome questions when declare a function Pin
nachilau17-Mar-04 15:32
nachilau17-Mar-04 15:32 
GeneralRe: Some questions when declare a function Pin
Prakash Nadar17-Mar-04 16:52
Prakash Nadar17-Mar-04 16:52 
GeneralMessage Box Hanging the Application Pin
jerry1211a17-Mar-04 14:23
jerry1211a17-Mar-04 14:23 
GeneralRe: Message Box Hanging the Application Pin
Prakash Nadar17-Mar-04 15:13
Prakash Nadar17-Mar-04 15:13 

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.