void CMyView::OnReserveBlacklist() 
{
// TODO: Add your command handler code here
if(m_pblacklistdlg==NULL)
{
m_pblacklistdlg=new CBlacklistDlg ;
m_pblacklistdlg->Create(IDD_BLACKLIST,this);
} m_pblacklistdlg->ShowWindow(SW_SHOW);

}*************************
// BlacklistDlg.h : header file
///////////////////////////////////////////////////////////////////////////////
// CBlacklistDlg dialogclass CBlacklistDlg : public CDialog
{
// Construction
public:
CBlacklistDlg(CWnd* pParent = NULL);   // standard constructor// Dialog Data
//{{AFX_DATA(CBlacklistDlg)
enum { IDD = IDD_BLACKLIST };
CListCtrl m_resultlist;
CString m_certificatenum;
CString m_certificatetype;
CString m_description;
CString m_name;
CString m_type;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBlacklistDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected: // Generated message map functions
//{{AFX_MSG(CBlacklistDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};*************************
// BlacklistDlg.cpp : implementation file
//#include "stdafx.h"
#include "hotel.h"
#include "BlacklistDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CBlacklistDlg dialog
CBlacklistDlg::CBlacklistDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBlacklistDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBlacklistDlg)
m_certificatenum = _T("");
m_certificatetype = _T("");
m_description = _T("");
m_name = _T("");
m_type = _T("");
//}}AFX_DATA_INIT
}
void CBlacklistDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBlacklistDlg)
DDX_Control(pDX, IDC_RESULTLIST, m_resultlist);
DDX_Text(pDX, IDC_CERTIFICATENUM, m_certificatenum);
DDV_MaxChars(pDX, m_certificatenum, 20);
DDX_CBString(pDX, IDC_CERTIFICATETYPE, m_certificatetype);
DDV_MaxChars(pDX, m_certificatetype, 10);
DDX_Text(pDX, IDC_DESCRIPTION, m_description);
DDX_Text(pDX, IDC_NAME, m_name);
DDV_MaxChars(pDX, m_name, 10);
DDX_Text(pDX, IDC_TYPE, m_type);
DDV_MaxChars(pDX, m_type, 10);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBlacklistDlg, CDialog)
//{{AFX_MSG_MAP(CBlacklistDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()放在CMainFrame中也不行,编译时无错误提示,就是对话框出不来。

解决方案 »

  1.   

    建立模态对话框也不行。
    void CMyView::OnReserveBlacklist() 
    {
    // TODO: Add your command handler code here CBlacklistDlg m_pblacklistdlg ;
    m_pblacklistdlg.DoModal();

    }
      

  2.   

    这样的加法,只有当你这个VIEW是激活时,点击菜单时才会对菜单消息进行处理,所以就会出现你所说那种情况了,一般的菜单消息都是加到CMainFrm中的,这样可以随时响应你的点击!
      

  3.   

    原先,我是把菜单响应函数放到CMainFrame中的,后来看到一些例子,就把这些函数都放到CView中了,有什么区别吗?我建立的是SDI工程,是不是可以随时响应点击是模态对话框和非模态对话框的区别吧!
    “当你这个VIEW是激活时”是什么意思?
    我这个对话框不显示好像与菜单消息响应函数放到哪里无关,因为我在同一个菜单消息响应函数里换了一个对话框,就没问题了,显示一切正常。
    请高手指点!
      

  4.   

    检查你的resource.h,如果你是从别的地方拷贝的资源,那么很可能资源ID重复,而VC又不会自动纠正,只有手动改了!有时候会这样的!
      

  5.   

    谢谢,我就是从另一个工程中拷的资源。我要做一个数据库系统,有很多对话框,可以实现查询、增加、修改数据库记录。请问新建工程时选择什么结构的?我现在建的是SDI工程,我需要其中的菜单,但不需要文档,是不是应该选择SDI工程但不支持“文档/视图结构”呢?还是建一个基于对话框的工程?
    要把原来工程中的对话框资源全部拷过来该怎么做呢?非要一个一个的拷吗?有没有什么办法可以直接把某个文件加入工程?(*.cpp,*.h可以导入工程,那资源文件呢?)
      

  6.   

    Tasehouny(阿甘):我看了resource.h文件,是有很多重复的ID值,我有好几个对话框,这些对话框中的控件ID名称相同会不会有影响?我删了几个已经不存在的“ID”值,可还是不能解决问题,你可以帮我看看源码吗?
    源码:
    #define IDD_ABOUTBOX                    100
    #define IDR_MAINFRAME                   128
    #define IDR_HOTELTYPE                   129
    #define IDD_BLACKLIST                   130
    #define IDD_LEND                        131
    #define IDD_LOSS                        133
    #define IDD_LOSS_REGISTER               134
    #define IDD_PAYMENT                     135
    #define IDD_RECEIVE                     136
    #define IDD_RECEIVE_SEARCH              137
    #define IDD_RESERVE_SEARCH              138
    #define IDD_KEEPACCOUNT                 139
    #define IDD_ACCOUNT_SEARCH              140
    #define IDD_TIMEREPORT                  141
    #define IDD_PLANE_INCREASE              142
    #define IDD_PARAMETER                   143
    #define IDD_POST                        145
    #define IDD_BUS_MODIFY                  146
    #define IDD_BUS_INCREASE                147
    #define IDD_PLANE_MODIFY                148
    #define IDD_POST_INCREASE               149
    #define IDD_POST_MODIFY                 150
    #define IDD_OPERATOR                    151
    #define IDD_OPERATOR_INCREASE           152
    #define IDD_OPERATOR_MODIFY             153
    #define IDD_CONFIGURATION_ROOM          154
    #define IDD_LEND_INCREASE               155
    #define IDD_RESERVE                     156
    #define IDD_CONTINUE                    158
    #define IDD_CHANGEROOM                  159
    #define IDD_CONFIGURATION_PARAM         160
    #define IDD_MAINFRAME                   161
    #define IDB_MAIN                        162
    #define IDD_CONFROOM_INCREASE           163
    #define IDD_BLACKLIST_INCREASE          164
    #define IDD_BLACKLIST_MODIFY            165
    #define IDD_TRAIN_INCREASE              166
    #define IDD_TRAIN_MODIFY                167
    #define IDD_GUESTFILE                   168
    #define IDD_LEFT                        170
    #define IDD_REGISTER                    171
    #define IDD_LOSSTREAT                   172
    #define IDD_ROOMSTATE                   173
    #define IDD_WORLDTIME                   175
    #define IDD_REPORT                      177
    #define IDD_DIALOG2                     178
    #define IDD_ROOMPRICE                   179
    #define IDD_PRICE_INCREASE              180
    #define IDD_FRONTMONEY                  181
    #define IDC_TODAY                       1005
    #define IDC_GROUPNAME                   1007
    #define IDC_INCREASE1                   1012
    #define IDC_INCREASE2                   1014
    #define IDC_CONTINUE                    1015
    #define IDC_BUTTON4                     1016
    #define IDC_INCREASE4                   1017
    #define IDC_HISTORY                     1018
    #define IDC_DATETIMEPICKER1             1019
    #define IDC_DATETIMEPICKER2             1020
    #define IDC_VALUE2                      1021
    #define IDC_EDIT1                       1022
    #define IDC_SEARCHITEM                  1023
    #define IDC_STARTTIME                   1023
    #define IDC_ARRIVETIME                  1024
    #define IDC_ROOMPRICE                   1024
    #define IDC_EDIT                        1025
    #define IDC_OPERATOR                    1030
    #define IDC_DATE                        1031
    #define IDC_DEPARTMENT                  1032
    #define IDC_ITEM                        1033
    #define IDC_ACCOUNTLIST                 1034
    #define IDC_BUTTON1                     1036
    #define IDC_FILE                        1036
    #define IDC_ARRANGE                     1036
    #define IDC_EXCHANGE                    1037
    #define IDC_FUTURE                      1037
    #define IDC_FIXEDEDIT                   1037
    #define IDC_BUTTON3                     1038
    #define IDC_BUTTON5                     1039
    #define IDC_TO                          1040
    #define IDC_HAWAII                      1040
    #define IDC_PLANENUM                    1041
    #define IDC_KARACHI                     1041
    #define IDC_TIMELIST_PLANE              1042
    #define IDC_MOSCOW                      1042
    #define IDC_TIMELIST                    1042
    #define IDC_FROM                        1043
    #define IDC_NAIROBI                     1043
    #define IDC_INCREASE                    1044
    #define IDC_RESERVENUM                  1045
    #define IDC_RESERVEDATE                 1046
    #define IDC_TIMEREPORT_TAB              1046
    #define IDC_FROMLAND                    1047
    #define IDC_TOLAND                      1048
    #define IDC_RESULT_LIST                 1048
    #define IDC_VIP                         1048
    #define IDC_MEETING                     1049
    #define IDC_PLACE                       1050
    #define IDC_PHONE                       1051
    #define IDC_POSTNUM                     1052
    #define IDC_OPERATORLIST                1053
    #define IDC_DELETEPASSWORD              1054
    #define IDC_EDIT2                       1055
    #define IDC_EDIT3                       1056
    #define IDC_CAIRO                       1056
    #define IDC_ROOMLIST                    1057
    #define IDC_ISRAEL                      1057
    #define IDC_PARIS                       1058
    #define IDC_BERLIN                      1059
    #define IDC_ROME                        1060
    #define IDC_VIENNA                      1061
    #define IDC_NEWDATELEAVE                1062
    #define IDC_DAYS                        1063
    #define IDC_CURRENTROOM                 1064
    #define IDC_BANGKOK                     1064
    #define IDC_NEWROOM                     1065
    #define IDC_NEWYORK                     1065
    #define IDC_BMP                         1066
    #define IDC_LOSANGELES                  1066
    #define IDC_EDIT4                       1067
    #define IDC_EDIT5                       1068
    #define IDC_ISTANBUL                    1069
    #define IDC_CERTIFICATETYPE             1070
    #define IDC_BUSNUM                      1071
    #define IDC_LONDON                      1071
    #define IDC_DISCOUNT                    1072
    #define IDC_TRAINNUM                    1072
    #define IDC_DURTY                       1073
    #define IDC_SETTLE                      1074
    #define IDC_MARKET                      1075
    #define IDC_CHARGE                      1075
    #define IDC_SOURCE                      1076
    #define IDC_OBJECTPRICE                 1076
    #define IDC_WAY                         1077
    #define IDC_PASSWORD                    1077
    #define IDC_PAYWAY                      1078
    #define IDC_FILELIST                    1078
    #define IDC_VISAVALID                   1079
    #define IDC_VALUE1                      1079
    #define IDC_CHANGE                      1080
      

  7.   

    #define IDC_BRUSSELS                    1080
    #define IDC_BEIJING                     1081
    #define IDC_CANCEL                      1082
    #define IDC_SINGAPORE                   1082
    #define IDC_CONTENT                     1083
    #define IDC_LEFTWAY                     1085
    #define IDC_SEOUL                       1086
    #define IDC_SYDNEY                      1087
    #define IDC_STATIC_TAB0                 1093
    #define IDC_DATEARRIVE                  1094
    #define IDC_STATIC_TAB1                 1094
    #define IDC_ROOMSTATE                   1097
    #define IDC_STATIC_TAB3                 1097
    #define IDC_FIXED                       1098
    #define IDC_EMPTY                       1099
    #define IDC_STATIC_TAB6                 1099
    #define IDC_STATIC_TAB7                 1100
    #define IDC_NAME                        1101
    #define IDC_STATIC_TAB8                 1101
    #define IDC_NUMBER                      1102
    #define IDC_CERTIFICATENUM              1102
    #define IDC_VALUE                       1102
    #define IDC_TYPE                        1103
    #define IDC_STATIC_TAB4                 1103
    #define IDC_DESCRIPTION                 1104
    #define IDC_STATIC_TAB5                 1104
    #define IDC_SEARCH                      1105
    #define IDC_STATIC_TAB2                 1105
    #define IDC_CREATE                      1106
    #define IDC_MODIFY                      1107
    #define IDC_TAB_REPORT                  1107
    #define IDC_DELETE                      1108
    #define IDC_PRINT                       1109
    #define IDC_RESULTLIST                  1110
    #define IDC_DIRTY                       1110
    #define IDC_PAY                         1111
    #define IDC_AVERAGEINCOME               1111
    #define IDC_RETURN                      1112
    #define IDC_LENDLIST                    1113
    #define IDC_SCATTEREDINCOME             1113
    #define IDC_OBJECT                      1114
    #define IDC_GROUPINCOME                 1114
    #define IDC_ROOMNUM                     1115
    #define IDC_ROOMSTOTAL                  1115
    #define IDC_DATEFROM                    1116
    #define IDC_DATETO                      1117
    #define IDC_DAILY                       1118
    #define IDC_PRICECONFIG                 1119
    #define IDC_USEDTOTAL                   1120
    #define IDC_INCOME                      1121
    #define IDC_RENTRATE                    1122
    #define IDC_REPAIRED                    1123
    #define IDC_LOSSNAME                    1124
    #define IDC_VIEW                        1124
    #define IDC_LOSSLIST                    1125
    #define IDC_REMAINLIST                  1125
    #define IDC_TREAT                       1126
    #define IDC_GROUPLIST                   1126
    #define IDC_RESERVELIST                 1127
    #define IDC_LEAVELIST                   1128
    #define IDC_REMARKS                     1129
    #define IDC_DAILYLIST                   1129
    #define IDC_PRICE                       1130
    #define IDC_PRICELIST                   1130
    #define IDC_LOSSDATE                    1131
    #define IDC_OBJECTLIST                  1132
    #define IDC_SEX                         1133
    #define IDC_STATIC_TO                   1135
    #define IDC_BIRTHDAY                    1136
    #define IDC_LANGUAGE                    1137
    #define IDC_COUNTRY                     1138
    #define IDC_CREDENTIALS                 1139
    #define IDC_CREDENTIALSNUM              1140
    #define IDC_CREDENTIALSTYPE             1141
    #define IDC_VISATYPE                    1142
    #define IDC_TELEPHONE                   1143
    #define IDC_TELEFAX                     1144
    #define IDC_FAX                         1144
    #define IDC_POSTCODE                    1145
    #define IDC_DATELEAVE                   1146
    #define IDC_TIMEINTO                    1147
    #define IDC_COUNT                       1148
    #define IDC_PEOPLE                      1148
    #define IDC_ROOMCOUNT                   1149
    #define IDC_ROOMS                       1149
    #define IDC_ROOMTYPE                    1150
    #define IDC_ROOMCODE                    1152
    #define IDC_INCLUDEPRICE                1153
    #define IDC_AGREEPARTMENT               1154
    #define IDC_ILLUSTRATION                1155
    #define IDC_CLOSE                       1156
    #define IDC_SAVE                        1157
    #define IDC_OK                          1158
    #define IDC_INSIDE                      1159
    #define IDC_UNABLE                      1160
    #define IDC_FREE                        1161
    #define IDC_CALL                        1162
    #define IDC_OKEDIT                      1163
    #define IDC_UNCHECKEDIT                 1164
    #define IDC_UNCHECK                     1165
    #define IDC_EMPTYEDIT                   1166
    #define IDC_DURTYEDIT                   1167
    #define IDC_GUESTTYPE                   1172
    #define IDC_GUESTNAME                   1173
    #define IDC_RESERVEWAY                  1177
    #define IDC_RESERVEPERSON               1178
    #define IDC_ADDRESS                     1179
    #define IDC_FRONTMONEY                  1181
    #define IDC_FRONTPAYWAY                 1182
    #define IDC_TOKYO                       1183
    #define IDC_REGISTER                    1184
    #define IDC_REGISTERED                  1184
    #define IDC_BROKEN                      1187
    #define IDC_COUNTRYLIST                 1196
    #define IDC_SUBSCRIBELIST               1203
    #define IDC_PARAM_TAB                   1204
    #define IDC_HOTELNAME                   1205
    #define IDC_OBJECTNAME                  1211
    #define IDC_GOT                         1212
    #define IDC_TREATED                     1214
    #define IDC_MISGOT                      1215
    #define IDC_RETURNED                    1217
    #define ID_RESERVE_SEARCH               32771
    #define ID_RESERVE_NEW                  32772
    #define ID_RECEIVE_SEARCH               32773
    #define ID_RECEIVE_REGISTER             32774
    #define ID_ACCOUNT_SEARCH               32775
    #define ID_ACCOUNT_REPORT               32776
    #define ID_ASK_WORLDTIME                32777
    #define ID_ASK_TIMEREPORT               32778
    #define ID_ASK_POST                     32779
    #define ID_CONFIGURATION_ROOM           32780
    #define ID_CONFIGURATION_PARAM          32781
    #define ID_CONFIGURATION_OPERATION      32782
    #define ID_RECEIVE_LEFT                 32783
    #define ID_ROOM_STATE                   32784
    #define ID_ROOM_LOSS                    32785
    #define ID_ROOM_LEND                    32786
    #define ID_OTHERS_PAY                   32787
    #define ID_RESERVE_BLACKLIST            32788// Next default values for new objects
    // 
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_3D_CONTROLS                     1
    #define _APS_NEXT_RESOURCE_VALUE        184
    #define _APS_NEXT_COMMAND_VALUE         32785
    #define _APS_NEXT_CONTROL_VALUE         1137
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif