|
m_listControlVariable.EnableWindow(TRUE);
Jetli
Constant Thing In World Is Change.
|
|
|
|
|
Hi,
The situation:
* Using a Window with the Scroll bar capabilities.
* The mapping mode is MM_HIMETRIC.
* Just drawn a Circle in the View using OnDraw()
* Handled MouseLeft button click to perform the hit test.
I know that:
* Mouse Co-ordinates are device co-ordinate system (in pixel)
* The circle drawn is in the Logical Co ordinate
My Doubt:
The following code does't work . Why? What is wrong with me. I have tested it after converting the point into Logical point.
Code:
void CEX04CView::OnLButtonDown(UINT nFlags, CPoint point) <br />
{<br />
CClientDC dc(this);<br />
OnPrepareDC(&dc);<br />
CRect rectDevice = m_rectEllipse;<br />
dc.DPtoLP(& point);<br />
if (rectDevice.PtInRect(point)) <br />
{<br />
if (m_nColor == GRAY_BRUSH)<br />
m_nColor = WHITE_BRUSH;<br />
else<br />
m_nColor = GRAY_BRUSH;<br />
InvalidateRect(rectDevice);<br />
}<br />
CScrollView::OnLButtonDown(nFlags, point);<br />
}
Thanks in advance for the Valuable help!
|
|
|
|
|
SivaramanDhamodharan wrote:
The following code does't work
"Doesn't work" is a little vague. What or where is failing exactly?
SivaramanDhamodharan wrote:
CRect rectDevice = m_rectEllipse;
Despite its name, rectDevice is in logical coordinates, right? Since you are converting the point to logical coordinates too, the test in rectDevice.PtInRect(point) should work as expected.
However, when calling InvalidateRect , you should pass a rect in device coordinates, so I'd try doing dc.LPtoDP(rectDevice) before the call to InvalidateRect .
On another point, you are calling CScrollView::OnLButtonDown with the modified value of point ... It probably doesn't matter (I don't think the default implementation actually uses this value), but I'd fix that too.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Do not convert the point coordinates to logical coordinates.
1) If the rectDevice is in device coordinates, then no conversion is needed.
2) If the rectDevice is in logical coordinates then convert it to device coordinates instead.
InvalidateRect() does not take a rectangle in logical coordinates and niether does CScrollView::OnLButtonDown(nFlags, point).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi John,
Thanks it works.
"If the rectDevice is in logical coordinates then convert it to device coordinates instead." - This helped me with the Quote "InvalidateRect() does not take a rectangle in logical coordinates"
Thanks a Lot.
The Working Code is :
CClientDC dc(this);<br />
OnPrepareDC(&dc);<br />
CRect rectDevice = m_rectEllipse;<br />
dc.LPtoDP(rectDevice);<br />
if (rectDevice.PtInRect(point)) <br />
{<br />
if (m_nColor == GRAY_BRUSH) <br />
{<br />
m_nColor = WHITE_BRUSH;<br />
}<br />
else <br />
{<br />
m_nColor = GRAY_BRUSH;<br />
}<br />
InvalidateRect(rectDevice);<br />
}
|
|
|
|
|
Hi..I want to insert a item to an existing tree and I want to make the item become the child of one of the tree members
for example:
before:
root
..|_parent1
..|_parent2
..|_parent3
after:
root
..|_parent1
..|_parent2
......|_(I want to insert my new item in here)
..|_parent3
but I didn't know how to do it. Plz help me because I'm a newbie in MFC programming
thx.
|
|
|
|
|
m_treeCtrl.InsertItem. From MSDN:
HTREEITEM InsertItem( LPTVINSERTSTRUCT lpInsertStruct );
HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter );
Download this project[^], you'll find it usefull.
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Call CTreeCtrl::GetItem() on the "parent2" item. Then call CTreeCtrl::InsertItem() to insert the new "child" item below that.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
thx 2 you all for your help. Can a tree control access another atttributes of a data? I am planning to make a tree control from a list of data
for example, I am a list of datas, each of data consists of Name, adrress, phone number, etc and I want to make the tree control based on the name. Does it exist any command to access/ display other attributes by clicking the tree element?
thx..
|
|
|
|
|
After inserting a node in the tree control, use SetItemData() to associate that node with the item in the list.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Can u give me some examples pls?because I'm still new in MFC and lack of experience in programming.
thx
|
|
|
|
|
|
thx...I have read the link u gave me, but I think it is not what I' looking for
for example I have a data base file that consist name,age,address,phone number,etc and I want to make a tree control based on the name for example. And then if I click the tree control attributes, I can access the other database attributes such as the age,address,phone,etc. Is there any function or maybe some links to help me..because I'm so confused.
thx...
|
|
|
|
|
One way would be to read the records from the database into a data structure and populate the tree control from that data structure.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
thx...I also have some problem on populating the tree control. I want to group the tree attributes if there are same occurences. I have tried to make the function, but when I run it, my program become not responding.
here is my function:
HTREEITEM CCDBMainDlg::LoadTree(CStringArray& tree)
{
m_hItem = m_treeCDB.GetNextItem(m_hItem,TVGN_ROOT);
if(m_treeCDB.ItemHasChildren(m_hItem))
{
m_hItem = m_treeCDB.GetChildItem(m_hItem);
while(m_treeCDB.GetItemText(m_hItem).Compare(tree.GetAt(12))!=NULL || m_hItem != NULL)
{
m_hItem = m_treeCDB.GetNextSiblingItem(m_hItem);
}
if(m_treeCDB.ItemHasChildren(m_hItem))
{
m_hItem = m_treeCDB.GetChildItem(m_hItem);
while(m_treeCDB.GetItemText(m_hItem).Compare(tree.GetAt(11))!=NULL || m_hItem != NULL)
{
m_hItem = m_treeCDB.GetNextSiblingItem(m_hItem);
}
if(m_treeCDB.ItemHasChildren(m_hItem))
{
m_hItem = m_treeCDB.GetChildItem(m_hItem);
while(m_treeCDB.GetItemText(m_hItem).Compare(tree.GetAt(0))!=NULL || m_hItem != NULL)
{
m_hItem = m_treeCDB.GetNextSiblingItem(m_hItem);
}
}
else
{
m_hItem = m_treeCDB.InsertItem(tree.GetAt(0),0,1,m_hItem);
}
}
else
{
m_hItem = m_treeCDB.InsertItem(tree.GetAt(11),0,1,m_hItem);
m_hItem = m_treeCDB.InsertItem(tree.GetAt(0),0,1,m_hItem);
}
}
else
{
m_hItem = m_treeCDB.InsertItem(tree.GetAt(12),0,1,m_hItem);
m_hItem = m_treeCDB.InsertItem(tree.GetAt(11),0,1,m_hItem);
m_hItem = m_treeCDB.InsertItem(tree.GetAt(0),0,1,m_hItem);
}
m_hItem = m_treeCDB.InsertItem(tree.GetAt(1),0,1,m_hItem);
m_treeCDB.EnsureVisible(m_hItem);
return m_hItem;
}
pls help.
thx.
|
|
|
|
|
firebolt77 wrote:
...but when I run it, my program become not responding.
One of the while loops is not ending. You'll need to set a breakpoint on each one, run the program using F5, and note which breakpoint was not hit. That'll tell you which loop is faulty.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
can anybody tell me what is Account operator.
|
|
|
|
|
Other than responding with "Someone that operates the account," you'll need to be a bit more specific.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
hi
|
|
|
|
|
since this is the Visual C++ message board and not some chat-site.
"Hello World!" would`ve been at least a little more appropriate than just plain "hi"
Other than that, when starting a new thread in this message board, please just post C++ related questions. There are message-boards for non programming related topics in the Lounge and Soapbox...
Cheers...
And since you look to be new here: Welcome!
|
|
|
|
|
Maybe jitendra is just a material person in a material world...
Oh, wait, that belongs in the "sucky music" forum...
|
|
|
|
|
It is easy to use exported functions from dll using LoadLibrary and GetProcAddress.
however it seems that there is no way to use exported functions from exe(executable application).
In other words, how can the communication between two applications(such as, function call) be done?
thanks
|
|
|
|
|
I think the only way to do that is RPC (Remote Procedure Call) used for communication of application running on remote hosts. I don't think there is another way to export functions from an executable, that's the job for a dynamic library only. A more common way for communication between apps is shared memory or pipes if they are running on the same host as RPC is a bit 'expensive' on CPU considering it adds some overhead.
Themis
|
|
|
|
|
There are many articles about IPC on CodeProject.
Don't try it, just do it!
|
|
|
|