|
liuty2006 wrote:
what I would pay special attention to, when i write programe?
Any data that is written by more than one thread should be wrapped in a critical section, or similar, to ensure atomic access.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hi, I need to trigger my OnEraseBkgnd() (not OnPaint()). What would be the appropriate way, PostMessage(WM_ERASEBKGND) ?
|
|
|
|
|
Invalidate(TRUE) triggers both, but if you want one and not the other, I guess you could try ::PostMessage.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
hmmm, Invalidate() is want I want to avoid and PostMessage() requires a pointer to a HDC. I need a background repaint only, perhaps a combination of RedrawWindow() arguments?
someone can help?
|
|
|
|
|
Aren't there methods that generate a HDC for your windows client area ? If not, you could set up a flag in your WM_PAINT handler so that it does nothing when m_bSkipPaint is true, for example.
m_bSkip = true;
Invalidate(TRUE);
m_bSkip = false;
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
Aren't there methods that generate a HDC for your windows client area ?
that would be great... how?
I tried this code, but didn't work:
<br />
CClientDC dc(this);<br />
PostMessage(WM_ERASEBKGND, (WPARAM) dc.m_hDC, 0);<br />
|
|
|
|
|
Anonymous wrote:
I tried this code, but didn't work:
CClientDC dc(this);
PostMessage(WM_ERASEBKGND, (WPARAM) dc.m_hDC, 0);
but at the same time, this code works:
<br />
CClientDC dc(this);<br />
OnEraseBkgnd(&dc);<br />
|
|
|
|
|
When my application starts up, I would like it not to create a new document, but I would like it to open ones if it is specified on the command line. How do I do that?
Tx
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
In your application object InitInstance() method, there will probably be some lines like:
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
ProcessShellCommand(cmdInfo);
The default action with no command line parameters is to open a new file, but you can change this easily by inserting the following code between the parse and the process:
if ( CCommandLineInfo::FileNew == cmdInfo.m_nShellCommand )
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
Dave
|
|
|
|
|
Tx for the info, it works great!
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I have created an application that host browser control.
My problem is that IWebBrowser::get_HWND is return E_FAIL.
I want get_HWND function to return my application's window handle.
YK.
|
|
|
|
|
Dear Code Project,
I am currently working on an installation program and have run into a problem. I don't know how to get the percent installed to the progress bar. How do I do that, or are there any articles on it? I have looked around for several weeks, but have not found anything on the subject.
PS--
If you know of any good tutorials for beginners on C++ Windows Registry functions pass that along too. I have had trouble with what I have found so far.
-- Steve
|
|
|
|
|
There are at least two good registry handling classes on CP. As to progress controls, you need to be able to divide your task so that you can express it as progress in terms of 100 being fully installed. Then create a progress bar and set it's position. Which half of this are you having trouble with ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Sorry. Creating the progress bar and feeding it numbers is pretty easy, but I don't know how to come up with a number. I need to constantly divide the completed bytes with the total number of bytes then multiply by 100. How do I constantly get the file size information I need?
-- Steve
|
|
|
|
|
Ah... Every installer progress control I have seen obviously did something like this:
how many files am I installing ?
add weight to files I know are bigger, so they represent 3 steps instead of 1 ( for arguments sake )
step every time a file has been copied.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
SteveBob wrote:
How do I constantly get the file size information I need?
If you are reading or writing these files, there are usually return values or reference parameters that will tell you the # of bytes written or read. Just add the number to a running total then divide by the total bytes and multiply by 100.
Jason Henderson start page ; articles
henderson is coming
henderson is an opponent's worst nightmare
* googlism *
|
|
|
|
|
I have an app, that receives data on multiple sockets on a thread pool and updates certain data objects. These data objects are accessed by MFC CFrameWnd derived windows to display them. I have seen that using critical sections in the data classes lead to many unfavourable inetractions causing deadlocks in MFC.
Is there an article/discussion on the procedures/guidelines that need to be followed in the design to prevent deadlocks in MFC apps when the data is mdified from another thread and the access to the data objects are protected using critical section or mutex?
Also, is it advisable to use a timer for periodic refresh of the windows OR send a message from the other thread to the window, asking it to refresh because of a data change? What are the procedures that can be used to prevent excessive re-painting due to large amounts of data arriving in a short period?
Any inputs are welcome.
Thomas
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Thomas George wrote:
Also, is it advisable to use a timer for periodic refresh of the windows OR send a message from the other thread to the window, asking it to refresh because of a data change? What are the procedures that can be used to prevent excessive re-painting due to large amounts of data arriving in a short period?
Funny you should ask that question. I'm working on an app right now with this very problem. I've tried both approaches. Using the timer works, in that it updates the screen regularly. Using the timer doesn't work when you've got a lot of data coming in, because WM_TIMER messages are low priority. As a result, the WM_TIMER doesn't happen in a timely fashion, so the display doesn't update as often as you'd like. Sending a message every 'N' data items has similar problems, in that it updates the display too much under high data rates. Fortunately, I can set this part of the problem aside for awhile, and let the back part of my brain figure out a solution.
Good luck. Sorry I couldn't be of any real help.
Software Zen: delete this;
|
|
|
|
|
I had no problems with updating my GUI regulary depending on WM_TIMER message, but I believe you have if you say so.
In another project I created a thread that posted a custom message (not WM_TIMER) in regular distance to my GUI message queue... my GUI then updates the display regular.
|
|
|
|
|
I am getting the warning that the performance counter DLL is not aligned on an 8-byte boundary. I originally thought the warning was being caused by our code, but even the Microsoft sample codes, ScribbleMouse and HWInputMon written by Jeffrey Richter (MSJ Aug 1998), are giving the same warnings.
I checked the allocation size in the case of the ScribbleMouse, and at 160 bytes, seems to be properly aligned.
Does anyone know of a solution to this, or how to resolve the problem.
I have looked at the KB Q262335 referred to below, and have tried various options without luck.
HOWTO: Align Performance Data of a Performance Extension DLL on an 8-Byte Boundary
SUMMARY
When the performance data buffer returned by a performance extension DLL is not aligned on an 8-byte boundary, the performance library (PERFLIB) part of ADVAPI32.dll will report a warning 1016 to the Application Log in Event Viewer. This article explains how the developer of a performance extension DLL can align the performance data on an 8-byte boundary.
Gaul
http://www.gaulles.com
|
|
|
|
|
Hi. Im working on a project that has a print preview class that prints a lot of small text boxes. The problem is that using CDC::DrawText(...), the charaters size do not change linearly with zoom, but in small discrete "jumps", making the word wrap change the word disposition between lines. This is terrible, because what you see is not what you get(WUSI(N!!!!)WUG)!
Im zooming using MM_ISOTROPIC map mode.
Ive tried using a CRichEditCtrl to display text and the zoom works great, which makes me think i can make the text boxes work the same.
How do i crack this one?!?!
Thanks in advanced!
|
|
|
|
|
When making custom draw controls, what “errors” would make the actual drawing take up system resources.
I have a custom graph that updates every second,, and it uses 2-4 % of the system, I think this is an error of some kind. I restore all of my GUI objects pens/brushes/etc.
Any help would be good.
"Best file compression around: DEL *.* = 100% compression."
<><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|
|
If the amount used does not grow, then there is no leak, and I dunno without seeing the code if there's anything that is being done that is wasteful.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I derived a class from CTreeView in order to implement drag and drop between trees. I also made it so I can add/delete/edit items in the tree. I need a way of saving the edited tree so I can load it up the next time I run my app.
Any suggestions? I don't want to have to parse through the tree and save/load that way.
|
|
|
|
|
|