弹出消息框

mazhichao84 2010-08-02 03:48:13
代码:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
extern PACKAGE int __fastcall MessageDlgPos(const AnsiString Msg,TmsgDlgType DlgType,TmsDlgButtons Buttons,int HelpCtx,int X,int Y);

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{ MessageDlg("can you use messagedlg?",mtConfirmation,TMsgDlgButtons()<<mbYes<<mbNo,0);
}
//---------------------------------------------------------------------------
错误提示:
Build
[C++ Error] Unit1.cpp(12): E2303 Type name expected
哪位帮帮忙,解决一下
...全文
82 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
ccrun.com 2010-08-02
  • 打赏
  • 举报
回复
倒分?
mazhichao84 2010-08-02
  • 打赏
  • 举报
回复
呵呵。。。
mazhichao84 2010-08-02
  • 打赏
  • 举报
回复
谢谢!!
ccrun.com 2010-08-02
  • 打赏
  • 举报
回复
这20分真难挣.
ccrun.com 2010-08-02
  • 打赏
  • 举报
回复
一声叹息.

#include <dialogs.hpp>

MessageDlgPos("消息内容", mtConfirmation,
TMsgDlgButtons() << mbYes << mbNo, 0, 100, 100);
周药师 2010-08-02
  • 打赏
  • 举报
回复

TForm1 *Form1;
//TMsgDlgType和TMsgDlgButtons 注意大小写
//可以正常弹出对话框了
extern PACKAGE int __fastcall MessageDlgPos(const AnsiString Msg,TMsgDlgType DlgType,TMsgDlgButtons Buttons,int HelpCtx,int X,int Y);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
MessageDlg("can you use messagedlg?",mtConfirmation,TMsgDlgButtons()<<mbYes<<mbNo,0);
}
mazhichao84 2010-08-02
  • 打赏
  • 举报
回复
不用那一行编译可以通过,这个我试过
但我需要的是用x,y确定消息框的位置
周药师 2010-08-02
  • 打赏
  • 举报
回复
TmsDlgButtons 这个类型不存在,
lz你用了三方控件?
ccrun.com 2010-08-02
  • 打赏
  • 举报
回复
extern PACKAGE int __fastcall MessageDlgPos(const AnsiString Msg,TmsgDlgType DlgType,TmsDlgButtons Buttons,int HelpCtx,int X,int Y);

报错是因为编译器不认识你的TmsgDlgType,TmsDlgButtons类型. VCL中只有TMsgDlgType和TMsgDlgButtons

把这个声明去掉就行了. 纯属画蛇添足.

如果你想在单元中使用MessageDlg,直接包含头文件:#include <dialogs.hpp>就行了.
周药师 2010-08-02
  • 打赏
  • 举报
回复
PACKAGE int __fastcall MessageDlgPos(const AnsiString Msg,TmsgDlgType DlgType,TmsDlgButtons Buttons,int HelpCtx,int X,int Y);
你的TmsDlgButtons 类型哪里来的?
明朝2013 2010-08-02
  • 打赏
  • 举报
回复
MessageDlg("can you use messagedlg?",mtConfirmation,TMsgDlgButtons()<<mbYes<<mbNo,0);
代码没错呀,
extern PACKAGE int __fastcall MessageDlgPos(const AnsiString Msg,TmsgDlgType DlgType,TmsDlgButtons Buttons,int HelpCtx,int X,int Y);
你用这做什么的?

552

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 茶馆
社区管理员
  • 茶馆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧