1.11M Members

[Win32] Getting the HWND from a resource ID

 
0
 

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

 
0
 

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!

Question Self-Answered as of 4 Years Ago
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: