|
Let's say it's one of the driving reasons
Everytime I go looking for some algorithm or method of getting something done, one of the first places I go is to Code Project It seems that ever good solution I've been able to find is almost always in C++.
That and the fact that most of the MS VC++ is geared toward C++ It's hard to find anything that doesn't involve classes and other C++ stuff. I've managed to muddle through for quite a while with them, but I'd really like to know what I'm doing
|
|
|
|
|
steve76063 wrote: What are some good books for picking up C++?
Start with Thinking in C++[^]. You can get a free HTML version of that book. Few more books you will be interested,
1 - The C++ programming language By Stroustrup
2 - Modern C++ Design: Generic Programming and Design Patterns Applied
3 - C++ coding standards - 101 Rules, Guidelines, and Best Practices By Herb Sutter, Andrei Alexandrescu
4 - Effective C++ Third Edition 55 Specific Ways to Improve Your Programs and Designs By Scott Meyers
5 - Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions By Herb Sutter
|
|
|
|
|
I am running into the problem of when a resource is active/accessible and not.
I want to disable (grey out) certain menu items when the files it needs are not available.
I tried using the resource ID of the menu item(s) in OnInitDialog() and in OnSysCommand(), but that didn't work.
CWnd *pCntrlItem;
if ( !bExists )
{
pCntrlItem = CWnd::GetDlgItem(ID_UTILITIES_ITEM1);
pCntrlItem->EnableWindow(FALSE);
}
Can anyone help? Thanks,
JJM
|
|
|
|
|
john john mackey wrote: I want to disable (grey out) certain menu items when the files it needs are not available.
That can easily be handled by adding an ON_UPDATE_COMMAND_UI macro in your message map. In the handler for that message, simply return TRUE/FALSE to enable/disable that particular menu item.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I'm obviously doing something wrong. I am even looking at some code that did the same thing (originally created in VC++ 6.0) and comparing it to what I am trying - not working.
In my Studio 2008 (VC++ 2008), I set the menu item's property to Grayed=True, Enabled=FALSE.
I have message handler for ON_UPDATE_COMMAND_UI(), and then I'm doing the debugger.
Since Enabled==FALSE, I can't get the button to change back even when my criterium is found:
void CStartupDlg::OnUpdateUtilitiesCoordConv(CCmdUI *pCmdUI)
{
CString sProcName;
sProcName.LoadStringA(IDS_MYFILE);
CFileStatus cfStat;
BOOL bExists = FALSE;
bExists = CFile::GetStatus(sProcName, cfStat);
if ( !bExists )
{
MessageBox("What the Deuce?!", NULL, MB_OK);
pCmdUI->Enable(FALSE);
}
else
{
pCmdUI->Enable(TRUE);
}
}
|
|
|
|
|
john john mackey wrote: In my Studio 2008 (VC++ 2008), I set the menu item's property to Grayed=True, Enabled=FALSE.
What happens if you leave those properties as default?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Doesn't do a thing either.
I'm moving ON_UPDATE_COMMAND_UI() into the //AFX_MSG_MAP section BEGIN_MESSAGE_MAP so that it looks like the VC++6.0 version, doing other changes to make it look like the working 6.0 version.
I'm puzzled
|
|
|
|
|
john john mackey wrote: Doesn't do a thing either.
Are you sure that pCmdUI->SetEnable(TRUE) is being called?
john john mackey wrote: I'm moving ON_UPDATE_COMMAND_UI() into the //AFX_MSG_MAP section BEGIN_MESSAGE_MAP...
Which won't affect the compiler as all of those comments are removed by the preprocessor before the compiler sees the code.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
When I set the resource properties of the menu item (like I did in my old code, VC++6.0) to Enabled = False, Greyed = True, it can't reach this update because the menu item is disabled - ON_UPDATE_COMMAND_UI() can't be called
I am so confused as to why it worked in old code and not now....
|
|
|
|
|
sorry for the same problem again, but I have one more question regarding this:
Is there a difference in how menu items are handle in Doc/View applications Vs. a Dialog-based app?
The previous example, which worked, was implemented in a Doc/View application. The ON_UPDATED_COMMAND_UI was placed in the view.cpp section of code. here is what worked:
(PrevProgramView.cpp)
BEGIN_MESSAGE_MAP(CPrevProgramView, CView)
ON_COMMAND(ID_FILE_ADJUST, OnFileAdjustTimes)
ON_UPDATE_COMMAND_UI(ID_FILE_ADJUST, OnUpdateFileAdjustTimes)
END_MESSAGE_MAP()
then the function
void CPrevProgramView::OnUpdateFileAdjustTimes(CCmdUI *pCmdUI)
{
if (m_existingFile)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
and my resource property for ID_FILE_ADJUST is set to: Enabled=False, Greyed=True
In the new piece of code I'm trying to write (Dialog-based app), I have the following:
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
ON_COMMAND(ID_UTILITIES_CONVERT, OnUtilitiesConvert)
ON_UPDATE_COMMAND_UI(ID_UTILITIES_CONVERT, &CMyDlg::OnUpdateUtilitiesConvert)
END_MESSAGE_MAP()
and the new function (that IS called) is
void CMyDlg::OnUpdateUtilitiesConvert(CCmdUI *pCmdUI)
{
CFileStatus cfStat;
CString sProcName;
BOOL bExists = FALSE;
sProcName.LoadStringA(IDS_COORD_CONV);
bExists = CFile::GetStatus(sProcName, cfStat);
pCmdUI->Enable( bExists );
}
with my resource ID_UTILITIES_CONVERT set to Enabled=False, Greyed=True.
NOTE: I even changed my ID_UTILITIES_CONVERT to Enabled=TRUE, Greyed=FALSE, changed pCmdUI->Enable( FALSE ); and set breakpoints - did not change the menu item to disabled
Don't know what is not working
|
|
|
|
|
john john mackey wrote: Is there a difference in how menu items are handle in Doc/View applications Vs. a Dialog-based app?
I've never added a menu to a dialog-based app.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hey everybody
Okay, I'm stuck on that one for a few month now...
Is there a way to get a clipboard paste event without system-wide hook???
Thanks a lot !!!!
|
|
|
|
|
Green Fuze wrote: Is there a way to get a clipboard paste event without system-wide hook???
I'm not even sure what that means. If you want to capture all WM_PASTE messages in the system then how else would it be done?
Otherwise maybe you are looking for SetClipboardViewer[^]
|
|
|
|
|
led mike wrote: If you want to capture all WM_PASTE messages in the system then how else would it be done?
Well, you may ask to the developers of all your applications (future ones included) to gently notify you when a WM_PASTE is to be issued...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I was starting to think about that solution after a while...
|
|
|
|
|
Hey,
Thanks for your help!
SetClipboardViewer is not a good solution because it simply tells you what is in the clipboard, and when it changes (copy/cut), but it doesn't tell you when an application pastes from the clipboard.
Besides that, WM_PASTE is not being used much nowadays (from what I checked a little bit), and it is not a complete solution, and it also requires a system-wide hook.
I was hoping to find something list "FindFirstPrinterChangeNotification()", but for paste, or some service that I can register to in order to receive notifications.
Thanks again!!!
|
|
|
|
|
Green Fuze wrote:
Is there a way to get a clipboard paste event without system-wide hook???
Are you wanting to know when the user pastes into any application? Have you seen the discussion here?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks a lot for your help!!!
DavidCrow wrote: Are you wanting to know when the user pastes into any application?
Yup!
DavidCrow wrote: Have you seen the discussion here?
I read this post, and it talks about system-wide hook.
I know how to do it using system-wide hook, and replacing the GetClipboardData() function to get notification, but it looks a bit of an overkill (unless there is no choice...!).
I was hoping to find something like FindFirstPrinterChangeNotification(), or a service I can register to get notifications...
Thanks again!!!
|
|
|
|
|
Hello Green, were You able to detect paste events, would You please post your code?
|
|
|
|
|
Hello All
is there any API to show how strong is password for respective user .in vc++
|
|
|
|
|
Do you mean the strength of the password they have just entered, or the strength of password required by their account settings?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Many varieties exist. One example is here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello All .
Can you please tell me how to di firewall rule in xp.
|
|
|
|
|
Look here[^]
[edit] Sorry - didn't notice your constraint that it should be under XP, not Vista. [/edit]
[edit2]There is the Windows Firewall API[^], though - that's accessible in XP SP2 and above... That let's you list the authorized applications and open ports, which are the closest you get to rules with the XP firewall.[/edit2]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hello frnd i write this under XP, not Vista. because inetfwpolicy2.rule you can get fw rules but it is only for vista
|
|
|
|