CWnd* pParentWnd 什么意思

m372897528 2011-06-20 10:17:49
BOOL Create( LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff );
上面是MSDN中的原型

void CDIAArtwoek:: bigpicshow()//显示图片
{
CStaticPic* myStatic;//CStaticPic继承CStatic类
for(int i=0;i<5;i++)
{
myStatic[i].Create( NULL,WS_EX_TRANSPARENT|WS_CHILD|WS_VISIBLE|WS_TABSTOP|SS_BITMAP|SS_NOTIFY , CRect(nx,30,100,100), this, IDC_PICTURE0+i)) ;
}
}
1 CWnd* pParentWnd是什么
2怎样获取CWnd* pParentWnd
3this与CWnd* pParentWnd什么关系
4用什么保存CWnd* pParentWnd,我想把this替换掉
...全文
519 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ly6765395 2011-06-20
  • 打赏
  • 举报
回复
1 CWnd* pParentWnd 指向父窗口的指针
2 CWnd::GetParent() 可以获取对象的父窗口指针,前提是有指定的父窗口。这里得指定一个窗口作为控件的父窗口
3this与CWnd* pParentWnd这里的this是指对象本身,是个CWnd指针,也就是说用当前窗口作为控件myStatic[i]的父窗口。
4如果不想指定当前窗口为父窗口的话,那就用另外的窗口指针替换它。如果是把当前窗口指定为父窗口的话,用this就行了。它本身就是当前窗口指针CWnd*类型

最后 多查阅MSDN
y1018799688 2011-06-20
  • 打赏
  • 举报
回复
学习勒。。。。
zjs100901 2011-06-20
  • 打赏
  • 举报
回复
1.pParentWnd 是父窗口的指针
2.在创建子的时候,父早就有了。
3.this就是CDIAArtwoek这个对象的指针,这是C++语言中的东西。
4.
hedy007 2011-06-20
  • 打赏
  • 举报
回复
CStatic::Create
BOOL Create( LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff );

Return Value

Nonzero if successful; otherwise 0.

Parameters

lpszText

Specifies the text to place in the control. If NULL, no text will be visible.

dwStyle

Specifies the static control’s window style. Apply any combination of static control styles to the control.

rect

Specifies the position and size of the static control. It can be either a RECT structure or a CRect object.

pParentWnd

Specifies the CStatic parent window, usually a CDialog object. It must not be NULL.

nID

Specifies the static control’s control ID.

Remarks

Construct a CStatic object in two steps. First call the constructor CStatic, then call Create, which creates the Windows static control and attaches it to the CStatic object.

Apply the following window styles to a static control:

WS_CHILD Always


WS_VISIBLE Usually


WS_DISABLED Rarely
If you're going to display a bitmap, cursor, icon, or metafile in the static control, you'll need to apply one of the following styles:

SS_BITMAP Use this style for bitmaps.


SS_ICON Use this style for cursors and icons.


SS_ENHMETAFILE Use this style for enhanced metafiles.
For cursors, bitmaps, or icons, you may also want to use the following style:

SS_CENTERIMAGE Use to center the image in the static control.
Example

CStatic myStatic;

// Create a child static control that centers its text horizontally.
myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(10,10,150,50), pParentWnd);

CStatic Overview | Class Members | Hierarchy Chart

See Also CStatic::CStatic


--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
hedy007 2011-06-20
  • 打赏
  • 举报
回复
1,父窗口的指针,这里就是CDIAArtwoek类的窗口
2,看你从那里获取了,
3,this是CDIAArtwoek类成员函数中的隐藏指针,指向CDIAArtwoek类对象
4,替换掉?为什么?CDIAArtwoek *pCDIAArtwoek = this;
  • 打赏
  • 举报
回复
呃,msdn吧,上面有你想要的

64,642

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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