Eroare la CEdit::OnGetDlgCode

Intrebari legate de programarea cu biblioteci precum MFC, ATL, WTL si GDI+.
Post Reply
rilley
Junior
Junior
Posts: 22
Joined: 11 Feb 2010, 01:24
Judet: Harghita

Eroare la CEdit::OnGetDlgCode

Post by rilley » 01 Apr 2012, 15:33

Salut

Un lucru nu il inteleg, cand pun aceasta linie de cod:
TRACE0("\n CCustomEdit::OnGetDlgCode");
UINT nDefDlgCode = CEdit::OnGetDlgCode(); // default value
UINT nCustomDlgCode = nDefDlgCode | DLGC_WANTALLKEYS; // wants all keys

imi zice :
probdlg.cpp(380): error C2248: 'CWnd::OnGetDlgCode' : cannot access protected member declared in class 'CWnd'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3016) : see declaration of 'CWnd::OnGetDlgCode'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(2273) : see declaration of 'CWnd'
probdlg.cpp(380): error C2352: 'CWnd::OnGetDlgCode' : illegal call of non-static member function
1> c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3016) : see declaration of 'CWnd::OnGetDlgCode'

Eroarea este la CEdit:: ....



User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3778
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi
Contact:

Re: Eroare la CEdit::OnGetDlgCode

Post by Ovidiu Cucu » 01 Apr 2012, 21:15

Inseamna ca acel cod nu-i nici in clasa CEdit, nici intr-o clasa derivata din CEdit.

User avatar
Marius Bancila
Fondator
Fondator
Posts: 2344
Joined: 11 Jul 2007, 11:45
Judet: Timiş
Location: Timisoara
Contact:

Re: Eroare la CEdit::OnGetDlgCode

Post by Marius Bancila » 07 Apr 2012, 22:25

Code: Select all

UINT nDefDlgCode = CEdit::OnGetDlgCode(); // default value
Metoda e un handler pentru WM_GETDLGCODE si e apelata de catre framework. Astfel de metode nu sunt gandite sa fie apleta din codul tau.

Ce vrei tu de fapt sa faci e sa tratezi acest mesaj in clasa ta.

Adaugi asta in header

Code: Select all

afx_msg UINT OnGetDlgCode();
pui asta in message map

Code: Select all

ON_WM_GETDLGCODE()
si implementezi metoda

Code: Select all

UINT ClasaTa::OnGetDlgCode()
{
  return DLGC_WANTALLKEYS;
}
Desigur pasii astia ii poti face si cu wizardul.

Update: se pare ca am bagat o eroare, OnGetDlgCode() e o metoda protected din CWnd, deci e accesibila din CEdit.
Marius Bancila
Fondator Codexpert, Microsoft MVP VC++
Site personal | Blog

Post Reply