开发者

VC++ 6.0 MFC - Problem using Macro defined in <WINSER.H>

开发者 https://www.devze.com 2023-01-11 05:31 出处:网络
I am facing a weird problem. I have got a file calledin which I am using a macro called \"WM_USER\", the macro is defined in another header file called . Now the problem is that when I am using the ma

I am facing a weird problem. I have got a file called in which I am using a macro called "WM_USER", the macro is defined in another header file called . Now the problem is that when I am using the macro in the compiler doesn't recognize it. Its not the case that I haven't included , because earlier I wasn't having any problems it came out of no where. Following is the error that is shown on the compiler:

d:\project\project original\mirec2pc v1.0\gui\constants.h(26) : error C2065: 'WM_USER' : undeclared identifier
d:\project\project original\mirec2pc v1.0\gui\constants.h(26) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(27) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(28) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(29) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(30) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(31) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(32) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(33) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(34) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(35) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(36) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(37) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(38) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(39) : error C2057: expected constant expression
d:\project\project original\mirec2pc v1.0\gui\constants.h(40) : error C2057: expected constant expression

and here is my piece of code :

#ifndef CONSTANTS_H
#define CONSTANTS_H

#ifdef __cplusplus
extern "C"
{
#endif

#define SRCNAME_COL         0
#define REC_STATUS_COL      1
#define REC_TYPE_COL        2
#define REC_FILE_NAME_COL   3
#define REC_TIMER_COL       4


#define DLG_BK_COLOR RGB(220,228,236)
#define STATIC_BOX_BORDER_COLOR RGB(128,160,192)
#define STATIC_BOX_BORDER_DARK_COLOR RGB(83,126,200)
#define STATIC_BOX_BORDER_LIGHT_COLOR RGB(241,245,254)

#define MY_COMPUTER "My Computer"
#define FILE_NAME "\\transconf.txt"

enum
{
    WM_START_REC                = WM_USER + 100,
    WM_STOP_REC                 = WM_USER + 101,
    WM_RELOAD_SCHD              = WM_USER + 102,
    WM_CONFIG_RELOAD            = WM_USER + 103,
    WM_PROG_BAR_UPDATE          = WM_USER + 104,    //  MESSAGE TO UPDATE     THE PROGRESS BAR [10/3/2007 smkniazi]
    WM_GET_NEW_MP3_FILE         = WM_USER + 105,    //  MESSAGE TO GET NEW FILE NAME IN CASE OF FILE SPLITTING IN MP3 RECORDING
    WM_FILE_OPEN_FAILED         = WM_USER + 106,        //  MESSAGE TO MAIN GUI THAT FILE OPEN HAS FAILED IN THE MP4/MP4 FILE OPEN FUNCTION
    WM_GET_NEW_AAC_FILE         = WM_USER + 107,
    WM_GET_NEW_WAV_FILE         = WM_USER + 108,
    WM_FILENAME_CHANGED         = WM_USER + 109,
    WM_UPDATE_FILE_PATH         = WM_USER + 110,
    WM_START_STREAM             = WM_USER + 111,
    WM_UPDATE_IRECORD_LIST      = WM_USER + 150,
    WM_UPDATE_IREC_STATUS_COL   = WM_USER + 151,
    WM_CLOSE_QT_WINDOW          = WM_USER + 152,
};    


#define COMBO_COMPARISON_CHAR               '-'
#define H264_GENERIC_MP4_HEADING            "--MP4 Generic--"
#define H264_DEVICE_SPFIC_HEADING           "--Device Specific--"
#define AUDIO_ONLY_HEADING                  "--Audio Only Recording--"
#define TS_MUX_HEADING                      "--Transport     Stream--"
#define H264_QVGA_MP_AT_420Kbps_STR         "    QVGA MP@420Kbps"
#define H264_QVGA_STR                       "    QVGA (320*240)"
#define H264_VGA_STR                        "    VGA (640*480)"
#define H264_D1_STR                         "    Full D1 (720*480/576)"
#define H264_PSP_Native_STR                 "    PSP Native"
#define H264_iPhone_IPODTOUCH_Native_STR    "    iPhone/iPod Touch Native"
#define H264_PSP_QVGA_STR                   "    PSP QVGA"
#define H264_IPOD_QVGA                      "    iPod QVGA"
#define H264_IPOD_VGA                       "    iPod VGA"
#define H264_PS3_STR                        "    Apple TV/PS3"
#define H264_XBOX_360_STR                   "    XBOX 360"
#define MP3_REC_STR                         "    MP3 Audio"
#define AAC_REC_STR                         "    AAC Audio"
#define WAV_REC_开发者_开发问答STR                         "    WAV Audio"
#define FLAC_REC_STR                        "    FLAC Audio"
#define TS_MUX_QVGA_STR                     "    TSMux QVGA (320*240)"
#define TS_MUX_VGA_STR                      "    TSMux VGA  (640*480)"
#define TS_MUX_FULLD1_STR                   "    TSMux FULL D1 (720*480/576)"


#define WM_UPDATE_FILE_PROG_BAR     WM_USER+200
#define WM_EDIT_COL_UPDATED         WM_USER+201
#define WM_UPDATE_REMOVABLE_DRIVES  WM_USER+202

#ifdef __cplusplus
}
#endif

#endif


You have no #include in your header so this is expectable. In case your constants.h is included in a file that includes a header with WM_USER definition, your code can compile. But IMO it is always better to do explicit inclusions.

Anyway, just #include <winuser.h> or since WM_USER is a constant, add this to the top of your header

#ifndef WM_USER
#define WM_USER                         0x0400
#endif

Cheers.

0

精彩评论

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