|
awah wrote: SPY++ only shows messages that the control has sent out, not messages that it receives
Incorrect. Spy++ shows the messages sent to a control. The 2nd value in the spy display is the window handle of the RECEIVING window. What you can't tell is where the message originated.
Judy
|
|
|
|
|
Dear all
how to do colour image quantization using VC++? who has code snippet? thanks a lot.
zhiyuan li
Li Zhiyuan
27/06/2007
|
|
|
|
|
|
while(getline(passage,nextword,'\n'))
{
int status = 0;
transform(nextword.begin(), nextword.end(), nextword.begin(), (int(*)(int))std::toupper);
int x=nextword.find(test1);
int y=nextword.find(test2);
int z=nextword.find(test3);
if(x!=std::string::npos)
{
status = 1;
}
if(y!=std::string::npos|| z!=std::string::npos)
{
status = 2;
}
string nextword;
ostringstream os(nextword);
string readInWord;
while (os>>readInWord)
{
if (status==0)
++wordCount[readInWord];
else if (status==1)
{
++wordCount[readInWord];
++single[readInWord];
}
else if (status==2)
{
++wordCount[readInWord];
++single[readInWord];
++compound[readInWord];
}
}
}
I am trying hard to get this code to work but seems to be something wrong. I am testing for 3 things and if present I am trying to update certain maps accordingly. I am getting some sort of error on the ostringstream os(nextword) not sure what this is or what it does. Someone put it in my code saying this would fix my problem but I have yet to figure it out.
|
|
|
|
|
andyspartyshop wrote: not sure what this is or what it does
Then why are you using it ? If you search this site for ostringstream, I have an article on it.
You're initialising a stringstream with a string which has not been initialised ( although it will initialise to "" ). What's the point of that ?
The code is pretty messy. At a minimum, change the if/else to a switch block and give x/y/z more meaningful names.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi All,
Can any one tell me how to convert LPRSTR data type to string date type in VC++. I am doing in the following way.
LPTSTR testLpt; // this I am getting from some method
string testStr = string(testLpt);
I am getting type cast error.
Can any tell me how to do this?
Thanks in advance.
Regards,
JK
|
|
|
|
|
Sounds like your LPTSTR is Unicode (wchar_t).
Try a wstring instead.
You also don't need to construct a temporary string and copy it to another string.
You can construct it in one step:
LPTSTR testLpt; // this I am getting from some method
wstring testStr(testLpt);
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
LPTSTR can be either Unicode or not depending on whether UNICODE is defined. Using std::wstring is ok if you are sure LPTSTR is always unicode. But in this case it would be more correct to have LPWSTR. What to do in current case, is to use std::basic_string<TCHAR>:
typedef std::basic_string<TCHAR> tstring;
Now, conversions between LPTSTR and tstring will work regardless of being unicode or not.
--
=====
Arman
|
|
|
|
|
Thanks for the info
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi Arman and Mark,
Thanks a lot. Its working fine with wstring for me.There are no compilation errors now.
But I am having one more problem.
I am using text resource file in my VC++ workspace.
I have included *.rc and *.h file. but I am not able to get the handle to resource file. Following is the sample code.
TCHAR sResName[5] = _T("#103");
TCHAR sRestype[12] = _T("MY_RESOURCE");
HRSRC hres = FindResource(NULL, sResName, sRestype);
HGLOBAL hbytes = LoadResource(NULL, hres);
LPVOID pdata = LockResource(hbytes);
LPBYTE sData = (LPBYTE)pdata;
LPTSTR sXml = (LPTSTR)sData;
wstring strXml(sXml);
In the above code i am not getting hres pointer.
The address of hres is null. Do u have any idea why I am not getting the pointer to resource file using FindResource(). I have included the resource file in the header files folder.
Is there any better way of doing the same?
Thanks in advance
JK
|
|
|
|
|
2 reasons I see for FindResource to fail -
1) A resource of type "MY_RESOURCE" with an integer ID of 103 isn't in the exe's resources.
2) The resource isn't compiled/linked into the exe file (since you've used NULL for hModule param)
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi Mark,
Thanks for the reply.
I have checked the ID number its correct.
And I have included resource file in the workspace and I have included resource header in my *.cpp.
I could complie successfully. When I debug and see the return type of findresource() it is NULL.
Do u any idea how to fix this.
Thanks in advance.
JK
|
|
|
|
|
It looks like it should work.
Without seeing the resource script I can't imagine.
You could try AfxGetInstanceHandle() instead of NULL for the module handle.
Also make sure the type is a string and not a macro for an integer.
That's all I can think of off hand...
Mark
This episode brought to you by the number 5
|
|
|
|
|
i am very bad in strings and LPTSTR all that crap
so i switched to using the class CString
simply type
CString MyString;
if you want to put something into your Cstring, type
MyString = "this is my string"<br />
if you want to pass your CString into a LPTSTR field, use MyString.GetBuffer()
switch to CString today!
|
|
|
|
|
I want to develop a program with features below :
1. The usb mass storage device should not be recognised by the windows operating system as a removable storage device at all. i.e. in the standard windows explorer the new removable drive should not be visible
2. But my program must recognise it , and must do all user applications like file operations on it
How can this be done , must i write a strong USB Bus filter driver ?
Thank you very much...
|
|
|
|
|
You're describing features of the hardware, it needs somehow to show a non standard interface to Windows, so Windows cannot tell what it is, but your software will know how to interact with it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I need help encrypting a string with Crypto++, RSA encryption. I downloaded it and integrated in my solution.
I have the keys in hex strings. All the samples I found read the keys from files or sign messages (I want to encrypt the string, not sign it).
Thanks
|
|
|
|
|
ErnestoNet wrote: All the samples I found read the keys from files or sign messages (I want to encrypt the string, not sign it).
They hide that information in the documentation[^]
|
|
|
|
|
|
Hi
In which scenarios would COM connection points be preferred to Windows Messaging (like regsisterwindowsmessage,postmessage) ?
Thanks
Rose81
|
|
|
|
|
Rose81 wrote: In which scenarios
Perhaps if you provide the list of "scenarios" we can filter it for you.
|
|
|
|
|
Rose81 wrote: In which scenarios would COM connection points be preferred to Windows Messaging (like regsisterwindowsmessage,postmessage) ?
In general:
Whenever you want a COM server to notify its client you should use connection points or preferably your own source interface.
More detailed explanation:
When you design COM servers you should always design with distribution in mind, i.e. your server may be used remotely from a different machine using DCOM. In this case you cannot send/post windows messages to the client.
Furthermore your server may be created in a UI-thread that may not necessarily have a window.
Tip of the day:
Regarding the concept of connection points even the COM authority Don Box recommends not to use connection points in his book "Effective COM"[^], but rather your own source interface.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I'm having the problem in an application I made in VC6 and Windows2003.
In Windows2003 works fine, but when I put the app in the WindowsXP where it has to be, it doesn't work.
I installed all the VStudio6 with the SP6 as I have it in Window2003, and still not working.
Something I noticed in the XP machine;
When I make a new project in VC6 and select a Windows Application -> Hello World Example, works ok.
BUT, I open the Example About Dialog it generates, and add a ProgressBar or a ListControl; when I run it, it runs, but the About Dialog si not load.
In my original App, I'm using a ListControl and a ProgressBar, so thats the problem......
Is there anybody that can help me ?
Guillermo.
-- modified at 14:47 Tuesday 26th June, 2007
I just tried in another XP and another Windows2003
and the same.
In XP doesn't work and in W2003 yes. :'( ¡Strange!
|
|
|
|
|
Are you calling InitCommonControls() (or InitCommonControlsEx()) somewhere BEFORE using any
controls?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I didn't explicitly add the InitCommonControls, it's necesary? cause in W2003 works. shouldn't be needed in W2003 also??
Where should I add it in the code ?
I read in MSDN something about it; it said the that problem with initcommoncontrols was in VC5 and that in VC6 was solved, so, if I need to add it; where should I put it?
in WinMain? or just before the DialogBox Call ?
Thnx!
|
|
|
|