|
I get a fatal error from an article posted on here.
http://www.codeproject.com/w2k/makexp.asp
Here's the exact error:
http://students.etsu.edu/zbkc9/error.png[^]
I've also tried include fstream without the .h and get different errors. Any ideas? Thanks. I'm wanting to learn C++ and I have Visual Studio .NET 2003 Professional. NOt sure if the version matters, but thought I would post it in case.
|
|
|
|
|
Try
<br />
#include <fstream><br />
using namespace std;<br />
It should work without the using statment, but then you'll need to preface with std::...
std::ofstream out("blah.txt");
He is smart. He will make our Windows go.
-- modified at 21:20 Saturday 3rd September, 2005
|
|
|
|
|
<fstream.h> is not part of the C++ standard, and should not be used in any new code.
It's not portable to modern compilers like VC++ 7.x
Should use <fstream> which is part of the C++ standard, and then use using namespace std, or prefix your types with std::
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
Hi all!
I'm searching a way to use the sql limit statement in my recordset (derived from CRecordset). Someone knows a way to do so?
In deep love
maTzeLein
|
|
|
|
|
Hi All
After running the program when I saw memory usage of this program in "Task Manager" then noticed that memory usage by program is continually increasing,
Though I am not doing any activity on the program.
Why is this taking place ?
Please reply
Thanks
|
|
|
|
|
Hello,
You probably got a memory leak somewhere in a function that gets called frequently!
You can use Visual Leak Detector[^] tp track any of these leaks down in a debug build. Run the program in the debugger and on exit, it will report all leaks in your program.
Is your program multithreaded by the way?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi
I am hooking into createfile API to differentiate between File open and File create . I am not ablt to differnetiate between the two operations.
In win2000 , CREATE_NEW is not at called and it is always giving OPEN_EXISTING .Further if i create a notepad file i am getting CREATE_ALWAYS . But if i create a .xls file i am getting OPEN_EXISTING
In win2003 , I am able to differentiate between Creation and open.
|
|
|
|
|
I don't know if here is the right place for this question.
I'm creating a setup project in Visual Studio .Net and i want to register a file type (say .jk) with a custom icon. In VS enviroment the only way to do this (i think) is to associate the file type with an executable. But this is not my case. I want the file .jk just to have my icon and nothing more. As you know there are files in Windows that display custom icons but are not associated with executables, so when you double click them you get a shell "Open With" dialog.
Any ideas how to deal with this?
|
|
|
|
|
I do not know how as I have never done that. But I would think it would be a registry entry that holds the data for that. So what I would do is find a file exetension that does what you want, then do a registry search for that extension. You should then be able to figure out what is entered in the registry and copy that for your own extension.
It might take a bit of detective work and some trial and error.
Good luck
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
|
Try starting here[^] in the MSDN.
Software Zen: delete this;
|
|
|
|
|
Hi,
I have a problem working with Html Help Workshop.
I paste pictures from Rational into Word and after I save the document as .htm and use it in Html Help Workshop the picture is not shown.
I don't know if this a bug.
Can you help me please?
|
|
|
|
|
Try looking at the HTML. There should be an <img src="file"> tag where the picture would be. Make sure the file exists, and contains the picture. You will need to add file to your help project as well.
Software Zen: delete this;
|
|
|
|
|
Hey guys, I`ve got a problem with Borland C++ Builder.
I have a code that I need but it`s written on BCB. And I need to do this code on VC++.
Almost all that code is easy, but I can`t find in VC++ function like
Graphics::TBitmap in BCB
Does anyone knows how can I change that function to work in VC?
Will be glad to any answer.
|
|
|
|
|
|
In the program this is for working with video stream in avi files...
Here is full class:
class PASCALIMPLEMENTATION TBitmap : public TGraphic
{
typedef TGraphic inherited;
private:
TBitmapImage* FImage;
TCanvas* FCanvas;
bool FIgnorePalette;
bool FMaskBitsValid;
bool FMaskValid;
TColor FTransparentColor;
TTransparentMode FTransparentMode;
void __fastcall Changing(System::TObject* Sender);
void __fastcall CopyImage(HBITMAP AHandle, HPALETTE APalette, const tagDIBSECTION &DIB);
void __fastcall DIBNeeded(void);
void __fastcall FreeContext(void);
TCanvas* __fastcall GetCanvas(void);
virtual HBITMAP __fastcall GetHandle(void);
TBitmapHandleType __fastcall GetHandleType(void);
virtual HBITMAP __fastcall GetMaskHandle(void);
bool __fastcall GetMonochrome(void);
TPixelFormat __fastcall GetPixelFormat(void);
void * __fastcall GetScanline(int Row);
TColor __fastcall GetTransparentColor(void);
void __fastcall NewImage(HBITMAP NewHandle, HPALETTE NewPalette, const tagDIBSECTION &NewDIB, bool
OS2Format, Classes::TStream* RLEStream);
void __fastcall ReadStream(Classes::TStream* Stream, int Size);
void __fastcall ReadDIB(Classes::TStream* Stream, unsigned ImageSize);
void __fastcall SetHandle(HBITMAP Value);
virtual void __fastcall SetHandleType(TBitmapHandleType Value);
void __fastcall SetMaskHandle(HBITMAP Value);
void __fastcall SetMonochrome(bool Value);
void __fastcall SetPixelFormat(TPixelFormat Value);
void __fastcall SetTransparentColor(TColor Value);
void __fastcall SetTransparentMode(TTransparentMode Value);
bool __fastcall TransparentColorStored(void);
void __fastcall WriteStream(Classes::TStream* Stream, bool WriteSize);
protected:
virtual void __fastcall Changed(System::TObject* Sender);
virtual void __fastcall Draw(TCanvas* ACanvas, const Windows::TRect &Rect);
virtual bool __fastcall GetEmpty(void);
virtual int __fastcall GetHeight(void);
virtual HPALETTE __fastcall GetPalette(void);
virtual int __fastcall GetWidth(void);
void __fastcall HandleNeeded(void);
void __fastcall MaskHandleNeeded(void);
void __fastcall PaletteNeeded(void);
virtual void __fastcall ReadData(Classes::TStream* Stream);
virtual void __fastcall SetHeight(int Value);
virtual void __fastcall SetPalette(HPALETTE Value);
virtual void __fastcall SetWidth(int Value);
virtual void __fastcall WriteData(Classes::TStream* Stream);
public:
__fastcall virtual TBitmap(void);
__fastcall virtual ~TBitmap(void);
virtual void __fastcall Assign(Classes::TPersistent* Source);
void __fastcall Dormant(void);
void __fastcall FreeImage(void);
virtual void __fastcall LoadFromClipboardFormat(Word AFormat, unsigned AData, HPALETTE APalette);
virtual void __fastcall LoadFromStream(Classes::TStream* Stream);
void __fastcall LoadFromResourceName(unsigned Instance, const AnsiString ResName);
void __fastcall LoadFromResourceID(unsigned Instance, int ResID);
void __fastcall Mask(TColor TransparentColor);
HBITMAP __fastcall ReleaseHandle(void);
HBITMAP __fastcall ReleaseMaskHandle(void);
HPALETTE __fastcall ReleasePalette(void);
virtual void __fastcall SaveToClipboardFormat(Word &Format, unsigned &Data, HPALETTE &APalette);
virtual void __fastcall SaveToStream(Classes::TStream* Stream);
__property TCanvas* Canvas = {read=GetCanvas};
__property HBITMAP Handle = {read=GetHandle, write=SetHandle, nodefault};
__property TBitmapHandleType HandleType = {read=GetHandleType, write=SetHandleType, nodefault};
__property bool IgnorePalette = {read=FIgnorePalette, write=FIgnorePalette, nodefault};
__property HBITMAP MaskHandle = {read=GetMaskHandle, write=SetMaskHandle, nodefault};
__property bool Monochrome = {read=GetMonochrome, write=SetMonochrome, nodefault};
__property TPixelFormat PixelFormat = {read=GetPixelFormat, write=SetPixelFormat, nodefault};
__property void * ScanLine[int Row] = {read=GetScanline};
__property TColor TransparentColor = {read=GetTransparentColor, write=SetTransparentColor, stored=TransparentColorStored
, nodefault};
__property TTransparentMode TransparentMode = {read=FTransparentMode, write=SetTransparentMode, default=0
};
};
In the program used next:
Graphics::TBitmap* FThumb;
and
FThumb->Width = lpbih->biWidth;
FThumb->Height = lpbih->biHeight;
But where is in that class Width and Height I don`t know...
|
|
|
|
|
How to add a Shortcut key at runtime into application's Accelerator table.
|
|
|
|
|
You may try getting the current accelerator handle (e.g., m_hAccelTable in a CFrameWnd) and:
1 - Use CopyAcceleratorTable to obtain the current table into an array of ACCEL structures.
2 - Add more ACCEL structures to the array.
3 - Create a new table from the array using CreateAcceleratorTable
4 - Changing the current accelerator to the new one.
5 - Destroy the old accelerator using DestroyAcceleratorTable
It's just a suggestion. Never tried it.
An alternative would be to create a separate table in a derived window and use it in your override for PreTranslateMessage:
BOOL CYourWindow::PreTranslateMessage(MSG* pMsg)
{
if (m_hAccel != NULL && TranslateAccelerator(m_hWnd, m_hAccel, pMsg))
return TRUE;
return CYourWindowBase::PreTranslateMessage(pMsg);
}
The above could be done in a class derived from CWinApp too.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hello,
How can I get unicode build?
I got these two errors after my trying.
C:\haranadh\abc.cpp(185) : error C2664: 'lstrcpyW' : cannot convert parameter 1 from 'char [32]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\haranadh\abc.cpp(187) : error C2665: 'AfxMessageBox' : none of the 2 overloads can convert parameter 1 from type 'char [32]'
Error executing cl.exe.
abc.exe - 2 error(s), 0 warning(s)
My code is as follows-
----------------------
struct ABCAAA
{
UINT cbSize;
DWORD dwMask;
DWORD dwEffects;
LONG yHeight;
LONG yOffset;
COLORREF crTextColor;
BYTE bCharSet;
BYTE bPitchAndFamily;
char szFaceName[32];
};
void CAbcDlg::OnMyButton()
{
ABCAAA cf;
lstrcpy(cf.szFaceName,_T("Wingdings 3"));
AfxMessageBox(cf.szFaceName);
}
-----
Here I changed some settings of vc++ to build my project in Unicode build.
1)I added in Project Settings->Link->Object/Librirary Modules-> version.lib Winmm.lib
2)Project Settings->C/C++->Preprocessor Definitions->WIN32,NDEBUG,_WINDOWS,_AFXDLL,_MBCS,UNICODE
-----
but I got errors. Previously before changes It works fine.
How can I get unicode build?
Tox, Alok or Anyone Please Help me.
|
|
|
|
|
The error message is telling you exactly what's wrong. lstrcpyW() (the Unicode version of lstrcpy() ) expects a unsigned short* (more commonly expressed as wchar_t* or LPWSTR ) as the first parameter, but you're passing a char array. You probably want szFaceName to be a TCHAR array.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | NEW~! CP SearchBar v3.0 | C++ Forum FAQ
#include "witty-quote.h"
|
|
|
|
|
Actually This is I am using as testing program.
But the structure in my actual program is predefined.
that is
typedef struct _charformat
{
UINT cbSize;
DWORD dwMask;
DWORD dwEffects;
LONG yHeight;
LONG yOffset;
COLORREF crTextColor;
BYTE bCharSet;
BYTE bPitchAndFamily;
char szFaceName[LF_FACESIZE];
} CHARFORMATA;
I am using an instance for that typedef.
Thanks for reply.
|
|
|
|
|
-change char szFaceName[32] to TCHAR szFaceName[32];;
|
|
|
|
|
I know that. Please check my previous reply.
That was predefined. Just here I wrote sample program.
Any way. Thanks for your reply.
|
|
|
|
|
If you want to write code that can be compiled both in MBCS and Unicode you need to:
- Define all your char arrays as TCHAR arrays (e.g., TCHAR szFaceName[32])
- Write all char and string literals using _T macro (e.g., _T("Wingdings 3"))
Additionally, for the Unicode build, you need to:
- Define both UNICODE and _UNICODE
- Remove the define for MBCS
- Set in the linker settings wWinMainCRTStartup as the entry point
That being said, the struct ABCAAA is actually the CHARFORMAT structure, right? Take a look at richedit.h in the VS include files. You'll see a CHARFORMATA (defining szFaceName as a char[]), and a CHARFORMATW (defining szFaceName as a WCHAR[]). Then, you'll see CHARFORMAT defined as follows:
#if (_RICHEDIT_VER >= 0x0200)
#ifdef UNICODE
#define CHARFORMAT CHARFORMATW
#else
#define CHARFORMAT CHARFORMATA
#endif // UNICODE
#else
#define CHARFORMAT CHARFORMATA
#endif // _RICHEDIT_VER >= 0x0200
So, it seems that CHARFORMATA is used even for Unicode builds, unless you also define _RICHEDIT_VER to 0x200 or more. See the following link for info about Rich Edit controls and their versions:
About Rich Edit Controls[^]
Then, if you are going to target 1.0 version, you'll keep using the CHARFORMATA struct, so your sample code should be written as follows:
void CAbcDlg::OnMyButton()
{
CHARFORMAT cf;
int nMaxNameLen = (sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]))-1;
strncpy(cf.szFaceName, "Wingdings 3", nMaxNameLen);
cf.szFaceName[nMaxNameLen] = '\0';
AfxMessageBox(A2T(cf.szFaceName));
}
This code should work in either MBCS or Unicode builds, for RichEdit version 1.0.
For RichEdit version 2.0 and higher, the code should be:
void CAbcDlg::OnMyButton()
{
CHARFORMAT cf;
int nMaxNameLen = (sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]))-1;
lstrcpyn(cf.szFaceName, _T("Wingdings 3"), nMaxNameLen);
cf.szFaceName[nMaxNameLen] = _T('\0');
AfxMessageBox(cf.szFaceName);
}
and that should again work for either Unicode or MBCS builds.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
i am getting error in following code please help
see the function below
i get date as "Sep-05-2005" which i initially read in smonth
after that take from it smonth as Sep and using switch nmonth as 9
now after taking month and removing it from string -05-2005 is left then
comes day
nday=05
now 05-2005 is left
but when 05 is removed instead of -2005 only -20 is left
this error occurs when first time this function is called on exit
for 2, 3 or ___ no error occurs we get complete -2005
i find this in debug mode
BOOL CXmlData::FnCheckForValidDates(CString szEndDate)
{
//Get Current date
CTime TodayDate=CTime::GetCurrentTime();
int nYear,nMonth,nDay;
CString sMonth;
//date format MM-DD-YYYY
//Extract Month
sMonth=(szEndDate.Left(szEndDate.Find('-')));
//remove the month from String
szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),""); //-05-2005
//Replace Extra '-'
szEndDate.TrimLeft('-');
//code to get int month from string smonth
if(sMonth == "Jan" )
{
nMonth=1;
}
else if(sMonth == "Feb" )
{
nMonth=2;
}
else if(sMonth == "Mar" )
{
nMonth=3;
}
else if(sMonth == "Apr" )
{
nMonth=4;
}
else if(sMonth == "May" )
{
nMonth=5;
}
else if(sMonth == "Jun" )
{
nMonth=6;
}
else if(sMonth == "Jul" )
{
nMonth=7;
}
else if(sMonth == "Aug" )
{
nMonth=8;
}
else if(sMonth == "Sep" )
{
nMonth=9;
}
else if(sMonth == "Oct" )
{
nMonth=10;
}
else if(sMonth == "Nov" )
{
nMonth=11;
}
else if(sMonth== "Dec")
{
nMonth=12;
}
//Extract Day
nDay=_ttoi(szEndDate.Left(szEndDate.Find('-')));
//remove the day from String//05-2005
szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),""); but here -20 is left
//Replace Extra '-'
szEndDate.TrimLeft('-');
//Extract year
nYear=_ttoi(szEndDate);
//Expiry date
CTime ExpiryDate(nYear,nMonth,nDay,0,0,0);
//comparison Routine
//first Check year
//comparing todays date with expirey date
if(TodayDate>ExpiryDate)
return FALSE;
#ifdef MYDEBUG
AfxOutputDebugString("Returning True");
#endif
return TRUE;
}
Ankit Aneja
|
|
|
|