|
Hey all,
I went to the launch of VC.NET 2003 in Ottawa a few months back, and during the Visual C++ presentation, we were shown a new feature that would save me a heck of a lot of time, unfortunately, I dont remember how to toggle this guy on or off!
Ok, you have a dialog, which contains a list control for example. There's an option for that control that you could specify that control to resize as the dialog does, without any extra code in your WM_SIZE message. From what I remember, you can specify the control to "hug" to TOP/BOTTOM/LEFT/RIGHT... I've searched high and low through the help and resource editor and I can't seem to find anything.
Our project is Win32, but I created a dummy dialog in VC++, and still no go.. Anyone farmilliar with this guy?
Mike.
doner@obtain.com
|
|
|
|
|
That "feature" is only for C# or VB.NET projects. Standard win32/MFC projects don't get this. Of course, I don't have 2003 version, but I don't think they added this. Maybe in a Managed C++ app, but I don't know.
Joel Lucsy
|
|
|
|
|
Today I profiled [using Rational Quantify] one of our applications in which a certain action took more and more time. I found the reason of the problem, but also noticed something else very strange.
Although the application runs most of the time in single-threaded mode, it has some actions that run multi-threaded. Therefore, some important datastructures were protected with a CriticalSection.
I noticed that the CriticalSection functions take about 15% of the total CPU time of the application. But there's more.
Consider the following small application:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
CRITICAL_SECTION Cs;
const long MAX_LOOPS=10000;
main ()
{
InitializeCriticalSection (&Cs);
for (long i=0;i<MAX_LOOPS;i++)
{
EnterCriticalSection (&Cs);
Sleep (1);
LeaveCriticalSection (&Cs);
Sleep (1);
}
DeleteCriticalSection (&Cs);
}
If this program is run through Quantify, it shows the following information:
Function Calls F Time F+D Time F(%) F+D(%) Avg F Min F Max F
mainCRTStartup 1 10617888 12589139 84,34 100,00 10617888 10617888 10617888
.Root. 0 0 12589139 0,00 100,00 0 0 0
.main_0. 0 0 12589139 0,00 100,00 0 0 0
LeaveCriticalSection 10000 1265606 1265606 10,05 10,05 126 71 1186
ExitProcess 1 378351 378351 3,01 3,01 378351 378351 378351
GetModuleHandleA 2 103729 103729 0,82 0,82 51864 1617 102112
GetVersionExA 1 69788 69788 0,55 0,55 69788 69788 69788
GetFileType 3 52111 52111 0,41 0,41 17370 11315 29385
HeapAlloc 40 21896 21896 0,17 0,17 547 239 7388
HeapCreate 1 17844 17844 0,14 0,14 17844 17844 17844
The function LeaveCriticalSection is indeed called 10000 times, but according to this table EnterCriticalSection is nowhere called in the application. There is no trace of the EnterCriticalSection function in the Rational Quantify reports.
It seemed like the compiler optimized EnterCriticalSection away, even if I compile with /Od /Zi. Can anybody explain this?
The second strange thing is that the maximum function time (Max F) of LeaveCriticalSection is much and much larger than the minimum function time (Min F). This means that in lot of cases the function was quite fast, but in some calls, the function was much slower. Can anybody explain this?
Of course simply removing the critical sections makes the application about 10-15% faster, but introduces a big risk when the application performs a multi-threaded action.
Nevertheless I thought that CriticalSections were the fastest way of synchronizing threads.
Does anybody know a method of improving the performance of CriticalSections or can anybody explain why LeaveCriticalSection takes much more time than EnterCriticalSection?
Thanks in advance.
Enjoy life, this is not a rehearsal !!!
My Articles:
- Implementing a Subject/Observer pattern with templates
- Different ways of writing class factories
- AutoRunner: a template class to automatically run start- and cleanup-code in code blocks
</
|
|
|
|
|
My guess is that the profiler isn't telling the truth. The fact that it isn't showing EnterCriticalSection rings alarm bells. Run the program in the debugger and verify that EnterCriticalSection is indeed being called. It must be. If there is a bottleneck it will be at EnterCriticalSection when another thread has it locked. LeaveCriticalSection should be instantaneous.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
I'm trying to compile a Linux game (Freeciv) with visual C++. The project is organized in severall libraries and 2 .EXEs. As it is a gnu cimpilation I would like to modify the sources as few as possible.
I've got a problem because each of the libraries has its sources and headers in a separate folder. Each time I try to compile the main project I've got the "fatal error C1083: Cannot open include file: 'astring.h'" error.
I know I can add those libraries directories to Visual Studio search path by using the Tools | Options | Directory menu. But this setting is for the whole Visual C++ not only for my project.
Is there a way to add those directories to the compiler search path just for a single project ?
Yarp
http://www.senosoft.com/
|
|
|
|
|
well, one simple fix is to put the full path of the files when you include them, ex:
#include "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\astring.h"
I dont know where astring.h is, but thats what i had to do for a project a few months ago. just put the full path in the include "" things.
*.*
cin >> knowledge;
|
|
|
|
|
Go to Project | Settings | C/C++ | Preprocessor and add the include directory to the "Additional include directories" field. For example, you could add "..\include" (without the quotes).
You can do a similar thing for the .lib files: go to the Link tab, and under Input, add the lib path to "Additional library path".
Tip: if you do either of the above, make sure the project is selected in the tree on the left, not just one file in the project. Also, make sure "All Configurations" are selected in the combobox (although you might have separate libs for debug and release, in which case you will want to do the Link step twice).
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
Thanks a lot, I've been wondering if it was possible for a long time now - but this afternoon I had no choice since I wanted this gnu project to be as less modified as possible.
Thnaks a lot for the reply
Yarp
http://www.senosoft.com/
|
|
|
|
|
I use m_edit.GetDC()->GetTextMetrics(&tm) to determine current font height. Then i call m_edit.SetFont(&myfont) but GetTextMetrics(&tm) returns old values. How to update DC object?
|
|
|
|
|
Without seeing more of your code it's hard to say. Please note that each and every call to GetDC() must have a corresponding call to ReleaseDC() . Since you are not saving the return from GetDC() , your code is not releasing the DC properly.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
I am doing an application where I need to show some pages with CHtmlView, and I want to know if it has successfuly opened the url. So if it has not, I can show some other page.
Thanks for any information.
|
|
|
|
|
Check the URL in OnBeforeNavigate2(). May help.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hi,
I need a method to detect network interface changes (both "Link up/down" and "Interface up/down" ) in windows 2000 and XP.
It needs to be event based. Polling is not an option.
I have googled for hours but I have found nothing usefull.
I have have no problem seeing the interface status, but i need to have some kinda event fired whenever changes are detected (and of course i need to recieve that event).
Any hints to as how this can be done would be greatly appreciated.
- Jugurd
|
|
|
|
|
Hi i would like to know how to wite a function that
copy's the contents of a string into another.
Without using strcpy.
How would i call the function?
To display contents of string that recieved the copy?
And olso is << vecInt[0] << only way to display a vectors
values?
New at VC++ begginer programer
Help plaese.
Thanks Lance
RL.Robile
|
|
|
|
|
Strings in C end with a 0 (zero) caracter, so you can do a while until you get this ending character.
I do not understand what you say about displaying vectors. Do you mean cout << vecInt[0]?
If so, are you programming a console application?
|
|
|
|
|
here's a simple way to display the contents of a vector in a console application...
for(int i = 0; i < my_vector.size(); i++)
{
cout << my_vector.at(i) << endl;
}
*.*
cin >> knowledge;
|
|
|
|
|
For string (basic_string)
use
string::copy(..)
<br />
string str("ttt");<br />
char *pStr = new char[nLen + 1];<br />
str.copy(pStr, nLen, 0)
For vector, you could use the iterator.
<br />
std::vector<int>::iterator yourItr;<br />
<br />
for(yourItr = vecInt.begin(); yourItr < vecInt.end(); yourItr ++)<br />
cout << *yourItr;
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi,
I am writing a small launcher and monitoring program - the program launches and monitors a specific external application (a game). What I want to do is have it so that if the user alt-tabs out of the game, my monitoring program deletes some sensitive temporary files; I then want it to rewrite them to disk when the user alt-tabs back into the game. The first part is easy, I just do this:
//g_hWnd = game window... check to see if it is no longer the focus...
if(g_hWnd != GetForegroundWindow())
{
HWND checkwnd = GetForegroundWindow();
//check that it hasn't lost focus to one of its children
if(GetParent(checkwnd)!=g_hWnd)
{
//program has definitely lost focus, so delete files:
DeleteTemporaryFiles();
}
}
However, I can't work out how to do the second part. When the user alt-tabs back into the game program, I need to write the temporary files back to disk *before* the game window takes focus again (otherwise the game program may look for files that aren't there and spew errors - it is fine so long as there is no input). This means that my program would have to somehow hold up the game program taking focus until the files have been rewritten to disk...
Does anybody have any idea of how I could do this? I have tried taking control over the various windows using the standard API settings such as SetForegroundWindow, SetWindowPos, SetActiveWindow etc, but they don't seem to work with handles to external applications (and I think I read that they work even less with Windows 2000 etc).
If anybody has any ideas of how I could do this, I would be very grateful.
Many thanks,
KB
P.S. I'm aware that this could be seen as undesirable behaviour for an application, but please don't tell me I shouldn't be doing this at all. The program that creates the launcher will have an option for "Remove temporary files when not focussed" or some such, so I won't force this sort of behaviour - it is just for extra security for those users of the launcher who don't want their temp files accessed.
|
|
|
|
|
Anybody? This is really driving me crazy. There must be a way to tell the window to wait until I've re-extracted the files before before opening again, but I just can't work it out...
Cheers,
KB
|
|
|
|
|
Hi group,
I am sure that in my last message ,i couldn't explain the problem
clearly.So i am writing the message again.
Actuall my application is acting as a OLE Automation client to MS Access.It uses Access application object's TransferText method to transfer a text file into a table in a mdb database.Now ,in the next statement in my client application ,i want to know whether the table-loading is completed(as it is a separate process and TransferText returns immidiately after firing the command).If yes,i will run some Table-dependent code.But i don't know a way through which the MS Access Application can notify me that the Loading operation is completed.
As this is a crucial issue, i need expert's help....
Thanks and regards.
|
|
|
|
|
Hi all,
I am working on a dialog base application using VC++ 6.
I have a requirement to create MSN like EMOTICON window, with a click on image and insertion in the CRichEditCtrl window.
After trying and searching still unable to find.
Can anybody help me for a workaround, really appreciated.
Thanks.
The Phantom.
|
|
|
|
|
how to place and then move and resize the image e-g jpg on the workspace?
|
|
|
|
|
load the jpg(there are some articles about that on CP), then use BitBlt or StretchBlt to move or resize the picture!
Don't try it, just do it!
|
|
|
|
|
Widely used style
for
ListBox - flat and single-line contoured - in Dialog.
How to make it?
How regulate 3d depth of border in common case,
and how to show single-line contour ?
thanks you.
|
|
|
|
|
How to disable temporarily update in CEdit? I want to change some text with ReplaceSel() method but it scrolls to inserted position. But u do not need it. My CEdit flicks because of that. In other words i want to change the text, which is not displayed at current view, without scrolling.
|
|
|
|