user2286339
user2286339

Reputation: 194

Win32 edit control default text

(NB: This is probably more of a programming style / architecture question)

When the main window is created (but not yet shown), my window procedure receives WM_CREATE; this is where I call CreateWindow for the edit control:

    case WM_CREATE:
        hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("edit"), L"Default text",
        WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
        10, 10, 150, 24, hWnd, (HMENU)ID_EDIT,
        hInst, NULL);
        break;

and as expected "Default text" shows up in the edit control.

I know I can also use SendMessage or SetWindowText.

So, I have three API calls to do what I want - which one should I be using?

best, Chris

Upvotes: 0

Views: 1048

Answers (1)

Ben
Ben

Reputation: 35653

If it is easy and convenient to set the text in CreateWindowEx, then do so.

If, for some reason, it is not convenient, then use SetWindowText.

In this case you probably don't want to use L"Default Text" as the default text in CreateWindowEx.

Since lpWindowName is optional, you may pass NULL to leave it blank.

Alternatively, you might use something which makes more sense for your application, such as L"(Loading...)".

Upvotes: 0

Related Questions