|
dont forget ctrl+shift+esc, and all the predefined windows keys (win+e ...)
int x=1, y=5;
x^=y^=x^=y;
<a href="http://www.codeproject.com/tips/StupidXORTrick.asp" target="_blank">ClickHereForHelp();</a>
|
|
|
|
|
I've got 2 applications that load the same dll. The 2 instances of the dll communicate with each other using shared memory.
#pragma data_seg(".shared")<br />
...<br />
#pragma data_seg()
But this only works for base types like integers and doubles. What I would like to have is a shared linked-list, containing a list of objects. Those objects have the basic linked list members (*prev, *next) and an extra char* for the name.
In fact, a linked list is not required, it can be a vector too, or another type ...
What's the best way to do this?
What classes or typelibrary would I have to use?
stl?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
From Visual C++ help:
However, if you need to share a C++ class instance, you should use a memory-mapped file, because each time a process attaches to the DLL, the constructor for the object is called. For example:
#pragma data_seg(".myseg")
_declspec(dllexport) CTest Counter1(0);
_declspec(dllexport) short Counter2 = 0;
#pragma data_seg()
Assume that the variables Counter1 and Counter2 are incremented in a function in the DLL. The value of Counter2 increases as expected, but on each process attach, the constructor for Counter1 is called reinitializing it to zero. In order to share Counter1, you must use a memory-mapped file. For more information about memory-mapped files, see File Mapping in the Win32 SDK documentation.
I guess you could use data_seg with pointer to linked list, but this would introduce problems with different heaps each dll instance uses.
[edit]
Disregard the idea with pointer - it would have no meaning, since actual object would live in address space of one process. Seems that going with File Mapping is only choice.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
File mapping, that's it allright
I hope that's not too buggy, that ms lib.
tnx!
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Grote Smurf (aka frisco) wrote:
I hope that's not too buggy, that ms lib
File mapping is a feature implemented at OS level - so it's hardly a 'lib'
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
So, it's really "core"-gates stuff? I'm already having a breakdown ...
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
|
Almost finished ...
It's not so hard cause I don't need to syncronise between processes. One process writes and another reads. While one process writes, the read processes can be disposed without further action.
With syncronisation, that's another pair of sleeves
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Hello,
I need to include instructions of compiling different kinds of files to others. I have all those compilers on my computer, but how can I tell my makefile or visual studio where they are. I know I could put the path in front of the compiler name, but the problem is that some of those use preprocessors and those I don't call myself.
-Janetta
|
|
|
|
|
In VC, you can use the Tools:options and directories to configure the executable files (paths) that are searched for the compilers/linkers used in your makefile.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
I use the splitter window in my project.Left view is derived from CTreeView , and the right view derived from CFormView.I added MS FlexGrid 6.0 and Remote Data Control 6.0 onto Form , set the DataSource of FlexGrid is connect to the RDC.Complied successfully,but when run it , reported Assert error.
Why?
Sincerely,Pole.
|
|
|
|
|
This:
Pole wrote:
Complied successfully,but when run it , reported Assert error.
is a bit vague.
Without knowing details about FlexGrid and RemoteDataControl I try to answer...
You are not trying to access the control variables before the OnInitialUpdate() has been called?
At that Time they may not yet exist.
|
|
|
|
|
I set the FlexGrid's Datasource attribute in Resource Editor.I did not code a line.
Sincerely,Pole.
|
|
|
|
|
Pole wrote:
I set the FlexGrid's Datasource attribute in Resource Editor.I did not code a line.
Maybe it is better to set the FlexGrid's Datasource attribute in ViewClass::InitialUpdate()?
|
|
|
|
|
But how to code it?I tried to do it like you say,but failed.
Sincerely,Pole.
|
|
|
|
|
In yout CFormView derived Class, you can use the C++ Class Wizard to make you a Handler for the Message 'OnInitialUpdate'.
In the body of this message-handler function, you can do the calls needed.
OnInitialUpdate() is the right function for all first-time initialisations of views and their childs.
|
|
|
|
|
I know that,but I don't know how to set FlexGrid's DataSource so that connect to the RDC(Remote Data Ctrl).
How to pragrammically set its DataSource attribute?
Sincerely,Pole.
|
|
|
|
|
Hello,
I’m trying to load A listbox object with table names from an access database file. I’m working with two dialogs. One is my main Dialog and the other is a dialog with a listbox object attached to it. When I try to add table names
To the list box an ASSERTION happens. I believe the Dialog with the listbox is destroyed before the AddString() function can load the table names. If this is true is there away around this? Any help would be much appreciated.
Thanks
Karl
<br />
void CLoadTablesDlg::OnButtonOpen() <br />
{<br />
CTableDlg dlgTable;<br />
<br />
_RecordsetPtr m_pRstOpenSchema;<br />
_ConnectionPtr m_pConnection;<br />
<br />
TCHAR szFilters[] = _T("Access files(*.mdb) | *.mdb | All files(*.*) | *.*||");<br />
<br />
CFileDialog dlg (TRUE, _T("mdb"), _T("*.mdb"),<br />
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters);<br />
<br />
if(dlg.DoModal () == IDOK)<br />
m_sFileName = dlg.GetPathName();<br />
<br />
HRESULT hr;<br />
<br />
_bstr_t strCnn("Provider=Microsoft.Jet.OLEDB.3.51; Data Source= " + m_sFileName + ";");<br />
<br />
try<br />
{<br />
hr = m_pConnection.CreateInstance(__uuidof(Connection));<br />
if(SUCCEEDED(hr))<br />
{<br />
m_pConnection->Open(strCnn, "", "", adModeUnknown);<br />
m_pRstOpenSchema = m_pConnection->OpenSchema(adSchemaTables);<br />
<br />
while (!(m_pRstOpenSchema->adoEOF))<br />
{<br />
_bstr_t table_name = m_pRstOpenSchema->Fields->GetItem("TABLE_NAME")->Value;<br />
<br />
CString strTableName = (LPCSTR)table_name;<br />
dlgTable.m_lstTables.AddString(strTableName);<br />
m_pRstOpenSchema->MoveNext();<br />
}<br />
<br />
}<br />
}<br />
catch (_com_error &e)<br />
{<br />
_bstr_t bstrSource(e.Source());<br />
_bstr_t bstrDescription(e.Description());<br />
TRACE( "Exception thrown for classes generated by #import" );<br />
TRACE( "\tCode = %08lx\n", e.Error());<br />
TRACE( "\tCode meaning = %s\n", e.ErrorMessage());<br />
TRACE( "\tSource = %s\n", (LPCTSTR) bstrSource);<br />
TRACE( "\tDescription = %s\n", (LPCTSTR) bstrDescription);<br />
}<br />
catch(...)<br />
{<br />
TRACE( "*** Unhandled Exception ***" );<br />
}<br />
<br />
}<br />
|
|
|
|
|
You can call AddString only after DoDataExchange was called (it's called by CDialog::OnInitDialog) and before dialog ends modal state.
You'll have to add strings in DoDataExchange or in InitDialog.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Russ Freeman wrote:
I want to add a toolbar to a view and I would like it to use the command routing for enabling and disabling of buttons
You don't route commands through toolbar. All you need to do is ensure that CToolBar::OnUpdateCmdUI is called - it will use MFC routing for enabling/disabling buttons.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Hi,
I'm trying to send a piece of mail using Simple MAPI's MAPISendMail function and, the linker is complaining that it can't find the function.
I'm linking to mapi32.lib, but this seems not to contain the function (mapi32.dll does, however, because I can access it from GetProcAddress). Does anyone know what the problem is?
Thanks,
Rich
|
|
|
|
|
I had the same problem in the past. You've got to do the lynking dynamically yourself (Microsoft admits the error here[^]. Here's some lines for the program I wrote back then, I guess it'll save you some tedious coding:
#include <mapi.h>
static HINSTANCE hMAPI=NULL;
#undef MAPILogon
#undef MAPILogoff
#undef MAPISendMail
#undef MAPISendDocuments
#undef MAPIFindNext
#undef MAPIReadMail
#undef MAPISaveMail
#undef MAPIDeleteMail
#undef MAPIFreeBuffer
#undef MAPIAddress
#undef MAPIDetails
#undef MAPIResolveName
#define MAPILogon (*lpfnMAPILogon)
#define MAPILogoff (*lpfnMAPILogoff)
#define MAPISendMail (*lpfnMAPISendMail)
#define MAPISendDocuments (*lpfnMAPISendDocuments)
#define MAPIFindNext (*lpfnMAPIFindNext)
#define MAPIReadMail (*lpfnMAPIReadMail)
#define MAPISaveMail (*lpfnMAPISaveMail)
#define MAPIDeleteMail (*lpfnMAPIDeleteMail)
#define MAPIFreeBuffer (*lpfnMAPIFreeBuffer)
#define MAPIAddress (*lpfnMAPIAddress)
#define MAPIDetails (*lpfnMAPIDetails)
#define MAPIResolveName (*lpfnMAPIResolveName)
static LPMAPILOGON lpfnMAPILogon=NULL;
static LPMAPILOGOFF lpfnMAPILogoff=NULL;
static LPMAPISENDMAIL lpfnMAPISendMail=NULL;
static LPMAPISENDDOCUMENTS lpfnMAPISendDocuments=NULL;
static LPMAPIFINDNEXT lpfnMAPIFindNext=NULL;
static LPMAPIREADMAIL lpfnMAPIReadMail=NULL;
static LPMAPISAVEMAIL lpfnMAPISaveMail=NULL;
static LPMAPIDELETEMAIL lpfnMAPIDeleteMail=NULL;
static LPMAPIFREEBUFFER lpfnMAPIFreeBuffer=NULL;
static LPMAPIADDRESS lpfnMAPIAddress=NULL;
static LPMAPIDETAILS lpfnMAPIDetails=NULL;
static LPMAPIRESOLVENAME lpfnMAPIResolveName=NULL;
if((hMAPI=LoadLibrary("MAPI32.DLL"))==NULL)
{
}
if(
(lpfnMAPILogon=(LPMAPILOGON)GetProcAddress(hMAPI,"MAPILogon"))==NULL||
(lpfnMAPILogoff=(LPMAPILOGOFF)GetProcAddress(hMAPI,"MAPILogoff"))==NULL||
(lpfnMAPISendMail=(LPMAPISENDMAIL)GetProcAddress(hMAPI,"MAPISendMail"))==NULL||
(lpfnMAPISendDocuments=(LPMAPISENDDOCUMENTS)GetProcAddress(hMAPI,"MAPISendDocuments"))==NULL||
(lpfnMAPIFindNext=(LPMAPIFINDNEXT)GetProcAddress(hMAPI,"MAPIFindNext"))==NULL||
(lpfnMAPIReadMail=(LPMAPIREADMAIL)GetProcAddress(hMAPI,"MAPIReadMail"))==NULL||
(lpfnMAPISaveMail=(LPMAPISAVEMAIL)GetProcAddress(hMAPI,"MAPISaveMail"))==NULL||
(lpfnMAPIDeleteMail=(LPMAPIDELETEMAIL)GetProcAddress(hMAPI,"MAPIDeleteMail"))==NULL||
(lpfnMAPIFreeBuffer=(LPMAPIFREEBUFFER)GetProcAddress(hMAPI,"MAPIFreeBuffer"))==NULL||
(lpfnMAPIAddress=(LPMAPIADDRESS)GetProcAddress(hMAPI,"MAPIAddress"))==NULL||
(lpfnMAPIDetails=(LPMAPIDETAILS)GetProcAddress(hMAPI,"MAPIDetails"))==NULL||
(lpfnMAPIResolveName=(LPMAPIRESOLVENAME)GetProcAddress(hMAPI,"MAPIResolveName"))==NULL){
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, everyone!
I wondered where the variable __STDC__ is defined.
I write a simple C program to test it, before include
other .h files, the variable is already defined.
(I use #ifdef to test the existence)
I have two question about the variable:
1. Where is the variable defined?
2. What is the function of the variable?
Cheers,
George
|
|
|
|
|
__STDC__ isn't a variable. It's a predefined preprocessor macro. Your Visual C++ help would tell you that __STDC__ Indicates full conformance with the ANSI C standard. Defined as the integer constant 1 only if the /Za compiler option is given and you are not compiling C++ code; otherwise is undefined. .
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Thanks, Tomasz my old friend!
I still have a question. Who should
define value of the macro? The source code
developer by hand? Or the system will
automatically add the setup of the macro
to the source code?
Cheers,
George
|
|
|
|