|
Hello all.
I have two listboxes in my program (side by side) that I am storing different data in. I want it so that when you click inside one of the listboxes, the other one "tracks it", meaning if I click on item #1 in listbox1, I want to instantly select item #1 in listbox2.
Currently, I am doing it this way:
void CMyTestAppDlg::OnLbnSelchangeList1()
{
int curSel = m_ListBox.GetCurSel();
m_ListBox2.SetCurSel(curSel);
}
( I also do the same code for the changeList2() )
This method works for me, the only problem is that it is slower than I had hoped. (When I click on one of the listboxes, it takes a good half second or so before the other one "catches up"). I am wondering if there is some other way of "linking" the listboxes so that the tracking is instant? (I know it's a long shot, but worth the question anyways
BTW: If I use the UP/DOWN arrow to move the selection in one of the listboxes, the tracking is instant and looks beautiful. I am guessing that the additional bit of overhead in processing the mouse click is what is slowing down the tracking process.
Thanks!
|
|
|
|
|
On a mouse click in the list box, it sounds like your handler doesn't get called until you release the mouse button. The delay you're experiencing could be the difference between when the button is pressed and released. To check this out, try pressing and holding the button and see if the change occurs only after the release.
Software Zen: delete this;
|
|
|
|
|
That is exactly what is happening!
Is there any way that I can make the listbox "onchange" happen on the press of the mouse button instead of the release?
Thanks
|
|
|
|
|
shultas wrote:
Is there any way that I can make the listbox "onchange" happen on the press of the mouse button instead of the release?
Yes. Try handling the NM_CLICK notification sent by the list box.
You will have to do a little work to figure out which item has been clicked on, since the NM_CLICK notification does not identify the item within the list box that was clicked. You should be able to get the position of the mouse cursor within the list box and compute the item based upon the size of the items in the box and the number of the topmost visible item.
Software Zen: delete this;
|
|
|
|
|
ilist_item *next = _current
<< _current = _current->next()
: _current;
I don't know the meaning of the above sentence extracted from book "C++ primer 3rd"
Could somebody tell me its meaning?
Thanks in advance!
|
|
|
|
|
Are you sure this is not a typo and it should be the conditional operator?
ilist_item *next = _current<br />
<< _current ? _current->next()<br />
: _current;
That does not look correct either, but it depends on the code, i.e. if _current != NULL go to the next node, otherwise return NULL
Of course I could be wrong
"The greatest mistake you can make in life is to be continually fearing you will make one." - Elbert Hubbard
|
|
|
|
|
I don't know if it is right
I only got it from a book "C++ Primer 3rd"
It is in sector 5.11.1
|
|
|
|
|
|
Yes
It is
Only my book is translated into chinese.
Those code may be found in A Linked List Example of chapter 5 Statements
Great!
Thanks!!!
|
|
|
|
|
The code is extracted from the function below:
inline ilist_item*
ilist::
next_iter()
{
ilist_item *next =_current
<<_current = _current->next()
:_current;
}
Mavbe the right is as you said, that is a conditional operator:
inline ilist_item*
ilist::
next_iter()
{
ilist_item *next =_current ? _current = _current->next() : _current;
}
Do you think so?
Thanks for your answer!!!
Happy 2004!!!
|
|
|
|
|
I can't say 100%, the simple test is to try and compile the code and step through using the debugger.
What I think it is, is a class to iterate through a linked list, where _current is the current node, next_item() checks if _current has been defined is so get the next node, otherwise return _current , which I asuume is NULL
Isn't C++ fun!
"There is no monument dedicated to the memory of a committee." - Lester J. Pourciau
|
|
|
|
|
Yeah!
C++ is very fun
and it is abundant in perfect thinking!
|
|
|
|
|
it is accessing the constructor (maybe) of that object.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
The code is extracted from the function below:
inline ilist_item*
ilist::
next_iter()
{
ilist_item *next =_current
<<_current = _current->next()
:_current;
}
Mavbe the right is as Mr. Ted Ferenc said:
inline ilist_item*
ilist::
next_iter()
{
ilist_item *next =_current ? _current = _current->next() : _current;
}
Do you think so?
Thanks for your answer!!!
Happy 2004!!!
|
|
|
|
|
You know.. that subject line sure looked suspicious for a forum like this.
--
They say the most horrible things, but I hear violins.
When I close my eyes, I'm at the center of the sun.
|
|
|
|
|
We don't have a medical forum yet, Jörgen.;P
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
True. I figure this forum can only treat missing semicolons and related issues.
--
They say the most horrible things, but I hear violins.
When I close my eyes, I'm at the center of the sun.
|
|
|
|
|
Good night and happy New Year.
Excuse my English as it's not my languaje.
My problems are two: I've just began learning VC++ on my own and I need to send a file using ZModem protocol.
I have searched for some code to learn from, but all I found was for Unix and wasn't commented or documented, so that and nothing is more or less the same.
Could someone explain something practical (not history or comparatives with other protocols) about zmodem or tell me where I could find a ready to use c++ class or activeX.
One more solution would be automating Hyperterminal, but i don't know if it's possible and as I said, I'm a beginner at VC++.
Any info is wellcome.
Thanks.
|
|
|
|
|
I did a search on Google[^] using the words "ZMODEM" "C++" "source" and "Windows", and came up with a large number of hits. Take a look and see if any of those fit your needs.
Software Zen: delete this;
|
|
|
|
|
I would like to understand how you can print the string from an edit box using dcPrint?
Example: dcPrint.TextOut(50,150,Editbox string here);
anyhelp greatly appreciated
ThankYou in advance.
Still no advice on how to achive this, does anyone have any sugestions that I might try?
|
|
|
|
|
hi,
ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
printing goes like this
void CMyDialog::OnFilePrint()
{
CString strValue;
int iRet;
CPrintInfo Info;
//set your info flags
PRINTDLG pdsetup;
HDC hdc;
//get your hdc from pdsetup
CDC dc; //dcPrint???
//Attach hdc with dc
//set drawing rect
//call OnPreparePrinting(&Info);
//call OnBeginPrinting(&dc, &Info);
DOCINFO docInfo;
// make your docinfo if needed
//iRet = dc.StartDoc(&docInfo);
//iRet = dc.StartPage();
//OnPrepareDC(&dc, &Info);
myEditBox.GetWindowText(strValue);
dc.TextOut( 200, 200, strValue); //place own coordinates
//dc.EndPage();
//dc.EndDoc();
//OnEndPrinting(&dc, &Info);
//dc.Detach();
hope it helps
dan
|
|
|
|
|
I'm trying to create a very simple diagnostic utility for Win98. In VC++ with MFC, how do I found out the numeric IP address of the computer on which the program is running?
|
|
|
|
|
One way is to call gethostname() followed by gethostbyname() .
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thank you but that seems to only get me the domain name. I'm trying to get the IP number so that I can track when the DHCP assigns a new one.
|
|
|
|
|
I'm not sure what your code looks like, but gethostname() and gethostbyname() is for getting the IP address of the host machine (i.e., the machine running the application).
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|