Windows Dialog Box not getting opened

情到浓时终转凉″ 提交于 2019-12-25 02:57:27

问题


Im trying to open a Dialog box in Windows machine(using windows credential provider), when the user presses a button. i tried the below code but, dialog box is not getting opened. i have a resource "IDD_DIALOG1" and callback method "ChangePasswordProc".

HWND hwndOwner = nullptr;

::DialogBox(HINST_THISDLL, MAKEINTRESOURCE(IDD_DIALOG1), hwndOwner,ChangePasswordProc);


回答1:


I didn't write in Windows GUI for a looong time, but perhaps try something like this:

HWND dialog = ::DialogBox(HINST_THISDLL, MAKEINTRESOURCE(IDD_DIALOG1), hwndOwner,ChangePasswordProc);
ShowWindow(dialog, SW_SHOW);

I remember, that creating window does not imply showing it - it must be done explicitly.




回答2:


To create any window from inside of Credential Provider you must first get parent window handle by calling OnCreatingWindow method of ICredentialProviderCredentialEvents interface.

HRESULT OnCreatingWindow([out] HWND* phwndOwner);

Pointer to this interface is supplying to your provider by calling Advise method of its ICredentialProviderCredential interface :

HRESULT Advise([in] ICredentialProviderCredentialEvents* pcpce);

Have a look at this post.



来源:https://stackoverflow.com/questions/55411840/windows-dialog-box-not-getting-opened

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!