|
Ok I have forgotten to say, if the entry correct send a message to a server!
Update the Database about time and Date!
I have a subclass DCCombobox!
/* --------------------------------------------------------------------
* Message-Map definieren
* ------------------------------------------------------------------
*/
BEGIN_MESSAGE_MAP(DCComboBox, CComboBox)
ON_WM_KEYUP()
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
int DCComboBox::OnCreate( LPCREATESTRUCT lpCreateStruct ){
return CComboBox::OnCreate(lpCreateStruct);
}
void DCComboBox::OnKeyDown(UINT nChar,UINT nRepCnt,UINT nFlags ) {
CWnd* parent = GetParent();
if( parent )
parent->PostMessage( WM_KEYDOWN,(WPARAM)nChar,
MAKELONG (nRepCnt,nFlags) );
CComboBox::OnKeyDown(nChar,nRepCnt,nFlags);
}
void DCComboBox::OnKeyUp(UINT nChar,UINT nRepCnt,UINT nFlags ) {
CWnd* parent = GetParent();
if( parent )
parent->PostMessage( WM_KEYUP, (WPARAM)nChar,
MAKELONG(nRepCnt,nFlags) );
CComboBox::OnKeyUp(nChar,nRepCnt,nFlags);
}
|
|
|
|
|
You're simply not making any sense. I am completely loss of what you are trying to do.
Ask a friend of yours to do an accurate translation of what you want to do and post that as a message. Otherwise we cannot help you any further, as we can't understand your motives at all.
The code you posted works correctly, as far as I can tell: it posts a message to the parent window when a keyboard event is received in the combo box control. Is this what you wanted to do ?
What is this 'send a message to server' ? What server ? Time ? Date ?? Database ??? You've completely shaken us. Start forming your problem anew, and this time ask a friend who has qualified english skills to translate it for you, so it will be easier for us to read.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
i have made an app which connects to IE and Netscape via DDE and tells the currently loaded URL
it is working fine with IE but
not with Netscape
netscape connects with NSShell,NETSCAPE and NSCMDLINE
but doesn't tell the URL
which of these three should i connect too
please Help
|
|
|
|
|
Looking at the Netscape's DDE Implementation guide (found here[^]), following details are described:
The DDE service name for Netscape browser is 'NETSCAPE'. The request for obtaining information about a page shown in a window can be obtained by sending a WWW_GetWindowInfo request, which is of type XTYP_REQUEST .
You can see these topics yourself by going to the specified web page.
Here is an MSDN link about using DDE for your convinience: Using Dynamic Data Exchange[^]
Hope this helps,
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
i have 2 list control says IDC_LIST1 and IDC_LIST2.
I am not using class wizard here. I am declaring in header file using afxmessage ie. afx_msg void OnItemclickList1(NMHDR* pNMHDR, LRESULT* pResult);
and on_NOTIFY ie ON_NOTIFY(HDN_ITEMCLICK, 0, OnItemclickList1)
I have one more list control ie IDC_LIST2 when i declare afxmessage and ON_NOTIFY, the control do not go there. it goes only for the first control.
even after giving the proper ID of the control instead of giving zero. I tried using the single function and then by finding out the ID, but it gives the same id for both the control, i dont get the id of the control( it could be id of the view where this control are placed).
what should be declaration in the BEGIN MESSAGE , END MESSAGE MAP. and how do i differentiate between this 2 controls.
abdul
|
|
|
|
|
hi people ,
any idea about how to convert a jpg/bmp file to .pcx format......
i also have to save the bmp file into vector image format ....any idea about how to go about it????????
|
|
|
|
|
Have a look to this[^] article, it may help.
HTH,
K.
Le temps se perd, "Si" n'existe pas
Tous les remords n'y changeront rien
Le temps se perd, "Si" n'existe pas
Donc à présent le choix reste mien
|
|
|
|
|
I found these words in the MSDN: "Global variables in a DLL source code file are global to each process using the DLL." I know this to be true, because the following dll and app work for me:
----- stupidDll.h -----
#ifndef STUPIDDLL_H
#define STUPIDDLL_H
int __declspec(dllexport) getStupidInt();
#endif
-------------------------
----- stupidDll.cpp -----
#include "stupidDll.h"
int x = 7;
int getStupidInt() { return x; }
-------------------------
----- stupidApp.cpp -----
#include "stupidDll.h"
#include "stdio.h
int main() {
printf("%d %d\n", getStupidInt());
return 0;
}
-------------------------
But say I don't want to have to call a function to get at the value of x. Shouldn't there be someway to export the symbol x in the DLL (just like I can export the symbol getStupidInt()) ?
I.e., I want to be able to have something like:
extern int x;
in stupidDll.h so that applications can reference this global data directly. I presume I need some sort of __declspec on the above, but I haven't been able to figure it out yet. In case it matters, the data I want to export are a couple of C++ objects -- not simple ints.
Thanks much,
Matt Busche
|
|
|
|
|
Have you tried to put in your DLL header the following declaration?
extern __declspec(dllexport) int x;
and in the DLL code:
int x;
PS. IMHO, global variables suck, especially in an OO design.
Le temps se perd, "Si" n'existe pas
Tous les remords n'y changeront rien
Le temps se perd, "Si" n'existe pas
Donc à présent le choix reste mien
|
|
|
|
|
KaЯl,
Yes. Actually that was the first thing I tried. I get:
stupidApp.obj : error LNK2001: unresolved external symbol "int x" (?x@@3HA)
stupidAp/stupidApp.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
And yes, in general I agree global variables (or in my case objects) suck, but if you knew what I was doing, I suspect you might forgive me. But I am not going to defend myself here. Never-the-less I appreciate your response and would be interested in any other ideas you may have.
Thanks,
Matt
|
|
|
|
|
Hum...The method I indicated works well for me.
Perhaps is there a mix between C and C++ decorations.
I've sent you a small sample, hope this help.
K.
Le temps se perd, "Si" n'existe pas
Tous les remords n'y changeront rien
Le temps se perd, "Si" n'existe pas
Donc à présent le choix reste mien
|
|
|
|
|
KaЯl,
Thanks very much for your sample code! I've got it working now. You never mentioned anything about dllimport! That was my problem. From my experimentation, I now believe the following:
- For global data (certainly for built-in data types and I presume this goes for global C++ objects as well), the DLL source code module must declare the data using __declspec(dllexport), BUT the application module must declare the data using __declspec(dllimport). This seems a tad annoying since the header file must look different for the DLL compile and the Application compile.
- For functions (and I presume this goes for class declarations as well), the DLL source code must likewise declare the function using __declspec(dllexport), BUT IN CONTRAST TO THE CASE FOR DATA the application can declare the function using __declspec(dllimport), __declspec(dllexport), or nothing at all!
Actually I just found the dllimport/dllexport descriptions in the MSDN that would seem to support my claims, though I find it somewhat cryptic -- the kind of description that makes sense only after you already know what it's trying to describe. Maybe I'm just mentally slow or lazy. I will have to read the entire section a time or two to see what I can learn.
Anyway, here is what I did for my source code to get this to work.
----- stupidDll.h -----
#ifndef STUPIDDLL_H
#define STUPIDDLL_H
#ifndef DllDecl
#define DllDecl __declspec(dllimport)
#endif
int DllDecl getStupidInt();
extern DllDecl int x;
#endif
-------------------------
----- stupidDll.cpp -----
#define DllDecl __declspec(dllexport)
#include "stupidDll.h"
int x = 8;
int foo = 7;
int getStupidInt() { return foo; }
-------------------------
----- stupidApp.cpp -----
#include "stupidDll.h"
#include "stdio.h"
int main(){
printf("%d %d\n", getStupidInt(), x);
return 0;
}
-------------------------
As you can see, my DllDecl macro normally expands to __declspec(dllimport); however, I predefined the DllDecl macro in StupidDll.cpp before the #include "StupidDll.h" to force it to instead expand to __declspec(dllexport).
Thanks again for your help. It was most helpful.
Matt
|
|
|
|
|
Matthew Busche wrote:
You never mentioned anything about dllimport
you asked how to export
You guessed well.
Generally, the technique is the following:
use one header file for both your DLL and your application. In it, define something like
#if _MY_DLL<br />
#define MYDDL_WHATEVER _declspec(dllexport)<br />
#else<br />
#define MYDDL_WHATEVER _declspec(dllimport)
Then, in the header, use:
extern MYDDL_WHATEVER int x;
In the settings of the DLL project, define the preprocessor definition MYDDL_WHATEVER. Et hop, it's done
You could also take a look to this article[^], it may contain useful info.
Matthew Busche wrote:
Thanks again for your help. It was most helpful.
My pleasure, and welcome on Codeproject!
K.
Le temps se perd, "Si" n'existe pas
Tous les remords n'y changeront rien
Le temps se perd, "Si" n'existe pas
Donc à présent le choix reste mien
|
|
|
|
|
use a def file, it's better for C exports.
Don't try it, just do it!
|
|
|
|
|
Alexander,
As I said in my email, I am trying to export two C++ objects -- not a simple integer. Do you still recommend a defs file? In addition, I have a few C++ base-class declarations and a few global C++ functions that I am also exporting. I would expect putting these in a defs file would not be as straight forward. Can you mix a defs file for data with __declspec for classes and functions all within the same DLL?
Thanks much,
Matt
P.S., what is the significance of the superscript M. in your login?
|
|
|
|
|
.
hello , i have used a class CPicture (obtained from this site itself) to load a jpeg image from the resource..now the problem is if i have to reload another image in the same sapce i have to unload the previous image....how do i do that????
Any kind of help is appreciated.
Thanking you.
Satadru
|
|
|
|
|
i hope u don#t want to unload the picture u just override the picture by calling the loadpicture function and replace the piecture in the same place.
Shanmuga Sundar.V
|
|
|
|
|
MY DLL CODE : CDBMgrClass is a generic class got added to the
DLL workspace for IGenericDBManager Interface.
I am calling my interface standard method i.e. STDMETHODIMP CGenericDBManager::Fetch(BSTR bstrSELECTSQLString, _Recordset **pFetchRecordset, BSTR *bstrFetchErrDesc, LPDISPATCH *ppVal)
from my stub in VC++(MFC). But the stub returns the OxThe thread 0x388 has exited with code 0 (0x0).
First-chance exception in GH_DBM_COMDLL_Stub_MFC_EXE.exe: 0xC0000005: Access Violation.
First-chance exception in GH_DBM_COMDLL_Stub_MFC_EXE.exe: 0xC0000005: Access Violation.
Below the DLL code : The STDMETHODIMP calls internally CDBMgrClass::ExecuteFetchQuery()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Function Name : ExecuteFetchQuery()
// Description : It does the EXECUTE of the FETCH SQL COMMAND
// Return Value : _RecordsetPtr
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_RecordsetPtr CDBMgrClass::ExecuteFetchQuery(char* sqlstring)
{
HRESULT hr = S_OK;
try
{
IsConnected();
m_csDatabaseOpLock.Lock();
TESTHR(m_pCommand.CreateInstance(__uuidof(Command)));
TESTHR(m_pRecordset.CreateInstance(__uuidof(Recordset)));
TESTHR(m_pParameter.CreateInstance(__uuidof(Parameter)));
m_pCommand->ActiveConnection = m_pConnObj;
m_pCommand->CommandText = sqlstring;
m_pCommand->CommandType = adCmdText;
m_pRecordset = m_pCommand->Execute(NULL, NULL, adCmdText);
m_pConnObj->Close();
}
catch(CException exception)
{
// Handle the exception here.
// "exception" contains information about the MFC DB exception.
TCHAR szCause[255];
EString strFormatted;
exception.GetErrorMessage(szCause, 255);
strFormatted = _T("The Error: ");
strFormatted += szCause;
OutputDebugString(strFormatted.c_str());
m_bIsConnected = FAILURE;
m_pRecordset = NULL;
}
catch(_com_error &e)
{
hr = e.Error();
_bstr_t bstrError = e.Description();
OutputDebugString(bstrError);
m_bIsConnected = FAILURE;
m_pRecordset = NULL;
}
catch(...)
{
}
m_csDatabaseOpLock.Unlock();
return m_pRecordset;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Function Name : Fetch
// Description : Interface Public Method
// Input : /*[in]*/BSTR bstrSELECTSQLString
// Output : /*[out]*/_Recordset **pFetchRecordset, /*[out]*/BSTR *bstrFetchErrDesc,/*[out]*/LPDISPATCH *ppVal
// Return Value : S_OK or E_FAIL
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
STDMETHODIMP CGenericDBManager::Fetch(BSTR bstrSELECTSQLString, _Recordset **pFetchRecordset, BSTR *bstrFetchErrDesc, LPDISPATCH *ppVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
CoInitialize(NULL);
HRESULT hr = S_OK;
CDBMgrClass* pDBMgrClass = NULL;
_RecordsetPtr m_pRecord_Set(__uuidof(Recordset));
m_pRecord_Set = NULL;
pFetchRecordset = NULL;
try
{
pDBMgrClass = new CDBMgrClass();
if(pDBMgrClass)
{
_bstr_t _bstrFetchQuery(bstrSELECTSQLString);
m_pRecord_Set = pDBMgrClass->ExecuteFetchQuery(_bstrFetchQuery.operator char*());
if(m_pRecord_Set)
*pFetchRecordset = m_pRecord_Set;
m_pRecord_Set->QueryInterface(IID_IDispatch,(void**) &ppVal);
m_pRecord_Set->Close();
}
else
{
EString strFormatted;
strFormatted = _T("\nGHDER Database Fetch Error\n");
_bstr_t _bstrFetchErrorString(_T(strFormatted.c_str()));
*bstrFetchErrDesc = _bstrFetchErrorString.operator wchar_t*();
delete pDBMgrClass;
}
// Clean up objects before exit
bstrFetchErrDesc = NULL;
delete pDBMgrClass;
}
catch(CException exception)
{
// Handle the exception here.
// "exception" contains information about the MFC DB exception.
TCHAR szCause[255];
EString strFormatted;
exception.GetErrorMessage(szCause, 255);
strFormatted = _T("The Error: ");
strFormatted += szCause;
_bstr_t _bstrFetchErrorString(_T(strFormatted.c_str()));
*bstrFetchErrDesc = _bstrFetchErrorString.operator wchar_t*();
delete pDBMgrClass;
hr = E_FAIL;
}
catch ( _com_error &e )
{
_bstr_t bstrError = e.Description();
_variant_t tErr(e.Error());
_bstr_t tMsg("IGenericDBManager::Fetch::=" );
tMsg += "::Error::";
tMsg += (_bstr_t) tErr;
*bstrFetchErrDesc = tMsg.operator wchar_t*();
delete pDBMgrClass;
hr = E_FAIL;
}
catch(...)
{
}
CoUninitialize();
return hr;
}
///////////////////////////////////////////////////////////////////////
STUB CALLER>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//////////////////////////////////////////////////////////////////////
void CGH_DBM_COMDLL_Stub_MFC_EXEDlg::OnFetch()
{
HRESULT hr = S_OK;
USES_CONVERSION;
BSTR *pbstrFetchErrString = NULL;
_RecordsetPtr pRecordset = NULL;
IGenericDBManager *pGenericDBManager = NULL;
BSTR bstrSELECTSQLQuery;
//FORM THE SQL QUERY FOR ANY TABLE
_bstr_t _bstrSELECTSQLString = (_T("SELECT * FROM GHDR1TS_HAZARDOUS_COMMODITY"));
bstrSELECTSQLQuery = _bstrSELECTSQLString.operator wchar_t*();
//END QUERY
pRecordset.CreateInstance(__uuidof(Recordset));
//Initialize the COM library
CoInitialize(NULL);
//Instantiate the COM object for the interface i.e. IDBM_ComDll
hr = CoCreateInstance(CLSID_GenericDBManager, NULL, CLSCTX_INPROC_SERVER,
IID_IGenericDBManager, (void **) &pGenericDBManager);
if (FAILED(hr))
{
MessageBox("\nIGenericDBManager Interface not instantiated\n", NULL, MB_OK);
return;
}
else
{
MessageBox("\nIGenericDBManager Interface instantiated\n", NULL, MB_OK);
VARIANT* pvntDB_Connect_Status = NULL;
BSTR* pbstrConnectErrString = NULL;
hr = pGenericDBManager->Connect((VARIANT*) &pvntDB_Connect_Status, pbstrConnectErrString);
if (SUCCEEDED(hr))
{
hr = pGenericDBManager->Fetch(bstrSELECTSQLQuery, &pRecordset, pbstrFetchErrString);
if (FAILED(hr))
{
MessageBox("\nIGenericDBManager::Fetch() failed\n", NULL, MB_OK);
return;
}
else
{
VARIANT* pConnection = NULL;
VARIANT* pTable = NULL;
_bstr_t _bstrTable(_T("GHDR1TS_HAZARDOUS_COMMODITY"));
_variant_t _vtTable(_bstrTable.operator const wchar_t *());
hr = pRecordset->get_ActiveConnection((VARIANT*) &pConnection);
_variant_t _vtConnection(*pConnection,true);
hr = pRecordset->Open( _vtTable.Detach(), _vtConnection.Detach(),adOpenKeyset,adLockOptimistic,adCmdText);
if(pRecordset != NULL)
{
int nRecordCount = pRecordset->RecordCount;
int nMaxRecords = pRecordset->MaxRecords;
int nFieldCount = pRecordset->Fields->Count;
MessageBox((LPCTSTR) nRecordCount, NULL, MB_OK );
MessageBox((LPCTSTR) nMaxRecords, NULL, MB_OK );
pRecordset->MoveFirst();
for (int i = 0; i< nRecordCount; nRecordCount++)
{
for(int j=0; j< nFieldCount; j++)
{
MessageBox((LPCTSTR)pRecordset->Fields->GetItem("IMO")->Value.bstrVal, NULL, MB_OK);
}
pRecordset->MoveNext();
}
pRecordset->Close();
}
else
{
MessageBox("NULL RECORDSET", NULL, MB_OK);
pRecordset->Close();
}
}
}
else
{
MessageBox("CONNECT FAILURE", NULL, MB_OK);
}
}
//Uninitialize the COM library
CoUninitialize();
}
/
|
|
|
|
|
This line's very suspicious:
*bstrFetchErrDesc = _bstrFetchErrorString.operator wchar_t*(); You're trying to assign a non-prefixed string to a variable that the caller expects will contain a BSTR. I think you're trying to stop your local _bstr_t object from freeing the encapsulated BSTR when it goes out of scope. The _bstr_t class does not have any way to do this (in Visual C++ 6.0); I recommend using ATL's CComBSTR instead, using its Detach method once you've assigned to *bstrFetchErrDesc .
You should also be aware that MFC overrides the global operator new , replacing it with a version that throws a CMemoryException when the allocation fails. It does not return NULL .
|
|
|
|
|
Hi there
I would just like to know how do i write a programme
that would take an error code as a argument and display
the error message thats associated with the error code
Example: ERROR CODE 00300
Print : Bad IP Checksum
How and in what should i store the list of errors
How do i iterate\scan thru the list get the error code
and print the error message.
Can i store both in one file?
|
|
|
|
|
Have you looked at FormatMessage() ?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
could u please use a topic that describes the problem?
Don't try it, just do it!
|
|
|
|
|
Hi,
I know it is possible to hook a function which is exported in a dll, but I was wondering if it is possible to hook a function in an exe?
thanx
Don't think you are, know you are...
|
|
|
|
|
Do you have the source of that exe?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Yes, I do have the source of that exe.
What I would like to do is make some sort of program that hooks several functions of the specific exe so I can extract internal information.
We have lots of version of this exe and we can't put lots of debugging information in them...
Don't think you are, know you are...
|
|
|
|
|