|
The 2 most common mistakes I make is to not call 'OleInitialize(NULL)' (or some variant ie. AfxOleInit()). Also, is the MDB file in your project directory of your build directory (ie. Debug/Release). If is is your project directory you may need to reference the DB like
char* m_strConnection = _T("Provider=Microsoft.Jet.OLEDB.4.0; Data Source = ../db1.mdb");
|
|
|
|
|
I'm working on an application (let's call it SCONES) which can be used as an OLE server, so that its results can be embedded in Word docs, for example. Now, I know I need to implement the Serialize() function for all my data objects for OLE purposes. On the other hand I don't want to use MS's proprietary file format for saving SCONES files to disk when it's not being an OLE server - I want to use XML. Do I have to write two separate sets of code for file saving and loading, or is there some smart way of doing both tasks in one? I can't be the first to encounter this problem, surely?
Peter Robinson
|
|
|
|
|
Hello Dear.
I have windows 98. I'm trying to execute a chatter application which is avaialbe in MSDN. But it is displaying the message & not executing. Message is giving below:
"This Application or Dll can not be loaded on windows 95 or on windows 3.1. It takes advantages of unicode features only available on windows NT."
When I press OK button, it display an other error message "The MFC42UD.DLL file cannot start. Check the file to determine the problem."
When I press ok on this button it terminates my application.
Pls replty me soon. I'll be thankful to you.
|
|
|
|
|
Can't tell you much more than they are - this program requires Unicode, and therefore requires Windows NT or 2000. It won't run under W98.
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 want to store key value pairs and access them ,
i want a return type of function to be CMap or something like it,
but this is not possible, = operator not overloaded
is there any alternative ?
parag
|
|
|
|
|
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
|
|
|
|