How do I remove the warning "conversion from 'int' to 'HMENU' of greater size"?

CDev-8220 300 Reputation points
2023-11-29T19:52:25.3933333+00:00

I followed the guide on Creating, Enumerating, and Sizing Child Windows, but I'm getting a warning on this line of code:

(HMENU) (int) (ID_FIRSTCHILD + i), 

warning C4312: 'type cast': conversion from 'int' to 'HMENU' of greater size

How do I fix this?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,904 questions
{count} votes

Accepted answer
  1. Viorel 121.3K Reputation points
    2023-11-29T20:24:14.5633333+00:00

    This seems to work: (HMENU)INT_PTR(ID_FIRSTCHILD + i).

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Barry Schwarz 3,736 Reputation points
    2023-11-29T20:21:57.5866667+00:00

    Look up the #pragma warning disable feature.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.