I am going to paste all the relevant parts the resource control statements
I am not quite sure what drives the Drawitem at one point I thought it was SetWindowText (I do that to )
have a breakpoint at the DRAWITMEM and doesnt get called
thanks
IDD_DIALOG10 DIALOGEX 0, 0, 769, 429
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Storage View / Change"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_TCB,"Static",WS_CHILD| SS_OWNERDRAW, 45,30,47,8
CONTROL "Owning TCB",IDC_TCB_LABEL,"Static",WS_CHILD | SS_OWNERDRAW, 41,13,58,8
CONTROL "",IDC_SP,"Static",WS_CHILD | SS_OWNERDRAW ,164,28,43,8
CONTROL "Storage SubPool",IDC_SUBPOOL_LABEL,"Static", WS_CHILD | SS_OWNERDRAW, 162,12,55,8
CONTROL "",IDC_ASID,"Static", WS_CHILD | SS_OWNERDRAW, 265,26,32,8
CONTROL "Asid",IDC_ASID_LABEL,"Static", WS_CHILD | SS_OWNERDRAW ,269,9,31,8,SS_OWNERDRAW
CONTROL "",IDC_FP,"Static", WS_CHILD | SS_OWNERDRAW , 399,31,19,8
CONTROL "Fetch Protect Key",IDC_FP_LABEL,"Static",WS_CHILD | SS_OWNERDRAW ,392,15,63,8
CONTROL "",IDC_CUSTOM5,"PieCOntrol",WS_TABSTOP,617,99,109,109
COMBOBOX IDC_COMBO1,491,236,48,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_EDIT2,"RichEdit20A",ES_MULTILINE | WS_BORDER | WS_TABSTOP,45,106,494,314
COMBOBOX IDC_COMBO2,637,244,67,16,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
LISTBOX IDC_LIST2,641,310,68,11,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
CONTROL "Storage Area",IDC_AREA_LABEL,"Static", WS_CHILD | SS_OWNERDRAW , 534,14,58,8
CONTROL "",IDC_AREA,"Static", WS_CHILD | SS_OWNERDRAW , 537,25,31,8
CONTROL "Storage Key",IDC_KEY_LABEL,"Static", WS_CHILD | SS_OWNERDRAW, 651,17,48,8
CONTROL "",IDC_KEY,"Static", WS_CHILD | SS_OWNERDRAW , 654,31,30,8
END
Defined in the Dialog class
CMystatic ctcb, csubpool, casid, cfp, carea, ckey, ctcblabel, csubpoolabel, casidlabel,cfplabel, carealabel, ckeylabel;
The CMystatic class
#pragma once
#include "afx.h"
#include "afxwin.h"
class CMystatic : public CStatic
{
DECLARE_DYNAMIC(CMystatic)
public:
CMystatic();
virtual void DrawItem(LPDRAWITEMSTRUCT pdi);
BYTE red;
BYTE green;
BYTE blue;
char fontface[16];
int width;
char text[9];
protected:
DECLARE_MESSAGE_MAP()
};
The DDX statements
void CStorge::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ASID_LABEL, casidlabel);
DDX_Control(pDX, IDC_ASID, casid);
DDX_Control(pDX, IDC_SUBPOOL_LABEL, csubpoolabel);
DDX_Control(pDX, IDC_SP, csubpool);
DDX_Control(pDX, IDC_TCB_LABEL, ctcblabel);
DDX_Control(pDX, IDC_TCB, ctcb);
DDX_Control(pDX, IDC_FP_LABEL, cfplabel);
DDX_Control(pDX, IDC_FP, cfp);
DDX_Control(pDX, IDC_AREA_LABEL, carealabel);
DDX_Control(pDX, IDC_AREA, carea);
DDX_Control(pDX, IDC_KEY_LABEL, ckeylabel);
DDX_Control(pDX, IDC_KEY, ckey);
DDX_Control(pDX, IDC_EDIT2, (CWnd&) *storagepointer);
}
The DRAWITEM
IMPLEMENT_DYNAMIC(CMystatic, CStatic)
CMystatic::CMystatic()
{
}
void CMystatic::DrawItem(LPDRAWITEMSTRUCT pdi)
{
ASSERT(pdi->CtlType == ODT_STATIC);
CDC* pDC = CDC::FromHandle(pdi->hDC);
ASSERT(pDC != NULL);
CWnd* phwnd = CWnd::FromHandle(pdi->hwndItem);
strcpy_s(&fontface[0],15, "Times New Roman");
pDC->FillSolidRect(&pdi->rcItem, RGB(240, 255, 255));
CString str;
phwnd->GetWindowText(str);
UINT nFormat = DT_CENTER;
DWORD dwStyle = phwnd->GetStyle();
if (dwStyle & SS_NOPREFIX)
nFormat |= DT_NOPREFIX;
if ((dwStyle & SS_CENTERIMAGE) && str.Find(_T('\n')) < 0)
{
nFormat &= ~DT_WORDBREAK;
nFormat |= DT_VCENTER | DT_SINGLELINE; }
if (dwStyle & SS_ELLIPSISMASK)
{
nFormat &= ~DT_EXPANDTABS; switch (dwStyle & SS_ELLIPSISMASK)
{
case SS_ENDELLIPSIS:
nFormat |= DT_END_ELLIPSIS | DT_MODIFYSTRING; break;
case SS_PATHELLIPSIS:
nFormat |= DT_PATH_ELLIPSIS | DT_MODIFYSTRING; break;
case SS_WORDELLIPSIS:
nFormat |= DT_WORD_ELLIPSIS; break;
}
}
if (!str.IsEmpty())
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,255));
int mapmode = pDC->GetMapMode();
CFont l_font;
LOGFONT lf;
TEXTMETRIC tm;
memset(&lf, 0x00, sizeof(lf));
pDC->GetTextMetrics(&tm);
lf.lfHeight = tm.tmHeight + 4;
CSize sz;
sz = pDC->GetTextExtent(str, str.GetLength());
lf.lfWidth = (sz.cx / str.GetLength()) + width;
lf.lfWeight = 700;
strcpy_s(lf.lfFaceName,15, &fontface[0]); l_font.CreateFontIndirect(&lf);
pDC->SelectObject(&l_font);
LPTSTR lpszText = str.GetBuffer();
pDC->DrawText(lpszText, -1, &pdi->rcItem, nFormat);
str.ReleaseBuffer();
}
else
{
pDC->SetTextColor(RGB(255, 0, 0));
pDC->DrawText(&text[0], -1, &pdi->rcItem, nFormat);
}
}
BEGIN_MESSAGE_MAP(CMystatic, CStatic)
END_MESSAGE_MAP()
|