|
The STL map collection has assignment operation and copy constructor, so you can return a std::map from a function.
|
|
|
|
|
It doesn't make sense to return map by value - it involves creating temporary object and this operation may be costly depending on the size of your map. You should pass the map object by reference:
void foo(CMyMapClass & map);
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Why this code doing me troubles ???????????
----------------------------------------------
void CFilesDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString str(50);
str = "22223333333333222";
CFile file;
if(file.Open("string.data",file.modeWrite|file.modeNoTruncate|file.modeCreate))
file.Write(&str,sizeof(str));
}
void CFilesDlg::OnButton2()
{
// TODO: Add your control notification handler code here
CString str(50);
CFile file;
if(file.Open("string.data",file.modeRead))
file.Read(&str,sizeof(str));
MessageBox(str);
}
---------------------------------------------------------
mimi
|
|
|
|
|
You need to tell us what's going wrong. Compile errors? Not giving the right output when you run it?
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
1/ I don't see any CString constructors that take a number
2/ you want to use str.GetLength() instead of sizeof(str).
3/ If the 50 was meant to be a size, you put less than 50 characters into the buffer before writing.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I changed little my code but the problem remained !
It is ok in compilation but write nonsense in the file and same in the messageBox.
Why ??????
--------------------------------------------------------------------------
void CFilesDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString str("222233772");
CFile file;
if(file.Open("string.data",file.modeWrite|file.modeNoTruncate|file.modeCreate))
file.Write(&str,str.GetLength());
}
///////////////////////////////////////////////////////////
void CFilesDlg::OnButton2()
{
// TODO: Add your control notification handler code here
char str[50];
CFile file;
if(file.Open("string.data",file.modeRead))
file.Read(str,10);
MessageBox(str);
}
---------------------------------------------------------------------
|
|
|
|
|
void CFilesDlg::OnButton1()
{
CString str(50);
str = "22223333333333222"; There's no such constructor for CString. Use
CString str("22223333333333222");
instead
CFile file;
if(file.Open("string.data",file.modeWrite|file.modeNoTruncate|file.modeCreate))
file.Write(&str,sizeof(str));
&str doesn't return a pointer to the characters contained in the CString, and sizeof(str) isn't the string length. To write the contents of the CString instead of pointers, reference counts and other useless information:
file.Write(str, str.GetLength());
}
void CFilesDlg::OnButton2()
{
CString str(50); Same error as before, use
CString str;
CFile file;
if(file.Open("string.data",file.modeRead))
file.Read(&str,sizeof(str));
What you need here is:
{
int len = file.Read(str.GetBuffer(50), 50);
str.ReleaseBuffer(len);
}
MessageBox(str);
}
|
|
|
|
|
now it is ok !
you are explain excellentand very clear.
thank you!
|
|
|
|
|
&str is your problem.
just use str.
CString has a (char *) overload
|
|
|
|
|
Hello
Here is a situation where in i need to display the gif's and jpgs in VC++ MFC application
Need some help regarding this
regadrs
Dwaraka
|
|
|
|
|
There are articles on the site on how to do this if all you need is to show them. GDI+ lets you load and save them, and manipulate them - so does paintlib ( www.paintlib.de )
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
|
Hi,
I have to work on a project related to xemacs. Now my code loads some dll's from within xemacs and my prof wants me to unload them before xemacs is shut.
So I have to find out exactly which part of the code is executed just before exit, and I dont really know how to do this.
Can anyone tell me if there are any tips to follow when trying to understand the code of a big project with loads of files? And more specifically can anyone tell me which code (also which file) is executed just before exit?
Thanks in advance.
Mayank.
PS - I am using xemacs-21.1.4, source can be found at
http://ftp.xemacs.org/xemacs-21.1/xemacs-21.1.4.tar.gz
|
|
|
|
|
I have a problem in refreshing the dialogbar.
What I did:
1)
A standard procedure to add a dialog bar in a simple single document program
as follows (in CMainFrame::OnCreate(...))
CDialogBar m_wndMyDialogBar;
if (!m_wndMyDialogBar.Create(this, CG_IDD_MYDIALOGBAR,
CBRS_RIGHT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,
CG_ID_VIEW_MYDIALOGBAR))
{
TRACE0("Failed to create dialog bar m_wndMyDialogBar\n");
return -1; // fail to create
}
2)
When added following code to enable dialog bar docking:
m_wndMyDialogBar.EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndMyDialogBar);
there appears another control bar, an "AfxControlBar" on top of the dialog
bar, which can be seen easily using Spy++.
Problem
When I want to add some other controls, like a popup menu inside the dialog
bar, the covered area will not refresh (or InvalidateRect) properly. Using
Spy++ I found out that it is not the area in the "dialog", but the one in
the unexplanable "AfxControlBar", that does not refresh properly, because
this AfxControlBar does not receive any message except "WM_SETCURSOR".
When I delete the code in part 2), there'll be no AfxControlBar covering my
dialog bar, and hence no such problem, but also no docking feature
available.
My understanding in MFC is very shallow. Can anyone explain to me about
this? Thanks a lot!
sunny
|
|
|
|
|
Hello
Can I use CreateFiber function on Win2K? The Microsoft documentation says yes, but I can't use it, because I get "undeclared identifier" error but I don't know why? I naturally use the "windows.h" include file.
Thanks
|
|
|
|
|
try <windows.h> instead of "windows.h" or include <winbase.h> cause it is defined there!
Make sure you're typing it correctly "CreateFiber"
Mh2!
|
|
|
|
|
I meant to say:
< windows.h >
or
< winbase.h >
Mh2
|
|
|
|
|
|
Make sure you declare the correct version of windows before compiling. Fibers were added to pretty late to NT 3.51 I think in a service pack.
|
|
|
|
|
Thanks Erik it successfully done.
Bye
|
|
|
|
|
I want to read the mpeg header info from video mpeg files and use the information for writing a program.can any body help me
|
|
|
|
|
Maybe Im wrong, but for something like that you will need to find out the exact: location / size / contents of the MPEG file header..
Then its just a matter of creating a class / struct that will hold the information once you read it in from the file.
Hardest Part of your Problem is finding out Where the information is stored (location of the header) and what the data structure is.
Might involve a little decodeing, but do some searches on the web and youll be fine.
recurse.org - Recusion For the Rest Of Us.
|
|
|
|
|
There is no such thing as a "mpeg file header". A MPEG data stream (or file) is a sequence of blocks, each containing the information necessary to decode that block, and the information varies from block to block.
|
|
|
|
|
If there is no such thing as mpeg file header then why does media player not open certain mpeg files in which i copy the data from the middle of the file. Xing player is able to open these files none the less. Can u give more info
|
|
|
|
|
Looking for good book on Programming in Visual C++.
I have C++ experience, but want to learn.
|
|
|
|