|
Sorry, I'm at work right now and don't have much time to respond.
You should consider using the OnUpdate... handlers to check and uncheck the items. These are called by MFC for each menu item just prior to displaying the menu. Here, you operate on a CCmdUI object for that menu item, telling it exactly how it should be displayed.
So if you keep a flag indicating the checked state of "option," you can easily check/uncheck "option" and "another_option" based on that state. Examples would be something like this, using both the On... and OnUpdate... handlers:
BOOL m_bOptionSelected = FALSE;
void OnOption()
{
m_bOptionChecked = FALSE;
}
void OnAnotherOption()
{
m_bOptionSelected = TRUE;
}
void OnUpdateOption(CCmdUI * pCmdUI)
{
pCmdUI->SetCheck( m_bOptionSelected ? BST_CHECKED :
BST_UNCHECKED);
pCmdUI->Enable(TRUE);
}
void OnUpdateAnotherOption(CCmdUI * pCmdUI)
{
pCmdUI->SetCheck( m_bOptionSelected ? BST_UNCHECKED :
BST_CHECKED);
pCmdUI->Enable(TRUE);
}
Hope it helps.
Bob Ciora
|
|
|
|
|
hi Bob,
sure it helped- alot.
thanks for informing me about ON_UPDATE message handlers. thanks again and best regards
|
|
|
|
|
lordgreg wrote: if( mmenu->GetMenuState(ID_RISANJE_MNOGOKOTNIK, MF_CHECKED) )
Shouldn't this be:
if (mmenu->GetMenuState(ID_RISANJE_MNOGOKOTNIK, MF_BYCOMMAND) == MF_CHECKED)
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Now Iam facing one problem in my code,
I need to select multiple items by holding ctrl key in Tree control.Please help me if anybody have readymade code. Its very Urgent.
|
|
|
|
|
|
Can someone tell what %ld stand for?
|
|
|
|
|
i guess you are talking about a string formatting parameter, like into printf()...
if so, %ld tells to the functions that a long decimal value is expected here...
you should have a look at Format Specification Fields[^] and printf Type Field Characters[^]
if not, please tell us a minimum because your are not clear at all...
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 5:58 Tuesday 6th September, 2005
|
|
|
|
|
I'm working on a project using the MS CHtmlEditView (VC++ 7.0). I need to send messages to MSHTML (i.e. WM_KEYDOWN ).
The usual procedure (pView->SendMessage(WM_KEYDOWN, 'A') ) has no effect.
Anyone have a clue on how to do that?
Thanks+regards
|
|
|
|
|
Hi,
I have an SDI Application with 3 views: CLeftView, CTopRightView, CBottomRightView. CTopRightView has a CListCtrl. In the code for CLeftView, if some condition is met, I want to add an item to the list control in CTopRightView.
To do this, in CLeftView I set a Doc var to the item i want to add. Next, I call UpdateAllViews() so it can call my Overridden OnUpdate functions in my views. My overriden OnUpdate function in CtopRightView adds the item set in Doc class to the list control.
The Problem: UpdateAllViews() seems to call OnCreate() before it calls my OnUpdate function, thus clearing all the contents I had in the list control, and then calls OnUpdate(). Is there any way to prevent it from calling the OnCreate()? I don't want to recreate the list control, just add an item to it.
TraileR ParK LifE 4Ever
|
|
|
|
|
UpdateAllViews() should not call OnCreate() method. Could you please make sure, you have created all views and initialized before calling UpdateAllViews() method.
Show us some code snipet..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Hi MailToGops,
Thanks for the reply. All views are created and initialized. Below is some code you requested of what I am trying to do:
in CLeftView:
GetDocument()->FileAction(&strFileName,1);
in Doc class:
void Ca1interfaceDoc::FileAction(CString* fl, int acn)<br />
{<br />
fileName = *fl;<br />
action = acn;<br />
<br />
SetModifiedFlag();<br />
UpdateAllViews(NULL);<br />
<br />
fileCount++;<br />
}
in CTopRightView:
int CTopRightView::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
if (CView::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
folderContents.Create(WS_VISIBLE|WS_CHILD|WS_BORDER|<br />
LVS_LIST|LVS_SINGLESEL,<br />
CRect(10,10,300,180), this, <br />
IDC_FOLDERCONTENTS);<br />
<br />
LV_ITEM lvItem;<br />
::memset(&lvItem, 0, sizeof(LV_ITEM));<br />
lvItem.mask = LVIF_TEXT|LVIF_STATE;<br />
lvItem.state = 0;<br />
lvItem.stateMask = 0;<br />
lvItem.pszText = "an item";<br />
lvItem.iItem = 0;<br />
<br />
folderContents.InsertItem(&lvItem);<br />
<br />
return 0;<br />
}<br />
<br />
void CTopRightView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)<br />
{<br />
<br />
if(GetDocument()->action == 1 ){<br />
LV_ITEM lvItem;<br />
::memset(&lvItem, 0, sizeof(LV_ITEM));<br />
lvItem.mask = LVIF_TEXT;<br />
lvItem.pszText = GetNTS(GetDocument()->fileName);<br />
lvItem.iItem = GetDocument()->fileCount;<br />
<br />
<br />
if(folderContents.InsertItem(&lvItem) == -1)<br />
folderContents.DeleteAllItems();<br />
<br />
GetDocument()->action = 0;<br />
}<br />
}
The reason I believe OnCreate gets called every time UpdateAllViews() runs is this:
*In CTopRightView::OnCreate() I create the list control along with a test item and add this test item.
*When I run the application I only see 2 items in the CTopRightViews's list control. The test item added in OnCreate() and the last item that was supposed to be added to the list control (many items are supposed to be added to the list control).
So it looks like every time UpdateAllViews is executed it recreates the list control with the test item and the most recent item to be added.
TraileR ParK LifE 4Ever
|
|
|
|
|
For an SDI application, this is normal behavior. When a view asks the document for the data to be rendered, it has the choice of adding only new items, or adding all the items (again). I prefer the latter as it is much easier to clear the list control and add all of the items, contrasted with figuring out which items in the document are already in the view's list and which are not.
The MSDN article Q103982 might be remotely related to what you are seeing.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi David,
Thanks for the reply.
So how would I specify that I want the View to add only new items?
The article refers to VC++ 6.1 and older. I am using VC++ .NET. I did not find OnInitialUpdate() function in the .NET Framework for CView, which they talk about in the article.
TraileR ParK LifE 4Ever
|
|
|
|
|
/*Trucker*\ wrote:
So how would I specify that I want the View to add only new items?
How many total items are we talking about here?
/*Trucker*\ wrote:
The article refers to VC++ 6.1 and older. I am using VC++ .NET. I did not find OnInitialUpdate() function in the .NET Framework for CView, which they talk about in the article.
That's why I indicated it might only be remotely related.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I am not sure why this is relevent but anyways... to give you an idea I will tell u what my application is.
It is Like Windows Explorer. So left pane is the directory tree, but the right pane holds just the files of selected folder in directory tree (dont worry about the third pane I mentioned earlier). So it could be a little, or it could be a lot of files/items... but lets say it shouldn't be too much because this is just an assignment for school I am doing, not some program for Bill Gates
TraileR ParK LifE 4Ever
|
|
|
|
|
I really don't know of a reason to not do it the way I previously suggested, especially for the volume of items you've indicated. It's just a much smoother approach to a fairly common doc/view situation.
I'm curious why you are creating the list views each time they need updating. That's seems a bit inefficient. Why not create them once at the start of the application, and then update their contents as the need arises? With MFC, this is very easy to do using CSplitterWnd .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
How to use CRecordset with CByteArray for storing BLOBs
|
|
|
|
|
See the article:
Using CLongBinary for BLOBs - By Shekar Narayanan
http://codetools.com/database/usingblob.asp
This link may give you the answer. Try it.
http://msdn2.microsoft.com/library(d=printer)/07w94zsx(en-us,vs.80).aspx
http://www.codeguru.com/forum/showthread.php?t=120577
HAPPY VINAYAKA CHAVITI
Nice talking to you.
|
|
|
|
|
I made some small tests, it seems that delete[] can always replace delete, without errors.
But in my working project, it is not the case, I don't know why.
|
|
|
|
|
without errors, maybe ! but not without memory leaks !!!!!!!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 5:05 Tuesday 6th September, 2005
|
|
|
|
|
Some implementations might delete all memory, so you might not see any memory leak, but no implementation will call the destructor for every element in the array. If you have resources acquired by elements in the array, they won't get released until the program dies.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
This is what I call "Programming by Behavior" and it is EVIL EVIL EVIL. You are ignoring the rules and just going by how the program appears to work in specific instances.
The C++ standard specifically states that delete [] and delete are not interchangeable. Doing so might work sometimes, but that doesn't mean it will always work.
If you have a class with a destructor, using delete will only invoke the destructor on the first element. Thus causing all sorts of problems if the class has a non-trivial destructor.
NEVER EVER interchange delete with delete []. It is just wrong.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
"Appears to work" is not a synonym for "does work correctly."
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Works as coded.
Bob Ciora
|
|
|
|
|
p is a pointer to an array, when running, the 1 fragment is ok, the 2 one is wrong. What's the reason?
//in the destructor
//1
if (p!=NULL) {
for (int i=0;i
|
|
|
|