BCB中有没有类似MFC中的CRect的东东?
小弟在程序中需要用CRect的对象,并要使用CRect方法,这便需要用到Afxwin.h这个头文件,可是我程序中已经用了vcl.h,若再用Afxwin.h编译报错[C++ Fatal Error] afxv_w32.h(14): F1003 Error directive: WINDOWS.H already included. MFC apps must not #include <windows.h>。类似的问题偶经常遇到,请教高手有什么法子可以解决之?谢谢 问题点数:20、回复次数:7Top
1 楼spcec(zeus)回复于 2003-09-02 20:48:23 得分 0
还有bcb中有什么函数可以起到和AfxGetInstanceHandle()以及GetSafeHwnd()一样的作用?Top
2 楼jishiping(JSP 季世平)回复于 2003-09-02 20:51:57 得分 5
CRect 是VC的东西,BCB中使用TRect。
VC中的AfxGetInstanceHandle(),BCB可以直接使用 HInstance 。Top
3 楼kingcaiyao(aking)回复于 2003-09-02 20:51:57 得分 3
TRect就是。
事实上TRect,CRect均是对Windows数据类型Rect的封装。Top
4 楼invalid(空心菜(Python是个好东东,大家多用用!))回复于 2003-09-02 21:05:06 得分 3
MFC的类一般是C开头,转换成borland的就是T开头Top
5 楼spcec(zeus)回复于 2003-09-02 21:36:01 得分 0
以下这两条语句在bcb中如何实现呢?
HINSTANCE hInst = AfxGetInstanceHandle();
//AfxGetInstanceHandle always returns the HINSTANCE of your executable file (.EXE) unless it is called from within a DLL linked with the USRDLL version of MFC. In this case, it returns an HINSTANCE to the DLL.
HWND hWnd = GetSafeHwnd();
//此函数返回的是CWnd类的m_hWnd数据成员。Returns the window handle for a window.
这两句需要放到__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)中执行
请大虾解惑,谢谢!Top
6 楼sun_wyz(欲将心事付瑶琴 知音少 弦断有谁听)回复于 2003-09-02 22:12:59 得分 4
HWND hWnd=Application->Handle;
hWnd就是你的程序的句柄了。Top
7 楼jishiping(JSP 季世平)回复于 2003-09-02 22:22:16 得分 5
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
//......
HWND hWnd = Handle;
//......
HINSTANCE hInst = HInstance;
//......
}Top



