|
If you need to release the mouse capture and stop scrolling, I think you can try this sequence:
SetCapture();
ReleaseCapture();
I hope it helps.
|
|
|
|
|
Hi Everyone.... i am trying to get this piece of code working over a WAN connection, when i use it on a LAN it works ok.. but when i use it on a wan i can create the connection etc, create and remove directories etc, but as soon as i try to use the openfile function it crashes, does anyone have any ideas why ??
oh, i have tried to use passive rather than Active mode, when i do this i cant use the FtpFindFile function ??
just wondered if anyone had any pointers....
this is the snippet of code..
<br />
CInternetSession oISession(AfxGetAppName());<br />
CFtpConnection* poFtpConnection;<br />
<br />
poFtpConnection = oISession.GetFtpConnection(csSite,"xxx","xxxxx",2001,FALSE);<br />
<br />
poFtpConnection->GetCurrentDirectory(csCurDir);<br />
<br />
poFtpConnection->CreateDirectory(csDir);<br />
poFtpConnection->SetCurrentDirectory(csCurDir + csDir);<br />
<br />
CInternetFile* pInternetFile = poFtpConnection->OpenFile(csFile, GENERIC_WRITE,FTP_TRANSFER_TYPE_BINARY);<br />
<br />
The bold part is where it is falling down...
Any help would be appreciated..
Thanks
Lee
|
|
|
|
|
oh, forgot to say, i am using port forwarding in the router and the ports been used for the ftp is 2001...2009 i need to do it like this because i am going to have multiple connections to the router... i have used smartFTP and it connnects fine using with the port forwarding....
Lee
|
|
|
|
|
Have you stepped into the OpenFile() method to narrow the problem down further?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes, it is falling over at the FtpOpenFile method..., the m_hConnection is a valid handle but the hFile that gets returned is NULL ??
|
|
|
|
|
racing57 wrote: it is falling over at the FtpOpenFile method...
When that function fails, what does GetLastError() return?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i have everything in a try catch block, so when it fails its caught and at that point the getlasterror function returns 0 ???? its just baffling me, because it works ok on a lan...
|
|
|
|
|
racing57 wrote: i have everything in a try catch block...
So what exception is thrown?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
well when i try and call GetErrorMessage i get nothing back, and GetLastError returns 0.... i just cant get my head round whats happening ??? help!!!!!
|
|
|
|
|
little update.... if i change the port to 21 then it works ok... but i need the port to be something different, ie 2001-2009 as there will be more than one client from the router.... anyone got any ideas as to what could be causing it ??
thanks in advance
Lee
|
|
|
|
|
racing57 wrote: ...when i try and call GetErrorMessage i get nothing back, and GetLastError returns 0...
GetLastError() will only work if it's called right after the function that fails. This is apparently not possible in your case as other functions have been called that have reset the value to 0. However, since you have a try /catch block, you know the exception that is being thrown.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
how, if i call the geterrormessage function not is returned ??
|
|
|
|
|
ahhhh, the error message i am getting is 12001 - No more Internet handles can be allocated.... what could be causing this ??
|
|
|
|
|
Hi Everyone, i am still having this problem over a wan... can anyone shed any light on it for me ?? i'm getting kinda desperate to get it sorted now...
Thanks in advance
Lee
|
|
|
|
|
Hi. I want to use text that is not english in the VC6 in some string. I have an English version of VC6 and WIndows XP. I can write in say Chinese or whatever in Word etc because I have the language option set in XP. But in VC, I can not write in anything but English. All other characters come out as ???. Any ideas on who I can do this or if there is anyway for VC6 to support entry of non English char in an English version.
THANKS in advance
|
|
|
|
|
I think you need to compile your software application as UNICODE enabled. Should work that way ...
|
|
|
|
|
(VC++ 6.0 MFC MDI application)
I'm attempting to add file in use functionality to a MFC MDI application for the life of a CDocument. By default, the CDocument appears to lock the file only during serialization then it releases the file. I need to provide functionality not unlike MS Word where it remains locked during editting.
Just for proof of concept, to just see it work, and later make it a little bit more robust, I was providing implementation for OnOpenDocument, OnSaveDocument, and OnCloseDocument with the original MFC code in them. I made whatever modifications needed to prevent CDocument::ReleaseFile from being called while the file was open and I put a member variable in the CDocument class m_pFile to use to assist in keeping that file locked and open. I'm checking the lpszPathName against GetPathName() to determine when to use the stored pointer versus cleaning it up/closing and getting a new file/pointer.
The files get locked as expected but file Open/Save-SaveAs doesn't modify the file (A temporary file gets created/destroyed during the attempt). Only a New/Save-SaveAs (with a unique name) puts the serialized data into the file. Any ideas or has anyone successfully did this in an MDI app without ripping too much out to do it?
|
|
|
|
|
I think you should try a different way. Define a member of CFile type inside your document class, and then override OnOpenDocument , OnSaveDocument , and OnCloseDocument functions. In these functions call the original ones, but also add your code for locking and unlocking the file using additional CFile member (or maybe with some other features).
I suppose the functions may look like this:
BOOL CMyDocument::OnOpenDocument(LPCTSTR lpszPathName)
{
if( ! CDocument::OnOpenDocument(lpszPathName)) return FALSE;
m_MyFile.Open(lpszPathName, CFile::shareExclusive);
return TRUE;
}
void CMyDocument::OnCloseDocument()
{
m_MyFile.Close();
CDocument::OnCloseDocument();
}
BOOL CMyDocument::OnSaveDocument(LPCTSTR lpszPathName)
{
m_MyFile.Close();
if( ! CDocument::OnSaveDocument(lpszPathName)) return FALSE;
m_MyFile.Open(lpszPathName, CFile::shareExclusive);
}
I hope it works.
|
|
|
|
|
Thanks. I was overcomplicating the problem. I'll build upon this. Thanks for your help Viorel!
BOOL CFileLockTestDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
// Attempt to lock the file to indicate to others that this file is "in use"
if (m_File.Open(lpszPathName,CFile::modeReadWrite|CFile::shareExclusive)) {
return TRUE;
}
return FALSE;
}
BOOL CFileLockTestDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: Add your specialized code here and/or call the base class
if (m_File.m_hFile!=CFile::hFileNull) {
m_File.Close(); // Unlock the file
}
if (!CDocument::OnSaveDocument(lpszPathName)) {
return FALSE;
}
// Attempt to lock the file to indicate to others that this file is "in use"
if (m_File.Open(lpszPathName,CFile::modeReadWrite|CFile::shareExclusive)) {
return TRUE;
}
return FALSE;
}
void CFileLockTestDoc::OnCloseDocument()
{
// TODO: Add your specialized code here and/or call the base class
if (m_File.m_hFile!=CFile::hFileNull) {
m_File.Close(); // Unlock the file
}
CDocument::OnCloseDocument();
}
|
|
|
|
|
this is an image/text mixed interface and needs to be preview.
i think 2 ways to do preview (e.g. to 25%):
1) display 1:1 in memory DC then resize to 25% by StretchBlt() to visible DC.
2) draw 25% directly in memory DC or visible DC - if so, how to determine font height and width to exact 25% of original font size?
how do you do for print preview?
thx
|
|
|
|
|
Disclaimer: This is not exactly what your asking for but it provides a generic skeleton for your OnDraw stuff so that the view, print, and print preview size themselves dynamically in a fit to width fashion. It uses an arbitrary world space to draw in.
Here's a little to get you started. Start a new MFC/SDI app (CScrollView) and plop this stuff in the appropriate locations. Set up menu/toolbar buttons for the zoomin/zoomout. Add some drawing code to your OnDraw and you should find that the drawing is fit_to_width in the view and it should be fit to width when printing and print preview. The rest is up to you. have fun...
(Let me know if I missed something)
///////////////////////////////////////////////
//Constants
const int MAX_SCALE = 20; // The maximum scale factor
//CDocument members...
protected:
CSize m_DocSize;
CSize CYourDoc::GetDocSize() const
{
return m_DocSize;
}
CYourDoc::CYourDoc()
{
// TODO: add one-time construction code here
m_DocSize=CSize(2000,2800);
}
//CScrollView members...
protected:
int m_Scale;
CYourView::CYourView()
{
// TODO: add construction code here
m_Scale=1; // Set scale factor 1:1
SetScrollSizes(MM_TEXT,CSize(0,0)); // Set arbitrary values
}
void CYourView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CScrollView::OnPrepareDC(pDC);
// TODO: Add your specialized code here and/or call the base class
// Set up the DC for the current scale factor
int nExtentX;
int nExtentY;
CSize sizeDoc;
CRect rectClient;
// Allows the rectangle to include the bottom and rightmost logical unit
// SetGraphicsMode(pDC->m_hDC,GM_ADVANCED);
pDC->SetMapMode(MM_ISOTROPIC); // Allow scaling with aspect ratio preserved
// Get pertinent rectangle data
GetClientRect(&rectClient);
sizeDoc=GetDocument()->GetDocSize();
sizeDoc.cy=(-sizeDoc.cy); // Y goes down as it increments
pDC->SetWindowExt(sizeDoc); // Window extent is size of document
// Calculate viewport extent
nExtentX=(int)(GetScale()*rectClient.Width());
nExtentY=(int)((GetScale()*((nExtentX*sizeDoc.cy)/(sizeDoc.cx))));
// What kind of device context do we have?
if (pDC->IsPrinting()==TRUE) {
// Printer Context. Allow printing to edge of context. No scaling. Margins?
pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES),-pDC->GetDeviceCaps(VERTRES));
} else {
// Context is for screen
pDC->SetViewportExt(nExtentX,nExtentY);
}
}
int CYourView::GetScale()
{
return m_Scale;
}
void CYourView::SetScale(int nScaleFactor)
{
m_Scale=nScaleFactor;
ResetScrollBars(); // Adjust scrollbars to new scale
}
void CYourView::OnUpdateViewZoomout(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (GetScale()>=2) pCmdUI->Enable(TRUE);
else pCmdUI->Enable(FALSE);
}
void CYourView::OnUpdateViewZoomin(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (GetScale()<MAX_SCALE) pCmdUI->Enable(TRUE);
else pCmdUI->Enable(FALSE);
}
void CYourView::ResetScrollBars()
{
CSize sizeDoc;
CClientDC dc(this);
this->OnPrepareDC(&dc); // Update the device context
sizeDoc=GetDocument()->GetDocSize();
dc.LPtoDP(&sizeDoc); // Logical to device
this->SetScrollSizes(MM_TEXT,sizeDoc); // Update scrollbars
}
void CYourView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: calculate the total size of this view
ResetScrollBars();
}
void CYourView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
ResetScrollBars();
}
// Toolbar/menu button handler
void CYourView::OnViewZoomin()
{
// TODO: Add your command handler code here
if (GetScale()<MAX_SCALE) SetScale(GetScale()+1);
Invalidate();
}
// Toolbar/menu button handler
void CYourView::OnViewZoomout()
{
// TODO: Add your command handler code here
if (GetScale()>=2) SetScale(GetScale()-1);
Invalidate();
}
|
|
|
|
|
I don't know why there are so many funny guys on this forum.
are u sure I am not using a dialog box?
I suggest u delete ur reply so my post is clear.
|
|
|
|
|
|
Hi
I'm trying to extend Marco Zaratti's CCESocket class to cater for multicasting.
I'm just getting to grips with both winsock and multicasting but have come to a brick wall.
The basic pseudocode of Marco's class goes like this:
CCESocket::Create(SOCK_DGRAM)
s = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP)
[my overridden function]
CMultiSock::Accept(localPort,localAddress)
CCESocket::Accept(localport)
m_localAddress.sin_family = AF_INET;
m_localAddress.sin_port = htons(localPort);
m_localAddress.sin_addr.s_addr = htonl(INADDR_ANY);
bind(s, (SOCKADDR*) &m_localAddress, sizeof(SOCKADDR_IN))
recvfrom(s,buf, bufSize, 0, (SOCKADDR*)&m_localAddress, &m_receiveAddrSz);
return
[my extra code to add multicast functionality in overridden Accept func]
<code>m_mReq.imr_multiaddr.s_addr = inet_addr("234.5.6.7");
m_mReq.imr_interface.s_addr = INADDR_ANY;
m_localAddress.sin_addr.S_un.S_addr = inet_addr("234.5.6.7");
m_localAddress.sin_port = localport;
setsockopt(s,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&m_mReq,sizeof(ip_mreq));
CreateEvent(NULL,FALSE,FALSE,L"Multicast-Event");
setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, (char *)&addr,sizeof(addr));
int TTL = 32 ;
nRet = setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL,(char*)&TTL, sizeof(TTL));
int loop = 1;
setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP,(char*)&loop, sizeof(loop));</code>
all returns are checked and this section has no problems
when I attempt to do a CCESocket::Send, the method goes through the accepting case, and sends to localaddress.
case SOCK_DGRAM:
if(m_udpReadyToSend)
{
while(len > 0)
{
if(m_socketState == ACCEPTING)
sentBytes = sendto(s, &buf[dataPtr], len, 0, (SOCKADDR*) &m_localAddress, sizeof(m_localAddress));
else
sentBytes = sendto(s, &buf[dataPtr], len, 0, (SOCKADDR*) &m_remoteAddress, sizeof(m_remoteAddress));
.
.
.snip
except it fails with error WSAEINVAL.
if I change the address to match the multicast address it still fails.
does anyone know what could be the problem?
Alistair
-- modified at 10:28 Thursday 3rd August, 2006
|
|
|
|
|
For extra info, this is compiled into a plain WIN32 MFC app on XP, with an eye to put it on a CE device, but my problem is firstly in the Full WIN32 environment, on VS2005 and Win XP
Thanks
-- modified at 11:08 Thursday 3rd August, 2006
|
|
|
|
|