A
A
anonymous2017-03-03 01:04:47
C++ / C#
anonymous, 2017-03-03 01:04:47

How to get button IDs created via CreateWindow() WinAPI?

I create buttons in a vector (because a different number depending on the conditions)

static vector<HWND> hBut;
hBut.push_back((CreateWindow(L"BUTTON", buf, WS_CHILD | WS_VISIBLE | WS_TABSTOP, x, y, nWidth, nHeight, hDlg, NULL, hInst, NULL)));

But I don’t know how to get the ID of all buttons, since they were created not graphically (by transferring) but by code. How to get them?
And since I’m asking a question, then maybe tell me how to do push_back () if I have a vector with a smart pointer:
static vector<std::shared_ptr<HWND>> hBut;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
none7, 2017-03-03
@anonymouss

I guess you need GetWindowLong(hButton, GWL_ID), but it can be zero by default. Shared_ptr needs a CWnd wrapper class that will destroy the window in its destructor. If you do not want to use MFC, then write an analogue yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question