|
|
|
One way is to use "command enablers"...
BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd)
...
ON_UPDATE_COMMAND_UI(ID_BUTTONID, OnUpdateButton)
...
END_MESSAGE_MAP()
void CMyFrameWnd::OnUpdateButton(CCmdUI* pCmdUI)
{
if (some_condition)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark thanks for reply, but I have dialog based application, there is no ON_UPDATE_COMMAND_UI
|
|
|
|
|
Then try in OnPaint.
if (condition)
button->EnableWindow (TRUE);
else
button->EnableWindow (FALSE);
is not the best way, but it will maybe work
NOTE: I have not read the article, so im not sure if I'm saying something catastrofical :P
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Well, anytime after a toolbar is created and the buttons are added to it, you can enable and
diable buttons when you need to:
// Disable a button
m_ToolBar.GetToolBarCtrl().EnableButton(ID_BUTTON1, FALSE);
// Enable a button
m_ToolBar.GetToolBarCtrl().EnableButton(ID_BUTTON1, TRUE);
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark, many thanks it works , but button was not greyed .
|
|
|
|
|
Romiks wrote: but button was not greyed
Looking at the article, it looks like there's a separate image list for disabled.
Are the images in that image list the same as the regular images?
You could try omitting the last parameter in the call to LoadTrueColorToolBar() - the system
should do its default "greying" for disabled buttons.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark, many thanks for help. I have tried to omit the last parameter, but it doesn't work .
I will try to use CButton instead of tool bar.
|
|
|
|
|
So the buttons diable but they don't look disabled?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Mark,
If I ommited the last parameter, buttons are not disabled.
|
|
|
|
|
I just downloaded the source - I'll take a look.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Ok..
It all works fine in the authors demo app.
The author actually omits the last parametr in the call to CTrueColorToolBar::LoadTrueColorToolBar
for the RIGHT toolbar. So, the right toolbar shows button bitmaps grayed by the system.
For the left toolbar he uses special bitmaps for disabled buttons that don't have any color,
just white/black/grays.
All the buttons except the first three on left and right are disabled. If you try to disable them
yourself they won't look any different
To enable them, you can add command enablers. For example, there's 9 buttons on the toolbars.
I enabled the 7th and 8th buttons like this (in MainFrm.cpp/.h):
afx_msg void OnUpdateButton32777(CCmdUI* pCmdUI);
afx_msg void OnUpdateButton32778(CCmdUI* pCmdUI);
ON_UPDATE_COMMAND_UI(ID_BUTTON32777, OnUpdateButton32777)
ON_UPDATE_COMMAND_UI(ID_BUTTON32778, OnUpdateButton32778)
void CMainFrame::OnUpdateButton32777(CCmdUI* pCmdUI)
{
pCmdUI->Enable(TRUE);
}
void CMainFrame::OnUpdateButton32778(CCmdUI* pCmdUI)
{
pCmdUI->Enable(TRUE);
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Ok...
I have dialog based MFC application
There is no ON_UPDATE_COMMAND_UI command
|
|
|
|
|
Romiks wrote: I have dialog based MFC application
Oh yeah, I forgot about that, sorry
Well I still go back to this:
// Disable button ID_BUTTON32777 in m_ToolBar
m_ToolBar.GetToolBarCtrl().EnableButton(ID_BUTTON32777, FALSE);
// Enable button ID_BUTTON32777 in m_ToolBar
m_ToolBar.GetToolBarCtrl().EnableButton(ID_BUTTON32777, TRUE);
I'm not sure why that doesn't work for you - I just tested it in a dialog toolbar here.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
If you have working dialog based project, could you please send me?
my mail:losqut@yandex.ru
As for me, buttons are not greyed
|
|
|
|
|
When using the Visual Studio Installer to create an installation, if I add a VC++ redistributable merge module (.msm) file to the solution, the installation puts the .dll(s) into the target directory.
Is there a way to have the installer put those in a subdirectory of the targetdir without having to open the .msi up with orca.exe and modifying stuff in there?
I'm trying to put those dll(s) in the equivalent of a bin directory along with my other dll(s) and ocx files.
|
|
|
|
|
While creating simple test multithreading application ,I am getting this bug.
I made function global.I dont want to declare static,I dont know whats wrong.
void CCustom1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
int m = 5;
CWinThread* tt;
tt = AfxBeginThread(Myfunc,&m,THREAD_PRIORITY_NORMAL,0,0,NULL);
}
UINT Myfunc(LPVOID pParam)
{
int* co = reinterpret_cast<int*>(pParam);
return 0;
}
Can anyone tell me,I searched many articles for bug,and all concludes that it must be
global or static,now I have global.still bug is pidding. My project settings are proper
for run time library.
|| ART OF LIVING ||
|
|
|
|
|
Do you still get the error if you declare your thread proc before the call to AfxBeginThread()?
UINT Myfunc(LPVOID pParam);
void CCustom1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
int m = 5;
CWinThread* tt;
tt = AfxBeginThread(Myfunc,&m,THREAD_PRIORITY_NORMAL,0,0,NULL);
}
UINT Myfunc(LPVOID pParam)
{
int* co = reinterpret_cast(pParam);
return 0;
}
*edit* You don't want to pass &m to your thread...m can/will go out of scope before MyFunc() uses<br />
it.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Looks like we posted a response at the same time
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Sorry,delayed responce,
If I made variable global ,written function declaration,where you shown but error is very same. No Change.
|| ART OF LIVING ||
|
|
|
|
|
From your posts below, it looks like you fixed it, right?
You'll still have to make sure any variables pointed to by a pointer passed to another thread
stay in existence until all threads that use the variable are done using it!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
yes that was another mistake
|| ART OF LIVING ||
|
|
|
|
|
Give this a try: (note the placement of the Myfunc function declaration before OnButton1 handler and note the use of the _cdecl modifier)
Hope this helps
//------------------------------------------
UINT _cdecl Myfunc(LPVOID pParam);
void CCustom1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
int m = 5;
CWinThread* tt;
tt = AfxBeginThread(Myfunc,&m,THREAD_PRIORITY_NORMAL,0,0,NULL);
}
UINT _cdecl Myfunc(LPVOID pParam)
{
int* co = reinterpret_cast(pParam);
return 0;
}
|
|
|
|