|
If you know function name and want it's header file, simply press F1 (help) when you are on function!
MSDN will show you detail of function and it's header file and library.
A. Riazi
|
|
|
|
|
Hi all, does anyone know where I can download the source for the ScopeGuard classes from Andrei Alexandrescu's CUJ article? The code is no longer with the article... does anyone have a copy they could send me?
Thanks
|
|
|
|
|
Have you looked in the Code Archive.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
The url in the article works OK for me:
ftp://ftp.cuj.com/pub/2000/1812/alexandr.zip[^]
Email me if you still can't get it and I'll send you a copy.
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Awasu 1.0.5 (beta)[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
In an application, i paint the caption bar myself. And i come across one problem, how to get the size and position of Maximizebox ,Minimizebox? So i can leave them alone,just paint the spare area.
|
|
|
|
|
Call GetSystemMetrics() with SM_CXMENUSIZE and SM_CYMENUSIZE to get the width and height of these items. You can compute their position from the window's dimensions. You'll need to use SM_CXBORDER and SM_CYBORDER (i.e. passed as args to GetSystemMetrics() ) in your calculations.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
i feel boring that in XP, the width and height of SM_CXMENUSIZE && SM_CYMENUSIZE is 18, but obviously the maximizebox and minimizebox are larger.
Here are some values got from GetSystemMetrics:
2000 ____________ XP
SM_CXICON 32 ____________ 32
SM_CYICON 32 ____________ 32
SM_CYMENUSIZE 18 ____________ 18
SM_CXSIZE 18 ____________ 25
SM_CYSIZE 18 ____________ 25
SM_CXSMICON 16 ____________ 16
SM_CXSMSIZE 12 ____________ 27
SM_CYCAPTION 19 ____________ 26
SM_CYSMCAPTION 16 ____________ 18
|
|
|
|
|
I've tried several ideas and so far nothing seems to work. I'm simply trying to add some code to keep a console 32 program open. This is the release version of the program being opened from Windows Explorer. I've tried _getch(); and even a while(!getch());
ANy ideas?
tanks
|
|
|
|
|
_getch() always worked for me. You must be doing something wrong. Posting some code that "doesn't work" would help. (is my depth of perception increasing?)
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
getch() usually does the trick. however, if there are any keys in the queue, it will see them, so you should use
while (kbhit()) getch();
getch();
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
I don't think so Toni...
Thanks Pete,will try
|
|
|
|
|
One important question: What happens when you are in the debugger? Does it make it to the _getch() statement?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
|
Thanks Pete,
I finally got it to work.
|
|
|
|
|
DaveE9th wrote:
I don't think so Toni...
Well, I am not the one having troubles with a getch() statement, that even the kids in my neighborhood know how to use it by now. You have posted this question so many times that one would think that you are dealing with the problem of the century. Read some books first.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
hello @all,
i need a something, that find the maximum of different int or double values.
for example:
max{1, 2.5, 2}=2.5
can anybody help me?
thank you very much.
sunny
|
|
|
|
|
use a macro like
#define max(a, b) (a > b ? a : b)
or if you need a variable ammount of arguments, create a function that uses va_list, like this one (MSDN example)
|
|
|
|
|
just two notes
a) you shouldn't use a macro if it can be expressed in the language - i.e.
template <typename T> inline T max(T a, T b) { return (a > b) ? a : b; } should do it without side effect problems, correct name scoping
b) if you need to use a macro, use braces around each argument,
#define max(a,b) ((a) > (b) ? (a) : (b))
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Use macro is not a good choice.You can find this in <<effective c++="">> Item 1 :
#define max(a,b) ((a) > (b) ? (a) : (b))
This little number has so many drawbacks, just thinking about them is painful. You're better off playing in the freeway during rush hour.
Whenever you write a macro like this, you have to remember to parenthesize all the arguments when you write the macro body; otherwise you can run into trouble when somebody calls the macro with an expression. But even if you get that right, look at the weird things that can happen:
int a = 5, b = 0;
max(++a, b); // a is incremented twice
max(++a, b+10); // a is incremented once
Here, what happens to a inside max depends on what it is being compared with!
|
|
|
|
|
I know of that -
That's what's commonly called "side effects" (I was referring to in my post) - that's why (mostly9 the first instruction never to use macros unless you cannot do without
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
I really haven't tested this code to check for errors but this is the general idea on how to get the maximum number:
int nNoNumbers = SOME_VALUE;
int *piArrayNums = new int[ nNoNumbers ];
...
...
int iMax = piArrayNums[ 0 ];
for( i = 0; i < nNoNumbers; i++ )
{
if( piArrayNums[ i ] > iMax )
{
iMax = piArrayNums[ i ];
}
}
The same thing can be done with doubles.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
|
hello @all,
i need a dynamic two-dimensional matrix. how can i do this?
thank you very much!
sunny
|
|
|
|
|
You can use malloc and realloc to do it all yourself, or use a STL vector or vectors.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
if you just need 2d array that doesnt shrink or grow frequently then you can use two approaches, pointers to pointers or a 1d array accessed by formula.
for pointers to pointers this is how it's done:
int ** p;
p = new int * [10];
for(int i = 0; i <10; i++)
p[i] = new int[10];
for(int i = 0; i < 10; i++)
for(int j = 0; j < 10; j++)
p[i][j] = rand();
for(int i = 0; i <10; i++)
delete [] p[i];
delete [] p;
for 1d arrays, you make an array with size m * n and access elements at i,j by formula j * m + i, where m are rows and n are columns.
int * p = new int[m * n];
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
p[j * m + i] = rand();
delete [] p;
this approach is better since the whole array elements are compact together rather than having group of 1d arrays scattered in the memory.
if you need an array that grows and shrink frequently, then you may use template containers to make array or arrays, rather than making your own class for it.
for example, if you gonna use the STL vector container you can declare the array as follows:
vector< vector<int> > my_matrix;
my_matrix.resize(10);
for(int i = 0; i <10; i++)
my_matrix[i].resize(10);
for(i = 0; i < 10; i++)
for(int j = 0; j < 10; j++)
my_matrix[i][j] = rand();
this also can be done using the MFC's CArray using the declaration
CArray< CArray<int, int>, CArray<int, int> > my_matrix;
|
|
|
|