Click here to Skip to main content
15,916,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: To hide a Dialog Pin
toxcct20-Mar-07 20:40
toxcct20-Mar-07 20:40 
GeneralRe: To hide a Dialog Pin
siddharthsan20-Mar-07 20:52
siddharthsan20-Mar-07 20:52 
AnswerRe: To hide a Dialog Pin
prasad_som20-Mar-07 21:21
prasad_som20-Mar-07 21:21 
GeneralRe: To hide a Dialog Pin
toxcct20-Mar-07 22:16
toxcct20-Mar-07 22:16 
AnswerRe: To hide a Dialog Pin
prasad_som20-Mar-07 22:40
prasad_som20-Mar-07 22:40 
GeneralRe: To hide a Dialog Pin
toxcct20-Mar-07 23:03
toxcct20-Mar-07 23:03 
AnswerRe: To hide a Dialog Pin
prasad_som20-Mar-07 23:22
prasad_som20-Mar-07 23:22 
GeneralRe: To hide a Dialog Pin
David Crow21-Mar-07 4:06
David Crow21-Mar-07 4:06 
prasad_som wrote:
Yup. dynamic cast fails in case of inapproriate down casting. For example, if you changed original code to,

CListBox* pWnd = dynamic_cast<clistbox*>(GetDlgItem(IDC_BUTTON1));
here pWnd will be NULL because GetDlgItem is not returning pointer of type CListBox( hope you get my point).


In order to understand why this happens, you have to know what GetDlgItem() is actually doing. GetDlgItem() will always return a CWnd*, but may or may not return a CButton* or CListBox*. When you call GetDlgItem(), MFC searches the map of window handles for an existing object that is bound to the specified window handle. If one exists, a CTempWnd object is created and returned. If an object is already bound to it, a pointer to that existing object is returned. This means that if there was already a CButton class bound to the IDC_BUTTON1 control, and then called GetDlgItem(), you would get back a a pointer to a CButton object, the one that is already bound to the control.



"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

"Judge not by the eye but by the heart." - Native American Proverb


QuestionRe: To hide a Dialog Pin
prasad_som21-Mar-07 4:19
prasad_som21-Mar-07 4:19 
AnswerRe: To hide a Dialog Pin
David Crow21-Mar-07 4:23
David Crow21-Mar-07 4:23 
GeneralRe: To hide a Dialog Pin
prasad_som21-Mar-07 7:38
prasad_som21-Mar-07 7:38 
QuestionRe: To hide a Dialog Pin
David Crow21-Mar-07 7:43
David Crow21-Mar-07 7:43 
AnswerRe: To hide a Dialog Pin
prasad_som21-Mar-07 8:00
prasad_som21-Mar-07 8:00 
GeneralRe: To hide a Dialog Pin
David Crow21-Mar-07 3:54
David Crow21-Mar-07 3:54 
AnswerRe: To hide a Dialog Pin
prasad_som20-Mar-07 20:40
prasad_som20-Mar-07 20:40 
QuestionCapture a menu of a Window [modified] Pin
surajcd20-Mar-07 20:04
surajcd20-Mar-07 20:04 
AnswerRe: Capture a menu of a Window Pin
Michael Dunn20-Mar-07 20:26
sitebuilderMichael Dunn20-Mar-07 20:26 
QuestionAdd folder to Start Menu Pin
kiranin20-Mar-07 19:42
kiranin20-Mar-07 19:42 
AnswerRe: Add folder to Start Menu Pin
KaЯl21-Mar-07 1:12
KaЯl21-Mar-07 1:12 
AnswerRe: Add folder to Start Menu Pin
ThatsAlok21-Mar-07 19:37
ThatsAlok21-Mar-07 19:37 
QuestionRadio buttons and combo boxes Pin
gingerballs20-Mar-07 19:35
gingerballs20-Mar-07 19:35 
AnswerRe: Radio buttons and combo boxes Pin
_AnsHUMAN_ 20-Mar-07 19:48
_AnsHUMAN_ 20-Mar-07 19:48 
AnswerRe: Radio buttons and combo boxes Pin
ThatsAlok20-Mar-07 22:25
ThatsAlok20-Mar-07 22:25 
QuestionImage processing algorithms for extracting characters from image Pin
JanapatiBalu20-Mar-07 19:20
JanapatiBalu20-Mar-07 19:20 
AnswerRe: Image processing algorithms for extracting characters from image Pin
Russell'20-Mar-07 23:39
Russell'20-Mar-07 23:39 

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.