-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIUtil.cpp
59 lines (49 loc) · 1.28 KB
/
UIUtil.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "stdafx.h"
#include "UIUtil.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#endif
namespace UIUtil
{
float GetFloat( CWnd* pParent , int ID )
{
TCHAR Buffer[64] = { 0 , };
pParent->GetDlgItemText( ID , Buffer , _countof(Buffer) );
return (float)_ttof(Buffer);
}
double GetDouble( CWnd* pParent , int ID )
{
TCHAR Buffer[64] = { 0 , };
pParent->GetDlgItemText( ID , Buffer , _countof(Buffer) );
return _ttof(Buffer);
}
int GetInt( CWnd* pParent , int ID )
{
return (int)pParent->GetDlgItemInt( ID );
}
CString GetString( CWnd* pParent , int ID )
{
TCHAR Buffer[512] = { 0 , };
pParent->GetDlgItemText( ID , Buffer , _countof(Buffer) );
return CString( Buffer );
}
BOOL IsCheck( CWnd* pParent , int ID )
{
return ((CButton*)pParent->GetDlgItem( ID ))->GetCheck() == BST_CHECKED;
}
void SetCheck( CWnd* pParent , int ID , BOOL Check )
{
((CButton*)pParent->GetDlgItem( ID ))->SetCheck( Check ? BST_CHECKED : BST_UNCHECKED );
}
CRect GetRelativeRect( CWnd* pParent , int ChildID )
{
CRect ChildRect;
CWnd* pChildCtrl = pParent->GetDlgItem( ChildID );
pChildCtrl->GetClientRect( &ChildRect );
pChildCtrl->ClientToScreen( &ChildRect );
pParent->ScreenToClient( &ChildRect );
return ChildRect;
}
};