OSDN Git Service

キャプチャ部分のバグ修正。
[winaudioj/wasapi2.git] / wasapi2 / tab_dialog.cpp
1 /*
2 ==============================================================================
3
4 Copyright 2005-11 by Satoshi Fujiwara.
5
6 async can be redistributed and/or modified under the terms of the
7 GNU General Public License, as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later version.
9
10 async is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with async; if not, visit www.gnu.org/licenses or write to the
17 Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
18 Boston, MA 02111-1307 USA
19
20 ==============================================================================
21 */
22 /* ToDo
23
24 TODO: リサイズに対応する
25
26 */
27
28 #include "stdafx.h"
29 #include "resource.h"
30 #define BOOST_ASSIGN_MAX_PARAMS 7
31 #include <boost/assign.hpp>
32 #include <boost/assign/ptr_list_of.hpp>
33 #include <boost/assign/ptr_list_inserter.hpp>
34 #include <boost/foreach.hpp>
35
36 #if _DEBUG
37 #define _CRTDBG_MAP_ALLOC
38 #include <crtdbg.h>
39 #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
40 #endif
41
42 #include "sf_windows.h"
43 #include "tab_dialog.h"
44 #include "CommDlg.h"
45 #include "icon.h"
46 #include "timer.h"
47 #include "exception.h"
48 #include "application.h"
49
50 #define THROW_IFERR(hres) \
51   if (FAILED(hres)) { throw sf::win32_error_exception(hres); }
52
53 #ifndef HINST_THISCOMPONENT
54 EXTERN_C IMAGE_DOS_HEADER __ImageBase;
55 #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
56 #endif
57
58 namespace sf 
59 {
60     tab_dialog_base::tab_dialog_base(sf::base_window& parent_window,HWND tab_hwnd,int tab_id,const std::wstring& menu_name,const std::wstring& name,HINSTANCE inst,LPCTSTR temp)
61       : base_win32_dialog_t(menu_name,name,false,0,0),parent_window_(parent_window)
62       ,tab_hwnd_(tab_hwnd),tab_id_(tab_id),inst_(inst),temp_(temp)
63     {
64
65     }
66
67     void tab_dialog_base::create()
68     {
69       hwnd_ =  CreateDialogW(inst_,temp_,(HWND)parent_window_.raw_handle(),thunk_proc_);
70       BOOST_ASSERT(hwnd_ != NULL);
71       if(hwnd_ == NULL)
72       {
73         throw win32_error_exception();
74       }
75
76       resize();
77     }
78
79     void tab_dialog_base::resize()
80     {
81       
82       DWORD dwDlgBase = GetDialogBaseUnits();
83       int cxMargin = LOWORD(dwDlgBase) / 4; 
84       int cyMargin = HIWORD(dwDlgBase) / 8;
85       RECT rci;
86       TabCtrl_GetItemRect(tab_hwnd_,0,&rci);
87       RECT r;
88       GetClientRect(tab_hwnd_,&r);
89       RECT rw;
90       GetWindowRect(tab_hwnd_,&rw);
91       POINT pt = {rw.left,rw.top + rci.bottom};
92       ScreenToClient((HWND)parent_window_.raw_handle(),&pt);
93
94       set_pos(HWND_TOP,
95         pt.x + cxMargin,
96         pt.y + cyMargin,
97         r.right - cxMargin * 2 - 1,
98         r.bottom - rci.bottom - cyMargin * 2 - 1
99         ,SWP_NOZORDER 
100         );
101     }
102 }
103