|
void CTreeViewDlg::OnNMRclickTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
CPoint ptMouse;
DWORD dwPos;
UINT nFlags;
CTreeCtrl *pTreeCtrl;
pTreeCtrl = (CTreeCtrl *)GetDlgItem(IDC_TREE1);
{
dwPos = ::GetMessagePos();
ptMouse.x = LOWORD (dwPos);
ptMouse.y = HIWORD (dwPos);
CPoint ptAction = ptMouse;
// convert coordinates
pTreeCtrl->ScreenToClient(&ptAction);
// determine if click is on tree item
HTREEITEM hItemRClick = pTreeCtrl->HitTest(ptAction, &nFlags);
// if click is on tree item,
if (hItemRClick != NULL)
{
// set selection to right+clicked item
pTreeCtrl->SelectItem(hItemRClick);
HMENU hMenu = LoadMenu(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MENU1));
if(hMenu)
{
hMenu = GetSubMenu(hMenu,1);
if(hMenu)
{
TrackPopupMenu(hMenu,0,ptMouse.x,ptMouse.y,0,pTreeCtrl->m_hWnd,NULL);
}
}
}
}
*pResult = 0;
}
i have done something like this
Noe the pop up menu is poping up
but whenever i click on something it does not go to respective
handler!!
Thanks and regards
Harshal
|
|
|
|
|
I think the pNMHDR argument of your handler actually does not point to NMTREEVIEW structure. (See the documentation of NM_RCLICK in case of tree controls). But you can obtain the current cursor position using GetCursorPos function:
CPoint point;
GetCursorPosition(&point);
I hope this helps.
|
|
|
|
|
2 questions
(1)how to get difference when user loads a file from "Open file" and "Recent fil" - or, how to know if user clicks a "Recent file" rather than "Open file"?
In my app, I used a setteing (or check register) to record "recent files", I think it is not a good way.
(2)how to change maximum allowed count of "recent files"?
|
|
|
|
|
1 => the function AddToRecentFileList of the application is automatically called by the document to complete the MRU (Most Recent Files) file list
when the application open a MRU file, the function OnOpenRecentFile is called by the application class
2 => in your class application::InitInstance there's the fuction LoadStdProfileSettings(5) which is called. This define the number of MRU
|
|
|
|
|
Hi,
I have a requirement to keep an application alive even after an user logs off. i.e When the second user logs in, the applications that are opened by the first user should remain open. Is there any way to do this? As our appication would take more time to shutdown and startup we dont want to close it while log off.
Can anybody help me out in resolving this...
An another thing i dont want run my application as a service ...
Is it possible to hibernate the application and wake up when the next user logs in?
Can anybody tell me the concept of Identity Switching? Can this be employed to solve this issue?
What happens when the Switch user is being called in Windows XP? Is there any API to accomplish this task?
Platform : Windows
Thanks,
Selva
-- modified at 4:25 Tuesday 21st November, 2006
~ Selva
|
|
|
|
|
SelvaKr wrote: to keep an application alive even after an user logs off. i.e When the second user logs in, the applications that are opened by the first user should remain open
I think you need to wrote a windows service application. Good luck!
|
|
|
|
|
Thanks for your reply Moga...
But i dont want to keep my app as a service...Any other way apart from this...
Is there any other way like XP's hibernation technique or only changing the user identities ....
Thanks.
~ Selva
|
|
|
|
|
If you detect that your app is being closed, and store it's state to a local file, you can read it again when the app opens. You would have to do something fairly funky for it to work like hibernation.
Christian Graus - C++ MVP
|
|
|
|
|
Hi Graus,
Thanks for your reply.
But this approach will again require all my supporting dlls to load again which will lead in time consumption again
Or is it possible to switch the identities of all the running applications instead of logoff/login. Will it change the user privilege of windows too?
Thanks.
~ Selva
|
|
|
|
|
SelvaKr wrote: Or is it possible to switch the identities of all the running applications instead of logoff/login. Will it change the user privilege of windows too?
No, that's not going to work.
Christian Graus - C++ MVP
|
|
|
|
|
SelvaKr wrote: An another thing i dont want run my application as a service
Why not? A service is exactly the solution to what you're asking.
SelvaKr wrote: Is it possible to hibernate the application and wake up when the next user logs in?
Why build your own keep-alive system when the OS already has one? I suppose you could make your app persist its state to a file, then read it back in on the next launch. But then it's not actually running after logoff.
|
|
|
|
|
Did you try to add a key in the following registry path "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" to automatically start your application for all users ?
|
|
|
|
|
Thanks for your reply..
But my app should not be closed while logoff..
I dont want to start it for each login since it would take more time to load.
~ Selva
|
|
|
|
|
I see 2 solutions :
- Create a service : I know that you dont want to do this...but a service is not closed on logoff
- Use the Run Registry Key to launch your app for each logon and optimize the applicatino loading
|
|
|
|
|
Thanks buddy
~ Selva
|
|
|
|
|
hi
how can we compress the file using MFC .kindely Help me
#sanroop#
|
|
|
|
|
Read This article[^]
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
|
Hi,
I have a few years experience in programming C/C++ for Unix/Linux, and recently also .NET.
I also know about win32 api.
What would be a good introduction to MFC for an experienced programmer?
Not a book, as I won't spend money on MFC (there IS a limit! ).
I'm talking about some online resource.
I'm looking for something that won't waste my time on stuff I already know.
Thanks!
|
|
|
|
|
ncryptor wrote: Not a book, as I won't spend money on MFC
Then you're not at all serious.
ncryptor wrote: I'm talking about some online resource.
Look around you. Heaps of MFC articles here.
ncryptor wrote: I'm looking for something that won't waste my time on stuff I already know.
Impossible to recommend, we don't know what you know, and any MFC resource is likely to cover stuff you know from Win32.
Christian Graus - C++ MVP
|
|
|
|
|
1. I never said I'm serious.
2. Heaps of mfc articles - ok, i know. but could you recommend one that describes the concept (not specific classes) in-depth?
3. maybe an article about what's the conceptual difference between programming with C in win32 api (which i already am familiar with) and programming MFC?
Of course i'll have to find articles and read them.
All I'm asking is, do you happen to know a good place to start, that isn't intended for total beginners.
Thanks!
|
|
|
|
|
ncryptor wrote: 2. Heaps of mfc articles - ok, i know. but could you recommend one that describes the concept (not specific classes) in-depth?
3. maybe an article about what's the conceptual difference between programming with C in win32 api (which i already am familiar with) and programming MFC?
Maybe you can start from this one[^]
|
|
|
|
|
Thanks!
I already found that one...but Thanks!
|
|
|
|
|
Hi,
I want to add a multiple line output to a edit box. I set the properties of the edit
box as multiline, Vscroll ,auto vsroll. Then I edited the CString member variable i created as follows
txt.Format("%d) %s, %s, %s, %s, %s, %d, Score: %f \n", i+1, temp->sDateTimeCreated, temp->sAuthor, temp->sAccessLevel, temp->sReportSource, temp->sComments, temp->iRating, temp->fSearchScore);
m_DisplayString += txt;
But it doesn't go to the next line in the newline character. Instead it shows a little line. Pls help me to resolve this.
|
|
|
|
|