|
The reason why I posted this today was because Chistian Graus mentioned about a WM_IDLE message. I searched MSDN for the message and could not find it.
I have a owner-data list that displays a live data feed. The only way I can update the screen is to use 'SetItemCount' function - but this redraws the entire list (for the part that is visible). If I did this on every update, the processor usage significantly shoots up. So, I decided to use a timer and a boolean variable (that gets set when an update occurs) and is reset when the painting is done in the timer.
Is there a better way to do this? I am just looking for alternatives that might be better. Due to some unknown reason, I am not satisfied with this solution.
Would the idle message be a good place to do this? and if so, how do I use it?
Thank you.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
In MFC there is and OnIdle handler that MDC generates for you.
How long do your updates take? I think the method that you have devised is perfectly acceptable. It is simple, and it would also be easy to change the update rate by changing the timer rate. Except, do you have multiple threads, because it may not be neccesary to flag your control as needing an update if you only have one thread.
If you are using teh SDK, there is a way to generate your own IDLE handler by using PeekMessage instead of GetMessage, and callng your handler whenever the queue does not have any messages. then you will have to insert a WaitMessage function when the message queue is empty to prevent the loop from spinning endlessly.
If you choose to do the idle handler, I would suggest that you put a limit on how often your list can update, because idle updates can happen quite frequently.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
The painting is fast and actually, I do not have any problems with it. I was just wondering whether the timer is the correct or atleast the most acceptable way to do it.
I do have multiple threads that change the data. Also, I did not want to paint unnecessarily when there is no change in data.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
I get around the update flicker by updating (not repopulating) the list control. This works quite well. I do the update in the WM_TIMER handler. If you want to see it in action, check out the Time Tracker tool of my product FooBar.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Does the update have a difference on owner-data, custom drawn list controls? The parent window gives the data to the control on LVN_GETDISPINFO notification. So, to initiate a paint, I call only the SetItemCount() or SetItemCountEx() function.
Btw, I am downloading the foobar. Looks great from the site.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
No, it shouldn't matter. Btw, to update the control, I just set the item text for the changed rows/columns.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Using the following:
VC++ 6.0/sp5
Win2K, Win95, and Win98
Our app uses some proprietary file formats and of course, the appropriate file types are associated with our app. However, when I double-click an associated file type, I get a message that is generate by windows that reads:
Cannot find the file "full path/name of file I clicked on" or one of it's
components. Make sure the path and filename are correct and that all
required libraries are available.
The path\filename are correct, and all of the required libraries are available. In fact, if I just load the app and open the very same file from within the app, it opens fine. Similarly, if I pass the desired filename in on the commandline, it opens fine. I can also drag a file onto the app window, and it will open without complaint.
At the top of OnInitInstance(), I have added the following code:
CString sCmdLine = ::GetCommandLine();
AfxMessageBox(sCmdLine);
The resulting string shows this (including all quote marks shown):
"D:\path\myprogram.exe" "
When I manually pass the filename in on the commandline, the same string shows this:
"D:\path\myprogram.exe" "D:\path\myfile.xyz"
What the heck is wrong here?
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
|
|
|
|
|
these are dumbass suggestions so dont yell at me for them being so
filename has no quote marks or wierd stuff in it?
filepath likewise?
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
Everything looks good on the paths and filenames (as they show up in explorer).
Could something be funky in the registry?
Hmmmm....
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
|
|
|
|
|
maybe the file association links got trashed?
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
John
How are you doing the association - and does the error happen with files with spaces in the name ?
If so the
shell\open\command default value might be this
<your app="" path=""> %1
try this
<your app="" path=""> "%1"
ensures that the spaces are treated as one full string instead of multiple files
also try
"<your app="" path="">" "%1"
if that doesn't work
|
|
|
|
|
Sorry that last message did't work quite right
John
How are you doing the association - and does the error happen with files with spaces in the name ?
If so the
shell\open\command default value might be this
<your app path> %1
try this
<your app path> "%1"
ensures that the spaces are treated as one full string instead of multiple files
also try
"<your app path>" "%1"
if that doesn't work
|
|
|
|
|
The problem may be in the registry. Look at the default value under HKEY_CLASSES_ROOT\.xyz (the value is noted <the_value> below).
Then look at the default value of the following key, that may be the cause of the problem:
HKEY_CLASSES_ROOT\<the_value>\shell\open\command
May be this string is just wrong (messed up quote or something).
I hope this helps,
David Defoort
|
|
|
|
|
I'm using Wise 9.1 for instalations, and for some reason, it's translating this:
"%MAINDIR%\myapp.exe" "%1"
to this (showing as it appears in the registry):
"D:\program files\mycompany\myapp\myapp.exe" "
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
|
|
|
|
|
adding another "%" to the original line fixed the basic problem, but I'm still getting this
Cannot find the file "full path/name of file I clicked on" or one of it's
components. Make sure the path and filename are correct and that all
required libraries are available.
weird.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
|
|
|
|
|
John Simmons / outlaw programmer wrote:
Cannot find the file "full path/name of file I clicked on" or one of it's components. Make sure the path and filename are correct and that all required libraries are available.
I know it has been a while, but did you ever find out what was causing this? I am having the same problem and it is driving me crazy.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Geeze - I'll have to go back and see what I did, and it will have to wait until tomorrow because that's work stuff, and I'm at home.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
"You won't like me when I'm angry..." - Dr. Bruce Banner
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
I've got a small SDI app. I have a bunch of settings I want to retain in between program loads. Where is the "proper" place to store them among the MFC classes that ClassWizard creates? Do I declare a struct in my CChildView class, or put it in CMainFrame?
On a more general note, if there's anybody that uses Sonork or ICQ or IRC and wouldn't mind me occasionally bugging them for a small finicky question like this every now and then, I'd appreciate the help. Until then I'll keep asking here and waiting patiently for CG to respond.
- Jason
(SonorkID 100.611)
"The sort of guy who'd give the kid an extra scoop of ice cream free if he was an ice-cream man"
- Nish, on Chris Maunder
|
|
|
|
|
I tend to make them either members of the document class or the app class depending on where they need to be used.
If there is a lot of them I will create a seperate class and have that be a member of the CDocument/CWinApp derived class.
Michael
|
|
|
|
|
Jason Hooper wrote:
settings I want to retain in between program loads
ummm ... the registry
when ur program exits nothing in the doc or whatever will be there
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
Yeah.. I didn't explain myself correctly. I plan to use the registry anyway, but I just wonder where the best place is to put the settings after I pull them from the registry.
- Jason
(SonorkID 100.611)
"The sort of guy who'd give the kid an extra scoop of ice cream free if he was an ice-cream man"
- Nish, on Chris Maunder
|
|
|
|
|
I tend to place the view specific settings in the View class and the document specific settings in the Doc class. And any setting that is common to all views/docs (if it is an MDI), in the App or MainFrame.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
errrrr
oooops
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
How do we feel about directly calling framework handlers?
I'm talking about setting up a DC and calling OnPaint(). I'm talking about calling the WM_COMMAND handler for a specific menu item.
Personally, I find this quite lazy. What should be done it to create a routine that does the required action, and then have both the framework handler and the user code call the routine.
Am I psycho?
J
|
|
|
|
|
ummmmm
maybe u should change ur name to jamie bates?
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|