如何按比例缩放对话框以及上面的控件 在一个按钮单击消息中创建一个对话框,希望能控制他的尺寸,那么如何能使这个对话框以及上面的控件按比例缩放而不是被截断或扩大呢?谢谢大家了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 举个例子,这个例子没有经过仔细测试在.h中声明/////////////////////////////////////////////////////////////////////////////// CSize1Dlg dialogstruct MyRect{ double left; double top; double right; double bottom;};struct MyControlSize{ struct MyRect r; HWND h; struct MyControlSize *next; struct MyControlSize *last;};BOOL CALLBACK EnumChildProc( HWND hwnd, // handle to child window LPARAM lParam // application-defined value); void MyDelete( void );在.cpp中/////////////////////////////////////////////////////////////////////////////// CSize1Dlg message handlersstruct MyControlSize first;CSize1Dlg *parent;struct MyRect pr;int ttt;int ppp;BOOL CALLBACKEnumChildProc( HWND hwnd, LPARAM lParam ){ struct MyControlSize *t; t = &first; while( t->next ) { t = t->next; } t->next = new struct MyControlSize; t->next->next = NULL; t->next->h = hwnd; t->next->last = t; RECT r; ::GetWindowRect( hwnd, &r ); t->next->r.left = ( double )r.left; t->next->r.top = ( double )r.top; t->next->r.right = ( double )r.right; t->next->r.bottom = ( double )r.bottom; return 1;}BOOL CSize1Dlg::OnInitDialog(){ CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here parent = this; EnumChildWindows( this->m_hWnd, EnumChildProc, 0 ); RECT r; RECT rr; GetClientRect( &r ); GetWindowRect( &rr ); ppp = ( rr.right - r.right ) / 2; ttt = rr.bottom - r.bottom - ppp; pr.left = ( double ) r.left; pr.top = ( double )r.top; pr.right = ( double )r.right; pr.bottom = ( double )r.bottom; return TRUE; // return TRUE unless you set the focus to a control}void CSize1Dlg::OnOK() { // TODO: Add extra validation here MyDelete(); CDialog::OnOK();}void CSize1Dlg::OnCancel() { // TODO: Add extra cleanup here MyDelete(); CDialog::OnCancel();}voidCSize1Dlg::MyDelete( void ){ struct MyControlSize *t = &first; while( t->next ) { t = t->next; } while( t->last ) { t = t->last; delete t->next; }}void CSize1Dlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here static bool bfirst = false; if( !bfirst ) { bfirst = true; } else { struct MyControlSize *t = &first; RECT r; GetClientRect( &r ); double xx = ( r.right - r.left ) / ( pr.right - pr.left ); double yy = ( r.bottom - r.top ) / ( pr.bottom - pr.top ); while( t->next ) { ::SetWindowPos( t->next->h, 0, ( int )( ( t->next->r.left -ppp ) * xx ), ( int )( ( t->next->r.top - ttt ) * yy ), ( int )( ( t->next->r.right - t->next->r.left ) * xx ), ( int )( ( t->next->r.bottom - t->next->r.top ) * yy ), 0 ); t = t->next; } Invalidate(); } } C++有没有编辑PDF的类库? 关于学习C++ 紧急求助!关于VC图像处理 如何像ListCtrl的item里面添加图片 注册表修改与删除中的权限问题! 请问如何在VC的操作界面上显示工具箱啊? VC如何表示十六进制?????????????/ 高手,请问sql server每次都自动启动服务?我不想这样,当我需要时,我才启动服务,我这怎么做到? 如何从一个文本文件中一行一行的读数据? 数据库论坛,来者加封! 如何获取软件安装路径 DIB图象显示的问题?
// CSize1Dlg dialog
struct MyRect
{
double left;
double top;
double right;
double bottom;
};
struct MyControlSize
{
struct MyRect r;
HWND h;
struct MyControlSize *next;
struct MyControlSize *last;
};BOOL CALLBACK EnumChildProc(
HWND hwnd, // handle to child window
LPARAM lParam // application-defined value
); void MyDelete( void );在.cpp中
/////////////////////////////////////////////////////////////////////////////
// CSize1Dlg message handlers
struct MyControlSize first;
CSize1Dlg *parent;
struct MyRect pr;
int ttt;
int ppp;BOOL CALLBACK
EnumChildProc( HWND hwnd, LPARAM lParam )
{
struct MyControlSize *t;
t = &first;
while( t->next )
{
t = t->next;
}
t->next = new struct MyControlSize;
t->next->next = NULL;
t->next->h = hwnd;
t->next->last = t;
RECT r;
::GetWindowRect( hwnd, &r );
t->next->r.left = ( double )r.left;
t->next->r.top = ( double )r.top;
t->next->r.right = ( double )r.right;
t->next->r.bottom = ( double )r.bottom;
return 1;
}BOOL CSize1Dlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
parent = this;
EnumChildWindows( this->m_hWnd, EnumChildProc, 0 );
RECT r;
RECT rr;
GetClientRect( &r );
GetWindowRect( &rr );
ppp = ( rr.right - r.right ) / 2;
ttt = rr.bottom - r.bottom - ppp;
pr.left = ( double ) r.left;
pr.top = ( double )r.top;
pr.right = ( double )r.right;
pr.bottom = ( double )r.bottom;
return TRUE; // return TRUE unless you set the focus to a control
}void CSize1Dlg::OnOK()
{
// TODO: Add extra validation here
MyDelete();
CDialog::OnOK();
}void CSize1Dlg::OnCancel()
{
// TODO: Add extra cleanup here
MyDelete();
CDialog::OnCancel();
}
void
CSize1Dlg::MyDelete( void )
{
struct MyControlSize *t = &first;
while( t->next )
{
t = t->next;
}
while( t->last )
{
t = t->last;
delete t->next;
}
}void CSize1Dlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
static bool bfirst = false;
if( !bfirst )
{
bfirst = true;
}
else
{
struct MyControlSize *t = &first;
RECT r;
GetClientRect( &r );
double xx = ( r.right - r.left ) / ( pr.right - pr.left );
double yy = ( r.bottom - r.top ) / ( pr.bottom - pr.top );
while( t->next )
{
::SetWindowPos( t->next->h,
0,
( int )( ( t->next->r.left -ppp ) * xx ),
( int )( ( t->next->r.top - ttt ) * yy ),
( int )( ( t->next->r.right - t->next->r.left ) * xx ),
( int )( ( t->next->r.bottom - t->next->r.top ) * yy ),
0 );
t = t->next;
}
Invalidate();
}
}