アットウィキロゴ

siki > win32 > win32util

***
ドキュメント ***
ヘッダファイル ***
ソースファイル ***
関連項目
名前空間 ***
クラス ***


siki/win32/win32util.hpp : ver090505

  1. /*
  2.  * win32util.hpp
  3.  * Copyright (C) 2009 siki
  4.  *
  5.  * This program is free software: you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation, either version 3 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program 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.  * You should have received a copy of the GNU General Public License
  15.  * along with this program. If not, see
  16.  * http://www.gnu.org/licenses/gpl-3.0.html.
  17.  *
  18.  * author:rei
  19.  */
  20. #ifndef __SIKI_WIN32_WIN32UTIL_H__
  21. #define __SIKI_WIN32_WIN32UTIL_H__
  22.  
  23. #include <windows.h>
  24.  
  25. namespace siki{
  26. namespace win32{
  27.  
  28. /***
  29.  *** hwndがダイアログかどうかを取得する
  30.  ***/
  31. bool IsDialog(HWND hwnd);
  32.  
  33. /***
  34.  *** hwndに関連付けられているHINSTANCEを取得する
  35.  ***/
  36. HINSTANCE GetInstanceHandle(HWND hwnd);
  37.  
  38. /***
  39.  *** hwndのウィンドウプロシージャを取得する
  40.  ***/
  41. WNDPROC GetWndProc(HWND hwnd);
  42.  
  43. /***
  44.  *** hwndのウィンドウプロシージャを設定する
  45.  ***/
  46. WNDPROC SetWndProc(HWND hwnd, WNDPROC proc);
  47.  
  48. } // namespace win32
  49. } // namespace siki
  50.  
  51. #endif // __SIKI_WIN32_WIN32UTIL_H__
  52.  



siki/win32/win32util.cpp : ver090505

  1. /*
  2.  * win32util.cpp
  3.  * Copyright (C) 2009 siki
  4.  *
  5.  * This program is free software: you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation, either version 3 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program 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.  * You should have received a copy of the GNU General Public License
  15.  * along with this program. If not, see
  16.  * http://www.gnu.org/licenses/gpl-3.0.html.
  17.  *
  18.  * author:rei
  19.  */
  20. #include "win32util.hpp"
  21.  
  22.  
  23. namespace siki{
  24. namespace win32{
  25.  
  26. /***
  27.  ***
  28.  ***/
  29. bool IsDialog(HWND hwnd){
  30. return static_cast<bool>(GetWindowLong(hwnd, DWL_DLGPROC));
  31. }
  32.  
  33. /***
  34.  *** WNDPROC GetInstanceHandle(HWND hwnd)
  35.  ***
  36.  *** hwndに関連付けられているHINSTANCEを取得する
  37.  ***/
  38. HINSTANCE GetInstanceHandle(HWND hwnd){
  39. return reinterpret_cast<HINSTANCE>(GetWindowLong(hwnd, GWL_HINSTANCE));
  40. }
  41.  
  42. /***
  43.  *** WNDPROC GetWndProc(HWND hwnd)
  44.  ***
  45.  *** hwndのウィンドウプロシージャを取得する
  46.  ***/
  47. WNDPROC GetWndProc(HWND hwnd){
  48. return reinterpret_cast<WNDPROC>(
  49. GetWindowLong(hwnd, IsDialog(hwnd) ? DWL_DLGPROC : GWL_WNDPROC));
  50. }
  51.  
  52. /***
  53.  *** WNDPROC SetWndProc(HWND hwnd, WNDPROC proc)
  54.  ***
  55.  *** hwndのウィンドウプロシージャを設定する
  56.  ***/
  57. WNDPROC SetWndProc(HWND hwnd, WNDPROC proc){
  58. return reinterpret_cast<WNDPROC>(
  59. SetWindowLong(
  60. hwnd,
  61. IsDialog(hwnd) ? DWL_DLGPROC : GWL_WNDPROC,
  62. reinterpret_cast<long>(proc)
  63. )
  64. );
  65. }
  66.  
  67.  
  68. } // namespace win32
  69. } // namespace siki
  70.  


[09/05/05 19:55][履歴][編集]
最終更新:2009年05月05日 19:55