|
Jim Crafton wrote: What I can't figure out is why the richedit lib is doing this in first place. Is there some magic incantation I have to perform to get my selection parameters to stick?
Aren't rich text controls supposed to remove selections if you click on it? I think that's the default behaviour of pretty much every editing component I've ever used in Windows. The reason it doesn't release the selection in WM_LBUTTONDOWN, is because it's possible to drag selected text around.
That's the theory anyway.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Well the MSDN docs seem to hint that this is not the case. But maybe they aren't quite right either. So I still need to hack around a bit. It does seem like I will have to *force* the rich edit to stay selected.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Hello,
I'd like to retrieve the IP addresses of the host my application is running on. I need to know ALL the IP addresses associated which each network card(Wi-fi, Bluetooth...)
But I don't know which Windows API functions to use.
Can someone help?
Thanks,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
use gethostbyname("localhost") and check the HOSTENT struct that's returned. Something like this:
struct in_addr addr;
hostent* host = gethostbyname( "localhost" );
if ( NULL != host ) {
memcpy( &(addr.s_addr), host->h_addr, host->h_length );
printf( "ip: %d.%d.%d.%d", addr.S_un.S_un_b.s_b1,
addr.S_un.S_un_b.s_b2, addr.S_un.S_un_b.s_b3, addr.S_un.S_un_b.s_b4 );
}
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Thanks for replying.
But your code retrieves only one IP address. What about IP addresses associated to other network cards?
Sincerely,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
Doh! My fault. Then I'm not sure. The function I sent you was the BSD style socket/net API. You need to look at the native Win32 APIs for that - I think what you want to look for is functions to enumeration network connections. Look up WSA, and functions that have Enum in their name.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
The best way to grab a list of all the ip addresses attached to your local system is using the IPHelper[^] library. You'll need to include the IPHlpApi.h and winsock2.h header files, then add iphlpapi.lib and ws2_32.lib to your list of import libraries.
MIB_IPADDRTABLE *pIPAddrTable = NULL;
DWORD dwSize = 0;
DWORD dwRetVal = 0;
if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) != ERROR_INSUFFICIENT_BUFFER )
{
printf( "Error getting buffer size." );
}
else
{
pIPAddrTable = ( MIB_IPADDRTABLE * ) malloc ( dwSize );
if ( (dwRetVal = GetIpAddrTable( pIPAddrTable, & dwSize, 0 ) ) != NO_ERROR )
{
printf("GetIpAddrTable failed.\n");
}
for( int i = 0; i < pIPAddrTable->dwNumEntries; i ++ )
{
in_addr add;
in_addr subnet;
ZeroMemory( & add, sizeof( in_addr ) );
ZeroMemory( & subnet, sizeof( in_addr ) );
add.S_un.S_addr = pIPAddrTable->table[ i ].dwAddr;
subnet.S_un.S_addr = pIPAddrTable->table[i].dwMask;
printf("IP Address: %s\n", inet_ntoa( add ) );
printf("IP Mask: %s\n\n", inet_ntoa( subnet ) );
}
free( pIPAddrTable );
}
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
Thank you for your answer.
It is definitely what I was looking for.
Best regards,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
|
When will these problems end? Today I tried the EM_SETTEXTEX message for a rich edit contol only to find that it's not defined in my richedit header file. I can't understand this, SETTEXTEX is available in version 2 of the control and even that is not defined :/
Does anybody have an up to date version of this file I could possibly borrow?
|
|
|
|
|
If you are working with VC 6.0 try a new version of the sdk.
When VC6.0 was released, there was no higher version of rtfedit.
You can download the windows sdk from microsoft homepage.
|
|
|
|
|
|
It has taken me 2 days to track down this problem so I aint very happy.
I have created a table within a rich edit control using the new dll version 4.1. For some reason none of the data within the cells was not being displayed. I tracked it down to the rtf \qc command which is supposed to center text. It works in Word and Wordpad, but it aint working in my app.
Strange thing is, when I first updated the control I had it working.
Does anybody know how to correctly center text within a table cell?
|
|
|
|
|
Hi there,
I've got data from the serial port stored in a CString variable,
e.g. 0123;0255;0192 with fixed size and the values are separeted with ';'
Now I need to splitt the values 0123 0255 and so on in other variables in order to make calculations.
My question: Is there an easy way to do this with the advadages of CString or do I need the way I would do in ordinary c-code: for (i=0 ...)
variable[i] = string [i] ... and so on?
|
|
|
|
|
If you are using Visual Studio 2002 or higher, then check out the CString::Tokenize method - you can use this to split the string into sub-strings, and then use _ttoi to convert the string to an int . For example:
CString str = _T("0123;0255;0192");
int nStartPos = 0;
CString strToken = str.Tokenize(_T(";"), nStartPos);
while (!strToken.IsEmpty())
{
int nVal = _ttoi(strToken);
TRACE(_T("Token value: %d\n"), nVal);
strToken = str.Tokenize(_T(";"), nStartPos);
}
HTH.
|
|
|
|
|
Dear Robert,
thanks for good idea. Unfortunately, I'm working under VC++ 6.0 and there is no Tokensize availible.
|
|
|
|
|
OK, well you could use the C strtok function instead, but it's messy (and you'd need to make a copy of the string first), e.g.:
CString str = "0123;0456;0789";
TCHAR* psz = new TCHAR [str.GetLength() + 1];
_tcscpy(psz, str);
TCHAR* pszTok = _tcstok(psz, _T(";"));
while (pszTok != NULL)
{
int nVal = _ttoi(pszTok);
...
pszTok = _tcstok(NULL, _T(";"));
}
delete [] psz;
|
|
|
|
|
I don't think strtok is thread-safe, so be warned!
|
|
|
|
|
Robert Edward Caldecott wrote: I don't think strtok is thread-safe, so be warned!
Is CString itself thread safe ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I'm being thick. You can obtain direct access to the CString buffer using CString::GetBuffer if that helps.
|
|
|
|
|
|
Thanks Mike,
this is really working!;)
|
|
|
|
|
I write a MFC app, like Graphic-Suite,only to view Image Infos,you can download my app from here :http://h1.ripway.com/jupiter/JHv2.zip[^]
Problem is when i runned my app,Image Infos Dlg did not appear.
Anyone can help me solute this app....
thanks so much.
|
|
|
|
|
I used MFC appwizard and made a single document interface.
I didn't add anyother codes than this code below in OnDraw function.
I wanted to make a pyramid looking bitmap in size 256*256.
But I had to make the pointer size into 256*256*16 to make it show the size of 256*256.
if i don't, a rectangle with four small boxes of pyramid and a large black box attached to it
appers. why is it?
void CWoosooView::OnDraw(CDC* pDC)
{
CWoosooDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int size = 256;// the size i want to make
int realsize = size*4;// this is the size i had to pump up.
// i made a pointer and added some values to make a rectangle look like a pyramid.
p = (unsigned char*)malloc(realsize*realsize);// i had to use *4 size all the way.
// below is a code for only one pyramid, but four of them appers. why is it?
for(int y = 0; y<realsize; y++){
="" for(int="" x="0;" x<realsize;x++){
="" if="" (((x="">=0) && (x<(realsize/2)))&&((y>=0) && (y<(realsize/2))))
*(p+realsize*y+x) = (int)(x+y)/4;
else if (((x<realsize) &&="" (x="">=(realsize/2)))&&((y>=0) && (y<(realsize/2))))
*(p+realsize*y+x) = (int)(realsize+(y-x))/4;
else if (((x>=0) && (x<(realsize/2)))&&((y<realsize) &&="" (y="">=(realsize/2))))
*(p+realsize*y+x) = (int)(realsize+(x-y))/4;
else if (((x<realsize) &&="" (x="">=(realsize/2)))&&((y<realsize) &&="" (y="">=(realsize/2))))
*(p+realsize*y+x) = (int)((2*realsize-x-y)/4);
}
}
CBitmap bitmap,bitmap2;
CDC memDC;
memDC.CreateCompatibleDC(pDC);
bitmap.CreateCompatibleBitmap(pDC,realsize,realsize);//realsize = *4 of the wanted size.
bitmap.SetBitmapBits(realsize*realsize,p); // here as well. i used 256*4.
free(p);
memDC.SelectObject(bitmap);
bitmap.DeleteObject();
pDC->BitBlt(0,0,size,size,&memDC,0,0,SRCCOPY);
// so i eventually only displayed the first pyramid of 4 by setting the size of BitBlt to 256*256.
bitmap2.GetBitmapBits(SRCCOPY,bitmap);
memDC.SelectObject(bitmap2);
bitmap2.DeleteObject();
pDC->StretchBlt(256,0,size/2,size/2,&memDC,0,0,size,size,SRCCOPY);
pDC->StretchBlt(384,0,size*2,size*2,&memDC,0,0,size,size,SRCCOPY);
}
woosoo
-- modified at 11:31 Saturday 18th March, 2006
|
|
|
|
|
|