1
0

creddlg.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef NULLSOFT_CREDAENTIAL_DIALOG_HEADER
  2. #define NULLSOFT_CREDAENTIAL_DIALOG_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <windows.h>
  7. #define CDS_USEUSERNAME 0x0001 // szUser will be used to prepopulate user name field
  8. #define CDS_USEPASSWORD 0x0002 // szPassword will be used to prepopulate user name field
  9. #define CDS_SKINDIALOG 0x0004 // Dialog will be skinned (requires hwndWA)
  10. #define CDS_APPMODAL 0x0008 // Dialog will be application(thread) modal.
  11. typedef struct _WACREDDLG
  12. {
  13. int size; // sizeof(WACREDDLG)
  14. HWND hwndParent; // parents HWND (passing NULL can be bad idea especially if not CDS_APPMODAL)
  15. LPWSTR szUser; // pointer to the user name buffer
  16. INT cchUser; // size of the user name buffer in characters
  17. LPWSTR szPassword; // pointer to the password buffer
  18. INT cchPassword; // size of the password buffer in characters
  19. DWORD flags; // any combination of CDS_XXX
  20. LPCWSTR title; // title of the dialog
  21. HBITMAP hbmp; // bitmap to display (can be NULL - this will make dialog smaller)
  22. LPCWSTR greating; // text to display on top of user name filed
  23. HWND hwndWA; // only if you want skinning handle to the Winamp main window
  24. } WACREDDLG, *PWACREDDLG;
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. INT ShowCredentialDialog(const WACREDDLG *pcd); // displays dialog. Returns: error(-1), canceled(0), ok(1)
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. //Expample
  33. //wchar_t usr[64], pwd[64];
  34. //WACREDDLG dlg;
  35. //ZeroMemory(&dlg, sizeof(WACREDDLG));
  36. //dlg.size = sizeof(WACREDDLG);
  37. //dlg.hwndWA = plugin.hwndParent;
  38. //dlg.hwndParent = g_hwnd;
  39. //dlg.flags = CDS_APPMODAL | CDS_USEPASSWORD | CDS_USEUSERNAME | CDS_SKINDIALOG;
  40. //dlg.title = L"User Credentials";
  41. //dlg.greating = L"Resource that you trying to access requires authentification.\nPlease enter credentials.";
  42. //dlg.szUser = usr;
  43. //dlg.cchUser = 64;
  44. //dlg.szPassword = pwd;
  45. //dlg.cchPassword = 64;
  46. //dlg.hbmp = (HBITMAP)LoadImage(NULL, "C:\\cred_banner.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
  47. //StringCchCopyW(usr, 64, L"testuser");
  48. //StringCchCopyW(pwd, 64, L"12345");
  49. //
  50. //
  51. //wchar_t buffer[256];
  52. //switch(ShowCredentialDialog(&dlg))
  53. //{
  54. // case -1: StringCchCopyW(buffer, 256, L"Error duaring initialization."); break;
  55. // case 0: StringCchCopyW(buffer, 256, L"Canceled by user."); break;
  56. // default: StringCchPrintfW(buffer, 256, L"Userdata:\nUser name:\t\t%s\nPassword:\t\t%s", usr, pwd); break;
  57. //
  58. //}
  59. //if (dlg.hbmp) DeleteObject(dlg.hbmp);
  60. // Example end
  61. #endif /*NULLSOFT_CREDAENTIAL_DIALOG_HEADER*/