Piotr Caban : mshtml: Added HTMLWindow2_prompt implementation.

Alexandre Julliard julliard at winehq.org
Fri Mar 13 09:14:02 CDT 2009


Module: wine
Branch: master
Commit: 147cf1da55b29ddae517a36f98d4f9895a80e950
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=147cf1da55b29ddae517a36f98d4f9895a80e950

Author: Piotr Caban <piotr.caban at gmail.com>
Date:   Thu Mar 12 19:08:06 2009 +0100

mshtml: Added HTMLWindow2_prompt implementation.

---

 dlls/mshtml/En.rc        |   11 ++++++
 dlls/mshtml/htmlwindow.c |   85 ++++++++++++++++++++++++++++++++++++++++++++-
 dlls/mshtml/resource.h   |    4 ++
 3 files changed, 98 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/En.rc b/dlls/mshtml/En.rc
index f438f98..09370de 100644
--- a/dlls/mshtml/En.rc
+++ b/dlls/mshtml/En.rc
@@ -53,3 +53,14 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "OK", IDOK, 200, 10, 45, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "Cancel", IDCANCEL, 200, 28, 45, 14, WS_GROUP | WS_TABSTOP
 }
+
+ID_PROMPT_DIALOG DIALOG 0, 0, 200, 90
+STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION ""
+FONT 8, "MS Shell Dlg"
+{
+    LTEXT "", ID_PROMPT_PROMPT, 10, 10, 180, 30
+    EDITTEXT ID_PROMPT_EDIT, 10, 45, 180, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+    PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+    PUSHBUTTON "Cancel", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
+}
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 6984a43..f143832 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -230,12 +230,93 @@ static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
     return E_NOTIMPL;
 }
 
+typedef struct
+{
+    BSTR message;
+    BSTR dststr;
+    VARIANT *textdata;
+}prompt_arg;
+
+static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
+        WPARAM wparam, LPARAM lparam)
+{
+    switch(msg)
+    {
+        case WM_INITDIALOG:
+        {
+            prompt_arg *arg = (prompt_arg*)lparam;
+            WCHAR wszTitle[100];
+
+            if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
+                        sizeof(wszTitle)/sizeof(WCHAR))) {
+                WARN("Could not load message box title: %d\n", GetLastError());
+                EndDialog(hwnd, wparam);
+                return FALSE;
+            }
+
+            SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
+            SetWindowTextW(hwnd, wszTitle);
+            SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
+            SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
+            return FALSE;
+        }
+        case WM_COMMAND:
+            switch(wparam)
+            {
+                case MAKEWPARAM(IDCANCEL, BN_CLICKED):
+                    EndDialog(hwnd, wparam);
+                    return TRUE;
+                case MAKEWPARAM(IDOK, BN_CLICKED):
+                {
+                    prompt_arg *arg =
+                        (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
+                    HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
+                    INT len = GetWindowTextLengthW(hwndPrompt);
+
+                    if(!arg->textdata)
+                    {
+                        EndDialog(hwnd, wparam);
+                        return TRUE;
+                    }
+
+                    V_VT(arg->textdata) = VT_BSTR;
+                    if(!len && !arg->dststr)
+                        V_BSTR(arg->textdata) = NULL;
+                    else
+                    {
+                        V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
+                        GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
+                    }
+                    EndDialog(hwnd, wparam);
+                    return TRUE;
+                }
+            }
+            return FALSE;
+        case WM_CLOSE:
+            EndDialog(hwnd, IDCANCEL);
+            return TRUE;
+        default:
+            return FALSE;
+    }
+}
+
 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
         BSTR dststr, VARIANT *textdata)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
-    return E_NOTIMPL;
+    prompt_arg arg;
+
+    TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
+
+    if(textdata) V_VT(textdata) = VT_NULL;
+
+    arg.message = message;
+    arg.dststr = dststr;
+    arg.textdata = textdata;
+
+    DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
+            This->doc->hwnd, prompt_dlgproc, (LPARAM)&arg);
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
diff --git a/dlls/mshtml/resource.h b/dlls/mshtml/resource.h
index c96749c..f409380 100644
--- a/dlls/mshtml/resource.h
+++ b/dlls/mshtml/resource.h
@@ -26,6 +26,10 @@
 #define ID_DWL_INSTALL      7602
 #define ID_DWL_STATUS       7603
 
+#define ID_PROMPT_DIALOG    7700
+#define ID_PROMPT_PROMPT    7701
+#define ID_PROMPT_EDIT      7702
+
 #define IDS_MESSAGE_BOX_TITLE  2213
 
 #define IDS_PRINT_HEADER_TEMPLATE  8403




More information about the wine-cvs mailing list