|
PatrykDabrowski wrote: (ie. like those in IE6)
Look up CReBar.
|
|
|
|
|
|
|
PatrykDabrowski wrote: I can't load my 32x32 24-bit bitmaps into it (Visual Studio 2003 resource editor converts them to some ugly-looking 8-colors bitmaps...)
When you create the image list for the toolbar control, try building it like this...
CBitmap bitmap;
bitmap.LoadBitmap(IDB_TOOLBARBITMAP);
// (the '2' in the following call is the number of buttons in the bitmap)
m_ToolBarImageList.Create(32, 32, ILC_COLOR24|ILC_MASK, 2, 1);
// (RGB(0x00,0xFF,0x00) sets the transparent color to bright green)
m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00));
|
|
|
|
|
Hi,
I get an error while running the application but i don't get when i debug it..the error is:
the exception Breakpoint
A breakpoint has been reached.
(0X80000003) occured in the application at location 0X7c901230
can anyone help me out with this?
thnx,
Priya
|
|
|
|
|
this happens in an ASSERT() when the condition is false...
|
|
|
|
|
i created xml file need to read, the file read the data ( ??? might be !!
not sure ,
when i print that data in the messagebox it gives the square box like.
hFile=CreateFile ( L"c:\\FileProperty.XML"
, GENERIC_READ | GENERIC_WRITE
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
if(hFile == INVALID_HANDLE_VALUE)
{
MessageBox(0,_T("File is not created"),_T("Create File"),0);
}
else
{
MessageBox(0,_T("File is created"),_T("Create File"),0);
}
bool bSucced=ReadFile(hFile,&szBuff,5000,&dwRecvLen,NULL);
szBuff[dwRecvLen] = '\0';
MessageBox(0,LPCWSTR(szBuff),L"Message",0);
how can i print that data in the string form?.
amit
|
|
|
|
|
Well, there seems to be a some errors in the code you posted.
You seem to have made the memory allocation for szBuff out-commented.
You assume that the file size doesn't exceed 5000 bytes.
I don't exactly get what you mean by "square box like", but I guess that you have enabled unicode for your build configuration and the first bytes in the "string" you want to display evaluates to a token that doesn't match a writeable character.
You even type cast to a LPCWSTR , which in this case doesn't have any effect since the MessageBox parameter is dependant on whether you have enabled unicode support or not.
The bottom line is that you have to be consistant: if you have enabled unicode support then you have to make sure that the file data is converted unless the file is already in unicode format, which I suspect it's not and that's what I think gives the result you've described.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
ya exactly , i forget to write that thing its unicode thats why its come like
square box but how can do it in readable form?
because the messagebox show the unicode character so how to make that data to
read meaningful.
ok i made that file unicode then will it give me the data in the proper
readable form?
amit
|
|
|
|
|
amitmistry_petlad wrote: ok i made that file unicode then will it give me the data in the proper
readable form?
Technically: yes.
But, perhaps other applications that are supposed to use the file may no longer use it since you've changed the file format.
My suggestion:
Read the file as usual and then convert to unicode with ::MultiByteToWideChar() .
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
But for that how can i convert my DWORD TO string look the following code:
std::string source(szBuff);
WCHAR w_Out[MAX_PATH];
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,source.c_str(),(int)(source.length() + 1),w_Out,MAX_PATH);
MessageBox(0,LPCWSTR(w_Out),L"Message",0);
amit
|
|
|
|
|
amitmistry_petlad wrote: DWORD
What DWORD?
If you mean values read from the xml-file, you can convert them from textual format into DWORDs by calling ::wcstol() .
I'm just guessing that the above is your problem. If it's not, describe it further.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
i think you might forget the previous code so ,
look i explain with detail code .
WCHAR szBuff[5000]={}; // which i have declare global
//below is my function which used the gelobal variable szBuff read data from file
void _FilePersistandata()
{
HANDLE hFile;
DWORD dwFileSize, dwHighSize, dwBytesRead ;
DWORD dwRecvLen = 0;
hFile=CreateFile ( L"c:\\FileProperty.XML"
, GENERIC_READ | GENERIC_WRITE
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
if(hFile == INVALID_HANDLE_VALUE)
{
MessageBox(0,_T("File is not created"),_T("Create File"),0);
}
else
{
MessageBox(0,_T("File is created"),_T("Create File"),0);
}
bool bSucced=ReadFile(hFile,<big>&szBuff</big>,5000,&dwRecvLen,NULL);
szBuff[dwRecvLen] = '\0';
<code>
std::string source(szBuff);
</code>
WCHAR w_Out[MAX_PATH];
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,source.c_str(),(int)(source.length() + 1),w_Out,MAX_PATH);
MessageBox(0,LPCWSTR(w_Out),L"Message",0);
}
let me know if something is wrong here ,then i'll change it.
amit
|
|
|
|
|
Instead of making assumptions about my memory, you should get your datatypes straight.
The things you claim to be DWORD is never DWORD in the code you've posted.
You declare szBuff as an array of WCHAR and WCHAR is a typedef that can be either 8 or 16 bits wide, but never 32 as a DWORD . In your configuration it's 16 bits wide since you've enabled support for unicode.
The only thing about szBuff that is 32 bits wide is its address you provide as argument in the call to ReadFile , but do not mix up an address with a 32 bit integer value.
ReadFile read the contents of a file in raw format, i.e. byte-wise, and puts it at a memory location you provide as argument, szBuff in your case. If the format of the data read doesn't fit your needs, convert it! In this case by calling MultiByteToWideChar providing the buffer with the data read as input and a pointer to a new location where you want the resulting data to be stored.
Bring up the memory debug window and have a look at your <codes>zBuff. After a successful call to ReadFile you will see the contents of your file there.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
|
hello friends
char ch[10];
Cstring str ="Rahul"
memset(ch,0,10);///set ch to '\0';
memcpy(ch,str,5);
plz tell me where ch will be stored..on heap or on stack..thanks
Born To Code
|
|
|
|
|
as you don't allocate it with a new, it will be in the stack...
|
|
|
|
|
Both of your variables will be located on the stack. Even the 10 bytes referred to by ch will be located on the stack.
To use the heap you have to allocate memory by calling new in C++ or malloc or similar in C and you always get a pointer in return to be able to refer to the allocated memory.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
rahul.shendurnikar wrote: char ch[10];
CString str ="Rahul"
Both of those allocate the specified objects on the stack - that is, the array of char and the CString object will be allocated on the stack.
However, note the memory used by the CString object will be allocated on the heap, because that is how CString s work. In other words, you are causing two kinds of allocations when really only one is required. Oh, and since heap allocation operations can raise exceptions, you should be assigning to that string object in a try/catch block just to be safe!
Note that you are getting really lucky by using memcpy to copy into the string object's buffer - that is generally not the correct way to get data into or out of a real object.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: Note that you are getting really lucky by using memcpy to copy into the string object's buffer - that is generally not the correct way to get data into or out of a real object.
Where is he doing that?
|
|
|
|
|
You are correct - he is copying out of it, but only by the grace of CString::operator LPCTSTR() . My warnings still stand, though.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
heh I just noticed it was memcpy .
I was thinking hmm I thought that's what the LPCTSTR() operator was FOR!
Never mind
|
|
|
|
|
Hi everybody,
in my application i have a GridCtrl on a View.
If the Grid has the focus and i hit a Key, the OnKeyDown Event of the GridCtrl responses.
All nice ...
But if i hit the Escape Key, this stroke will not be catched in the GridCtrl.
Also the F6-Key.
Is there a special thing that i don't know?
Big thanks
|
|
|
|
|
In a text box. you need to override the OnGetDlgCode function as shown to get all keys.
UINT CEdit_Numeric::OnGetDlgCode()
{
return( CEdit::OnGetDlgCode() | DLGC_WANTALLKEYS );
}
Then you can get the keys with
void CEdit_Numeric::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch(nChar)
{
case VK_RETURN:
.................
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
maybe its the same with a grid control
|
|
|
|
|
Big thanks !
It resolves the problem behind this problem LOL
|
|
|
|
|