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

通用对话框有以下六个
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! 
    

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值