开发者

How do I use the IFileDialogCustomize::GetEditBoxText() method?

开发者 https://www.devze.com 2023-02-28 03:48 出处:网络
WCHAR wcText[100] = {0}; WCHAR *pText = wcText; WCHAR **ppText = &pText; HRESULT hr = pDialogCustomize->GetEditBoxText(dwCtrlID, ppText);
WCHAR wcText[100] = {0};
WCHAR *pText = wcText;
WCHAR **ppText = &pText;

HRESULT hr = pDialogCustomize->GetEditBoxText(dwCtrlID, ppText);

The edit box contains the text "5000" but this text isn't returned by the GetEditBox开发者_开发技巧Text method.

How can I get the text from the edit box?


According to http://msdn.microsoft.com/en-us/library/bb775908%28VS.85%29.aspx, GetEditBoxText allocates and returns a string for you (that you must later free with CoTaskMemFree). I'm assuming that you're checking the wcText array after the function call, and it is empty? This is because GetEditBoxText is changing the value of pText.

Try:

WCHAR *pText = NULL;
HRESULT hr = pDialogCustomize->GetEditBoxText(dwCtrlID, &pText);

if (S_OK == hr && NULL != pText)
  // function succeeded and pText points to a buffer of text that must free when done using
0

精彩评论

暂无评论...
验证码 换一张
取 消