|
My control is written in C++ / MFC. It takes more than two lines of code to produce this, but it gives you a lot of control over what is happening.
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
I'm interested in the answer too...
sun.lcr
|
|
|
|
|
Hi, I need to use the same thread for several Dialogs. I do it for one dialog and it works, because I associate it with this dialog. But If I want to use it in another dialog, ¿How can I do it? How can I associate it with several dialogs?
Another question: How Can I use a member class dialog variable in another Dialog code?
Thanks.
Regards,
Javier
|
|
|
|
|
That may be a questionable programming practice. Isn't there any other place where you can put that variable that is accessible to all dialogs?
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Yes, sorry, I only need two variables managed in the thread that they could be accessible from all dialogs, and I need to resume or to stop the thread from a button in any dialog.
How can I do it? I only need to know to make accessibles threads variables(or member variables) or something else.
Regards.
Regards,
Javier
|
|
|
|
|
Try a global object. Not a clean solution, but works.
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
ok, what is the clean solution?
If I do it like global object, how can i define it?Any sample or code for learn it?
Thank you.
Regards,
Javier
|
|
|
|
|
illidan99 wrote:
ok, what is the clean solution?
Language purists don't like globals... that's all. I regularly use globals and it's very easy to do. I create two files, one named "globals.h" that is included in all cpp files that need to access the global variables. For instance:
#ifndef __GLOBALS__
#define __GLOBALS__
extern int g_nInteger;
extern HANDLE g_hThread;
#endif
Now, you include in your project a cpp file named "globals.cpp":
#include "stdafx.h"
#include "globals.h"
int g_nInteger = 0;
HANDLE g_hThread = NULL;
And that's all you need.
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
ok, thank you
Regards,
Javier
|
|
|
|
|
Hi,
We have a embedded product that contains a USB1 host port on it. We have a thought of using a USB connection to transfer data from a PC to the product. However PC's have host ports and our product has a host port.
Is it possible to connect these 2 hosts together, and if so does anyone know how?
thanks,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
I'm using Entrek CodeSnitch to detect memory leaks. The strange thing is that i get a Error: Memory verwrite detected at... at the beginnig of the events sequence. I tried to write a blank MFC application with AppWizard and it reports exactly the same error.
Is there a problem with Entrek CodeSnitch or with MFC?
Thank you.
|
|
|
|
|
|
I use wininet to connect on ftp server.
InternetOpen OK.
- InternetOpen(_T("FTP"),INTERNET_OPEN_TYPE_PROXY ,NULL,NULL,INTERNET_FLAG_ASYNC);
InternetConnect(to the ftp) OK
- InternetConnect(hInternetOpen,_T("XXX.XXX.XXX.XXX"),INTERNET_INVALID_PORT_NUMBER,_T("pocket"),_T("password"),INTERNET_SERVICE_FTP,INTERNET_FLAG_TRANSFER_BINARY,NULL);
But when i use ftpputfile
- FtpPutFile(hFtpconnection,_T("test.txt"),_T("test.txt"), FTP_TRANSFER_TYPE_BINARY,NULL)
The ftp server(WAN) receive the command but the file is not send and a timeout close the transfer.
Into LAN ftp server, this code works!!! But not on a remote(WAN) server!!!
I nothing any more understands there.
Please help meeeee! thanks
|
|
|
|
|
Hi All!
I have a cabwiz problem!
I can't include registry key width commas - example: "ToDay" - How can I do it?
THX
Sorry my bad english
|
|
|
|
|
I got question about XML, i found some articles about how to use it on pocket.
So i've tried to write a programm, but it doesn't compile. Maybe i don't have the dll's or *.h ??? I got Embeded 3.0.
|
|
|
|
|
|
Hello,
I've been trying to move items up and down in a DataGrid in the .Net Compact Framework, using Visual Basic .Net 2003. I have tried using the InsertAt command, but I have not been able to get it to work.
Here is my current code to move an item up:
Dim currentpos As Integer
currentpos = DataGrid1.CurrentRowIndex
If currentpos >= 0 Then
Dim row As DataRow
row = DataTable.Rows(DataGrid1.CurrentRowIndex)
Dim NewRow As DataRow
NewRow = DataTable.NewRow
NewRow(0) = row.ItemArray.GetValue(0)
DataTable.Rows.RemoveAt(DataGrid1.CurrentRowIndex)
DataTable.Rows.InsertAt(NewRow, currentpos - 1)
End If
My code seems to sometimes work, other times it moves two items up, and sometimes it moves items around randomly.
Could anyone please help?
Thanks
|
|
|
|
|
Hi all,
I want to start mobile programing.
Is there any links to help me?
Best Wishes.
Thanks.
|
|
|
|
|
What platforms do you want to target?
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
I need to write a .NET compact framework application that play a playlist of MP3 audio items on a Pocket PC(Win CE). The items need to be overlapped and/or played simultaneously.
It looks fairly simple to do overlaps of linear (noncompressed) files in DirectX or to play MP3's using the Windows MediaPlayer but how do I do both.
I have tried to find out what approach to use to be able to do this.
Any suggestions?
-Svein
|
|
|
|
|
Hi y'all:
I have a iPAQ HP 5550 with winCE 4.2 and i want to read from serial port using evc++ 4.0. I have written this code, and it works (it reads) but it doesn't work fine, because i know what i have to read and the results i get are not good. So, it reads, but it doesnt write correctly in the file.
I have to say that i proved the same code (except necessary changes) in a PC with Visual Studio 6.0 and it works fine!
CAN ANYBODY HELP ME?? Thanks a lot !
Here's the code:
/***********************************************************/
#include <windows.h>
#include <winbase.h>
DWORD WINAPI ReadThread( LPVOID lpParam );
static HANDLE hPort;
static HANDLE hFile;
BOOL auxbool;
DWORD dwNumberOfBytesWritten;
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
//////////////////////////////////////////////////////////////////
TCHAR *filename = TEXT("\\multithread.txt");
hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
LPTSTR lpszPortName;
lpszPortName = TEXT("COM1:");
DWORD dwError;
DCB PortDCB;
COMMTIMEOUTS CommTimeouts;
hPort = CreateFile (lpszPortName,
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
//// IOCTL_SERIAL_SET_QUEUE_SIZE /////
SetupComm(hPort, 131072, 131072);
ZeroMemory(&PortDCB, sizeof(PortDCB));
PortDCB.DCBlength = sizeof (DCB);
if(!GetCommState (hPort, &PortDCB))
{
MessageBox (NULL, TEXT("ERROR : Falla GetCommState"),TEXT("Error"), MB_OK);
char *error = "ERROR : Falla GetCommState";
WriteFile(hFile, error, sizeof(error), &dwNumberOfBytesWritten, NULL);
return 0;
}
//// IOCTL_SERIAL_SET_BAUD_RATE ////
PortDCB.BaudRate = CBR_57600;
//// IOCTL_SERIAL_SET_LINE_CONTROL ////
PortDCB.StopBits = ONESTOPBIT;
PortDCB.Parity = NOPARITY;
PortDCB.ByteSize = 8;
//// IOCTL_SERIAL_SET_CHARS ////
PortDCB.EofChar = 0;
PortDCB.fErrorChar = 0;
PortDCB.EvtChar = 0;
PortDCB.XonChar = 0x11;
PortDCB.XoffChar = 0x13;
//// IOCTL_SERIAL_SET_HANDFLOW ////
// PortDCB.shake ??
// PortDCB.replace ??
PortDCB.XonLim = 0;
PortDCB.XoffLim = 16384;
// resto
PortDCB.fBinary = TRUE;
PortDCB.fParity = FALSE;
PortDCB.fOutxCtsFlow = FALSE; //
PortDCB.fOutxDsrFlow = FALSE; //
PortDCB.fDtrControl = DTR_CONTROL_HANDSHAKE; //
PortDCB.fDsrSensitivity = FALSE; //
PortDCB.fTXContinueOnXoff = TRUE; //
PortDCB.fOutX = FALSE; //
PortDCB.fInX = FALSE; //
PortDCB.fErrorChar = FALSE;
PortDCB.fNull = FALSE;
PortDCB.fRtsControl = RTS_CONTROL_HANDSHAKE; //
PortDCB.fAbortOnError = FALSE;
PortDCB.wReserved = 0;
if (!SetCommState (hPort, &PortDCB))
{
MessageBox (NULL, TEXT("Unable to configure the serial port"),TEXT("Error"), MB_OK);
char *error = "Unable to configure the serial port";
WriteFile(hFile, error, sizeof(error), &dwNumberOfBytesWritten, NULL);
return FALSE;
}
GetCommTimeouts (hPort, &CommTimeouts);
// CommTimeouts.ReadIntervalTimeout = MAXDWORD;
CommTimeouts.ReadIntervalTimeout = MAXDWORD;
CommTimeouts.ReadTotalTimeoutMultiplier = 0;
CommTimeouts.ReadTotalTimeoutConstant = 0;
CommTimeouts.WriteTotalTimeoutMultiplier = 10;
CommTimeouts.WriteTotalTimeoutConstant = 1000;
if (!SetCommTimeouts (hPort, &CommTimeouts))
{
MessageBox (NULL, TEXT("Unable to set the time-out parameters"),
TEXT("Error"), MB_OK);
dwError = GetLastError ();
char *error = "Unable to set the time-out parameters";
WriteFile(hFile, error, sizeof(error), &dwNumberOfBytesWritten, NULL);
return FALSE;
}
//// IOCTL_SERIAL_PURGE ////
PurgeComm(hPort, PURGE_RXCLEAR);
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
DWORD dwThreadId, dwThrdParam = 1;
HANDLE hThread;
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
ReadThread, // thread function
&dwThrdParam, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
// Check the return value for success.
if (hThread == INVALID_HANDLE_VALUE)
{
char *error = "CreateThread failed";
WriteFile(hFile, error, sizeof(error), &dwNumberOfBytesWritten, NULL);
}
else
{
CloseHandle( hThread );
}
//////////////////////////////////////////////////////////////////
Sleep(3000);
auxbool = TRUE;
CloseHandle( hThread );
CloseHandle(hFile);
CloseHandle(hPort);
return TRUE;
}
/*****************************************************************/
DWORD WINAPI ReadThread( LPVOID lpParam )
{
UCHAR Byte = 0x00;
UCHAR xL = 0x00;
UCHAR xH = 0x00;
UCHAR buff[1000];
UCHAR cero = 0x30;
UCHAR uno = 0x31;
UCHAR dos = 0x32;
UCHAR tres = 0x33;
UCHAR cuatro = 0x34;
UCHAR cinco = 0x35;
UCHAR seis = 0x36;
UCHAR siete = 0x37;
UCHAR ocho = 0x38;
UCHAR nueve = 0x39;
UCHAR a = 0x41;
UCHAR b = 0x42;
UCHAR c = 0x43;
UCHAR d = 0x44;
UCHAR e = 0x45;
UCHAR f = 0x46;
UCHAR otro = 0x2A;
UCHAR spc = 0x20;
UCHAR LF = 0x0A;
DWORD dwBytesTransferred;
DWORD dwCommModemStatus;
DWORD dwBytesWritten;
DWORD dwErrors;
COMSTAT comstatus;
int cuenta = 1;
WriteFile (hFile, &spc, 1, &dwBytesWritten, NULL);
SetCommMask (hPort, EV_RXCHAR);
if (hPort != INVALID_HANDLE_VALUE)
{
cuenta=1;
}
else
{
cuenta=1;
}
while (hPort != INVALID_HANDLE_VALUE)
{
WaitCommEvent (hPort, &dwCommModemStatus, 0);
SetCommMask (hPort, EV_RXCHAR);
if (dwCommModemStatus & EV_RXCHAR)
{
do
{
ZeroMemory(buff, sizeof(buff));
ClearCommError(hPort, &dwErrors, &comstatus);
if (comstatus.cbInQue <= 1000)
{
ReadFile (hPort, buff, comstatus.cbInQue, &dwBytesTransferred, 0);
}
else
{
ReadFile (hPort, buff, 1000, &dwBytesTransferred, 0);
char *error = "Más de mil";
WriteFile(hFile, error, sizeof(error), &dwNumberOfBytesWritten, NULL);
}
if (dwBytesTransferred > 0)
{
for (int p = 0; p < (int)dwBytesTransferred; p++)
{
for (int i=0; i<=3; i++)
{
xL = xL + (buff[p] & (1 << i));
xH = xH + ((buff[p] & (1 << (i+4)))>>4);
}
switch (xH)
{
case 0 : WriteFile (hFile, &cero, 1, &dwBytesWritten, NULL); break;
case 1 : WriteFile (hFile, &uno, 1, &dwBytesWritten, NULL); break;
case 2 : WriteFile (hFile, &dos, 1, &dwBytesWritten, NULL); break;
case 3 : WriteFile (hFile, &tres, 1, &dwBytesWritten, NULL); break;
case 4 : WriteFile (hFile, &cuatro, 1, &dwBytesWritten, NULL); break;
case 5 : WriteFile (hFile, &cinco, 1, &dwBytesWritten, NULL); break;
case 6 : WriteFile (hFile, &seis, 1, &dwBytesWritten, NULL); break;
case 7 : WriteFile (hFile, &siete, 1, &dwBytesWritten, NULL); break;
case 8 : WriteFile (hFile, &ocho, 1, &dwBytesWritten, NULL); break;
case 9 : WriteFile (hFile, &nueve, 1, &dwBytesWritten, NULL); break;
case 10 : WriteFile (hFile, &a, 1, &dwBytesWritten, NULL); break;
case 11 : WriteFile (hFile, &b, 1, &dwBytesWritten, NULL); break;
case 12 : WriteFile (hFile, &c, 1, &dwBytesWritten, NULL); break;
case 13 : WriteFile (hFile, &d, 1, &dwBytesWritten, NULL); break;
case 14 : WriteFile (hFile, &e, 1, &dwBytesWritten, NULL); break;
case 15 : WriteFile (hFile, &f, 1, &dwBytesWritten, NULL); break;
}
switch (xL)
{
case 0 : WriteFile (hFile, &cero, 1, &dwBytesWritten, NULL); break;
case 1 : WriteFile (hFile, &uno, 1, &dwBytesWritten, NULL); break;
case 2 : WriteFile (hFile, &dos, 1, &dwBytesWritten, NULL); break;
case 3 : WriteFile (hFile, &tres, 1, &dwBytesWritten, NULL); break;
case 4 : WriteFile (hFile, &cuatro, 1, &dwBytesWritten, NULL); break;
case 5 : WriteFile (hFile, &cinco, 1, &dwBytesWritten, NULL); break;
case 6 : WriteFile (hFile, &seis, 1, &dwBytesWritten, NULL); break;
case 7 : WriteFile (hFile, &siete, 1, &dwBytesWritten, NULL); break;
case 8 : WriteFile (hFile, &ocho, 1, &dwBytesWritten, NULL); break;
case 9 : WriteFile (hFile, &nueve, 1, &dwBytesWritten, NULL); break;
case 10 : WriteFile (hFile, &a, 1, &dwBytesWritten, NULL); break;
case 11 : WriteFile (hFile, &b, 1, &dwBytesWritten, NULL); break;
case 12 : WriteFile (hFile, &c, 1, &dwBytesWritten, NULL); break;
case 13 : WriteFile (hFile, &d, 1, &dwBytesWritten, NULL); break;
case 14 : WriteFile (hFile, &e, 1, &dwBytesWritten, NULL); break;
case 15 : WriteFile (hFile, &f, 1, &dwBytesWritten, NULL); break;
}
xL = 0x00;
xH = 0x00;
Byte = 0x00;
if (cuenta%16 == 0)
{
cuenta = 1;
WriteFile (hFile, &LF, 1, &dwBytesWritten, NULL);
}
else
{
cuenta++;
}
WriteFile (hFile, &spc, 1, &dwBytesWritten, NULL);
}
}
} while ((dwBytesTransferred == 1) && (auxbool = FALSE));
}
}
return 0;
}
/*****************************************************************/
|
|
|
|
|
I got interesting problem...
I wrote a programm, that parses a string (like CSV), but separating value is "#". This programm works ok on Asus MyPAL, Compaq, and works different on HP, it parses the string wrong... I can't understand... Please, anybody... help...
|
|
|
|
|
Can you please show the code?
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Yes, by the way - thank you very much for everything, you helps me so much, every time... You are my HERO!!!
Here is the code:
CFile f;
int ColumnsNumber;
int ColumnsLength;
char* Razdelitel = "?";
char* String;
if(f.Open((CString)DATA_DESTINATION+_T("Nomen.dat"),CFile::modeRead))
{
f.Read(&ColumnsNumber,sizeof(int));
f.Read(&ColumnsLength,sizeof(int));
char* data = new char[ColumnsLength+1];
data[ColumnsLength] = 0;
f.Read(data,ColumnsLength);
String = strtok(data,Razdelitel);
String = strtok(NULL,Razdelitel);
String = strtok(NULL,Razdelitel);
String = strtok(NULL,Razdelitel);
for(int i = 0;i<ColumnsNumber-4;i++)
{
CString str = strtok(NULL,Razdelitel);
Nomen::PRICESHEAD.push_back(str);
}
delete[] data;
data = new char[f.GetLength()-ColumnsLength-9];
f.Seek(ColumnsLength+9,CFile::begin);
f.Read(data,f.GetLength()-ColumnsLength-9);
Razdelitel = "#";
String = strtok(data,Razdelitel);
do
{
Nomen n;
n.m_FullPath = String;
n.m_Code = strtok(NULL,Razdelitel);
n.m_Name = strtok(NULL,Razdelitel);
n.m_Ostatok = strtok(NULL,Razdelitel);
for(unsigned int i = 0;i<Nomen::PRICESHEAD.size();i++)
{
n.m_Prices.push_back(strtok(NULL,Razdelitel));
}
CString temp;
for(i = 0;i<n.m_FullPath.GetLength();i++)
{
if(n.m_FullPath.GetAt(i)!=10)
temp+=n.m_FullPath.GetAt(i);
}
n.m_FullPath = temp;
temp = "";
for(i = 0;i<n.m_Name.GetLength();i++)
{
if(n.m_Name.GetAt(i)!=10)
temp+=n.m_Name.GetAt(i);
}
n.m_Name = temp;
m_Nomenklatura.push_back(n);
}
while(String = strtok(NULL,Razdelitel));
delete [] data;
}
else
{
MessageBox(NULL,_T("Can't load Nomen"),_T("Îøèáêà Çàãðóçêè Ôàéëà"),MB_ICONERROR);
}
f.Close();
Razdelitel = "?";
if(f.Open((CString)DATA_DESTINATION+_T("Agents.dat"),CFile::modeRead))
{
f.Read(&ColumnsNumber,sizeof(int));
f.Read(&ColumnsLength,sizeof(int));
char* data = new char[ColumnsLength+1];
data[ColumnsLength] = 0;
f.Read(data,ColumnsLength);
String = strtok(data,Razdelitel);
String = strtok(NULL,Razdelitel);
for(int i = 0;i<ColumnsNumber-2;i++)
{
KontrAgent::HEAD.push_back(strtok(NULL,Razdelitel));
};
delete[] data;
data = new char[f.GetLength()-ColumnsLength-9];
f.Seek(ColumnsLength+9,CFile::begin);
f.Read(data,f.GetLength()-ColumnsLength-9);
data[f.GetLength()-ColumnsLength-10] = 0;
Razdelitel = "#";
String = strtok(data,Razdelitel);
do
{
KontrAgent k;
k.m_Code = String;
k.m_Name = strtok(NULL,Razdelitel);
for(int i = 0;i<KontrAgent::HEAD.size();i++)
{
k.m_Columns.push_back(strtok(NULL,Razdelitel));
}
m_KontrAgents.push_back(k);
}
while(String = strtok(NULL,Razdelitel));
}
else
{
MessageBox(NULL,_T("Íå Ìîãó Çàãðóçèòü ôàéë êîíòðàãåíòîâ"),_T("Îøèáêà Çàãðóçêè Ôàéëà"),MB_ICONERROR);
}
the structure Nomen is
struct Nomen
{
CString m_FullPath;
CString m_Ostatok;
CString m_Code;
CString m_Name;
CString m_Quantity;
CString m_PriceType;
CString m_PriceTypeName;
vector <CString> m_Prices;
static vector <CString> PRICESHEAD;
};
and Kontratent is:
struct KontrAgent
{
CString m_Code;
CString m_Name;
vector <CString> m_Columns;
static vector <CString> HEAD;
};
|
|
|
|
|
Looks like you are mixing char with wchar_t . This may work but you have to know exactly what you are doing: is the file encoded in ANSI or UNICODE? If it is an ANSI file, my approach is to read it all into a buffer and convert, to UNICODE and then parse it.
Note that the difference you are expereiencing with the different machines may be due to different levels of support of the char string functions in the different machines (my guess).
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|