472,958 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 4206
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.