|
>>well at first i just read all of it into one buffer. i defined it like so
>>char *szBuffer;
Well Mr. Hotshot, are you allocating memory for szBuffer ??? before using it with your file-handling-functions.... IF NO.... god help you .
If yes... sorry.
USE malloc or new to alllocate appropriate amount of memory.
>>note: when i did this in segments i defined my buffer like
>>char szBuffer[1024];
look closely... here you alocate the buffer's size to be 1024 bytes. BUT in char* szBuffer.... YOU MAY NOT BE ALLOCATING ANY MEMORY and the 'BLUE SCREEN' loves programmers like you.
.... i hope i helped;)
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Funny how right when i go and ask for help my problem seem to be solved before i get an answer
I kinda reverted my code to the way it was when i gettting the bsod and now it seems to be working just fine
and i manged to get SetFilePointer() to go to the end but i had to use GetFileSize()
Logically you would think you could go to the end by doing
SetFilePointer( hFile, 0, NULL, FILE_END );
but i cant it get it to work doing that
infact i cant even get it to go anywhere from FILE_END
just occured to me could that be becuase i only used GENERIC_WRITE access?
|
|
|
|
|
Well, here's an idea to stop all those kind helping people from answering for nothing:
Once you realize you solved your problem, you could edit your original post and change its title, appending "<--solved" to it.
This would also have the added advantage of giving a clue to people having the same kind of question that they might find their answer in that thread.
Anyone agrees with me ?
|
|
|
|
|
Hi,
my application will always have this error after running for a while. The app regularly pops up modeless dialog and closing it after a while. This cycle repeats itself. The background property page will always do OnPaint when this modeless dialog pop up and closes.
Need advise on what could be the problem and how to resolve it. Thanks.
|
|
|
|
|
post some code so we will be able to guide you.
Jaime
|
|
|
|
|
please see below for portion of code
pDC->GetClipBox(&m_rect);
CreateCompatibleDC(pDC);
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
m_pOldBitmap = SelectObject(&m_bitmap); // ASSERT here
setWindowOrg(m_rect.left, m_rect.top);
Thanks.
|
|
|
|
|
Are you placing it in OnPaint method? if you are, that CreateCompatibleDC used is the global ::CreateCompatibleDC that expects a HDC as the parameter. That way, be sure the pDC is casted correctly to an HDC. By using the global API function, you will be returned an HDC for the new DC, which MUST be deleted when the DC is no longer needed.
Second, You are creating a compatible DC but you are not using it. You just continue using the old one.
Third, are you DeleteObject the bitmap you are creating?
Finally, if you are implementing a sort of double buffering, why not using a well tested class such as CMemDC which you can find in CodeProject? This class does all those affairs by you.
Jaime
|
|
|
|
|
Hi Jaime,
thanks for your reply. Actually I'm already using CMemDC and those codes are from there and the ASSERT happen in that class.
This is the CGridCtrl Class from by Chris Maunder.
void CGridCtrl::OnDraw(CDC& DrawDC)
{
CMemDC dc(&DrawDC);
#else // Use normal DC - this helps in debugging
void CGridCtrl::OnDraw(CDC& dc)
{
#endif
CRect rect;
int row,col;
CRect clipRect;
if (dc.GetClipBox(&clipRect) == ERROR) return;
EraseBkgnd(&dc); // OnEraseBkgnd does nothing, so erase bkgnd here.
// This necessary since we may be using a Memory DC.
int nFixedRowHeight = GetFixedRowHeight();
int nFixedColWidth = GetFixedColumnWidth();
......
}
Hope this is clearer. Thanks.
|
|
|
|
|
NadAzur wrote:
Hope this is clearer
Not really. What is the ASSERT text you get? Which file? What Line?
Bikram Singh
|
|
|
|
|
Dear All,
We need to generate a Word Document by using MFC. I know the method is Automation and I searched MSDN and Created and saved a simple document with one sentence in it.
But the prblem is that we need to create a document with
- Table of Contents
- Different paragraph style and headings.
- Tables with differnt styles.
- Border to the page,
- Header and Footer.
- Differnt color and fonts for different paragraphs.
- Insert Picture to Some places.
in brief, need to do almost everything by code. I searched a lot in internet to find such tutorials. But cant find. almost all are for VB. But i need VC++ code. Please help me.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Converting VB samples to VC++ is easy once you've got your head around the Word object model.
There are some good examples here[^], which go beyond a simple document. The mail-merge one is pretty good.
I've found the best way to learn the Word Object model is to use the Word Macro recorder to generate VBA code for the operation and then convert that to C++. It's fairly easy if you use #import to generate the C++ wrappers for the object model.
Michael
CP Blog [^]
|
|
|
|
|
Dear Michael,
Thank you very much for your advice. Its very much helpful.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Just load MS Word..... menu Tools/Macro and Record New macro..... do the operation you want to know the code, stop recording, go to Visual Basic Editor and see the code. You can get help for the objects and their methods too.
You can do everything by code.
Jaime
|
|
|
|
|
Dear Jaime,
Thank you very much for your reply. Its very much helpful and easy.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
CString m_sname ;
Rsc->PutCollect("s_name",_variant_t(m_sname));
The question is
when m_sname's value is 6B 62 7A FA 1B D4 A2 7C,
6B is 'k',62 is 'b',7A is 'z',D4 A2 is '寓'(chinese word),7C is '|',but 7A FA has no corresponding character .so 7A FA has
been changed to 3F('?') and stored .I want to know if some ways can solve this question.Thank you !
|
|
|
|
|
use nvarchar datatype in the SQL Server column
Jaime
|
|
|
|
|
sirtimid wrote:
db.Open(_T(""), FALSE, FALSE, "ODBC;DSN=MY_DSN");
I believe this should be (with added exception handling):
TRY
{
db.Open(NULL, FALSE, FALSE, "ODBC;DSN=MY_DSN");
}
CATCH(CDBException, pDBException)
{
...
}
END_CATCH But that's probably just a semantics thing.
sirtimid wrote:
Now I want to open the table "MyTable" from the database, how should I do this?
Derive a class from CRecordset using ClassWizard. It will ask you which table(s) the record set should operate on. After than, just instantiate an object of this new class, something like:
TRY
{
CMyRecordset rs(&db);
rs.Open();
if (! set.IsBOF())
{
rs.MoveFirst();
while (! rs.IsEOF())
rs.MoveNext();
}
}
CATCH(CDBException, pDBException)
{
...
}
END_CATCH
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
1)
The Class Wizard has a problem with MSAccess 2000 files. I you will need to make the same database with Access 97 and derive your classes with that.
2)
For MSAccess, using CDaoDatabase and CDaoRecordset are the better choice.
3)
Do like DavidCrow has written before.
MS
|
|
|
|
|
I have both Studio 6 and Studio .NET installed on one machine. I want to be able to attach to either debuggers via Task Manager right click "Debug" context menu item. I have figured out how to modify the "Debug" command for either studio (e.g. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger). However, what I want is to add 2 items to the context menu of Task Manager so that I can choose which debugger I want. I haven't been able to find the location of Task Manager's context menu data in the registry which makes me think that it may not be alterable. Unless someone knows and I have overlooked - which I am hoping is the case.
Thanks!
|
|
|
|
|
Why not a simple EXE that acts as a proxy.
Once an attach has been requested, u pop up this exe and from it you have the various choices, and based on the choice, you invoke the correct debugger with the correct command line.
Something like :
"MSDEV -p procid -e procid"
I have to tell you that Studio .NET will nag that he aint the JIT debugger, so a workaround to this problem would be to set it as the JIT debugger then to reactivate yourself as the JIT debugger afterwards.
Good luck.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for the response and suggestion, but I have successfully launched VC6 Debugger by altering the registry previously mentioned and haven't had a problem with the JIT debugger. If it turns out that I can't add to the context menu, I will pursue your suggestion.
Thanks!
|
|
|
|
|
Maybe i didnt make it clear, but VC6 would attach happily by just using the command line, VS.NET would nag if he finds out he's not the prefered JIT
Another choice is like it is suggested in the other post, to attach from within the interface.
For me i find it much easier to have a small exe where i can chose directly my debugger for the current problem, would it be VC6 VS.NET, WinDbg, OllyDbg or ... let it crash!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
You can't modify task-manager but both VS.NET and VS6 allow you to attach to a running process. The option is on the debug menu of VS.NET and on the Build->Start Debug menu of VC6.
Michael
CP Blog [^]
|
|
|
|
|
Thanks - I am aware of that, but I am falling in line with the adage that "Programmers are lazy."
|
|
|
|
|
Jnewg5 wrote:
Thanks - I am aware of that, but I am falling in line with the adage that "Programmers are lazy."
As a lazy programmer myself, I find using the VS.NET menu easier and quicker, but then again it is very rare that I need to debug an app built by VS6. Only got one supported product using it now.
Michael
CP Blog [^]
|
|
|
|