We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,478 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

[Win32] Getting the HWND from a resource ID

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

1
Contributor
1
Reply
46 Minutes
Discussion Span
2 Years Ago
Last Updated
2
Views
Question
Answered
Schoorsteen
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 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!

Schoorsteen
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0
Question Self-Answered as of 2 Years Ago

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0592 seconds using 2.72MB