|
zeus_master wrote: 1>how can I get current mouse position?
use GetCurrentMessage() funtion. it will return a structure of MSG. The MSG contains a member that holds the point in which the last message occured.
U can also GetCursorPos() to get mouse the position. But I prefer the first one. Also I think there is no need to call ScreenToClient(&point) .
zeus_master wrote: 2>the add and del note command?
I didn't understand this
nave
|
|
|
|
|
|
suppose u have right clicked the mouse while the mouse is moving fast. By the u call time GetCursorPos() the mouse might have moved to some another location or even over some other window. So showing popup at that point make no sense.
do u agree?
nave
|
|
|
|
|
Naveen R wrote: do u agree?
Yeah I do. I see that with tray applications. Click on the tray icon and move your mouse. The menu comes up where your mouse pointer is.
But since I am lazy :-> I like this. It saves me the time and effort to move down and click on the menu there.;)
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Million thanks!
2> I mean how to add or delete the tree notes?
|
|
|
|
|
so what i understood is, u want to show some popup menu will item Add and Delete.
When u click Delete button u and u want to delete the selected item..
1) call GetSelectedItem( ); -> it will return and handle to the selected item
2) the call the DeleteItem(); with the handle returned by the GetSelectedItem()
now to add a child node under the seleted node
3. Call
InsertItem( LPCTSTR lpszItem, HTREEITEM hParent = TVI_ROOT, HTREEITEM hInsertAfter );
with hParent as the handle returned by GetSelectedItem();
nave
|
|
|
|
|
I'v tried them, thank you.
but there still a problem while insert Items.
+ROOT1
|
-ROOT2
|_child1
|_child2
|_child3
first, LClick set sel on child1; then move mouse to child2,RClick child2, Pop-menu appears on child2,it is normal/OK.
1>but the focus still at stay at child1, whill click pop-menu add note command , a new child note will be created under child1 ,but not the position RClick occurs and not the position pop-menu on( should be child2).
void CMainFrame::OnInsertItem()
{
// TODO: Add your command handler code here
m_Tree.InsertItem("new node",m_Tree.GetSelectedItem(),TVI_LAST);
m_wndTree.UpdateWindow(); // it seems useless
}
2>and the new child note will be not visible/enable at once, I need LClick the ROOT2 or other notes, the new created note can be visible.
if I insert the items based on ROOT note, it can be refresh and can be seen right away .
void CMainFrame::OnInsertROOTItem()
{
// TODO: Add your command handler code here
m_Tree.InsertItem("New note",TVI_ROOT);
}
-- modified at 3:50 Thursday 15th June, 2006
|
|
|
|
|
zeus_master wrote: 1>but the focus still at stay at child1,
in that case u should explicitly set the focus to child2.
The HitTest() function will help u in this
1. Take the mouse point
2. Call HitTest funtion with that point( this will retun the handle to the item below that point )
3. Call SetItemState() for this item
4. Now the underling item will be selected. after this u show the popup menu...
zeus_master wrote: 2>and the new child note will be not visible/enable at once,
did u tried EnsureVisible() funtion?
nave
|
|
|
|
|
void CMainFrame::OnRclickTree(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CMenu dMenu;
if(!dMenu.LoadMenu(IDR_TREERKEY))
{
AfxThrowResourceException();
}
CMenu *pPopupMenu = dMenu.GetSubMenu(0);
ASSERT(pPopupMenu != NULL);
CPoint point;
::GetCursorPos(&point); /* here the point still stay at where LClick set sel */
// const MSG * pMsg;
// pMsg = GetCurrentMessage();
// point = pMsg->pt;
HTREEITEM pitem;
pitem=m_Tree.HitTest(point);
m_Tree.SetItemState(pitem,TVIS_SELECTED,NULL);
pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,point.x,point.y,AfxGetMainWnd());
*pResult = 0;
}
I faild, set breakpoint and found that, the point still keep on the place where LClick set sel tree item, and the RClick at another item seems can't return mouse point at once. but what strangeness is the pop-menu can appear at where the RClick point/item.
is the code wrong?
appreciate for your kindly help.
|
|
|
|
|
zeus_master wrote: pitem=m_Tree.HitTest(point);
there is problem here
before u make the hittest
do like this
CPoint Pt = point
ScreenToClient( Pt );
pitem = m_Tree.HitTest(Pt);
nave
|
|
|
|
|
it still didn't work.
I debuged the code and found that calling ::GetCursorPos(&point); in RClick function, still return the point set by LClick.
|
|
|
|
|
This code in splitter won't compile. The left pane is CTreeCtrl derived class and the right pane is CTabCtrl derived.
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CX_TreeView), CSize(100, 100), pContext) ||
!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CX_TabView), CSize(100, 100), pContext) )
Here is the compiler (VC 6.0) output:
X_SplitFrame.cpp
Including X_TabView.h : header file
F:\Dev\0 Image\V1\Image Project\X_SplitFrame.cpp(57) : error C2039: 'classCX_TabView' : is not a member of 'CX_TabView'
f:\dev\0 image\v1\image project\x_tabview.h(13) : see declaration of 'CX_TabView'
F:\Dev\0 Image\V1\Image Project\X_SplitFrame.cpp(57) : error C2065: 'classCX_TabView' : undeclared identifier
I build both classes using MFC New class and I used #pragma message to make sure the header is included.
What did I missed?
Thanks for reading.
Vaclav
|
|
|
|
|
I think I found it. The CTabCtrl is not CView derived.
Vaclav
|
|
|
|
|
Vaclav wrote: I think I found it. The CTabCtrl is not CView derived.
Correct. You'll have to use a CFormView with a CTabCtrl inside it.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I'm trying to show the shell context menu for a file when only having the file name. I got the menu to come up but not all the menu items are showing up - like the ones virus scanners or zip utilities add to all files ("Scan File", "Add to Zip" etc.). Is there anything I'm missing:
typedef HRESULT (WINAPI *lpfnSHBindToParent)(LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast);
LRESULT OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
lpfnSHBindToParent pSHBindToParent = (lpfnSHBindToParent)GetProcAddress(GetModuleHandle(TEXT("SHELL32.DLL")), "SHBindToParent");
if (pSHBindToParent)
{
LPOLESTR pwszFileName;
#ifdef UNICODE
pwszFileName = strFullFileName;
#else
WCHAR wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, strFullFileName, -1, wsz, ARRAYSIZE(wsz));
pwszFileName = wsz;
#endif
LPSHELLFOLDER pDesktopFolder;
if (SHGetDesktopFolder(&pDesktopFolder) == NOERROR)
{
LPITEMIDLIST pidl;
if (pDesktopFolder->ParseDisplayName(hMainWnd, NULL, pwszFileName, NULL, &pidl, NULL) == S_OK)
{
LPSHELLFOLDER pParentFolder;
LPCITEMIDLIST pidlLast;
if (pSHBindToParent(pidl, IID_IShellFolder, (void**)&pParentFolder, &pidlLast) == S_OK)
{
IContextMenu* picm;
if (pParentFolder->GetUIObjectOf(hMainWnd, 1, &pidlLast, IID_IContextMenu, NULL, (void**)&picm) == S_OK)
{
HMENU hMenuPopup = CreatePopupMenu();
if (hMenuPopup)
{
if ( SUCCEEDED( picm->QueryContextMenu(hMenuPopup, 0, 1, 0x7fff, CMF_NORMAL) ))
{
}
DestroyMenu(hMenuPopup);
}
picm->Release();
}
pParentFolder->Release();
}
CoTaskMemFree(pidl);
}
pDesktopFolder->Release();
}
}
return 0;
}
- thanks
|
|
|
|
|
I program in Visual C++ 6.0 and use the MFC macros quite a bit. I am looking for a good publication that explaines each of the MFC functions, what the arguments are and how they work. Specifically, when using a function, how does one delete an object and re-instate it. If there is a good publication out there, I would appreciate a response on how to purchase or? Thanks in avance, Sid Kraft at sid_kraft@msn.com.
Sid
|
|
|
|
|
You will not find many macros definitions in "MFC internals", I think MSDN does better job.
Vaclav
|
|
|
|
|
is there anyway to stop the slider and buttions from showing that mci makes?
|
|
|
|
|
Can you be more specific
whitesky
|
|
|
|
|
when you use MCIWndPlay MCIWndStop MCIWndPause it makes a button and a slider in your dialog and they are right at the top of the dialog the button is hidden so it dont matter the slider can be seen and if it can be done ill keep it if it can be moved and resized
look at this artical http://www.codeproject.com/audio/mp3player.asp[^] if you compile that project it will have the extra button and slider at the top
|
|
|
|
|
remove WS_VISIBLE in this function MCIWndCreate and send me is your problem solve or no
whitesky
|
|
|
|
|
that made it disappear but i would like to keep the slider but only if i can resize it and move it.
|
|
|
|
|
you can use from m_Video = MCIWndCreate in MoveWindow to change size
whitesky
|
|
|
|
|
thanks dude got that working right now just a few more things and ill be good to go
|
|
|
|
|
I've created an MFC application that "should" talk to a device on my PC.
do I have to #include anything special in order for SetupDiEnumDeviceInterfaces, HANDLE, HDEVINFO, etc. to work?
Thanks!
Kitty5
|
|
|
|