下記のプログラムを実行するとステータスが0×0100と0×0300しか返ってこず、
if分が実行されません。
MFCダイアログでは上手く実行できますが、
ActiveXでは上手く実行できません。
原因がわからず困っています。
この記述だとActiveXでは上手くいかないのでしょうか?
UINT nState = lpDrawItemStruct->itemState;
現状:ボタンを押下しても下2ケタの2ビットが取得できない。
<取得したい値>
ODS_SELECTED 0x0001
ODS_FOCUS 0x0010
開発環境
・Visual Studio 2008
・ActiveXコントロール
・Windows7
VC++
1void CAXSMPCtrl::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 2{ 3 // TODO: ここにメッセージ ハンドラ コードを追加するか、既定の処理を呼び出します。 4 if (lpDrawItemStruct->CtlType == ODT_BUTTON) { 5 if (nIDCtl == IDC_BUTTON1) { 6 CDC dc; 7 dc.Attach(lpDrawItemStruct->hDC); 8 CRect rect(lpDrawItemStruct->rcItem); 9 10 CDC* pDC = &dc; 11 CString strCaption; 12 UINT nState = lpDrawItemStruct->itemState; 13 CRect focusRect, btnRect; 14 focusRect.CopyRect(&lpDrawItemStruct->rcItem); 15 btnRect.CopyRect(&lpDrawItemStruct->rcItem); 16 17 // フォーカス矩形領域の作成 18 focusRect.left += 4; 19 focusRect.right -= 4; 20 focusRect.top += 4; 21 focusRect.bottom -= 4; 22 23 // ボタンのキャプションを取得 24 m_pButton1->GetWindowText(strCaption); 25 26 // ボタンの描画(背景色、エッジ、キャプション) 27 DrawBkGround(pDC, btnRect, GetBackGroundColor()); 28 DrawCaption(pDC, btnRect, GetTextColor(),strCaption); 29 pDC->DrawEdge(btnRect,EDGE_RAISED,BF_RECT); 30 31 // フォーカスを得たときや選択されているとき 32 if (nState & ODS_FOCUS) 33 { 34 if (nState & ODS_SELECTED) 35 { 36 pDC->DrawEdge(btnRect,EDGE_SUNKEN,BF_RECT); 37 } 38 pDC->DrawFocusRect(focusRect); 39 }// ボタンが無効であるとき 40 else if(nState & ODS_DISABLED) 41 { 42 DrawCaption(pDC, btnRect, GetDisabledColor(), strCaption); 43 } 44 dc.Detach(); 45 return; 46 } 47 COleControl::OnDrawItem(nIDCtl, lpDrawItemStruct); 48 } 49}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/10/28 12:22
2015/10/28 13:13