OSDN Git Service

サムネイル・ツールバーを実装してみた。
[wintimer/wintimer.git] / wintimer / sf_windows.cpp
index 04df552..3d74e70 100644 (file)
@@ -4,9 +4,18 @@
 #include <boost/assign/ptr_list_of.hpp>
 #include <boost/assign/ptr_list_inserter.hpp>
 #include <boost/foreach.hpp>
+
+#if _DEBUG
+#define _CRTDBG_MAP_ALLOC
+#include <crtdbg.h>
+#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
+#endif
+
 #include "sf_windows.h"
 #include "exception.h"
 
+
+
 #define THROW_IFERR(hres) \
   if (FAILED(hres)) { throw sf::win32_error_exception(hres); }
 
@@ -113,7 +122,7 @@ namespace sf
     //
     // Because the CreateWindow function takes its size in pixels, we
     // obtain the system DPI and use it to scale the window size.
-    FLOAT dpiX, dpiY;
+    //FLOAT dpiX, dpiY;
     //factory_->GetDesktopDpi(&dpiX, &dpiY);
 
 
@@ -124,33 +133,36 @@ namespace sf
       WS_OVERLAPPEDWINDOW,
       CW_USEDEFAULT,
       CW_USEDEFAULT,
-      static_cast<uint32_t>(ceil(width_ /** dpiX / 96.f*/)),
-      static_cast<uint32_t>(ceil(height_ /** dpiY / 96.f*/)),
+      static_cast<uint32_t>(dpi_.scale_x(width_)),
+      static_cast<uint32_t>(dpi_.scale_y(height_)),
       NULL,
       NULL,
       HINST_THISCOMPONENT,
       this
       );
+    ::GetWindowPlacement(hwnd_,&wp_);
   }
 
-  void base_win32_window::show(uint32_t show_flag) 
-  {
-    //HRESULT hr = S_OK;
-    //BOOL enable;
-    //DwmIsCompositionEnabled (&enable);
-    //if(enable){
-    //   //Create and populate the BlurBehind structre
-    //   DWM_BLURBEHIND bb = {0};
-    //   //Enable Blur Behind and Blur Region;
-    //   bb.dwFlags = DWM_BB_ENABLE;
-    //   bb.fEnable = true;
-    //   bb.hRgnBlur = NULL;
-
-    //   //Enable Blur Behind
-    //   hr = DwmEnableBlurBehindWindow(hwnd_, &bb);
-    //}
-    ::ShowWindow(hwnd_,show_flag);
-  }
+  //void base_win32_window::show() 
+  //{
+  //  //HRESULT hr = S_OK;
+  //  //BOOL enable;
+  //  //DwmIsCompositionEnabled (&enable);
+  //  //if(enable){
+  //  //   //Create and populate the BlurBehind structre
+  //  //   DWM_BLURBEHIND bb = {0};
+  //  //   //Enable Blur Behind and Blur Region;
+  //  //   bb.dwFlags = DWM_BB_ENABLE;
+  //  //   bb.fEnable = true;
+  //  //   bb.hRgnBlur = NULL;
+
+  //  //   //Enable Blur Behind
+  //  //   hr = DwmEnableBlurBehindWindow(hwnd_, &bb);
+  //  //}
+  //  ::ShowWindow(hwnd_,SW_SHOW);
+  //  ::GetWindowPlacement(&wp_);
+  //}
+
 
   void base_win32_window::update() {::UpdateWindow(hwnd_);}
 
@@ -162,6 +174,8 @@ namespace sf
   base_win32_window::base_win32_window(const std::wstring& title,const std::wstring& name,bool fit_to_display,float width,float height)
     : title_(title),name_(name),fit_to_display_(fit_to_display),width_(width),height_(height),thunk_(this,base_win32_window::WndProc),hwnd_(0)
   {
+    memset(&wp_,0,sizeof(wp_));
+    wp_.length = sizeof(WINDOWPLACEMENT);
     thunk_proc_ = (WNDPROC)thunk_.getCode();
     //create_device_independent_resources();
   }