关闭

wince VC++ Common dialog box 打不开的问题

标签: dialogwincevc++nullfunctionexe
799人阅读 评论(1) 收藏 举报
分类:

通用对话框有以下六个
DWORD CommDlgExtendedError();
This function returns a common dialog box error value. This value indicates the most recent error to occur during the execution of one of the following common dialog box functions:

ChooseColor
ChooseFont
GetOpenFileName
GetSaveFileName
PageSetupDlg
PrintDlg

举例 :
ChooseColor

                 HINSTANCE hCommLib;//Common dlg instance
   
   typedef BOOL (*LPFNCHOOSECOLOR) (LPCHOOSECOLOR lpcc);
   
   LPFNCHOOSECOLOR lpfnChooseColor;
   
   //Load common dlg
   hCommLib = LoadLibrary(TEXT("Commdlg.dll"));
   if(hCommLib){
    lpfnChooseColor =(LPFNCHOOSECOLOR) GetProcAddress(hCommLib,TEXT("ChooseColor"));
   }
   CHOOSECOLOR cc;
   static COLORREF cr[16];
   //   TCHAR szOut[128];
   INT rc;
   
   // Initialize color structure.
   memset (&cc, 0, sizeof (cc));
   memset (&cr, 0, sizeof (cr));
   
   cc.lStructSize = sizeof (cc);
   cc.hwndOwner = NULL;
   cc.hInstance = NULL;
   cc.rgbResult = g_Option.rgbColor;
   cc.lpCustColors = cr;
   cc.Flags = CC_ANYCOLOR;
                        rc = (lpfnChooseColor) (&cc);

在动态库中,可以用以上代码打开设置颜色对话框,然而在Exe 中就不可以了。

改为以下形式就可以了

cc.hwndOwner = hwnDlg;
cc.hInstance = hCommLib;

因该是句柄的问题。

Best Regards To All! 
    

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:16142次
    • 积分:340
    • 等级:
    • 排名:千里之外
    • 原创:17篇
    • 转载:4篇
    • 译文:0篇
    • 评论:4条
    最新评论