|
i have a program that it read dxf. but my program only read simle's dxf.
hope have i that friend help to you . my program project is send to your friend.please your email to me
yangxjn@hotmail.com
yangxjn@163.com
MSN:yangxjn@hotmail.com
|
|
|
|
|
What exactly are you asking (or telling us) here?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
I am currently trying to communicate via the COM port with a device of mine. For now, the device just echoes immediatly the character it receives.
PC Platform: WinXP Pro, MS VStudio 6.0, VC++
I read some articles from the site (really helpful, like to thank konchat, Ashish Dar - good articles for head start in Win API serial port programming) and tried to send some chars through the serial port and subsequently reading the char return by the device. (note: already tried the device with hyperterminal and it echoes well, no hang-ups or smth).
I used 8n1, non-overlapped mode for the serial port.
at first it seemed the program works, when trying to send (e.g. characters 65 to 90 ASCII) by the 24 char (Y) the program doesn't receive characters any more (they still get to the device as it shows me which chars arrived by flashing LED-s connected to a register).
Even stranger, if a run the program.. stop it, say it.. after the 10 sent character and run it again, exactly at the 14 char it will stop receiving data. (10+14= ??!!! exactly, 24).
Is there something i am doing wrong?. Here the code that does the sending:
<br />
<br />
DCB dcb = {0};<br />
dcb.DCBlength = sizeof(DCB);<br />
DWORD dwBaudRate=9600;<br />
BYTE byStopBits=1,<br />
byByteSize=8, <br />
byParity=NOPARITY;<br />
COMMTIMEOUTS cto;<br />
const HANDLE hPort = CreateFile( portname,<br />
GENERIC_READ | GENERIC_WRITE, <br />
0, <br />
0, <br />
OPEN_EXISTING, <br />
0,
0);<br />
<br />
if (hPort == INVALID_HANDLE_VALUE)<br />
AfxMessageBox("Could not open "+portname+" port.");<br />
else<br />
{<br />
cto.ReadIntervalTimeout = 1000;<br />
cto.ReadTotalTimeoutConstant = 1000;<br />
cto.ReadTotalTimeoutMultiplier = 1000;<br />
cto.WriteTotalTimeoutConstant = 1000;<br />
cto.WriteTotalTimeoutMultiplier = 1000;<br />
SetCommTimeouts(hPort, &cto);<br />
int index=1;<br />
for (int k=0; k < 10; k++)<br />
for (int i=65; i< 91; i++)<br />
{<br />
char outb[1],inb[1];<br />
DWORD sent,read;<br />
outb[0]=(i);<br />
if (WriteFile(hPort,outb,1,&sent,NULL)==0)<br />
{<br />
AfxMessageBox("Error Writing to "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << index << ": sent=" << char(outb[0]) << " ";<br />
index++;<br />
inb[0]=0;<br />
if (ReadFile(hPort, inb, 1, &read, NULL)==0)<br />
{<br />
AfxMessageBox("Error reading from "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << "rcvd=" << char(inb[0]);<br />
if (outb[0]==inb[0]) <br />
std::cout << " ... OK";<br />
else<br />
std::cout << " ... NOK";<br />
std::cout << std::endl << std::endl;<br />
PurgeComm(hPort, PURGE_TXABORT | PURGE_RXABORT | <br />
PURGE_TXCLEAR | PURGE_RXCLEAR);<br />
}
<br />
}
if(CloseHandle(hPort) == 0)<br />
{<br />
AfxMessageBox("Error closing "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << "Port " << portname << " closed." << std::endl << std::endl;<br />
Any ideas, anyone?
Looking forward to your replies.
Found the bug. If anyone steps across this one in future: when using Win API for Serial Port access, always set the DCB Structure or else the code will work only partially (only God and Bill Gates know why but... who am I to judge :P ). I used a system call "system('mode COM1..... ');" to set the com parameters and the API doesn't seem to cope very well with that.
Anyways... Happy coding
Nik0n
|
|
|
|
|
|
Hi, Thx for the reply.
No handshake for now: no hardware rts/cts nor software xon/xoff. just wanna see it run for a
while, no packet dropping, no hang-ups.
It's just a preliminary test before writing the software for the device.
Nik0n
|
|
|
|
|
Thanks in advance.
I want to display a transparent label on a dialog; where as a bitmap is set as the dialogs background.
The problem is that if the text in label is not changing its fine, but if the numbers in label are changed they overwrite the previous one creating black squares at each charchter position.
Here is how i set the image as back ground of dialog;
void MyDlg::OnPaint()
{
CPaintDC dc( this ); // Device context for painting
CBitmap bmp, *poldbmp;
CDC memdc;
bmp.LoadBitmap( IDB_BITMAP13 );
memdc.CreateCompatibleDC( &dc );
poldbmp = memdc.SelectObject( &bmp );
dc.BitBlt( 0, 31, 1009, 521, &memdc, 0, 0, SRCCOPY );
memdc.SelectObject( poldbmp );
// Do not call CDialog::OnPaint() for painting messages
}
The problem remains same if OnEraseBkgnd function is used for background image;
And here is how I display a Transparent Label:
HBRUSH CDBDlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd->GetDlgCtrlID() == IDC_L1) // IDC_L1 is label ID
{
pDC->SetBkMode(TRANSPARENT);
hbr = (HBRUSH)::GetStockObject(NULL_BRUSH);
}
return hbr;
}
static labels are absolutely fine but the changing ones mess up.
|
|
|
|
|
Let say I want to develop a system that can keep all the student information. So if I click at 1 of their name, this system will display their profile information (include photo). The problem now is I don't know how to upload their photo into this system. Can anybody help me pls..
|
|
|
|
|
If the Web Service support XML language and can be reached with SOAP or HTTP protocols, then MSDN has all the information you could ever need[^].
If it's not a XML Web Service, then you must find out what protocol it uses and what queries it replies to. Then build a manual Internet-connection object, initialize and connect it to the web service, create query strings manually, and post them through the object to the service. Then read the results and interpret them according to the documentation of the Web Service.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
I am working on the reporting part of a big project. The problem is that the users of the product can have either version 8.5 or 10.0 of crystal reports. The task is to identify the version of the crystal report they have on the system and then create the relative activeX control either 8.5 or 10.0 from the code using its dlls to display the reports.
I know that I can extract the version and the path of the dlls from the registry of the system. The actual problem arises when i need to use that dll to create the control dynamicallyfrom the code at runtime and use it to display the reports.
Hope some one could help me out.
Thanx in advance.
..RR..
|
|
|
|
|
hi rahim,
suppose if the two version dll's are named as crystal32_8.dll and crystal32_10.dll. then u register the both the dll's in the registry, then instantiate both the dll's classes. Then in the reporting function try to read the version of the report file and based on the version call the appropriate object.
{
// in the main class
CCrystal_8 m_cry8 ; // object used to get the services of crystal32_8.dll
CCrystal_10 m_cry10 ; // object used to get the services of crystal32_10.dll
}
{
//in the area of reporting the file
int ver ;
1. get the version info of the report file and store it in the ver
2. if(ver == 8)
//use the object m_cry8 to show that file
else
//use the object m_cry10 to show that file
}
naren
|
|
|
|
|
I have the code as
DEVMODE devmode;
devmode.dmFields = DM_ORIENTATION;
devmode.dmOrientation = DMORIENT_LANDSCAPE;
devmode.dmSize = sizeof(DEVMODE);
CPrintDialog g_dlgPrt(FALSE);
g_dlgprt.DoModal();
Before showing the print dialog box , i want to set the radio button to landscape in the dialog box.
I tried the following code,
HGLOBAL hgdvmode = GlobalHandle((LPCVOID)&devmode);
g_dlgprt.m_pd.hdevmode = hgdvmode;
But this not working .
can you help in this regard.
|
|
|
|
|
See the MSDN example Q193103.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you.
I too got the solution..
LPDEVMODE pDMX = NULL;
CPrintDialog prtdlg(FALSE);
pDMX = (LPDEVMODE)GlobalAlloc(GPTR, sizeof(DEVMODE));
if (!pDMX) {
MessageBox("Out of Memory");
return FALSE;
}
// Initialize the DEVMODE structure.
pDMX->dmSize = sizeof(DEVMODE);
pDMX->dmFields = DM_ORIENTATION;
pDMX->dmOrientation = DMORIENT_LANDSCAPE;
prtdlg.m_pd.hDevMode = pDMX;
|
|
|
|
|
Hi. I have an ActiceX that I’d like to communicate with a web service. I assume it is possible to do it but I don’t know where to start.
I know how to create a web service (using C#) but it’s the call from the “old” ActiveX that’s not clear to me.
_____________________________
...and justice for all
APe
|
|
|
|
|
I assume you're using C++ here. MSDN has instructions for you right here[^]. The consuming of Web Services in C++ is very similar to C#, with the exception that C++ requires wrapper class generation (which is done automatically for you). I hear Visual Studio 2005 is different in this aspect, as the C++/CLI is introduced. Consuming Web Services in this environment is pretty much the same for C# and C++.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Ok, the tutorial on MSDN starts with:
On the Project menu, click Add Web Reference to display the ...
I'm using Visual Studio 6.0...
_____________________________
...and justice for all
APe
|
|
|
|
|
Ahh, so you're using VS 6.0.
Unfortunately this version of Visual Studio does not have a direct Web Services support, like it doesn't have C# support at all. You need to do everything manually in this version. Manual labor is highly difficult and most prone to errors. In order to efficiently use Web Services, I recommend you to move into Visual Studio 2003 .Net version.
If you must use VS 6, then start by learning SOAP, as it's the "language" of Web Services. Then create an Internet-connection, open a HTTP connection to the Web Service, generate a string that can be interpreted as a SOAP request with the proper parameters, post a HTTP Post command into the service and fetch results with HTTP Get. I'm sorry I can't give any more detailed instructions or specific help, because I've never done this manually. The auto-generated wrapper classes (Add Web Reference) have saved me the task.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Hi
I have a CString type variable that Content is Numberic
how can get this CString as a Integer?
|
|
|
|
|
Hope this will help You.
Example
CString str = "45" ;<br />
int m ;<br />
m = atoi(str.GetBuffer(str.GetLength() ) );
|
|
|
|
|
That is wrong. DO NOT call GetBuffer() - that returns a "writable" pointer, which you don't need.
CString comes with bucketloads of operater overloads.
CString str = "45" ;
int m ;
m = atoi( (const char *) str);
using System.Beer;
|
|
|
|
|
The cast is not necessary. This will suffice:
int m = atoi(str);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Indeed. But it's harmless and illustrates the point that atio() wants a *const* char *.
I ought to have written that. I'm lazy.
Merry Xmas;
|
|
|
|
|
atoi(), atof()
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
Hi,
I am working with Win32 serial communication.
I have an unsigned char array with data
Unsigned char data[7];
data[6] = 0xC0;
data[5] = 0x00;
data[4] = 0x00;
data[3] = 0x00;
data[2] = 0x03;
data[1] = 0x00;
data[0] = 0xA0;
CString szMsg;
szMsg.Format("%02X,%02X,%02X,%02X,%02X,%02X,%02X", data[0], data[1], data[2], data[3], data[4],data[5], data[6]);
OutputDebugString(szMsg);
//A0,00,03,00,00,00,C0 -------------Actual data
I want to append “\r\n” to these characters after copying them into the buffer for writing on the port. When I send data to port I append “\r\n”, so that while recieving, if I get more than two lines I can seperate them out by searching for new line.
Send(data);
I had to use functions like _mbslen , _mbscpy and _mbscat because of unsigned char data type.
I did this way:
bool CPanelInterface::Send( unsigned char* cBuffer)
{
size_t len = _mbslen(cBuffer)+2;
//It is showing len = 3 -------I did not understand this. When I passed a 7 byte array, why it is showing the length as 3.
CString szMsg;
szMsg.Format("%02X%02X%02X%02X%02X%02X%02X", cBuffer[0], cBuffer[1], cBuffer[2],cBuffer[3], cBuffer[4], cBuffer[5], cBuffer[6]);
OutputDebugString("\n ");
OutputDebugString("Send1---");
OutputDebugString(szMsg);
//Send1---A00003000000C0 ---------------correct
unsigned char* myBuffer = new unsigned char[len];
_mbscpy(myBuffer, cBuffer);
The data is getting corrupted here after this call to _mbscpy.
CString szMsg;
szMsg.Empty();
szMsg.Format("%02X%02X%02X%02X%02X%02X%02X", myBuffer[0], myBuffer[1], myBuffer[2],myBuffer[3], myBuffer[4], myBuffer[5], myBuffer[6]);
OutputDebugString("\n ");
OutputDebugString("Send2---");
OutputDebugString(szMsg);
//Send2---A000CDFDFDFDFD -------------- Corrupted myBuffer -> data after copy
szMsg.Empty();
szMsg.Format("%02X%02X%02X%02X%02X%02X%02X", cBuffer[0], cBuffer[1], cBuffer[2],cBuffer[3], cBuffer[4], cBuffer[5], cBuffer[6]);
OutputDebugString("\n ");
OutputDebugString("Send3 After Copy---");
OutputDebugString(szMsg);
//Send3 After Copy---A00003000000C0 ------------------ cBuffer is still having correct data
unsigned char endch[2];
endch[0]= '\r';//\n"};
endch[1]= '\n';
_mbscat(myBuffer, endch);
szMsg.Empty();
szMsg.Format("%02X%02X%02X%02X%02X%02X%02X", myBuffer[0], myBuffer[1], myBuffer[2],myBuffer[3], myBuffer[4], myBuffer[5], myBuffer[6]);
OutputDebugString("\n ");
OutputDebugString("Send4---");
OutputDebugString(szMsg);
//Send4---A00D0ACCCCD010----------_ mbscat is also not working properly.
if(!serial.SendData(myBuffer, len))
{
MessageBox(NULL, "Write Failed", "Serial Library Interaface", 0);
myBuffer = NULL;
delete myBuffer;
return false;
}
serial.FlushPort();
myBuffer = NULL;
delete myBuffer;
return true;
}
I am stuck here and am unable to understand why my buffer is getting corrupted after using these string functions. can anyone please help me to solve this problem.
Thanks in anticipation of information.
Madhavi
|
|
|
|
|
I'm not really motivated to go through your code line by line.
But I don't get why you're working with both CString and also char * buffers and libc string functions. I'd say stick with one or the other.
using _mbs???() functions is wrong. They're for wide character sets, and you're dealing with byte data.
1. You want a \r\n at the end of your string? Put it in your format string:-
CString szMsg;
szMsg.Format("%02X%02X%02X%02X%02X%02X%02X<font color="red">\r\n</font>", cBuffer[0], cBuffer[1], cBuffer[2],cBuffer[3], cBuffer[4], cBuffer[5], cBuffer[6]);
or, you can use CString's "+" operater to join two strings:-
CString szMsg;
szMsg.Format("%02X%02X%02X%02X%02X%02X%02X", cBuffer[0], cBuffer[1], cBuffer[2],cBuffer[3], cBuffer[4], cBuffer[5], cBuffer[6]);
szMsg = szMsg + "\r\n";
2. Not using _mbscpy
I don't know where you get your "len" variable from. But use strcpy() instead.
unsigned char* myBuffer = new unsigned char[len];
strcpy(myBuffer, cBuffer);
Those things should help.
Jon
using System.Beer;
|
|
|
|
|