SourceForge.jp

dkutilDialog.h

説明を見る。
00001 #ifndef _dkutil_Dialog__h_
00002 #define _dkutil_Dialog__h_
00003 
00004 namespace dkutil{
00005     
00007 extern bool OpenColorDialog(COLORREF *GetAndSetColor,HWND WindowHandle=NULL);
00008 
00016 
00017 inline  bool OpenColorDialog( long *pR, long *pG, long *pB ,HWND WindowHandle=NULL)
00018 {
00019     COLORREF color=RGB(*pR,*pG,*pB);
00020     bool r = OpenColorDialog(&color,WindowHandle);
00021     *pR = (color>>16) & 0xFF;
00022     *pG = (color>> 8) & 0xFF;
00023     *pB = (color>> 0) & 0xFF;
00024     return r;
00025 }
00026 
00027 
00028 
00029 
00031 inline bool OpenColorDialog(RGBTRIPLE *color_tag,HWND WindowHandle=NULL){
00032     long r,g,b;
00033     bool result = OpenColorDialog(
00034         (long *)&r,
00035         (long *)&g,
00036         (long *)&b,
00037         WindowHandle);
00038     color_tag->rgbtRed = (BYTE)r;
00039     color_tag->rgbtGreen = (BYTE)g;
00040     color_tag->rgbtBlue = (BYTE)b;
00041     return result;
00042 }
00044 inline bool OpenColorDialog(RGBQUAD *QuadColor,HWND WindowHandle=NULL){
00045     COLORREF *ptr = (COLORREF *)&QuadColor;
00046     COLORREF color = *ptr;
00047     bool r = OpenColorDialog(&color,WindowHandle);
00048     *ptr = color;
00049     return r;
00050 }
00051 
00069 inline bool FileOpenDialog( char *pPath,size_t size, const char *pTitle, const char *pFilter, const char *pExt ,HWND WindowHandle=NULL)
00070 {
00071     if(pPath == NULL || size < MAX_PATH){
00072         return false;
00073     }
00074     pPath[0] = '\0';
00075 
00076     //今この関数を呼び出しているソフトのディレクトリを保存。
00077     char path[MAX_PATH];
00078     memset(path,0,sizeof(path));
00079     ::GetCurrentDirectory(MAX_PATH,path);
00080     
00081     // ファイルオープン
00082     
00083     OPENFILENAME ofn;
00084     ZeroMemory( &ofn, sizeof(OPENFILENAME) );
00085     
00086     ofn.lStructSize     = sizeof(OPENFILENAME);
00087     ofn.hwndOwner       = WindowHandle;
00088     ofn.lpstrTitle      = pTitle;
00089     ofn.lpstrFilter     = pFilter;
00090     ofn.nFilterIndex    = 1;
00091     ofn.lpstrFile       = pPath;
00092     ofn.nMaxFile        = 256;
00093     ofn.lpstrDefExt     = pExt;
00094     ofn.lpstrInitialDir = NULL;
00095     ofn.Flags           = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
00096 
00097     bool result = (::GetOpenFileName( &ofn ) != false);
00098 
00099     //ディレクトリ設定を戻す
00100     SetCurrentDirectory(path);
00101 
00102     return result;
00103 }
00104 
00105 
00119 inline bool FileSaveDialog( char *pPath, size_t size,const char *pTitle, const char *pFilter, const char *pExt ,HWND WindowHandle=NULL)
00120 {
00121     if(pPath==NULL || size < MAX_PATH){
00122         return false;
00123     }
00124     pPath[0] = '\0';
00125     
00126     //今この関数を呼び出しているソフトのディレクトリを保存。
00127     char path[MAX_PATH];
00128     memset(path,0,sizeof(path));
00129     ::GetCurrentDirectory(MAX_PATH,path);
00130 
00131 
00132     OPENFILENAME ofn;
00133     ZeroMemory( &ofn, sizeof(OPENFILENAME) );
00134     
00135     ofn.lStructSize     = sizeof(OPENFILENAME);
00136     ofn.hwndOwner       = WindowHandle;
00137     ofn.lpstrTitle      = pTitle;
00138     ofn.lpstrFilter     = pFilter;
00139     ofn.nFilterIndex    = 1;
00140     ofn.lpstrFile       = pPath;
00141     ofn.nMaxFile        = 256;
00142     ofn.lpstrDefExt     = pExt;
00143     ofn.lpstrInitialDir = NULL;
00144     ofn.Flags           = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
00145 
00146     bool result = (::GetOpenFileName( &ofn ) != false);
00147 
00148     //ディレクトリ設定を戻す
00149     SetCurrentDirectory(path);
00150 
00151     return result;
00152 }   
00153     
00154 }//end of dkutil namespace
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 #endif //end of include once

dkutil 1.02リリース前 d金魚専用マニュアルバージョンに対してSun Dec 28 21:23:07 2003に生成されました。 doxygen 1.3.5