|
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
|
|
|
|
|
|
thanks done
but i do not understand why was it giving error that way
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Ankit Aneja wrote:
i do not understand why was it giving error that way
Because there are two 05 in the string
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
thanks ,very clever
but this was not my code
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Ankit Aneja wrote:
this was not my code
then whose code is this
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
it is not good to tell person name publiculy because that
person is having good reputation on code project
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
In programming world ppl do not go by their reputation of a good person in codeproject, If s/he writes bad code it means s/he writes bad code plus the ppl in codeproject dont take programming mistakes too personally.
Your comments probably help the dev to understand his mistake.
-prakash
|
|
|
|
|
Hello everybody,
Does anybody know how I can use the method ExecWB of the WebBrowser control for opening a file on the local machine:
ExecWB(OLECMDID_OPEN, OLECMDEXECOPT_DODEFAULT, ?, ?);
I don't know the use of parameters 3 and 4.
I Also don't want to use Navigate method because of the download prompting.
thanks in advance
Roozbeh.
-- modified at 4:14 Saturday 3rd September, 2005
|
|
|
|
|
I wanna to know about this syntax
istream& getline(char *buffer, int length, char terminal_char);
& operator before getline ,what it represent?
Or sometime instead of & there is * also.
What it represent?
Rupal
|
|
|
|
|
hum, i think you need some basic notions about C++.
in such declaration syntax, operator & represent the declaration of a reference, and operator * represent the declaration of a pointer...
in you example, getline get as paramater a pointer to char (buffer), an int (length) and a char (terminal_char). it returns then a reference to an istream instance.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
|
return back the reference of an object
|
|
|
|
|
Rupali Sarda wrote:
What it represent?
Please don't mind, you need read this book, it's contain all the basic concept of c++ Plus it free online http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hello
I have a dialog based application where i am popping a modeless dialog from the OnInitDialog() of this dialog.I alos have a menu in the parent dialog.What i want is that if user clicks on red cross button and calls OnClose()(WM_CLOSE)then only he should be able to create another modeless dialog through menu.How should i override the OnClose and menu handler.I tried to set a variable of my parent dialog in OnClose of modeless dialog and then check it in OnMenu(0 handler but this is not working.Can somebody expalin to me what happens when we click on red cross button of modeless dialog.Do i need to call destroyWindow()?
please help
thanks in advance
|
|
|
|
|