473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to get the resource ID of a frame window?

Hey All,

After a doc/view/frame is created and initialized, is there a way from
within the frame class code (CMyChildFrame::OnUpdateFrameMenu()) to get the
resource ID (nIDResource = IDR_???TYPE) used by CFrameWnd::LoadFrame()?

I know the member variable m_nIDHelp is set to nIDResource in the
LoadFrame() call, but don't feel that is a safe way to retrieve the resource
ID. So I was hoping there was an API that I could call to get the resource ID
that was used by the frame to load the menu, icon, and string table. I need
to dynamically reload the frames menu at runtime after the frame has alrady
been created in order to alter it. I am trying to avoid passing this in as a
new parameter to the constructor and I have tried to make the call GetMenu()
from inside of OnUpdateFrameMenu() but get an exception.

Thanks for any help,
Danny

Jul 21 '05 #1
3 4241
Hi Danny,
I know the member variable m_nIDHelp is set to nIDResource in the
LoadFrame() call, but don't feel that is a safe way to retrieve the resourceID. So I was hoping there was an API that I could call to get the resource IDthat was used by the frame to load the menu, icon, and string table. I needto dynamically reload the frames menu at runtime after the frame has alradybeen created in order to alter it.


Based on my understanding, you do not want to use the m_nIDHelp directly
to retrieve the resource IDs which used by the CFrameWnd::LoadFrame() call,
please correct me if I have misunderstood anything.

In this scenario, since the resource ID is unique in the application, do
you have tried to use a UINT array to cache the nIDResource parameter of
the CMyChildFrame::LoadFrame() call...

If you prefer a Win32 API to do this, the EnumResourceNames API is an
option, but at first you need to know what and which types of these
resources you wanted...
http://msdn.microsoft.com/library/de...us/winui/winui
/windowsuserinterface/resources/introductiontoresources/resourcereference/re
sourcefunctions/enumresourcenames.asp
Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 21 '05 #2
> Based on my understanding, you do not want to use the m_nIDHelp directly
to retrieve the resource IDs which used by the CFrameWnd::LoadFrame() call,
please correct me if I have misunderstood anything.

In this scenario, since the resource ID is unique in the application, do
you have tried to use a UINT array to cache the nIDResource parameter of
the CMyChildFrame::LoadFrame() call...

If you prefer a Win32 API to do this, the EnumResourceNames API is an
option, but at first you need to know what and which types of these
resources you wanted...
http://msdn.microsoft.com/library/de...us/winui/winui
/windowsuserinterface/resources/introductiontoresources/resourcereference/re
sourcefunctions/enumresourcenames.asp


Yes, I am afraid to use the m_nIDHelp because it is possible that it may get
changed without my knowledge. And it also is not intended as a place holder
for referencing the resource ID used to load the menu, icon and string table.
To the best of my understanding it is used as a base/offset into the help
context.

The EnumResourceNames API requires knowledge of the resource you are trying
to access, which in turn would require me to pass something in the
constructor. I do not want to require the developers to do this.

As a solution, I have derived my own class (CMyChildFrame) from CMDIChildWnd
and did an override of LoadFrame(), in LoadFrame() I saved the nIDResource
value to a member variable (m_IdrFrameTypeResourceId). During
OnUpdateFrameMenu(), I then use the m_IdrFrameTypeResourceId to load the menu
from the resources. Now the developers are not required to make any code
modifications.

FYI: Here's what I am doing:
====================
When a new doc/view/frame is opened by the user, I am merging the main frame
menu with my child frames menu. This allows me to have an independent main
frame menu that the developers can modify as needed and not have to update
all the individual child frame menus. The child frame menu only contains menu
items releated to that doc/view/frame. This app will end up having around 30
to 40 doc/view/frame components in it.

The IDR_MAINFRAME menu: File View Help
My IDR_MYFRAME menu: Actions Window
Merged menu: File View Actions Window Help

Everything works great now, and is very automated, except for one thing, the
'Windows' menu item (which is the standard one) does not show the open files
anymore. So I'm trying to find out when the open files list is updated on the
menu item, so I can merge the menus at the appropriate time.

Here's the code snippet:

void CGuiPanelChildFrame::OnUpdateFrameMenu(BOOL bActive, CWnd* pActiveWnd,
HMENU hMenuAlt)
{
CMDIChildWnd::OnUpdateFrameMenu(bActive, pActiveWnd, hMenuAlt);

if( bActive == TRUE )
{
CMenu MainMenu;
if( MainMenu.LoadMenu( IDR_MAINFRAME ) == 0 )
return;

CMenu GuiPanelMenu;
if( GuiPanelMenu.LoadMenu( m_IdrFrameTypeResourceId ) == 0 )
return;

if( MergeMenu( &MainMenu, &GuiPanelMenu, true ) == false ) //
codeproject.com
return;

if( AfxGetMainWnd()->SetMenu( &MainMenu ) == 0 )
return;

MainMenu.Detach();
}
}
Thanks for your help and any advice,
Danny

Jul 21 '05 #3
OK Danny, thanks for sharing your resolution with us:)
Good Luck!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: adraj | last post by:
hi i'm working with a MDI application, client/server application. my application goes like this, when i clicked a 'Connect' menu a connection with remote machine is establised and a new child frame...
5
by: Danny Pressley | last post by:
Hey All, After a doc/view/frame is created and initialized, is there a way from within the frame class code (CMyChildFrame::OnUpdateFrameMenu()) to get the resource ID (nIDResource =...
1
by: Zuhaib Hyder | last post by:
how to logout from frame window/page to normal window/page (no frame)? and how to open new normal page(no frame) from frame page?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.