|
Hello,
when I move my mousepointer of a MSFlexgrid is there any way to find out, which cell/row is pointed? I need this, because I wan't to display further information about cell-data.
|
|
|
|
|
I've been taking my project back and forth between my home and work machines (win2K and XP) and each time a perfectly working version on one will crash on the other until I do a rebuild all. Then it works fine! I suddenly realized (and am aghast ) that this means I have to rebuild on the users machine - Impossible. SO what are my options? WOuld it work on all XPs if I distributed a version built on XP, and on all WIn2K if I distributed a version built on Win2K? Does this happen to you. Why does it happen and how to you get around this? I dont touch the code at all on either machine. Just a Rebuild All and the program works perectly. Incidentally its both the release and debug versions that I have to rebuild.
Thanks,
ns
|
|
|
|
|
Rebuild All doesn't compare the modification dates of source/obj/exe files. Normal build minimizes the work and doesn't compile source files when corresponding obj is already present and has later date.
Maybe date/time clocks on your machines aren't in sync?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Nope, the clocks are synced except for perhaps a few minutes difference.
|
|
|
|
|
But you're moving source between computers, not .exe?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
This is true. I've only been testing the perfectly working version from the debugger. I'll try to run the exe from the release and debug folder. Maybe that will not crash. What is the reason that the source needs rebuilt?
Thanks,
ns.
Do you feel certain that the exe from the debug/release folder wont crash? I cant check it out till tonight (the machines at home).
|
|
|
|
|
ns wrote:
What is the reason that the source needs rebuilt?
I'd say that there's 90% chance the problem isn't related to rebuild. But still, there's 10% left
Can you compare the release binaries produced on both machines?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
I will next time it happens. First I have to go figure out how one compares release binaries! THe only thing I know is WinDiff and I've used it only for text files. So if the binaries are different then its a clue indicating what? Sorry to keep bothering you with my questions.
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
THe only thing I know is WinDiff
fc /b from the command line.
Binaries should be (almost) identical. I believe there's some date/time stamp in the PE file. Other differences may indicate different versions of DLLs you're linking with at runtime.
BTW: if debug build crashes, you should easily pinpoint the problem.
Another thing: are you using #import?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Tomasz Sowinski wrote:
Binaries should be (almost) identical. I believe there's some date/time stamp in the PE file.
It's semi-documented how to avoid this (sort of). Look up the environment variable LINK_REPRO in MSDN. When set it makes the linker set the PE timestamp to 2^32-1 (i.e. 0xffffffff).
|
|
|
|
|
Cool! How did you find this variable? Late night debugging session?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
I certainly am using #import. Is this known to cause a problem like this?
Thanks for the binary comparing info.
ns
|
|
|
|
|
Instead of a debug exe build a release exe and take it home and run it. If it works then you are OK. If it does not, then you need to worry about the DLLs your exe is using and various dependency and version issues. It should not happen but yo never know.
|
|
|
|
|
Does it also crash if you start the exe or just when started from the IDE ?
It could be differences in the MFC dll's or something like that(?). If so you could use static linking so the exe would run on any version.
Check for compiler warnings.
Good luck
Rutger
|
|
|
|
|
Isnt it a fact that you can only choose static or dynamic linking at the very start of the program? Can you switch at this stage (midway), How do you do that? I saw such an option when I created the app using the appwizard.
Thanks so much,
ns
|
|
|
|
|
ns wrote:
snt it a fact that you can only choose static or dynamic linking at the very start of the program? Can you switch at this stage (midway), How do you do that? I saw such an option when I created the app using the appwizard.
Thanks so much,
You can change it if you go to Project->settings (or press <ALT>+F7) then you will see the general tab where you can select how to use the MFC (options are not at all, shared or static)
Regards
Rutger
|
|
|
|
|
It happened to me too and I finally found the reason: if one of your machines has "Microsoft .NET platform" installed and the other doesn't, the problem arises. Then I completely removed .NET from my machine and the problem is gone.
I'm not sure if this solves your problem but that's how I solved mine.
|
|
|
|
|
well, I did install the .net beta last year. Maybe some residual side effect. Thanks,
ns
So I should build on my XP which has never met .net...hopefully that will be okay.
|
|
|
|
|
Hi,
I was playing around a little with .Net, just for fun and created a dialog based project. I added a button to my dialog and created an OnBnClickedButton1() function. But I tried to make this function return a BOOL rather than being void.
I then get the following error message:
error C2440: static_cast: cannot convert from BOOL(__thiscall CSampleDlg::*)(void) to AFX_PMSG.
Anyone can explain to me how does one make this function return something. Or is it not allowed in .Net?
Thanks
Regards
Rui
|
|
|
|
|
VC.NET has improved type checking in message maps. The header of your function is simply not compatible with ON_CONTROL event handler.
Anyway, it's MFC who calls your handler - so return value is ignored.
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Modifying signature of message handlers were never recommended...
|
|
|
|
|
I'm truing to make cd-label app, so...
How can i add text, from textbox, into bitmap and save them together in bmp, or jpg?
|
|
|
|
|
|
Hi there !
My problem is as follows:
I have a CFtpConnection and there are some cases, that it is blocking.
I already put it into a thread, everything is working good, but: When it blocks, how can i kill it (like TerminateThread() , but this is not cleaning up...)
Thanx in advance!
Olli
I feel like I'm diagonally parked in a parallel universe.....
|
|
|
|
|
I would recommend to use async monikers instead of MFC classes such like CFtpConnection and so on.
In a previous project, I just derived my class from IBindStatusCallback and implemented a few methods required for data transfer. The good news is that I could stop the transfer at any moment properly, hence achieving what you are looking for.
Below is a sample code that did a http://... file transfer :
class CXmlInternetFileManager : public CXmlFileManager, public IBindStatusCallback
{
protected:
long m_cRef;
char m_szProxy[MAX_PATH];
int m_nProxyPort;
IBinding* m_pBinding;
IStream* m_pStream;
HWND m_hwndStatus;
FILE *m_tmpFile;
BOOL m_bStop_EvrythingIsReceived;
DWORD m_dwLoadedSoFar;
DWORD m_dwOffsetReadByClient;
public:
CXmlInternetFileManager();
virtual ~CXmlInternetFileManager();
virtual BOOL Open(char *szURL);
virtual BOOL Read(char *szInputBuffer, int nMaxLength, int &nActualLength);
virtual BOOL Close();
public:
virtual HRESULT __stdcall QueryInterface(const IID& iid, void** ppv) ;
virtual ULONG __stdcall AddRef() ;
virtual ULONG __stdcall Release() ;
virtual HRESULT STDMETHODCALLTYPE OnStartBinding(
DWORD dwReserved,
IBinding __RPC_FAR *pib);
virtual HRESULT STDMETHODCALLTYPE GetPriority(
LONG __RPC_FAR *pnPriority);
virtual HRESULT STDMETHODCALLTYPE OnLowResource(
DWORD reserved);
virtual HRESULT STDMETHODCALLTYPE OnProgress(
ULONG ulProgress,
ULONG ulProgressMax,
ULONG ulStatusCode,
LPCWSTR szStatusText);
virtual HRESULT STDMETHODCALLTYPE OnStopBinding(
HRESULT hresult,
LPCWSTR szError);
virtual HRESULT STDMETHODCALLTYPE GetBindInfo(
DWORD __RPC_FAR *grfBINDF,
BINDINFO __RPC_FAR *pbindinfo);
virtual HRESULT STDMETHODCALLTYPE OnDataAvailable(
DWORD grfBSCF,
DWORD dwSize,
FORMATETC __RPC_FAR *pformatetc,
STGMEDIUM __RPC_FAR *pstgmed);
virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable(
REFIID riid,
IUnknown __RPC_FAR *punk);
private:
CXmlInternetFileManager& operator=(const CXmlInternetFileManager &obj);
};
#include "stdafx.h"
#include "XmlFileManager.h"
CXmlInternetFileManager::CXmlInternetFileManager() : m_cRef(0)
{
}
CXmlInternetFileManager::~CXmlInternetFileManager()
{
Close();
}
CXmlInternetFileManager& CXmlInternetFileManager::operator=(const CXmlInternetFileManager &obj)
{
return *this;
}
HRESULT CXmlInternetFileManager::QueryInterface(const IID& iid, void** ppv)
{
if (iid == IID_IUnknown)
{
*ppv = static_cast<IBindStatusCallback*>(this) ;
}
else if (iid == IID_IBindStatusCallback)
{
*ppv = static_cast<IBindStatusCallback*>(this) ;
}
else
{
*ppv = NULL ;
return E_NOINTERFACE;
}
reinterpret_cast<IUnknown*>(*ppv)->AddRef() ;
return S_OK ;
}
ULONG CXmlInternetFileManager::AddRef()
{
return InterlockedIncrement(&m_cRef) ;
}
ULONG CXmlInternetFileManager::Release()
{
if (InterlockedDecrement(&m_cRef) == 0)
{
delete this ;
return 0 ;
}
return m_cRef ;
}
BOOL CXmlInternetFileManager::Open(char *szURL)
{
HRESULT hr;
if (!szURL || strlen(szURL)==0)
return FALSE;
m_dwLoadedSoFar=0;
m_dwOffsetReadByClient=0;
m_bStop_EvrythingIsReceived = FALSE;
strcpy(m_szURL, szURL);
m_tmpFile = fopen("c:\\test.txt","w+b");
IBindCtx *pbc=NULL;
hr = CreateAsyncBindCtx(0, this , NULL, &pbc);
if (FAILED(hr))
return FALSE;
IMoniker *pmk=NULL;
WCHAR *swzURL = new WCHAR[strlen(szURL)+1];
::MultiByteToWideChar(CP_ACP, 0, szURL, -1, swzURL, strlen(szURL)+1);
hr = CreateURLMoniker(NULL, swzURL, &pmk);
if (FAILED(hr))
return FALSE;
hr = pbc->RegisterObjectParam(SZ_ASYNC_CALLEE, pmk);
if (FAILED(hr))
return FALSE;
IStream* pStream;
hr = pmk->BindToStorage(pbc, NULL, IID_IStream, (void**) &pStream);
if (FAILED(hr))
return FALSE;
delete [] swzURL;
return TRUE;
}
BOOL CXmlInternetFileManager::Read(char *szInputBuffer, int nMaxLength, int &nActualLength)
{
while(1)
{
peekMessage();
nActualLength = 0;
if ( m_dwOffsetReadByClient < m_dwLoadedSoFar)
{
long nAvailable = m_dwLoadedSoFar - m_dwOffsetReadByClient;
if (nAvailable>nMaxLength-1)
nAvailable = nMaxLength-1;
fseek(m_tmpFile,m_dwOffsetReadByClient,SEEK_SET);
nActualLength = fread(szInputBuffer, 1, nAvailable, m_tmpFile);
szInputBuffer[nActualLength]='\0';
m_dwOffsetReadByClient += nAvailable;
return TRUE;
}
if (m_bStop_EvrythingIsReceived)
return TRUE;
}
}
BOOL CXmlInternetFileManager::Close()
{
if (m_tmpFile)
{
fclose(m_tmpFile);
m_tmpFile=NULL;
}
return TRUE;
}
HRESULT STDMETHODCALLTYPE CXmlInternetFileManager::OnStartBinding(
DWORD dwReserved,
IBinding __RPC_FAR *pib)
{
m_pBinding = pib;
m_pBinding->AddRef();
m_pStream = NULL;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CXmlInternetFileManager::GetPriority(
LONG __RPC_FAR *pnPriority)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CXmlInternetFileManager::OnLowResource(
DWORD reserved)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CXmlInternetFileManager::OnProgress(
ULONG ulProgress,
ULONG ulProgressMax,
ULONG ulStatusCode,
LPCWSTR szStatusText)
{
return(NOERROR);
}
HRESULT STDMETHODCALLTYPE CXmlInternetFileManager::OnStopBinding(
HRESULT hresult,
LPCWSTR szError)
{
m_pBinding->Release();
m_pBinding = NULL;
m_pStream = NULL;
m_bStop_EvrythingIsReceived = TRUE;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CXmlInternetFileManager::GetBindInfo(
DWORD __RPC_FAR *grfBINDF,
BINDINFO __RPC_FAR *pbindinfo)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CXmlInternetFileManager::OnDataAvailable(
DWORD grfBSCF,
DWORD dwSize,
FORMATETC __RPC_FAR *pformatetc,
STGMEDIUM __RPC_FAR *pstgmed)
{
if (m_pStream==NULL)
m_pStream = (IStream*) pstgmed->pstm;
if (0)
{
m_pBinding->Abort();
}
else
{
if (dwSize > m_dwLoadedSoFar)
{
DWORD dwRead = dwSize - m_dwLoadedSoFar;
DWORD dwActuallyRead;
char *buf = new char[dwRead];
m_pStream->Read(buf, dwRead, &dwActuallyRead);
fseek(m_tmpFile,0,SEEK_END);
fwrite(buf,1,dwActuallyRead,m_tmpFile);
delete buf;
m_dwLoadedSoFar = dwSize;
}
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CXmlInternetFileManager::OnObjectAvailable(
REFIID riid,
IUnknown __RPC_FAR *punk)
{
return S_OK;
}
And I swallow a small raisin.
|
|
|
|