|
I need the window handle, having the ID Process, the ID Thread, the handle Process,and the handle Thread of the process that launch the application.
|
|
|
|
|
Take a look at EnumThreadWindows
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
when the process is unique, but it has more windows (for example WINWORD.EXE), I find the HANDLE at the first window, but not the HANDLES of other windows
|
|
|
|
|
I am wondering if anyone could give me some pointers on making a reuseable control that has the following features.
It needs to be able to display small 16x16 icons in the position i want. no text, perhaps a tooltip.
Next, it has to change the icons when i want to... this is fairly easy.
And finally, it has to have a focus rect around the currently selected bitmap, and this selection must be retrivable by a call into it, also easy.
what i need advice on, is would I subclass out of a generic static control to do this, or would it be better to slap some bitmaps into a gdi surface?
Is there a good totorial on creating controls such as this, or, how would i go about making this out of pure gdi?
thanks for your tips!
|
|
|
|
|
You can do almost all of that with the list view control. The standard control shows the focus rect around the label, not the icon, but you can draw your own focus indicator if you custom draw the icons.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
If you mean buffer overflows it's not about CSocket. It's a problem with all TCP/IP server-programs.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
If you want your data to be secure then you need to use SSL (Secure Socket Layer) with your socket class.
|
|
|
|
|
I am writing a program in C++ that opens a file, reads through it character by character counting each individual character, that I am later to create a histogram for. That part I have done, however, I am having a problem with the last part. It need to Rewrite the sentences inside the file so the first letter of each sentence is capitalized and everything else is lowercase. I am also having a problem validating a space between words, any help would be great. Thanks in advance.
P.S. -- I am doing something like this to check for a space.
// x is the letter I am reading in
char x;
if(isspace(x) != 0)
{
cout << "I hit a space";
outfile << " ";
}
Nick Parker
|
|
|
|
|
What do you mean by "validating" a space?
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
The space between these words would all count as a space, as would a line feed, tab, and form feed. Which is why I felt that using the isspace() function should be proper. I am iccorectly using this, because it doesn't seem to be working for me. Should I not use a char variable to read this in ??
I am just not really sure where to go with this. Thanks.
Nick Parker
|
|
|
|
|
Ok, so you're just keeping a "whitespace" counter, and incrementing it every time you find a space/tab/etc in the input. isspace() should do that. I'd suggest tracing thru isspace() to see if it's not returning true like you expect when you hit a tab/form feed/etc.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Does this sound like it should work, and print a blank space then as well?
do{
infile >> x;
if(isspace(char(x)) != 0)
{
cout << "Space hit!!!\n";
outfile << " ";
}
else
{
cout << x << '\n';
outfile << x;
}
}while(!infile.eof());
Thanks for your help
Nick Parker
|
|
|
|
|
One catch about istream::eof is that it returns true only after you've read the EOF marker. So right after infile >> x; , add if ( !infile.eof() ) . Otherwise, you'll parse the last character in the file twice.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Thanks, that solved one of the problems I hadn't mentioned on here, is there any problem using a char instead of an int to process the isspace() function? I seem to see a lot of people using an int, I'm just a little stuck here, trying to catch it. Thanks for all the help
Nick Parker
|
|
|
|
|
Dear Folks,
Am having trouble planting the Win32 function "Enumprinters" in my
MFC project.
Used the following code:
DWORD dwNeeded, dwReturned;
PRINTER_INFO_5 pinfo5
::EnumPrinters(NULL,NULL,5,NULL,0,&dwNeeded, &dwReturned);
pinfo5=malloc(dwNeeded);
::EnumPrinters(PRINTER_ENUM_LOCAL, NULL,5, (PBYTE) pinfo5, dwNeeded, &dwNeeeded, &dwReturned);
Keeps on coming back with the following error:
C:\LabPrint\figDialog.cpp(95) : error C2039: 'EnumPrinters' : is not a member of '`global namespace''
C:\LabPrint\figDialog.cpp(95) : error C2065: 'EnumPrinters' : undeclared identifier
I'm mystified. The code is right out of Petzold. Can't figure
out why the function 'EnumPrinters' seems to be undeclared.
Any help much appreciated!! Thought this would be real simple....;)
Thanks so much,
Brett G.
|
|
|
|
|
Hi,
all
I am a beginner in vc programming.Now I have some problems
in my program.I want to display a bitmap of 24 bits,but It
seems that there are some colors the system can't display
correctly. My source code follows below.
CClientDC dc(this);
HBITMAP hBitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle (),"E:\\Bg.BMP",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmBG;
bmBG.Attach(hBitmap);
BITMAP bm;
bmBG.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap* pOldBitmap=(CBitmap*)dcMem.SelectObject(&bmBG);
CRect lRect;
GetClientRect(&lRect);
lRect.NormalizeRect();
DIBSECTION ds;
BITMAPINFOHEADER &bmInfo=ds.dsBmih;
bmBG.GetObject(sizeof(ds),&ds);
CPalette pal;
int nColors = bmInfo.biClrUsed ?bmInfo.biClrUsed : 1 << bmInfo.biBitCount;
if( nColors > 256 ) pal.CreateHalftonePalette( &dc );
else{
// Create the palette
RGBQUAD *pRGB = new RGBQUAD[nColors];
::GetDIBColorTable( dcMem, 0, nColors, pRGB );
UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * nColors);
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
pLP->palVersion = 0x300;
pLP->palNumEntries = nColors;
for( int i=0; i<ncolors;i++)
{
="" plp-="">palPalEntry[i].peRed = pRGB[i].rgbRed;
pLP->palPalEntry[i].peGreen = pRGB[i].rgbGreen;
pLP->palPalEntry[i].peBlue = pRGB[i].rgbBlue;
pLP->palPalEntry[i].peFlags = 0;
}
pal.CreatePalette( pLP );
delete[] pLP;
delete[] pRGB;
}
dc.StretchBlt(10,10,lRect.Width()-10,lRect.Height()-10,&dcMem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
I will appreciate your advanced help.
Best Regards.
|
|
|
|
|
If the system cannot display 'some colors' correctly, it's because it's running in 8 or 16 bit.
What's the point of the lines between DIBSECTION ds and delete[]pRGB ?
Because you're using stretchblt, you might like to try dc.SetStretchBltMode(COLORONCOLOR) to get the best possible result.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Thank you for your help very much, It is ok now .
The point of the lines between DIBSECTION ds adn delete[]
pRGB is to create the logic Palette.I only copy it from
the book ,I really did not know why.
|
|
|
|
|
Any bitmap greater than 8 bit does not need a palette - the bits contain the colour information.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I have data in CStringArray. Can someody tell me how to sort it so that i can put it in text files sorted.
Help me with some code.
In my dream, I was dorwning in my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Another reason MFC containers suck hard. STL containers do this stuff with ease.
Here's some code from MSDN - why they couldn't build it in is beyond me. If you *must* use MFC containers, then this is how to do it:
#include <afx.h>
#include <iostream.h>
#include <afxcoll.h>
class CSortStringArray : public CStringArray {
public:
void Sort();
private:
BOOL CompareAndSwap(int pos);
};
void CSortStringArray::Sort()
{
BOOL bNotDone = TRUE;
while (bNotDone)
{
bNotDone = FALSE;
for(int pos = 0;pos < GetUpperBound();pos++)
bNotDone |= CompareAndSwap(pos);
}
}
BOOL CSortStringArray::CompareAndSwap(int pos)
{
CString temp;
int posFirst = pos;
int posNext = pos + 1;
if (GetAt(posFirst).CompareNoCase(GetAt(posNext)) > 0)
{
temp = GetAt(posFirst);
SetAt(posFirst, GetAt(posNext));
SetAt(posNext, temp);
return TRUE;
}
return FALSE;
}
void main()
{
CSortStringArray sortArray;
sortArray.Add(CString("Zebra"));
sortArray.Add(CString("Bat"));
sortArray.Add(CString("Apple"));
sortArray.Add(CString("Mango"));
for (int i = 0; i <= sortArray.GetUpperBound(); i++)
cout << sortArray[i] << endl;
sortArray.Sort();
cout << endl;
for (int j = 0; j <= sortArray.GetUpperBound(); j++)
cout << sortArray[j] << endl;
}
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Be warned, that's a nice implementation of a Bubble sort, which is not particularly quick with large lists.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Your idea is just fine but i'll be having lots of strings in it so isn't there any way to make it fast.What about converting the whole array into char** and then using qsort. how can i do that plz help me out.Also how STL does it i dont have to stuck to MFC.
In my dream, I was dorwning in my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
STL is the way to go. Just #include<vector> and you can create a CString vector like so:
vector<CString> m_MyVector;
Then you can do all sort of things not just sorting. SGI has a lot of STL docs online, you could look there.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
<Center><A href = "http://www.sonork.com" target = "_Blank">Sonork</A> ID 100.10002:MeanManOz</Center><Center>I live in <U><B>Bob's HungOut</B></U> now</center>
|
|
|
|
|
In case you're still interested, I have a nice global method that uses qsort to do it for you:
static int CompareStringsAscending(const void* pElement1, const void* pElement2)
{
return ((CString*)pElement1)->Compare(*(CString*)pElement2);
}
static int CompareStringsDescending(const void *pElement1, const void* pElement2)
{
return -(((CString*)pElement1)->Compare(*(CString*)pElement2));
}
static int CompareStringsAscendingNoCase(const void* pElement1, const void* pElement2)
{
return ((CString*)pElement1)->CompareNoCase(*(CString*)pElement2);
}
static int CompareStringsDescendingNoCase(const void *pElement1, const void* pElement2)
{
return -(((CString*)pElement1)->CompareNoCase(*(CString*)pElement2));
}
void AMS_SortArray(CStringArray* pArray, bool bCaseSensitive = true, bool bAscending = true)
{
ASSERT(pArray);
int nElements = pArray->GetSize();
if (nElements <= 0)
return;
int nSize = sizeof(CString*);
void* pFirstElement = (void*)&((*pArray)[0]);
if (bCaseSensitive)
{
if (bAscending)
qsort(pFirstElement, nElements, nSize, CompareStringsAscending);
else
qsort(pFirstElement, nElements, nSize, CompareStringsDescending);
}
else
{
if (bAscending)
qsort(pFirstElement, nElements, nSize, CompareStringsAscendingNoCase);
else
qsort(pFirstElement, nElements, nSize, CompareStringsDescendingNoCase);
}
}
AMS_SortArray is the one to use, but you should probably rename it to something more appropriate.
Regards,
Alvaro
|
|
|
|
|