|
Thanks DavidCrow,
What is d-pointer?
I divide into small piece because we are discuss in short statements, e.g. ten lines of answers, 5 minutes or less is enough to answer a question. If my questions are too big, I do not want to bring extra burden to people here to answer, say write an answer for 20 minutes.
regards,
George
|
|
|
|
|
<br />
#include "FindNoPlat.h"<br />
#include "stdafx.h"<br />
#include "ODBC1.h"<br />
<br />
#include "ODBC1Set.h"<br />
#include "ODBC1Doc.h"<br />
#include "ODBC1View.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
IMPLEMENT_DYNCREATE(CODBC1View, CRecordView)<br />
<br />
BEGIN_MESSAGE_MAP(CODBC1View, CRecordView)<br />
ON_COMMAND(ID_RECORD_APPEND, OnRecordAppend)<br />
ON_BN_CLICKED(IDC_CHOICE1, OnChoice1)<br />
ON_BN_CLICKED(IDC_CHOICE2, OnChoice2)<br />
ON_COMMAND(ID_RECORD_FIND, OnRecordFind)<br />
ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)<br />
ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)<br />
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)<br />
END_MESSAGE_MAP()<br />
<br />
<br />
CODBC1View::CODBC1View()<br />
: CRecordView(CODBC1View::IDD)<br />
{<br />
m_pSet = NULL;<br />
m_cStatus_saman = _T("");<br />
<br />
}<br />
<br />
CODBC1View::~CODBC1View()<br />
{<br />
}<br />
<br />
void CODBC1View::DoDataExchange(CDataExchange* pDX)<br />
{<br />
int iStrLength;<br />
<br />
iStrLength = m_pSet->m_Status_saman.GetLength();<br />
m_cStatus_saman="$"+m_pSet->m_Status_saman.Left(iStrLength-2);<br />
<br />
<br />
CRecordView::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_CHOICE2, m_oChoice2);<br />
DDX_Control(pDX, IDC_CHOICE1, m_oChoice1);<br />
DDX_Control(pDX, IDC_EDIT4, m_opermit_perjalanan);<br />
DDX_Control(pDX, IDC_EDIT3, m_oStatus_saman);<br />
DDX_Control(pDX, IDC_EDIT2, m_oSykt);<br />
DDX_Control(pDX, IDC_EDIT1, m_oNo_plat);<br />
DDX_FieldText(pDX, IDC_EDIT1, m_pSet->m_No_plat, m_pSet);<br />
DDX_FieldText(pDX, IDC_EDIT2, m_pSet->m_Sykt, m_pSet);<br />
DDX_FieldText(pDX, IDC_EDIT4, m_pSet->m_permit_perjalanan, m_pSet);<br />
DDX_Text(pDX, IDC_EDIT3, m_cStatus_saman);<br />
}<br />
<br />
BOOL CODBC1View::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
<br />
return CRecordView::PreCreateWindow(cs);<br />
}<br />
<br />
void CODBC1View::OnInitialUpdate()<br />
{<br />
m_pSet = &GetDocument()->m_oDBC1Set;<br />
CRecordView::OnInitialUpdate();<br />
GetParentFrame()->RecalcLayout();<br />
ResizeParentToFit();<br />
<br />
}<br />
<br />
<br />
BOOL CODBC1View::OnPreparePrinting(CPrintInfo* pInfo)<br />
{<br />
return DoPreparePrinting(pInfo);<br />
}<br />
<br />
void CODBC1View::OnBeginPrinting(CDC* , CPrintInfo* )<br />
{<br />
}<br />
<br />
void CODBC1View::OnEndPrinting(CDC* , CPrintInfo* )<br />
{<br />
}<br />
<br />
<br />
#ifdef _DEBUG<br />
void CODBC1View::AssertValid() const<br />
{<br />
CRecordView::AssertValid();<br />
}<br />
<br />
void CODBC1View::Dump(CDumpContext& dc) const<br />
{<br />
CRecordView::Dump(dc);<br />
}<br />
<br />
CODBC1Doc* CODBC1View::GetDocument()
{<br />
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CODBC1Doc)));<br />
return (CODBC1Doc*)m_pDocument;<br />
}<br />
#endif //_DEBUG<br />
<br />
CRecordset* CODBC1View::OnGetRecordset()<br />
{<br />
return m_pSet;<br />
}<br />
<br />
<br />
<br />
void CODBC1View::OnRecordAppend() <br />
{<br />
<br />
if (m_pSet->CanAppend() == 0)<br />
MessageBox("Cannot Append Records",<br />
"Database Opening Error",<br />
MB_OK|MB_ICONERROR);<br />
<br />
else<br />
{<br />
m_oChoice1.SetWindowText("Submit Data");<br />
m_oChoice2.SetWindowText("Cancel");<br />
<br />
<br />
<br />
m_oNo_plat.SetWindowText("");<br />
m_oSykt.SetWindowText("");<br />
m_oStatus_saman.SetWindowText("");<br />
m_opermit_perjalanan.SetWindowText("");<br />
}<br />
<br />
}<br />
<br />
.<br />
.<br />
<br />
void CODBC1View::OnRecordFind() <br />
{<br />
<br />
FindNoPlat oFindIt;
BOOL Found=FALSE;
int iStrLength;
char* cQuantity="Empty1";
char* cStorage="Empty2";
CDBVariant varBookmark;
<br />
if (oFindIt.DoModal()==IDOK)<br />
<br />
{<br />
if (m_pSet->CanBookmark())<br />
m_pSet->GetBookmark(varBookmark);<br />
<br />
m_pSet->MoveFirst();<br />
<br />
<br />
while (!m_pSet->IsEOF() ^ Found);<br />
<br />
{<br />
if (m_pSet->m_No_plat == oFindIt.m_FindNoPlat);<br />
Found=TRUE;<br />
<br />
<br />
m_pSet->MoveNext();<br />
<br />
}<br />
<br />
if (!Found);<br />
<br />
{<br />
<br />
MessageBox("Record not found!",<br />
"Database Error",<br />
MB_OK|MB_ICONERROR);<br />
<br />
if (m_pSet->CanBookmark())<br />
m_pSet->SetBookmark(varBookmark);<br />
<br />
else<br />
m_pSet->MoveFirst();<br />
<br />
}<br />
<br />
<br />
{<br />
<br />
m_oNo_plat.SetWindowText(m_pSet->m_No_plat);<br />
m_oSykt.SetWindowText(m_pSet->m_Sykt);<br />
m_opermit_perjalanan.SetWindowText(m_pSet->m_permit_perjalanan);<br />
<br />
<br />
iStrLength = m_pSet->m_Status_saman.GetLength();<br />
m_oStatus_saman.SetWindowText("$" + m_pSet->m_Status_saman);<br />
}<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
this code use to find data in database using application ODBC..
there were 5 error while i compie it..
error C2065: 'FindNoPlat' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'oFindIt'
error C2065: 'oFindIt' : undeclared identifier
error C2228: left of '.DoModal' must have class/struct/union type
<
can anybody explain it to me..
tq
|
|
|
|
|
It looks like if you fix the first error, the rest of the errors
will go away.
I'd assume the FindNoPlat class is defined in the #included FindNoPlat.h file - is it?
Is the FindNoPlat class in a different namespace?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
if (m_pSet->m_No_plat == oFindIt.m_FindNoPlat);
Found=TRUE;
, the planted bomb lol
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Aren't you supposed to be working
hehe
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I posted that message when I was putting on my shoes! . Cp Suxx!
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Ever heard of formatting? I know your code was probably formatted and this was lost then you pasted it, but you can (and I do) manually paste in tabs and rectify this. I can't be bothered to even look at code when it's presented like this.
Steve
|
|
|
|
|
ieyra204 wrote: can anybody explain it to me..
We already tried. See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
In a dll, i start a thread using _beginthread like:
_beginthread(Mythread,0,LPVOID(this));
void MyThread(LPVOID pVoid)
{
CMyClass* pClass = static_cast<CMyClass*>(pVoid);
pClass->SetValue(1);
}
Everything works nicely until i try to access one of the member vars from CMyClass. The app begins to lock up on me. I may be missing something fundamental here. Anyone have any thoughts?
|
|
|
|
|
There's nothing in the code you've shown that looks like it would
lock anything up. Actually the thread shown could finish before
_beginthread() completes on the calling thread
You can examine the call stack of all the threads in the debugger when it's
locked up and maybe that will help determine the offending code.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Here's my fundamental question about your thread....
You're now accessing "this" from your thread?
And are you also accessing "this" from the thread that created it?
Are you employing appropriate locks to protect "this"?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
LCI wrote: Everything works nicely until i try to access one of the member vars from CMyClass.
You mean, if you try to access a specific member or "ANY" member?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Any member this seems to have an issue with .
|
|
|
|
|
what do you mean by "The app begins to lock up on you". if you are human being i don't know whether you are using such an advanced technology
The bad cast can endup in undefined state, can you please post what you are passing to the thread?
|
|
|
|
|
Here is what i have:
The app freezes in Class B which is a dll. I know that there is something
wrong with the parameter that the thread is receiving in that dll, but i cannot figure it out.
ClassA
{
CWinThread* pThreadA[3] = {NULL};
CClassA::BeginAllThreads()
{
CClassC* pApp = reinterpret_cast<cclassc*>(AfxGetApp());
if (NULL == pThreadA[i])
{
pThreadA[i] = AfxBeginThread(ThreadGetOne,
(LPVOID)pApp->m_arrPtr[i],
THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED,
NULL);
pThreadA[i]->m_AutoDelete = FALSE;
pThreadA[i]->ResumeThread();
pApp->arrPtr[i]->StartThread();
}
}
void ThreadGetOne(LPVOID pVoid)
{
CClassB* pPointer = (CClassB*)pVoid
while (TRUE)
{
pPointer->Readport();
}
}
}
//This is a .dll
ClassB
{
void CClassB::StartThread()
{
_beginthread(MYBThread, 0, LPVOID(this));
}
void MYBThread(void* pVoid)
{
CClassB* pPointer = static_cast<cclassb*>(pVoid);
while (pPointer->IsOn()) //HERE IS WHERE THE APP Freezes
{
//do something
}
_endthread();
}
}
ClassC
{
CClassB* m_arrPtr[3];
}
|
|
|
|
|
LCI wrote: pApp->arrPtr[i]->StartThread();
are you correctly assigning the Object for arrPtr[i]? as far you are not dereferencing the this pointer you can call a member function with invalid pointer.
void CClassB::StartThread()
{
_beginthread(MYBThread, 0, LPVOID(this));
}
in startThread function you are only passing the this pointer which is not deferenced, possibly IsOn is using the this pointer crashes the application.
|
|
|
|
|
I sort of see what you are saying. Can you expand a little?
Thanks,
|
|
|
|
|
are you sure arrPtr[i] contains valid object? debug it or show the code that fills the array.
|
|
|
|
|
I will check.
In my code i use it to make another function call in class B and all is well. However, the call in questiuon here is actually used within an "if" block. Scope should be ok though. I will check on it.
|
|
|
|
|
I am looking for a C++ function which can identify the architecture of an executable file (binary) e.g. whether it is a 32 bit or 64 bit. I heard such a function might be available in imagehlp.dll
Can somebody help?
|
|
|
|
|
harsha1305 wrote: I heard such a function might be available in imagehlp.dll
Excellent! Please post back what you find after reading the imagehlp documentation
|
|
|
|
|
led mike wrote: Excellent! Please post back what you find after reading the imagehlp documentation
he he he.. please let me know also... any way some voted you down, let me average it down!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Like I care if monkeys on this site vote me down. I can still read documentation and develop my own software, monkey votes will never change that.
|
|
|
|
|
In imagehlp, maybe MapAndLoad()[^]
and LOADED_IMAGE.FileHeader.Machine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Just curious, what did you find attractive about that bait?
|
|
|
|