|
The reason I use such ugly code, is because that's the only code I know. I am a begginer in programming. At the moment I am reading some materials on STL and MFC, but find it quite difficult to understand, as I have a lot of gaps in my programming knowledge. To that I have no one to ask for help apart from the forum. So THANK YOU all for helping me out!
Maybe you could help me out with this error I get:
cannot convert parameter 1 from 'unsigned short' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast.
The solutions you helped me out with, was not exaclty what I was looking for. Basicaly pszData is only 1 character at a time. So I want to store that 1 character in an array, then add the next character that comes from pszData and add it to the array. When I have 10 characters, That's when I want to display on screen. pszData recieves a character at different times, could be a split second or a whole day.
Thanks in Advance!
|
|
|
|
|
tomek18 wrote:
The reason I use such ugly code, is because that's the only code I know. I am a begginer in programming. At the moment I am reading some materials on STL and MFC, but find it quite difficult to understand, as I have a lot of gaps in my programming knowledge.
Only time and practice will learn. We were all beginners once, and we are glad to help a fellow programmer!
tomek18 wrote:
cannot convert parameter 1 from 'unsigned short' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast.
Can you post the code? It's much easier for us to understand your problem if we see some code. If we see it, we can tackle the problem much faster.
tomek18 wrote:
The solutions you helped me out with, was not exaclty what I was looking for. Basicaly pszData is only 1 character at a time. So I want to store that 1 character in an array, then add the next character that comes from pszData and add it to the array. When I have 10 characters, That's when I want to display on screen. pszData recieves a character at different times, could be a split second or a whole day.
If you only need to wait for 10 characters, why are you using so large buffers? You don't even need to do all the copying! Try the following code:
std::stringstream m_sstrDataBuffer;
void CChildView::SortData(LPCTSTR pszData)
{
m_sstrDataBuffer << pszData;
if( m_sstrDataBuffer.str().length() >= 10 )
{
DisplayData(m_sstrDataBuffer.str().c_str());
m_sstrDataBuffer.str("");
}
}
Hope this helps!
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
Can you post the code? It's much easier for us to understand your problem if we see some code. If we see it, we can tackle the problem much faster.
I would if it just wasn't that long. I got the source code from this web site. if your interested http://www.codeproject.com/system/serial.asp
Basicaly the program just reads a character through the serial COM port, then passes that character to pszData. What I want to do, is to store all the single characters that come in, and after 80 have been recieved I want to sort out the data, and only send about 10 characters to the Display.
At the moment I am having problems converting Data types. Pointers, Strins, LPCTST, etc... I don't understand them much. And everytime I try a method I get an error saying something like: cant convert pointer to string vice versa.
Please Help me
|
|
|
|
|
As long as a pointer doesn't point to a class, you can convert it from anything to anything. Unless you don't know what you are doing, you will get away with it.
The serial class that you are using is a good one. I use it too in one of my programs. So the problem is definitly not there.
Your problem however, is that you don't pass the number of bytes in the buffer (pszData) to your SortData function. You have that number, since the serial class demands a buffer size for the read actions. I suggest that you use those values to determine how much data is recieved.
tomek18 wrote:
At the moment I am having problems converting Data types. Pointers, Strins, LPCTST, etc... I don't understand them much. And everytime I try a method I get an error saying something like: cant convert pointer to string vice versa.
Use static_cast<PointerType>(OtherPointerType) for this purpose.
I think that you are a little bit over your head with this project if you have problems like this. I suggest that you do some more reading about data types, pointer arithmic and such. The basics should be enough to get the job done.
Good luck with it.
P.S.
If you have some problems with something, by all means, ask and post the source code too! Otherwise we will not be able to help you much...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
tomek18 wrote:
Basicaly pszData is only 1 character at a time.
While the compiler couldn't care less, and it certainly is not required, you might want to consider a different variable naming convention so that you and others who read your code can make better sense of it. See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
i debug my program, and the exception (unhandled exception in gis.exe(MFCO42D.DLL):0xc0000005 access violation.) arised when the instruction(mapinfo.CreateDispatch("MapInfo.Application"))run. how can i deal with it?
|
|
|
|
|
It is the debug version of the MFCOLE Shared Library.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
how can i deal with the problem?
|
|
|
|
|
Well, either mapinfo is not a valid COleDispatchDriver object, or "MapInfo.Application" is not a valid automation object identifier. I'd have to see more of your code to know for sure.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
liuyue wrote:
mapinfo.CreateDispatch("MapInfo.Application"))
Please Check that mapinfo variable hold valid reference to memory
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
hello,
i need to know who to determine whether a user is logged on or not. i have already tried GetUserName but this didn't work, because i have a service running as 'system', so GetUserName only returns 'system'. Now, how can i get this information ?
OS: Windows 2000
Thanks in advance.
|
|
|
|
|
Check out the UserName property of Win32_ComputerSystem .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
If this is Windows 2000 and you think they will always launch the shell you could simpy enumerate processes looking for explorer.exe or whatever they replaced the shell with.
Alternatively you could write a Winlogon Notification DLL which gets notified of events such as Logon and Logoff.
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
thanks for the hints, but i have found another workaround. because i have already a process which gets launched at startup - i simply put a pipe in it, which delivers the needed informationen whether a user has logged on.
thanks anyway.
|
|
|
|
|
actually i want to open number of files at same time and at each time when ill click on "openfile" on "file" menu a check box would be created for each file. On each open file action check box would be created on group box next to previous one.
how can i do this?
|
|
|
|
|
softtec wrote:
how can i do this?
Do what? Open a number of files at the same time? Create a checkbox for each opened file? Add to a menu? What group box?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
actually i have created a menu
when i click openfile on File menu, a checkbox is created in groupbox right
but it works only when i open single file
as i click openfile menu i got assertion error
now i want whenever i click on open file menu,check box is created
and if i again click on open file menu another checkbox will be created just below the previuos one in the same groupbox.
|
|
|
|
|
softtec wrote:
a checkbox is created in groupbox right
What groupbox?
softtec wrote:
as i click openfile menu i got assertion error
What line of what file is asserting?
Are you using MFC?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
CButton b;
CRect rect;
rect.SetRect(20,20,200,40);
b.Create(name,WS_CHILD | WS_VISIBLE | BS_CHECKBOX | BS_AUTOCHECKBOX,rect,&m_Stat,2)
where CButton m_Stat;is variable connected to GroupBox
|
|
|
|
|
I have Proj.exe + Proj.exe.manifest
Proj.exe calls foo.dll
Question: How can I disable influence of manifest on foo.dll
May be there is some compilation keys which can explicitly tell to use ComCtrl32.dll version 5 instead of 6(support XP styles)
Another words foo.dll should not use XP styles enabled in manifest but Proj.exe should
Thanks
We yesterday got drunk with Bacchus ...
|
|
|
|
|
Guys do you think it could help?
If you do not define this macro in your project, it is automatically defined as 0x0500. To define a different value, you can add the following to the compiler directives in your make file; substitute the desired version number for 0x0400.
/D _WIN32_IE=0x0400
Another method is to add a line similar to the following in your source code before including the Shell and Common Control header files; substitute the desired version number for 0x0400.
#define _WIN32_IE 0x0400
#include <commctrl.h>
Version Description
0x0200 The application is compatible with Comctl32.dll and Shell32.dll version 4.00 and later. The application cannot implement features that were added after version 4.00 of Comctl32.dll.
0x0300 The application is compatible with Comctl32.dll and Shell32.dll version 4.70 and later. The application cannot implement features that were added after version 4.70 of Comctl32.dll.
0x0400 The application is compatible with Comctl32.dll and Shell32.dll version 4.71 and later. The application cannot implement features that were added after version 4.71 of Comctl32.dll.
0x0401 The application is compatible with Comctl32.dll and Shell32.dll version 4.72 and later. The application cannot implement features that were added after version 4.72 of Comctl32.dll.
0x0500 The application is compatible with Comctl32.dll version 5.80 and later, and Shell32.dll and Shlwapi.dll version 5.0 and later. The application cannot implement features that were added after version 5.80 of Comctl32.dll, or version 5.0 of Shell32.dll and Shlwapi.dll.
0x0501 The application is compatible with Comctl32.dll version 5.81 and later, and Shell32.dll and Shlwapi.dll version 5.0 and later. The application cannot implement features that were added after version 5.81 of Comctl32.dll, or version 5.0 of Shell32.dll and Shlwapi.dll.
0x0600 The application is compatible with Comctl32.dll version 6.0 and later, and Shell32.dll and Shlwapi.dll version 6.0 and later. The application cannot implement features that were added after version 6.0 of Comctl32.dll, or version 6.0 of Shell32.dll and Shlwapi.dll.
We yesterday got drunk with Bacchus ...
|
|
|
|
|
What do you mean by "a cleaner way?"
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I'm still unclear as to what you are asking.
http://www.codeproject.com/dll/[^]
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
As in make the Code shorter more proffesional or more appealing ?
I cant think of another shorter method to do this.
I cant use Class Items like stated on the link you send me.
|
|
|
|
|
Given that it's hard to tell what your code is even doing, it's impossible for me to offer any suggestion(s). Does it solve the probem it was meant to solve? If so, why are you wanting to mess around with it? If not, what are you using to confirm its inefficiency?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|