Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
void CVCDlg::OnStriction() //open Striction box
{

HANDLE hMutexOneInstance = ::CreateMutex( NULL, FALSE, _T("IDD_STRICTION"));

bAlreadyRunning = ( ::GetLastError() == ERROR_ALREADY_EXISTS ||
                    ::GetLastError() == ERROR_ACCESS_DENIED);

if(!bAlreadyRunning)
{
CDialog *BadFileD = new CDialog(IDD_STRICTION, this);
BadFileD->DoModal();
OnButton1();
CMenu* pMenu = GetMenu();
pMenu->ModifyMenu( ID_STRICTION, 0, ID_STRICTION, "Expansion" ); 
}
ReleaseMutex(hMutexOneInstance);
CloseHandle(hMutexOneInstance);
}


What I have tried:

I have a GUI that has a menu. the code i above makes the GUI window gets smaller. once i click on the Striction (on the menu) it does the job, it makes the GUI window smaller. Inside the If statement i am using
GetMenu();
to change the text on the Menu from Striction to Expansion to do the reverse order to make get to its origional size.

the problem i am facing at the moment is when i click on the menu twich, the Menu text does not change back to Striction. although the GUI keeps getting bigger and smaller as i want.
Posted
Updated 3-Jul-18 19:32pm

1 solution

It looks like the function OnButton1() is the place where you are doing the resizing. You could either move modify the menu there, or return a status variable to indicate if the window is big or small.

For example:
CMenu* pMenu = GetMenu();
int isBig = OnButton1();
if(isBig)
{
    pMenu->ModifyMenu( ID_STRICTION, 0, ID_STRICTION, "Striction" );
}
else
{
    pMenu->ModifyMenu( ID_STRICTION, 0, ID_STRICTION, "Expansion" );
}
 
Share this answer
 
Comments
Baderd94 4-Jul-18 13:20pm    
Thaddeus Jones, I moveed modify the menu to OnButton1() and, it worked. thank you so much
[no name] 4-Jul-18 13:31pm    
Nice, anytime :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900