|
I guess I wanted each instance to be unique.
|
|
|
|
|
Software2007 wrote: My question is how will I be able to find out the application instance
You could store the process ID; but that should change each time you start the applications.
Software2007 wrote: as I need for each of these instances to have its own settings. can this be done?
How will you start the application ? or the question is how do you match the settings for each instance of the application ?
Could you start each instance with a command line parameter with the setting information ?
Where are the settings stored ? files ? registry ?
M.
Watched code never compiles.
|
|
|
|
|
I guess the above suggestion would wrk for me by assigning registry names based on each instance number like Registry instance #1, Registry Instance #2...etc), I can read and write based on the instance #.
|
|
|
|
|
|
Hi All,
I am running an application which is a form view application.I am allocating memory of size 160kb in a for loop .I am allocating memory at the begining of for loop for each iteration and freeing it at the end of each iteration.I have 133 such iteration.But i am facing a problem.In the 9th iteration when i am trying to allocate a memory using malloc the application crashes.
I am getting the following messsage in the output window.
HEAP[TEST.exe]: HEAP: Free Heap block 3f277a8 modified at 3f27850 after it was freed
I am getting the following messages in the call stack window:
ntdll.dll!7c90120e()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!7c96e139()
ntdll.dll!7c94b535()
ntdll.dll!7c927573()
ntdll.dll!7c91005d()
ntdll.dll!7c927784()
ntdll.dll!7c927573()
> TEST.exe!_heap_alloc_base(unsigned int size=160036) Line 105 + 0x28 bytes C
TEST.exe!_heap_alloc_dbg_impl(unsigned int nSize=160000, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 427 + 0x9 bytes C++
TEST.exe!_nh_malloc_dbg_impl(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 239 + 0x19 bytes C++
TEST.exe!_nh_malloc_dbg(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0) Line 296 + 0x1d bytes C++
TEST.exe!malloc(unsigned int nSize=160000) Line 56 + 0x15 bytes C++
TEST.exe!TEST_IDP_FUNC1(unsigned char * pucSrcImg=0x07200068, unsigned char * pucDstImg=0x059d4d68, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 529 + 0x11 bytes C
TEST.exe!TEST_IDP_FUNC2(unsigned char * pucSrcImg=0x05aecc58, unsigned char * pucDstImg=0x03f00690, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, unsigned short uiDstRows=400, unsigned short uiDstCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 4117 + 0x1b bytes C
TEST.exe!CTEST::FUNC3(CTESTImage * objSrcImage=0x03e726c8, CTESTImage * objDstnImage=0x03e7a050, unsigned char * pucDstImg=0x03f00690) Line 107 + 0x25 bytes C++
TEST.exe!CTESTView::FUNC4() Line 8346 C++
TEST.exe!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x0039c900, unsigned int nID=32902, int nCode=0, void (void)* pfn=0x00401276, void * pExtra=0x00000000, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 82 C++
TEST.exe!CCmdTarget::OnCmdMsg(unsigned int nID=32902, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 381 + 0x27 bytes C++
TEST.exe!CView::OnCmdMsg(unsigned int nID=32902, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 162 + 0x18 bytes C++
TEST.exe!CFrameWnd::OnCmdMsg(unsigned int nID=32902, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 942 + 0x23 bytes C++
TEST.exe!CFrameWndEx::OnCmdMsg(unsigned int nID=32902, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 995 + 0x18 bytes C++
TEST.exe!CWnd::OnCommand(unsigned int wParam=32902, long lParam=0) Line 2364 C++
TEST.exe!CFrameWnd::OnCommand(unsigned int wParam=32902, long lParam=0) Line 366 C++
TEST.exe!CFrameWndEx::OnCommand(unsigned int wParam=32902, long lParam=0) Line 359 + 0x10 bytes C++
TEST.exe!CWnd::OnWndMsg(unsigned int message=273, unsigned int wParam=32902, long lParam=0, long * pResult=0x015cfcd8) Line 1769 + 0x1e bytes C++
TEST.exe!CWnd::WindowProc(unsigned int message=273, unsigned int wParam=32902, long lParam=0) Line 1755 + 0x20 bytes C++
TEST.exe!AfxCallWndProc(CWnd * pWnd=0x0039a4a0, HWND__ * hWnd=0x00190eae, unsigned int nMsg=273, unsigned int wParam=32902, long lParam=0) Line 240 + 0x1c bytes C++
TEST.exe!AfxWndProc(HWND__ * hWnd=0x00190eae, unsigned int nMsg=273, unsigned int wParam=32902, long lParam=0) Line 403 C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e4189cd()
user32.dll!7e418a10()
TEST.exe!AfxInternalPumpMessage() Line 183 C++
TEST.exe!CWinThread::PumpMessage() Line 900 C++
TEST.exe!CWinThread::Run() Line 629 + 0xd bytes C++
TEST.exe!CWinApp::Run() Line 865 C++
TEST.exe!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020882, int nCmdShow=1) Line 47 + 0xd bytes C++
TEST.exe!wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020882, int nCmdShow=1) Line 34 C++
TEST.exe!__tmainCRTStartup() Line 263 + 0x2c bytes C
TEST.exe!wWinMainCRTStartup() Line 182 C
kernel32.dll!7c817077()
Please help.
Thanking you,
Ashwath.
|
|
|
|
|
Code Watson, we need code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Code, plz. Urgent. Doesn't that work?
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
Chris Meech wrote: I am Canadian. [heard in a local bar]
I don't get it (I feel stupid...).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Ah, OK. Thank you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ashwath1979 wrote: I am allocating memory of size 160kb in a for loop
Don't do this.
Use a standard STL container like vector instead.
The container will manage the heap allocations for you.
|
|
|
|
|
This error means that your application has freed the memory but continued to use it or modify it after doing so. This can happen in a Windows application if you try to pass the memory to a window (like an edit box or other control) via the message queue using PostMessage, or an API call that uses PostMessage.
|
|
|
|
|
I use pdf library version 5 from here and I didn't get it an error :
try
{
PDFlib pdf;
pdf.set_parameter("compatibility", "1.4");
if (pdf.open("test.pdf")==-1)
{
AfxMessageBox("Can not create PDF file.", MB_ICONERROR);
return;
}
pdf.begin_page(a4_width, a4_height);
int font=pdf.findfont("Arial", "winansi", 1);
pdf.setfont(font, 12);
pdf.set_text_pos(10, a4_height - 10);
pdf.show("Hello World!");
pdf.arc(3,40,1,2,2);
pdf.end_page();
pdf.close();
}
catch(PDFlib::Exception& pException)
{ .... }
the application shutdown without any warning ...
error result is :
error C2039: 'Exception' : is not a member of 'PDF'
d:\vc++\mdi\testpdf\pdflib.hpp(67) : see declaration of 'PDF'
error C2061: syntax error : identifier 'Exception'
can you give me a hint ?
|
|
|
|
|
hi,
take a look at
catch(PDFlib::Exception& pException)
may the 'Exception' does not exists in PDFlib.
|
|
|
|
|
Which version of the library are you using? The Exception class is part of the PDFlib class, not part of the PDF class as the error message correctly states.
What is really odd with your error message is that the code is to instantiate a PDFlib::Exception object which is valid, but the error message says that Exception is not part of PDF. Where is PDF declared?
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
Object Exception is declared in pdflib.hpp , which is included in top of file that contain listing code : #include "pdflib.hpp" , still , Exception object is not recognized in catch statement ...
|
|
|
|
|
I noticed something : Exception object have precompiled statement :
#ifdef PDF_THROWS_CPP_EXCEPTIONS class Exception { public:
Exception(string msg, void *opaque); string get_message();
const void *get_opaque();
...
...
...
I put same thing on try/catch statement and I not have compile errors anymore , but , when program front that dummy code , programs stop without any warning , which prove that catch statement don't catch really error ...
|
|
|
|
|
Hello,
I am having a problem with iostream in the header file FlexLexer.h and the generated output of the gnuwin32 flex -+ code.
I am using the flex tool of gnuwin32
flex
and want to use the -+ switch to create "c++" code.
If I compile the flex generated code and the FlexLexer.h header I get the error
fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
I replaced the #include <iostream.h> in the FlexLexer.h with
#include <iostream>
using namespace std;
but now I get the error:
error C2872: 'istream' : ambiguous symbol
This error occures because the generated code contains a forward
class istream;
Is there a way to get rid of it and to replace it with
#include <iostream>
using namespace std;
Can anyone help me with this problem?
Thanks a lot,
Andreas.
Andreas.
|
|
|
|
|
Yes since istream is in the std namespace, its forward declaration must also be in std namespace. Change the forward declaration to:
namespace
{
class istream;
};
-Saurabh
|
|
|
|
|
That doesn't help, than I get the following error:
FlexLexer.h(66) : error C2872: 'istream' : ambiguous symbol
1> could be 'C:\Program Files\Microsoft Visual Studio 8\VC\include\iosfwd(700) : std::basic_istream<_Elem,_Traits> std::istream'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> or '.\abc.cpp(27) : `anonymous-namespace'::istream'
Andreas.
|
|
|
|
|
Hello,
everybody who is interested in, I found a solution (workaround) for the iostream problem:
First replace FlexLexer.h the line
#include <iostream.h>
with
#include <iostream>
using namespace std;
than modify the skeleton file
flex.skl that you can find in the unix version flex and replace the line:
class istream;
with
#include <iostream>
using namespace std;
than use flex with the skeleton file argument: -Sflex.skl
Cheers,
Andreas.
Andreas.
|
|
|
|
|
Thanks for your post, it's saved me a lot of headache
maybe we can finetune it a little: the first part is redundant since you already do
#include <iostream>
using namespace std;
in the skeleton/generated code
I see two options here:
1. do
#include <iostream>
using namespace std; in the skeleton and just comment #include <iostream.h> out of FlexLexer.h
maybe this is cleaner since FlexLexer.h depends on iostream:
2. replace #include <iostream.h> with
#include <iostream>
using namespace std;
in FlexLexer.h and in the skeleton move FlexLexer inclusion forward so you dont need isstream forward definition anymore:
#include <FlexLexer.h><br />
hope this helps
|
|
|
|
|
I heard that GUI updation is not preferred in Worker Thread.
Does any one tell me the reason with the help of a msdn article.
Ajayraj
|
|
|
|
|
Have a look at this article[^] at the section called "Worker threads and the GUI II: Don't touch the GUI".
|
|
|
|
|
It would be not possible
to manage any alarm events or even the mouse click events -
without the updating of a complex drawn picture
(for example, with motions, blinking, transformations, Direct2D interludes...) -
by a worker thread... But it is possible (with a worker thread)
virtual void BeHappy() = 0;
|
|
|
|
|