0

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);

Navin
  • 130
  • 1
  • 6
  • Are you able to see your dialog if you press `Alt+Tab`? It is possible that the dialog is hidden behind credential provider – Wander3r Mar 29 '19 at 07:05
  • i can't able to see – Navin Mar 29 '19 at 09:07
  • Are You trying to raise dialogue from inside of Credential Provider? Inside of which method You are doing it? – Alexander Mar 29 '19 at 13:46
  • What have you tried? Have you looked at the value returned by the DialogBox call? Have you verified that IDD_DIALOG1 refers to a valid dialog box resource and that the resources are linked into your project? Have you looked with Spy++ to see if the window exists but it simply offscreen or missing WS_VISIBLE? – Adrian McCarthy Mar 29 '19 at 18:47

2 Answers2

0

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.

Diodacus
  • 663
  • 3
  • 8
  • i tried this too HWND hwndGoto = NULL; // Window handle of dialog box if (!IsWindow(hwndGoto)) { PrintLn("No previous Window available"); hwndGoto = CreateDialog(HINST_THISDLL, MAKEINTRESOURCE(IDB_TILE_IMAGE), hwndOwner, nullptr); ShowWindow(hwndGoto, SW_SHOW); } – Navin Mar 29 '19 at 10:13
0

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.

Alexander
  • 1,232
  • 1
  • 15
  • 24