|
i afraid i'm using
HDITEM hdi;
hdi.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT;
hdi.fmt = HDF_STRING | HDF_LEFT | HDF_OWNERDRAW;
t!
|
|
|
|
|
You've mentioned in the first post that there's 'no problem with WM_ handlers'.
Does this mean that parent window gets WM_DRAWITEM as expected and the only problem is with forwarding to virtual DrawItem method in header?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
parent has to deal something with?
i thought it goes to myhdrctrl::onpaint or onsize and similars
t!
|
|
|
|
|
parent has to deal something with?
Yes, but MFC does this for you automatically. Can you use Spy++ and check if parent gets WM_DRAWITEM?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
yes parent gets wm_drawitem with header ctrl id (fprocessed: false)
t!
|
|
|
|
|
|
sorry but _is_ virtual
afxcmn.h
class CHeaderCtrl : public CWnd
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
t!
|
|
|
|
|
sorry but _is_ virtual
You're right, it is virtual. But it doesn't buy you anything. You still need ON_WM_DRAWITEM_REFLECT.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
wm_drawintem_reflect? where to find it?
i tried wm_drawintem but is not called too
t!
|
|
|
|
|
No, there's no message named WM_DRAWITEM_REFLECT. You need a macro in the message map.
BEGIN_MESSAGE_MAP(CYourHeader, CHeaderCtrl)
ON_WM_DRAWITEM_REFLECT()
END_MESSAGE_MAP()
This will connect your DrawItem method into MFC message handling mechanism. Parent window will call CYourHeader::DrawItem when handling WM_DRAWITEM.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
nothing
i tried
afx_msg void DrawItem ( LPDRAWITEMSTRUCT lpDrawItemStruct );
into hdr.h too - the same
when i look to examples i have (tree-list-ctrls on cp) there is my version only, i see nothing like this
t!
|
|
|
|
|
Another idea: put the breakpoint in CHeaderCtrl::OnChildNotify. Does the program stop there?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
|
This is strange. I've checked the MFC sources. Here's how is expected to work:
1) parent window receives WM_DRAWITEM message - this is done by Windows itself, no MFC needed at this point
2) message map in CWnd class has a handler for this message. Default implementation is in CWnd::OnDrawItem
3) CWnd::OnDrawItem checks if message applies to menu or child window. If child window needs to be owner-drawn, it will be notified. Notification is performed by calling virtual CWnd::OnChildNotify. CHeaderCtrl and other classes override this function.
4) CHeaderCtrl::OnChildNotify explicitly checks for WM_DRAWITEM. If this is the case, it calls virtual CHeaderCtrl::DrawItem. Default implementation just contains ASSERT(FALSE), so you should at least have an assert (assuming some problems with overriding DrawItem).
5) overriden CYourHeader::DrawItem does the job.
If CHeaderCtrl::OnChildNotify is not called, the next suspect is WM_DRAWITEM handler in parent class. Do you explicitly handle WM_DRAWITEM in the parent window?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
parent is commnon static control created into dialog editor (property page)
no own class subclassed to it
CStatic *pStatic = (CStatic*)((CPropertyPage*)wnd)->GetDlgItem(ID_STATIC);
m_Header.Create(WS_CHILD | WS_VISIBLE | WS_DISABLED | HDS_HORZ, headerRect, pStatic, 12345 /* id */);
t!
|
|
|
|
|
OK - I can see what's going wrong. The parent isn't subclassed by MFC. When static window receives WM_DRAWITEM, the message goes to DefWindowProc, not to CWnd::OnDrawItem.
The 'pStatic' pointer you're getting via GetDlgItem points to a temporary object, which is destroyed by MFC during idle processing.
You need member CStatic variable associated - change the id from IDC_STATIC to something else, IDC_HDR_PARENT and use ClassWizard to add a member control variable.
Optionally, add m_static manually to CYourDlg and call m_static.SubclassDlgItem(IDC_HDR_PARENT, this) in CYourDlg::OnInitDialog.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
really, parent was whole problem
thanks very much
t!
|
|
|
|
|
I been working with MFC for while and there is something I always wondered
when I create controls dynamic for ex.
CEdit *pEdit = new CEdit;
pEdit->Create( WS_CHILD | WS_VISIBLE , rcEditRect , this , nID );
Then i always need to give the control an ID ( nID )
What is this for ?? Can I use any number here as long as it have not been used before ?
what if 2 controllers get the same ID what could happened ?
I never had any problems with it yet. I always use nID++ before creating the next controller. but it been bugging me that I didn't really understand the purpose of the nID
I been suspecting that it is used when finding items when i use
GetDlgItem .. But is that all it is used for ??
/Mathias
|
|
|
|
|
The ID is defined in resource.h with lines like this:
#define IDD_ACTION 1012
where IDD_ACTION is the name you gave your control when you created it in the dialog editor. When you create your own ID's it is imperative that no two controls on the one dialog have the same ID because a dialog recieves messages like WM_DRAWITEM, which specify the control that sent the message by specifying the ID.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I want create DLL that gives a dialog box.
I create dll with the classWizard(dll), I added Dialog to the resource
and class CMyDialod for it.
Now mukkie discussed me to add to the header file of CMyDialog So:
-----------------------------------------------------------------
#ifdef DLL_BUILDING
#define DllExportImport __declspec(dllexport)
#else
#define DllExportImport __declspec(dllimport)
#endif
class DLLExportImport CMyDialog : public CDialog
------------------------------------------------------------------
I made it but it's performs me the below errors :
----------------------------------------------------------------
Dlg1.cpp
C:\Windows\Desktop\dll1\Dlg1.cpp(19) : warning C4273: 'CDlg1::CDlg1' : inconsistent dll linkage. dllexport assumed.
C:\Windows\Desktop\dll1\Dlg1.cpp(28) : warning C4273: 'DoDataExchange' : inconsistent dll linkage. dllexport assumed.
C:\Windows\Desktop\dll1\Dlg1.cpp(36) : warning C4273: '_GetBaseMessageMap' : inconsistent dll linkage. dllexport assumed.
C:\Windows\Desktop\dll1\Dlg1.cpp(36) : warning C4273: 'GetMessageMap' : inconsistent dll linkage. dllexport assumed.
C:\Windows\Desktop\dll1\Dlg1.cpp(36) : warning C4273: 'protected: static struct AFX_MSGMAP const CDlg1::messageMap' : inconsistent dll linkage. dllexport assumed.
C:\Windows\Desktop\dll1\Dlg1.cpp(36) : error C2491: 'CDlg1::messageMap' : definition of dllimport static data member not allowed
C:\Windows\Desktop\dll1\Dlg1.cpp(36) : warning C4273: 'private: static struct AFX_MSGMAP_ENTRY const * const CDlg1::_messageEntries' : inconsistent dll linkage. dllexport assumed.
C:\Windows\Desktop\dll1\Dlg1.cpp(36) : error C2491: 'CDlg1::_messageEntries' : definition of dllimport static data member not allowed
Generating Code...
Error executing cl.exe.
dll1.dll - 2 error(s), 6 warning(s)
--------------------------------------
Why ??????
|
|
|
|
|
|
I tried now to delete all the additions that I made ,
So I have in my dll project only regular dialog and his simple class(-CDlg1).
And I added function in the dll1.cpp so:
----------------------------------------------
extern "C" __declspec(dllexport) long CallDlg()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CDlg1 dlg;
dlg.DoModal();
return 0;
}
--------------------------------------------
Now I get the errors
--------------------Configuration: dll1 - Win32 Debug--------------------
Compiling...
dll1.cpp
C:\Windows\Desktop\dll1\dll1.cpp(58) : error C2146: syntax error : missing ';' before identifier 'code'
C:\Windows\Desktop\dll1\dll1.cpp(58) : error C2501: 'My' : missing storage-class or type specifiers
C:\Windows\Desktop\dll1\dll1.cpp(58) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
dll1.dll - 3 error(s), 0 warning(s)
__________________________________
What can I to do ???
|
|
|
|
|
the erros is so:
--------------------Configuration: dll1 - Win32 Debug--------------------
Compiling...
dll1.cpp
Linking...
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in dll1.obj
mfcs42d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already defined in dll1.obj
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in dll1.obj; second definition ignored
mfcs42d.lib(dllmodul.obj) : warning LNK4006: __pRawDllMain already defined in dll1.obj; second definition ignored
Creating library Debug/dll1.lib and object Debug/dll1.exp
Debug/dll1.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
dll1.dll - 3 error(s), 2 warning(s)
|
|
|
|
|
Did you define DLL_BUILDING in your pre-processor settings?
Michael
|
|
|
|
|