473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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: :OnUpdateFrameM enu()) to get the
resource ID (nIDResource = IDR_???TYPE) used by CFrameWnd::Load Frame()?

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 OnUpdateFrameMe nu() but get an exception.

Thanks for any help,
Danny

Jul 21 '05 #1
3 4267
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::Load Frame() 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 EnumResourceNam es 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
/windowsuserinte rface/resources/introductiontor esources/resourcereferen ce/re
sourcefunctions/enumresourcenam es.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::Load Frame() 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 EnumResourceNam es 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
/windowsuserinte rface/resources/introductiontor esources/resourcereferen ce/re
sourcefunctions/enumresourcenam es.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 EnumResourceNam es 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_IdrFrameType ResourceId). During
OnUpdateFrameMe nu(), I then use the m_IdrFrameTypeR esourceId 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 CGuiPanelChildF rame::OnUpdateF rameMenu(BOOL bActive, CWnd* pActiveWnd,
HMENU hMenuAlt)
{
CMDIChildWnd::O nUpdateFrameMen u(bActive, pActiveWnd, hMenuAlt);

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

CMenu GuiPanelMenu;
if( GuiPanelMenu.Lo adMenu( m_IdrFrameTypeR esourceId ) == 0 )
return;

if( MergeMenu( &MainMenu, &GuiPanelMen u, 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
1230
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 window created. after some process, when i click 'Disconnect' menu the prevailing connection should be closed as well as its appropriate child frame window i've coded only for disconnecting the socket connection but not for destroying chld frame...
5
459
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 = 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...
1
1375
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
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.