我的程序是这样的:
void CCreateButtonView::OnRButtonDown(UINT nFlags, CPoint point)
{ CWnd m_ax;
LPCTSTR pszName = "MSDBGrid.DBGrid";
//控件的ProgID ,这里我用的是DBGrid32.ocx
m_ax.CreateControl (pszName,NULL, WS_VISIBLE | WS_CHILD,
CRect(100,100,200,200), this, AFX_IDW_PANE_FIRST);
m_ax.ShowWindow(SW_SHOW); CView::OnRButtonDown(nFlags, point);
}想要实现的功能是:在View中右键单击动态创建DBGrid.ocx控件的子窗体,通过调试发现没有问题,创建成功,但就是不能将创建的控件显示出来。
最奇怪的是,如果我在m_ax.ShowWindow(SW_SHOW);之后加上一句 AfxMessageBox("hehe");创建的子窗体居然能显示出来了,请高手指点,这到底是怎么回事啊?应该怎么解决?多谢
void CCreateButtonView::OnRButtonDown(UINT nFlags, CPoint point)
{ CWnd m_ax;
LPCTSTR pszName = "MSDBGrid.DBGrid";
//控件的ProgID ,这里我用的是DBGrid32.ocx
m_ax.CreateControl (pszName,NULL, WS_VISIBLE | WS_CHILD,
CRect(100,100,200,200), this, AFX_IDW_PANE_FIRST);
m_ax.ShowWindow(SW_SHOW); CView::OnRButtonDown(nFlags, point);
}想要实现的功能是:在View中右键单击动态创建DBGrid.ocx控件的子窗体,通过调试发现没有问题,创建成功,但就是不能将创建的控件显示出来。
最奇怪的是,如果我在m_ax.ShowWindow(SW_SHOW);之后加上一句 AfxMessageBox("hehe");创建的子窗体居然能显示出来了,请高手指点,这到底是怎么回事啊?应该怎么解决?多谢
解决方案 »
- CFormView视图的切换.对话框的控件没有和参数关联
- C++ 对话框C++ 对话框C++ 对话框C++ 对话框 问题来了!!!!!!!!
- "stdafx.h"问题 急
- 如何在对话框上分别显示两张图片
- 使用VC开发网管软件Net-SNMP和SNMP++,使用哪个好?
- 放分!放分!放分!明日揭帖
- 高分求《VC++技术内幕》第四版!!
- 请教:WSASend (5) failed with error 这样报错怎么解决?
- 怎样往一个COleDataSource类型的变量放一个CListCtrl项?
- 谁知道哪有指纹识别的源码?
- EnableMenuItem好像失效了?
- 单文档程序,需要打开不同的doc,这时,内存在哪里释放啊
m_ax.CreateControl (pszName,NULL, WS_VISIBLE ,CRect(100,100,200,200), this, AFX_IDW_PANE_FIRST); WS_CHILD似乎不能被CreateControl 识别:Only a subset of the Windows dwStyle flags are supported for CreateControl: WS_VISIBLE Creates a window that is initially visible. Required if you want the control to be visible immediately, like ordinary windows.
WS_DISABLED Creates a window that is initially disabled. A disabled window cannot receive input from the user. Can be set if the control has an Enabled property.
WS_BORDER Creates a window with a thin-line border. Can be set if control has a BorderStyle property.
WS_GROUP Specifies the first control of a group of controls. The user can change the keyboard focus from one control in the group to the next by using the direction keys. All controls defined with the WS_GROUP style after the first control belong to the same group. The next control with the WS_GROUP style ends the group and starts the next group.
WS_TABSTOP Specifies a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control of the WS_TABSTOP style.