开发者

Returning int_ptr from dialogboxes

A dialogbox proc has a return type of BOOL but what i'm trying to do

case WM_CTLCOLORSTATIC:
        {
    开发者_如何转开发        HBRUSH g_hbrBackground = CreateSolidBrush(RGB(237, 209, 238));
            HDC hdcStatic = (HDC)wParam;
            SetBkMode(hdcStatic, TRANSPARENT);
            return (INT_PTR)g_hbrBackground;
        }

The above (INT_PTR) cases a performance warning conversion from int_ptr to bool, how it is done?


Here's the declaration of a dialog proc:

INT_PTR CALLBACK DialogProc(
  __in  HWND hwndDlg,
  __in  UINT uMsg,
  __in  WPARAM wParam,
  __in  LPARAM lParam
);

There's no BOOL there.

Use correct types and your problem disappears.

Cheers & hth.,


Typecast a brush handle to BOOL. This is way ugly, but this is how it is.


return (BOOL)(g_hbrBackground != 0);

should solve the warning.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜