|
<br />
received[dwBytesRead] = '\0';<br />
what does this line mean? I have "access violation" with this line.
Thanks, Mark
|
|
|
|
|
macmac38 wrote:
what does this line mean?
It appends a \0 character to the end of the string.
macmac38 wrote:
I have "access violation" with this line.
How big is the received array, and what is the value of dwBytesRead ?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
<br />
char received[40];<br />
<br />
port.Read(received, sizeof(received), overlapped, &dwBytesRead);<br />
<br />
TRACE( "Bytes read: %d",dwBytesRead);<br />
<br />
received[dwBytesRead] = '\0';<br />
<br />
SetDlgItemText(IDC_SHIFT_X, received);<br />
<br />
Bytes read: 1Bytes read: -858993460Bytes read: -858993460Bytes read: -858993460
Thanks, Mark
|
|
|
|
|
macmac38 wrote:
TRACE( "Bytes read: %d",dwBytesRead);
Since dwBytesRead is a DWORD , you'll need to use the %lu format.
Nonetheless, if received[] is only 40 bytes, trying to access the -858993460th position, or any value outside of 0-39, is obviously wrong. Check the return value of Read() beforehand.
In your original post, you indicated that 58 characters were being sent to the serial port. You'll need room for that plus one more so received[] should be 59 not 40. This is not the root of the problem, however, but will eventually need to be addressed.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
<br />
<br />
char received[59];<br />
<br />
port.Read(received, sizeof(received), overlapped, &dwBytesRead);<br />
<br />
<br />
TRACE( "Bytes read: %lu",dwBytesRead);<br />
<br />
received[dwBytesRead] = '\0';<br />
<br />
SetDlgItemText(IDC_SHIFT_X, received);<br />
Bytes read: 1
I donn't know where's the problem? Normaly it seems easy..?
Like to solve it today
Thanks, Mark
|
|
|
|
|
macmac38 wrote:
I donn't know where's the problem?
Are you sure a problem exists? Maybe there was only one byte available to read.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
But this Byte output like: j
which means no character in it?
But the full string is arriving..
if i don't use this line:
received[dwBytesRead] = '\0';
the output is:
-0.714853,-0.192273jjjjjjjjjjjjjjjjj
Thanks, Mark
|
|
|
|
|
macmac38 wrote:
But the full string is arriving..
How are you verifying this claim?
Whct class does the Read() method belong to? I'm curious if the fourth parameter is being used correctly. If more than one byte is being read, yet dwBytesRead equals 1, something is awfully wrong. It might also be the third parameter, but I've never used the OVERLAPPED structure before so I can't say for sure.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I created a custom resource in the SDI project, in other words, there is a new folder named "MyText" under the "MyView recources" in the resource view workspace , and there is an entry named "IDR_MYTEXT1" in the "MyText" folder. The content of IDR_MYTEXT1 is imported from a text file. I want to show the text file in the view window. but some error occured, I can't see the text file content at all.
Thanks for help in advance!
void CMyView::OnInitialUpdate()
{
CView::OnInitialUpdate();
HRSRC hrsrc=::FindResource(::AfxGetApp()->m_hInstance,"IDR_MYTEXT1","MyText");
HGLOBAL hglb=::LoadResource(::AfxGetApp()->m_hInstance,hrsrc);
LPVOID m_ptr=::LockResource(hglb);
}
void CMyView::OnDraw(CDC* pDC)
{
CMy0421Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->TextOut(0,0,"I insert a text file as a custom resource, and show it in the SDI program");
pDC->TextOut(100,100,(char*)m_ptr);
}
Have you tried Internet Telephone Services[^]
|
|
|
|
|
chocm wrote:
...but some error occured
And that error would be what?
In the OnInitialUpdate() method, you have a local variable named m_ptr . How are you expecting to access this variable from within the OnDraw() method?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
m_ptr is a member variable of CMyView, so I think it is valid in the OnDraw();
|
|
|
|
|
So change the LPVOID m_ptr=::LockResource(hglb) statement to m_ptr=::LockResource(hglb) instead.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes I have change the line to m_ptr=::LockResource(hglb), the problem is still the same, no text file was shown as expected.
I tried to set a breakpoint at the line:
HGLOBAL hglb=::LoadResource(::AfxGetApp()->m_hInstance,hrsrc);
and then pressed the button Go, in the output window, I got hrsrc's value is 0X00000000, clicked to extract the button left to the "hrsrc", there is some info shown as "unused CXX0030: Error: expression can't be evaluated"
the hglb's vaule is 0xcccccccc
Does the FindResource() work improperly? I need more suggestions, Thanks!
|
|
|
|
|
chocm wrote:
Does the FindResource() work improperly?
Not if it is used correctly. If it, or LoadResource() are returning NULL , call GetLastError() to find out why.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I was told to add the MAKEINTRESOURCE to the parametre in the function FindResource(), Then all the code began to work properly.
FindResource(::AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDR_MYTEXT1),"MYTEXT");
Another question, under what condition is the MAKEINTRESOURCE necessary?
|
|
|
|
|
chocm wrote:
Another question, under what condition is the MAKEINTRESOURCE necessary?
See here.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I need to scroll CListView to bottom.
How to do it?
thanks.
|
|
|
|
|
Check the Scrolling Functions of CWnd
GetScrollPos Retrieves the current position of a scroll box.
GetScrollRange Copies the current minimum and maximum scroll-bar positions for the given scroll bar.
ScrollWindow Scrolls the contents of the client area.
ScrollWindowEx Scrolls the contents of the client area. Similar to ScrollWindow, with additional features.
GetScrollLimit Retrieves the limit of the scroll bar.
SetScrollPos Sets the current position of a scroll box and, if specified, redraws the scroll bar to reflect the new position.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I would like to retrieve audio file properties.
such as sample-rate and so on.
Does enyone know some library or easy way how
to do it.
Not only WAV but for example how to retrieve
this information from MP3 file.
I don't need to play it I just need to know
their properties.
Thanx for any help
viliam
|
|
|
|
|
Hi,
Im having trouble adding IME support to my component.
Im having trouble with both the IME-caret location and the apperance of it.
http://www.compona.com/crm/pages/EditMessagePage.ascx?ID=95[^]
Does anyone know how to set the ime caret style to the same style as shown on the notepad shot?
and does anyone have any clue why the caret is shown at the top left corner the first time it appears?
(i am setting the caret location everytime my normal caret moves in the control)
//Roger
|
|
|
|
|
How to hide cursor for a while?
Kaldoklv
|
|
|
|
|
int ShowCursor(
BOOL bShow // cursor visibility
);
bShow=FALSE
|
|
|
|
|
Hi,
I'm working on a project which calls a Word instance in a view in the program (the programmer who made it used smartpointers). This works fine for Office 97 -> Xp, but it DOESN'T work with Office 2003(sometimes it does, mostly it doesn't). My colleagues and I cannot find the problem.
Does anyone know what may be the problem? How do we solve it?
Re-writing the complete code is not really an option.
extra info: when terminating the program I get an acces violation error. The contents of the address called in the assembly is empty.
tnx for your help!!
|
|
|
|
|
Can't really help, but that sounds like exactly the sort of thing I need to do for a current app - can you give me any pointers as to how you've acheved it? Pretty Please???
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
I cannot explain how you use smartpointers as I don't understand them really well myself.
However there is a second way for automation.
You have to "import" the library stuff from office itself. (for word 2003 it's the MSWORD.OLB file) These contain all the functions available for working with Word. (cfg Excel, Acces, ...) If you succesfully imported them you can make Objects of the the Word application and use them as any other Object. (see msdn for more info)
You have to read a lot of that stuff to understand it all. There are also examples on msdn.
(btw I found my error, if you get the same, try pressing ALT-F5)
there is also an object model file called VBAOF11.CHM (again office 2003) in your office. Here you can find additional info.
hope it's helpfull (but to explain it all it's just TOO much)
|
|
|
|