Hey there,

I've been attempting some Win32 programming for a while now, but I just can't seem to find a function where I can get the HWND by the resource ID.

Just an example:

CreateWindowEx(NULL,
				L"BUTTON",
				text,
				WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
				x, y,
				width, height,
				parent,
				(HMENU)IDC_BUTTON_OK,
				GetModuleHandle(NULL),
				NULL);

HWND btn = getHWNDFromResource((HMENU)IDC_BUTTON_OK); // What function should I use here?

This is just example code, and not my real code, it's used in a diffrent way in my program.

getHWNDFromResource is a non-existant function and I hope to hear from you how I actually should solve this problem.

Hope to hear from you!

Thanks,

Schoorsteen

Seems like I finally found the answer myself. I found it with pure luck while browsing for something else on the MSDN. The answer is GetDlgItem

http://msdn.microsoft.com/en-us/library/ms645481%28v=VS.85%29.aspx

But my next question is, what is better, to have a lot of HWND-variables in my global scope, or just to call GetDlgItem() everytime I need the HWND ?

Thanks in advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.