|
::GetSysColor(COLOR_3DFACE);
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
|
You want this:?
const int d = 100;
int var[d];
for (int i = 0; i < d; ++i)
var[i] = 0;
cout << var[5];
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Not really, even though that is the most logical way to do it. I am curious to know whether in C it is possible to substitute a piece of a variable name with something like a string. e.g:
int variable = 7;
char c[] = "able";
cout << vari%c;//no problem here b/c I'm using a placeholder or such.
ralf.riedel@usm.edu
|
|
|
|
|
RalfPeter wrote:
I am curious to know whether in C it is possible to substitute a piece of a variable name with something like a string.
No, compiled languages like C and C++ do not retain 'variable names' in generated code. Constructs like yours are generally used in scripts.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Your looking for enum() kind of functionality, as found in high level languages such as Perl and SQL. Obviously this isn't possible with a compiled language, because you'd have to ship the compiler with the application!!!
Sorry (again) thomas, but you did say you liked mail.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
How can get the free space available in a drive?
Thanks
Neha
|
|
|
|
|
GetDiskFreeSpace() ought to do the trick.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
BOOL GetDiskFreeSpaceEx(a,b,c,d);
a = "c:\directory" or NULL. If NULL, function returns space in drive where function resides.
b = pointer to variable to receive free bytes available to user of the calling thread.
c = ditto for available (free+used) bytes.
d = pointer to variable to receive total bytes on disk.
ralf.riedel@usm.edu
|
|
|
|
|
I found a smaple code from MS. And here is the link:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q231497
|
|
|
|
|
I do some works on WM_PAINT:
//////////////////////////////////////////////////////////////////////////
CDC* pDC = GetDC();
CDC cacheDC;
cacheDC.CreateCompatibleDC( pDC );
if( m_pBitmap == NULL )
{
m_pBitmap = new CBitmap;
m_pBitmap->CreateCompatibleBitmap( &cacheDC, m_ClientRect.Width(), m_ClientRect.Height() );
}
CBitmap* pOldBmp = cacheDC.SelectObject( m_pBitmap );
cacheDC->SetTextColor( RGB(0, 0, 255 ) ); //color blue
cacheDC->TextOut( "hello world" );
pDC->BitBlt( m_ClientRect.left,
m_ClientRect.top,
m_ClientRect.Width(),
m_ClientRect.Height(),
&cacheDC, 0, 0, SRCCOPY );
cacheDC.SelectObject(pOldFont);
cacheDC.SelectObject( pOldBmp );
cacheDC.DeleteDC();
//////////////////////////////////////////////////////////////////////////
But the text out is still black, what's the matter? May be I forget some steps?
I'm amumu, and you?
|
|
|
|
|
Your bitmap is monochrome. Change the 1st parameter in CreateCompatibleBitmap to pDC.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Aprt from what Tomas said, you should also be calling SaveDC() and RestoreDC(-1) on your cacheDC object. Although you select back in the original font/bitmap, you shold also restore the original text colour.
DC's should always be returned to the system in the exact state you got them. Thats why SaveDC() / RestoreDC() is so good for you in this situation.
CDC* pDC = GetDC();
CDC cacheDC;
cacheDC.CreateCompatibleDC( pDC );
if( m_pBitmap == NULL )
{
m_pBitmap = new CBitmap;
m_pBitmap->CreateCompatibleBitmap( &cacheDC, m_ClientRect.Width(), m_ClientRect.Height() );
}
caccheDC.SaveDC() ;
cacheDC.SelectObject( m_pBitmap );
cacheDC->SetTextColor( RGB(0, 0, 255 ) );
cacheDC->TextOut( "hello world" );
pDC->BitBlt( m_ClientRect.left,
m_ClientRect.top,
m_ClientRect.Width(),
m_ClientRect.Height(),
&cacheDC, 0, 0, SRCCOPY );
cacheDC.RestoreDC(-1) ;
cacheDC.DeleteDC();
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
I'm working on a project that uses multiprocessor computer. I want to use multithread teachnique for this and assign a specific thread to a specific CPU. I'm searching materials for my project. Please show me some if you know about this field.
Thanks a lot.
dxKy
|
|
|
|
|
Dang Xuan Ky wrote:
I want to use multithread teachnique for this and assign a specific thread to a specific CPU.
SetThreadAffinityMask does that.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Be careful though, the OS is pretty good at dividing your threads up between CPU's, and if you start trying to force a thread to a cpu, you may well in fact decrease your application's performance.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Jon is correct. You really shouldn't be assigning threads to a CPU. Unless you really have a very strong grasp of the ramifications, you are likely to degrade performance.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Maybe you guys should answer to the original poster? He'll get email notification, etc.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
We thought you'd like the email!!! personally, i *love* getting mail that i don't care about
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Jon Hulatt wrote:
We thought you'd like the email!!!
I do I'm just worried about our multi-threaded programmer who can be totally unaware about this discussion
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I think that I can use SetProcessAffinityMask. For a process I assign it to one CPU and the other to another CPU. The two process can communicate through share memory. That's all what I think but now I try to find a sample to demonstrate the using of SetProcessAffinityMask. I read it a lot in MSDN but nothing is found. If you have the code, please show me. Thanks everybody.
|
|
|
|
|
Don't try to outsmart OS scheduler - your performance will be significantly down if you tie one process to first CPU and the other to second CPU. Just let Windows do its work and stop worrying about that.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have tried to find an answer the the question abovee, but the search failed.
Is there a simple way to get a serial number of the newtork card? Maybe an API call?
Thanks!
Ales
|
|
|
|
|
http://www.codeproject.com/useritems/getmac.asp
Should this go in Mike Dunn's C++ FAQ?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
//
// Link with ws2_32.lib and iphlpapi.lib
//
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <iphlpapi.h>
int __cdecl main()
{
HRESULT hr;
IPAddr ipAddr;
ULONG pulMac[2];
ULONG ulLen;
ipAddr = inet_addr ("216.145.25.31");
memset (pulMac, 0xff, sizeof (pulMac));
ulLen = 6;
hr = SendARP (ipAddr, 0, pulMac, &ulLen);
printf ("Return %08x, length %8d\n", hr, ulLen);
size_t i, j;
char * szMac = new char[ulLen*3];
PBYTE pbHexMac = (PBYTE) pulMac;
//
// Convert the binary MAC address into human-readable
//
for (i = 0, j = 0; i < ulLen - 1; ++i) {
j += sprintf (szMac + j, "%02X:", pbHexMac[i]);
}
sprintf (szMac + j, "%02X", pbHexMac[i]);
printf ("MAC address %s\n", szMac);
delete [] szMac;
return 0;
}
|
|
|
|