|
// LinkSocket.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "LinkSocket.h"
#include "ServerDlg.h"
#include "Server.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLinkSocket
CLinkSocket::CLinkSocket(CServerDlg* pDlg)
{
m_pDlg = pDlg;
}
/////////////////////////////////////////////////////////////////////////////
// CLinkSocket member functions
CLinkSocket::~CLinkSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CLinkSocket, CSocket)
//{{AFX_MSG_MAP(CLinkSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
IMPLEMENT_DYNAMIC (CLinkSocket, CSocket)
void CLinkSocket::OnReceive(int nErrorCode)
{
CSocket::OnReceive(nErrorCode);
m_pDlg->Read(this);
}
|
|
|
|
|
// ServerDlg.h : header file
//
#if !defined(AFX_SERVERDLG_H__68FD52BF_0A0E_4EF9_8F71_52B633DED1A3__INCLUDED_)
#define AFX_SERVERDLG_H__68FD52BF_0A0E_4EF9_8F71_52B633DED1A3__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "afxwin.h"
#include "LinkSocket.h"
#include "ListenSocket.h"
/////////////////////////////////////////////////////////////////////////////
// CServerDlg dialog
class CServerDlg : public CDialog
{
// Construction
public:
CServerDlg(CWnd* pParent = NULL); // standard constructor
struct Packet
{
int packetno;
int cstatus;
char UserID[10];
char Message[20];
};
Packet RPacket;
Packet SPacket;
int State;
CListenSocket* lSocket;
CLinkSocket* eSocket;
CString screen;
void pAccept(void);
void Read(CLinkSocket* eSocket);
// Dialog Data
//{{AFX_DATA(CServerDlg)
enum { IDD = IDD_SERVER_DIALOG };
CButton m_bStop;
CButton m_bListen;
CButton m_bDisconnect;
CString m_sStatus;
int m_sPort;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CServerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CServerDlg)
virtual BOOL OnInitDialog();
afx_msg void OnHelpInfo();
afx_msg void OncmdDisconnect();
afx_msg void OncmdListen();
afx_msg void OncmdStop();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SERVERDLG_H__68FD52BF_0A0E_4EF9_8F71_52B633DED1A3__INCLUDED_)
|
|
|
|
|
// ServerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Server.h"
#include "ServerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CServerDlg dialog
CServerDlg::CServerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CServerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CServerDlg)
m_sStatus = _T("");
m_sPort = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CServerDlg:oDataExchange(CDataExchange* pDX)
{
CDialog:oDataExchange(pDX);
//{{AFX_DATA_MAP(CServerDlg)
DDX_Control(pDX, IDC_cmdStop, m_bStop);
DDX_Control(pDX, IDC_cmdListen, m_bListen);
DDX_Control(pDX, IDC_cmdDisconnect, m_bDisconnect);
DDX_Text(pDX, IDC_Status, m_sStatus);
DDX_Text(pDX, IDC_Port, m_sPort);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CServerDlg, CDialog)
//{{AFX_MSG_MAP(CServerDlg)
ON_WM_HELPINFO()
ON_BN_CLICKED(IDC_cmdDisconnect, OncmdDisconnect)
ON_BN_CLICKED(IDC_cmdListen, OncmdListen)
ON_BN_CLICKED(IDC_cmdStop, OncmdStop)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CServerDlg message handlers
BOOL CServerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
State = 0;
GetDlgItem(IDC_cmdDisconnect) -> ShowWindow(FALSE);
GetDlgItem(IDC_cmdStop) -> EnableWindow(FALSE);
GetDlgItem(IDC_cmdListen) -> ShowWindow(TRUE);
screen.Empty();
SPacket.packetno = 0;
return TRUE; // return TRUE unless you set the focus to a control
}
void CServerDlg::OnHelpInfo()
{
MessageBox(_T("Help"));
}
//Listen Function
void CServerDlg::OncmdListen()
{
UpdateData(TRUE);
lSocket = new CListenSocket(this);
int Port;
Port = m_sPort;
//char* txtPort;
//int i = m_sPort;
//_itoa(i, txtPort, 10);
//MessageBox(txtPort,NULL,MB_OK);
//If cannot create port
if (!lSocket->Create(Port))
{
MessageBox(_T("No port Created!"), NULL, MB_OK);
return;
}
else
{
}
//If cannot listen
if (!lSocket->Listen())
{
MessageBox(_T("Cannot listen"), NULL, MB_OK);
return;
}
else
{
MessageBox(_T("Listening"), NULL, MB_OK);
GetDlgItem(IDC_cmdListen) -> EnableWindow(FALSE);
GetDlgItem(IDC_cmdStop) -> EnableWindow(TRUE);
State = 1;
}
}
//Accept Function
void CServerDlg::pAccept(void)
{
eSocket = new CLinkSocket(this);
if (lSocket->Accept(*eSocket))
{
State = 2;
MessageBox(_T("Connection Accepted!"), NULL, MB_OK);
GetDlgItem(IDC_cmdStop) -> ShowWindow(FALSE);
GetDlgItem(IDC_cmdDisconnect) -> ShowWindow(TRUE);
}
else
{
MessageBox(_T("Connection not Accepted!"), NULL, MB_OK);
delete eSocket;
}
}
// Read Function
void CServerDlg::Read(CLinkSocket* eSocket)
{
CString strcommand;
int pRead = eSocket->Receive(&RPacket, sizeof(Packet));
if (pRead > 0)
{
if (RPacket.cstatus == 0)
{
OncmdDisconnect();
}
else
{
//command = mbstowcs(buffer, RPacket.Message, 100)
}
}
}
void CServerDlg::OncmdStop()
{
GetDlgItem(IDC_cmdListen) -> EnableWindow(TRUE);
GetDlgItem(IDC_cmdDisconnect) -> EnableWindow(FALSE);
SPacket.cstatus = 0;
lSocket->Close();
delete lSocket;
GetDlgItem(IDC_cmdListen) -> EnableWindow(TRUE);
GetDlgItem(IDC_cmdStop)-> EnableWindow(FALSE);
State = 0;
}
// Disconnect Function
void CServerDlg::OncmdDisconnect()
{
SPacket.cstatus = 0;
eSocket->Close();
lSocket->Close();
delete eSocket;
delete lSocket;
GetDlgItem(IDC_cmdDisconnect) -> ShowWindow(FALSE);
GetDlgItem(IDC_cmdStop) -> ShowWindow(TRUE);
State = 1;
}
|
|
|
|
|
I have realised what is the root of my problem: I am somehow unable to override my clistensocket::onaccept function. I have tried the solution u have posted and my own method of transfering the clistensocket::onaccept function to the main dialog classes but still I am unable to override my function. So, can any experts point why did I go wrong?
|
|
|
|
|
Hi all,
I am currently developing a PocketPC application using SqlCe2.0 and Evc++ 3.0. I am using SSCEOLEDB.
I saw the following thread in google
http://groups.google.co.in/groups?q=memory+leaks+in++ssceoledb&hl=en&lr=&ie=UTF-8&selm=078301c33c6c%24de966a80%24a301280a%40phx.gbl&rnum=1
regarding the memory leaks in SqlCe2.0 and EVC++ 3.0.
I am into the same problem now.
Memory leaks occurs every time i execute ICommandText->Execute() method.
I heard that memory leak occurs due to ICommandText->Execute() when we use Oledb for oracle. Does the same problem occurs in SqlCe2.0?
Kindly send your suggestions.
|
|
|
|
|
Greetings to all,
I am in need of some sample code or documentation (something, ANYTHING) to get me started. I've just been thrown into the CE development arena and need to write an Owner Drawn ListBox Control that will run under CE. It needs to display different fonts, fontcolor, and background colors on a line by line basis. I've not worked with CE and need a place to start. Any suggestions would be appreciated.
Christopher Reiff
|
|
|
|
|
Christopher Reiff wrote:
Owner Drawn ListBox in CE???
No freakin' way... (no OS support)
Use the list view control instead: one column and a custom draw bonanza to fill in your wildest dreams (and there are lots of articles here on CP too).
But if you really really really must use a list box, try these general principles (good luck - it's not easy ):
QA: How do I create a combo box with check marks?[^]
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Thank you João,
I'll give the list view control a shot and see what happens.
-Chris
|
|
|
|
|
i am developing a freeware app for pocket pc and am seeking an mp3
player component that from code, i can make play, pause, jump to a specific
time in the track, and read the elapsed time (pref in seconds) and
total track time. something that lets you control the play bar or view the
file graphically (waveform) as it plays and click on a portion to jump
play to that part would be nice but not necessary.
currently the only thing i've found is this cfcom product by odyssey
that lets you embed windows media player, but it's way too expensive and
has too limited license for the $ (i would pay for such a component as long as it was affordable but $400 ain't!)
does anyone know about anything that might work? someone at opencfnet.org found a way to p-invoke WMP, but you can't read the elapsed time or tell the player to jump forward to a specific time so that won't do for my purposes.
i am working in vb.net for compact framework, so either a .NET
assembly that i could include in my project, or vb.net or c# code would be
best c++ would be way over my head.
any information or advice would be most appreciated!
|
|
|
|
|
Hello !!
I have a question about making the cab file with cabWizzard (using an inf file).
I need to install a complete application on the pocket PC. This application supports multiple language. I have a resource directory in wich there is a sub-directory for each language. In each of these subdirectories, there are files containing the string in a specified language. So, the files from the different sub-directories have the SAME names.
For example:
....\MEC\NLS\FR -> contains the file PDI.str with the strings in french
....\MEC\NLS\ENG -> contains the file PDI.str with the strings in english
So now in my inf file (in order to construct the cab file), how do I specify that for the french resources, I need the PDI.str in the FR directory and for the english resources, I need the PDI.str in the ENG directory.
I wrote something like that:
[DefaultInstall]<br />
CopyFiles = BinaryFiles, FrenchResources, DutchResources<br />
<br />
[SourceDisksNames]<br />
1 = ,"Common files",,C:\MEC\Sources Pocket\Pocket Download\BIN<br />
2 = ,"French resources",,C:\MEC\Sources Pocket\Pocket Download\NLS\FR<br />
3 = ,"Dutch resources",,C:\MEC\Sources Pocket\Pocket Download\NLS\NEE<br />
<br />
<br />
[SourceDisksFiles]<br />
PDI Lite.exe = 1<br />
PDI.str = 2<br />
PDI.str = 3<br />
<br />
<br />
[DestinationDirs]<br />
BinaryFiles = 0, %InstallDir%\BIN<br />
FrenchResources = 0, %InstallDir%\NLS\FR <br />
DutchResources = 0, %InstallDir%\NLS\NEE<br />
<br />
<br />
[BinaryFiles]<br />
"PDI Lite.exe"<br />
<br />
[FrenchResources]<br />
"PDI.str"<br />
<br />
[DutchResources]<br />
"PDI.str"<br />
...And magically, that does work but I don't know why ? How can the cabwizzard differenciate the two PDI.str in SourceDisksFiles entry ???
Another little question: how can I copy dll's and register them automatically (with specifying something in the .inf file) ?
Thanks for your responses
|
|
|
|
|
Ooops... No sorry, in fact that doesn't work .
In this case, for the French and Dutch resources, the same file will be copied, that is the file in Dutch (the last one in the SourceDisksFiles entry).
How can I specify that in the %InstallDir%\NLS\FR I want the file that comes from the ....\MEC\NLS\FR directory on the desktop PC and that in the %InstallDir%\NLS\NEE directory I want the file from the ....\MEC\NLS\NEE directory ???
Thanks
|
|
|
|
|
Hi floks,
I want to download emails having attachements from email server (lets say hotmail.com) to PDA(wince3.0 and pocket 2002) into perticular directory(attachment only)
How can we download these files from sever ? Please let me know I am in urgent need.
Thanks in advance
Naresh
|
|
|
|
|
Hi All,
I am trying to store the large objects into SqlCe database. I have the datatype as image in the sql ce. The data to be stored is available as BYTES. Could anyone suggest me some solutions to achieve the same.
I tried to save by executing the commandtext. But i was not able to build a query using the byte data. I tried to use the IRowsetChange interface wherein i retrieve a rowset and update the same using the IRowsetChange->SetData(...) method. I was not able to store the data still and the program doesnt execute beyond the setdata method.
Any suggestion in this regard will be helpful.
Development environment:
EVC3.0
SqlCe.
rmkmani.
|
|
|
|
|
|
Hi~
Lei wrote
"I have 2 forms, form1 contains a ListView. What I want to do is, when
clicking an item in the ListView, hide form1 and show form2. Code for
ListView's SelectedIndexChanged: { form2.Show(); this.Hide(); }. When I
click the item, form2 shows with form1's title and menu. I noticed that when mouse down, the SelectedIndexChanged event was triggered and bring form2 to front. But when mouse up, system redrawed the selected item and bring title and menu back to form1's. I tried to handle MouseDown and MouseUp event of ListView but they were never triggered. Now I used a tricky way to solve the problem: start a thread and use Control.Invoke to switch forms. It is not good, I think there must be a better solution. Thanks."
I am facing the same problem. Someone solve it with setting timer. However, is there any other way to solve it?
Thanks~
|
|
|
|
|
Hi,
Is there any DataGrid ActiveX for eVC++ 4.0 ?!
Regards,
Hadi
|
|
|
|
|
Not an ActiveX, but one of the most successful articles here on CodeProject also works on CE:
MFC Grid control 2.25[^]
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Oh yes, i knew MFC Grid but i didn't know it could works on CE too
Thanks alot Chris, Thanks alot João
Regards,
Hadi
|
|
|
|
|
Hi~
Lei wrote
"I have 2 forms, form1 contains a ListView. What I want to do is, when
clicking an item in the ListView, hide form1 and show form2. Code for
ListView's SelectedIndexChanged: { form2.Show(); this.Hide(); }. When I
click the item, form2 shows with form1's title and menu. I noticed that when mouse down, the SelectedIndexChanged event was triggered and bring form2 to front. But when mouse up, system redrawed the selected item and bring title and menu back to form1's. I tried to handle MouseDown and MouseUp event of ListView but they were never triggered. Now I used a tricky way to solve the problem: start a thread and use Control.Invoke to switch forms. It is not good, I think there must be a better solution. Thanks."
I am facing the same problem. Someone solve it with setting timer. However, is there any other way to solve it?
Thanks~
|
|
|
|
|
I need to display data in a grid with bitmap (icon) in cell depending on the data
It's not possible to override the Paint methods of DataGridTextBoxColumn in the compact framework
Is there any way to have such a datagrid (with bitmap for each cell) based on the .NET compact framework datagrid ?
|
|
|
|
|
HI~
I have ever tried to use form as a dialog box but it occupy the whole screen
How to make a dialog box that not cover the whole screen?
I don't want it cover the parent application
thank
|
|
|
|
|
Hi,
I don't know what's wrong with below code, When I run this It always return the first record.
pRecCus->Find( _bstr_t("Code=" + strCusCode), 0, adSearchForward, 1L ); <br />
if( !pRecCus->adoEOF )<br />
{<br />
m_List.SetItemText( i, 1, (LPCTSTR)((_bstr_t)pRecCus->GetFields()->GetItem(_variant_t("Name"))->Value) );<br />
}
Regards,
Hadi
|
|
|
|
|
How to operate with this format. Actually i'd like to have a Server side (some terminal) and a lot of pocket pcs. And i want to transfer messages thru the GSM format between them. Is It Possible, and where to find info about this.
Thanks.
|
|
|
|
|
please explain more ; so we can understand
|
|
|
|
|
Hi,
I think that he has the same problem of mine. He wants to connect; using ppc with internal/external GSM cell phone like modem (my is internal), to another PC and transfert data in several ways. Like a terminal application, using AT command to connect ATDT ...
I've posted some question aboit TAPI, but if you know anything ... please any suggestion is gold for me.
Thanks in advance.
Montons
|
|
|
|
|