Search code examples
c++winapinsis

NSIS Plugin: Cant get HWND from parameter function


I have my own NSIS Plugin DLL I have made. The dll has one function which takes a hwnd id number as a parameter and then creates a edit box window with that hwnd as the editboxes parent hwnd.

My Problem: I am having trouble passing a HWND to my NSIS Plugin DLL. I can retrieve the hwnd id and then identify the actual hwnd(I think) but when I create my editbox its never shown on the hwnd?

What am I doing wrong. How do I correctly find the hwnd passed as parameter?

    extern "C" void __declspec(dllexport) __cdecl CreateEditbox(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
    {
        g_hwndParent=hwndParent;
        EXDLL_INIT();

        {
            int hwndID = popint();
            HWND hwnd  = GetDlgItem(hwndParent, hwndID);
            HWND a = CreateWindowEx(WS_EX_TRANSPARENT, TEXT("Edit"), text, WS_VISIBLE|WS_CHILD, 20, 20, 100, 20,
            hwnd, NULL, GetModuleHandle(NULL), NULL);
        }
    }

My NSIS code:

    Page custom Start

    Function Start
        nsDialogs::Create 1018
        Pop $0

        tbox::CreateEditbox $0

        nsDialogs::Show
    FunctionEnd

Solution

  • nsDialogs::Create returns the HWND (not ID) of the inner dialog.

    nsDialogs can already create edit boxes so your current code is pointless...