|
So all you are really wanting to do is output the sum of 1 and 2 to the screen?
With C:
printf("%d\n", 1 + 2); With C++:
cout << 1 + 2 << endl; Does that help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
I have that. I am able to display output to the screen using cout<<. I want to send the output on the screen to the printer.
|
|
|
|
|
Well, if you are running your program from a command prompt, just redirect its output to the printer like:
C:\> myprog.exe > prn
or
C:\> myprog.exe > lpt1
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Q1-does function CreateMapFile() create the file in MEMORY?
Q2-do we need to call DeleteFile() to clean the file from memory or somewhere before app exits?
includeh10
|
|
|
|
|
is CreateMapFile?
You have CreateFileMapping and OpenFileMapping which return a handle. Then use CloseHandle before your program exits.
No, you have to also follow the CreateFileMapping and OpenFileMapping with MapViewOfFileEx and then use UnmapViewOfFile
Sequence:
CreateFileMapping or OpenFileMapping
MapViewOfFileEx
Use the mapped memory
UnmapViewOfFile
CloseHandle
|
|
|
|
|
not really.
if doing
CreateFileMapping
......
CloseHandle
the file is still there because another app can open it.
i need to delete the file because i have to create thousands of maping files, i need to delete some files if they are useless.
CloseHandle does not delete mapping files - similar to normal files.
includeh10
|
|
|
|
|
MSDN To fully close a file mapping object, an application must unmap all mapped views of the file mapping object by calling UnmapViewOfFile, and close the file mapping object handle by calling CloseHandle. The order in which these functions are called does not matter. The call to UnmapViewOfFile is necessary because mapped views of a file mapping object maintain internal open handles to the object, and a file mapping object will not close until all open handles to it are closed.
So, if you unmap all the views and then close the handle, the memory map file will be gone.
If you want to delete the 'regular' file, then use DeleteFile().
Otherwise, you are getting something mixed up or I don't understand what you want to do.
There is no need to 'delete' a memory mapped file. It will happen on its own if the above guidelines are followed.
|
|
|
|
|
i need to pass a string from app A to app B.
app B is dialog based, app A knows HWND handle of app B.
i test by SendMessage or PostMessage from A to B, but the string can not be passed.
any idea?
thx
includeh10
|
|
|
|
|
includeh10 wrote:
i test by SendMessage or PostMessage...
I presume you used the WM_COPYDATA message. Yes? Otherwise, a code snippet would be especially helpful.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
no, i use in this way:
(in app A)
::SendMessage(hwndB,WM_USER+1,(int)(LPCSTR)csA,0);
//csA is object of CString
(in app B)
WindowProc(UINT msg,WPAREM w,LPARAM l)
{
switch(msg)
{
case WM_USER+1:
{
CString csB=(char*)w;
}
break;
............
but csB gets nothing - the reason i guess is that a string can not be passed to another app (app adress) in this way.
is WM_COPYDATA better?
any suggestion?
includeh10
|
|
|
|
|
includeh10 wrote:
is WM_COPYDATA better?
I'll let you be the judge of that:
http://tinyurl.com/62khl
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
it looks great.
i will test it.
thanks
includeh10
|
|
|
|
|
i tested it.
it is perfect!!!!
cheers
includeh10
|
|
|
|
|
additionally, there's another simple way to do it...
Convert the string to a global atom: GlobalAddAtom
ATOM GlobalAddAtom( LPCTSTR lpString );
this converts the string to a handle -- which you can transmit via Post/Send Message to any other process. Use GlobalGetAtomName() on the other end to convert it back.
It's a simple way to send small strings (255 chars or less).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hello all,
I am using a CSplitterWnd. I would like to prevent the user from dragging
the splitter any closer than a certain distance from the edge of the window.
I found that CSplitterWnd::SetRowInfo() and CSplitterWnd::SetColInfo() allow
you to set a "minimum" size. However, it's not the case that the user can't
drag the splitter past this minimum. It's just that if he does so drag the
splitter, the window size will become 0.
Is there a way to do what I wish and pysically disallow the splitter to move
past a certain point?
Thanks,
Jitendra
|
|
|
|
|
I'm wrote a simple code to creates a empty Dialog. But I've an exception with him. Why?
DLGTEMPLATE dlg;
dlg.x = 0;
dlg.y = 0;
dlg.cx = 200;
dlg.cy = 200;
dlg.style = WS_BORDER|WS_CHILD|WS_VISIBLE;
dlg.dwExtendedStyle = 0;
dlg.cdit = 0;
CDialog Dialog;
Dialog.InitModalIndirect(&dlg);
DoModal();
Best regards,
Eugene Pustovoyt
ICQ UIN: 161325180
|
|
|
|
|
From MSDN: "To create a modal dialog box indirectly, first allocate a global block of memory and fill it with the dialog box template. Then call the empty CDialog constructor to construct the dialog-box object. Next, call InitModalIndirect to store your handle to the in-memory dialog-box template."
Here is the most IMPORTANT part:
"first allocate a global block of memory"
It does not matter which version of InitModalIndirect you call, the DLGTEMPLATE must be in a globaly allocated memory block. That means using GlobalAlloc(...).
If this is not the cause of exception, then the MSDN remarks section may be wrong.
The only question that remains is: who is responsible for freeing the memeory?
Search the MSDN for the sample code:
"DLGTEMPL: Creating Dialog Templates Dynamically"
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi all
can anyone recommend the best way of accessing an omnis database ?
at the moment im using an mfc odbc consumer class connection using crecordset to access it
but it sooo slow when querying
or maybe anyone knows how to export the tables from omnis to say access in c++
any ideas
thanks
si
|
|
|
|
|
I'm creating a library with som custom controls. How can I have a bitmap drawn on a custom button?
When the button control is in a .lib - where to put the image?
What about resource conflicts?
Thanks for any comment
|
|
|
|
|
Put them in a DLL or ActiveX library, both types of libraries have there own resources. Their resources can not conflict with your resources, unless the DLL treats externaly supplied resource IDs the same as internaly supplied IDs.
For buttons:
http://www.codeproject.com/buttonctrl/[^]
For libraries visit the COM or Libraries section of codeproject.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
To make it simple, I made this small utility that converts a binary file into an array of unsigned chars for the compiler to read. This enables me to #include the binary chunk directly into the source.
Wooh, does this smell like good old times..
|
|
|
|
|
Hi,
I'm using SQLBulkOperations(m_hstmt,SQL_ADD) in one of my methods when trying to bulk copy a table from one db to another.
It was tested and worked fine for copying from Oracle to mdb, but when trying to copy from mdb to oracle or oracle to oracle I get SQL_NEED_DATA.
I checked over and over and the code seems fine to me (buffers were created and assigned). The SQLBulkOperation call looks like these:
ODBC_CALL(::SQLSetStmtAttr(m_hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (void*)wRow, 0));
if(!Check(nRetCode)){
}
ODBC_CALL(::SQLBulkOperations(m_hstmt,SQL_ADD));
Can anyone help ?
Thanks
|
|
|
|
|
Hello Friends,
I am using CFormView on which I have a combo box and a Tree Control. When any item is being inserted depending upon some boolean variable the color for the item should be either red or black.
For example;
bool valid = false;
if(valid)
treecontrol item text color = red;
else
treecontrol item text color = black;
I am not using CTreeView, but I have CFormView on which they are two controls.
I am not able to set the color for the individual items.
Please help regarding the above matter.
Thanks in Advance.
Neelesh K J Jain.
|
|
|
|
|
Neelesh K J Jain wrote:
I am not able to set the color for the individual items
Thats because there are no options to set individual display properties, both for the Tree Control and the List Control.
If you need such control, have a look at using Custom Drawing. Take a look at this[^] and this[^] to start.
I Dream of Absolute Zero
|
|
|
|