|
Hi All
I have run out of ideas can anyone help me.
I have created a extension DLL for a Patient selection dialog. When the dialog opens it initializes a list with with patient details. The user can then select one of the patients and the dialog closes and then the program can query the dialog before its destruction to get the index of the patient who was selected.
void CTestApp::OnFileOpen()
{
CLantisPatientSelectDlg dlg;
if(dlg.DoModal() == IDOK){
m_nPatID1 = dlg.GetPatID1();
}
}
To try and be tidy in the OnOK() member function of my class derived from CDialog I delete all of the list.
void CLantisPatientSelectDlg::OnOK()
{
int nIndex;
CPatientDetails *pPatientDetails;
CListCtrl *pList = (CListCtrl *)GetDlgItem(IDC_PATIENTLIST);
nIndex = pList->GetSelectionMark();
if(nIndex != -1){
POSITION pos = m_lpPatients.FindIndex(nIndex);
if(pos != NULL){
pPatientDetails = m_lpPatients.GetAt(pos);
m_nSelectedPatID1 = pPatientDetails->m_Pat_ID1;
}
} else {
m_nSelectedPatID1 = -1;
}
// Get any background list loading to terminate
m_bTerminateLoad = true;
::WaitForSingleObject(m_hListLoadingThread,INFINITE);
DeletePatientList();
CDialog::OnOK();
}
void CLantisPatientSelectDlg::DeletePatientList()
{
CPatientDetails *pPatientDetails;
POSITION pos = m_lpPatients.GetHeadPosition();
while(pos != NULL){
pPatientDetails = m_lpPatients.RemoveHead();
delete pPatientDetails;
pos = m_lpPatients.GetHeadPosition();
}
}
Now all of this seems to work alright until it comes to the end of the OnFileOpen() function at which point the instance of the dialog goes out of scope and the system deletes it. At this point the list which was cleared before and had 0 elements now seems to have a count of -1 (0xFFFFFFFF) and the routine to get rid of it crashes.
I am using a different header file for the DLL'ed Dialog in the application which only lists the functions that have been exported.
Any ideas??
|
|
|
|
|
Delete the m_lpPatients list in the dialog's destructor. That way it gets cleaned up no matter if the OK, Cancel, or X button is used.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Yeah I agree with you and I was doing that but it doesn't seem to be the problem. When it comes time to destruct the instance of the dialog the list, which is empty by this time, appears to have been corrupted in some way and hence can't delete properly.
I have just noticed something else. In the code section
void CTestApp::OnFileOpen()
{
CLantisPatientSelectDlg dlg;
if(dlg.DoModal() == IDOK){
m_nPatID1 = dlg.GetPatID1();
}
}
In my testing before posting I didn't have the
m_nPatID1 = dlg.GetPatID1();
line and hence my code went on to destruct the dlg instance immediately. Now with this code a new failure mode is occurring along with the old one which is generated when you Cancel out of the dialog. In the line highlighted above the dlg.GetPatID1() function runs correctly and returns an int but an access violation occurs when this return value is copied to the m_nPatID1 variable.
I must be doing something silly. I just can't see it.
Andrew
|
|
|
|
|
Andrew Hoole wrote:
Now all of this seems to work alright until it comes to the end of the OnFileOpen() function at which point the instance of the dialog goes out of scope and the system deletes it. At this point the list which was cleared before and had 0 elements now seems to have a count of -1 (0xFFFFFFFF) and the routine to get rid of it crashes.
Do you also iterate through the list and delete items when the dialog is destroyed? It looks like you only do this when clicking OK so I'm confused about the part you wrote above stating that the system deletes the dialog and something happens to the list.
What does your GetPatID1() function do - just return the value of the int found during the OnOK() function or does it make use of the list also?
Does anything else access your list?
One last thought - is that style of iteration safe? I don't use lists very often and haven't seen that style of iteration before. I got so frustrated using lists recently (a similar crashing issue that I just couldn't figure out)- I just ended up going with a CTypedPtryArray. I know this won't always work but in my case, the list wasn't really needed and the array worked just fine (and I was able to move on).
If you do figure it out, please post what you found. Good luck!
|
|
|
|
|
Hi
I'm stilling working on this but have started a new post as the topic seems to have move on a bit. See DLL memory issue[^] post.
Andrew Hoole
|
|
|
|
|
Hi, I want to use VC++ (6.0) to create an excel file,
add rows, and set each column to a certain width
so that when the file opens the data are in decent display.
Could you give me some code sample or application sample to do this?
Appreciate your time and help!
|
|
|
|
|
Google for examples of Office, specifically Excel, Automation.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi guys,
is it somehow possible to call the windows password dialog with an API Call
and check if the user entered the correct password ?!?
Or is it possible to get the encrypted password of the user currently logged in??
I want to add a password authentication to my application which uses/checks the
entered password against the users windows password...
Is that somehow possible ?!?
THX
|
|
|
|
|
You can make your own dialog to collect the information, then call LogonUser to validate it. Don't forget to close the handle if it is successful.
|
|
|
|
|
Blake Miller wrote:
...call LogonUser to validate it.
Good idea, but the process that calls LogonUser() must have the SE_TCB_NAME privilege. This is not necessary with Windows XP. Another restriction is that LogonUser() is not available on Windows 9x or ME.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Nice this works fine
I just needed it for Win2k/WinXP not Win98 so thats OK...
THX
|
|
|
|
|
How about LookupAccountName() ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Well, DarkCloud DID mention he wanted to test the password in the first message... I am curious in what sequence of function calls LookupAccountName would be used to verify the password?
|
|
|
|
|
Blake Miller wrote:
I am curious in what sequence of function calls LookupAccountName would be used to verify the password?
As am I. My post was in reference to someone wanting the domain of the current user. I think it was posted Wednesday or Thursday, but that post has been deleted. It's odd that my post would get (randomly) attached to another thread.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
That would explain a LOT of wierdness in the universe
I did think it odd you would post something seemingly irrelevant to the current thread. So I was indeed curious how that function would have helped.
Thanks
|
|
|
|
|
Hi guys,
I am having problem passing BSTR* parameter into a Visual Basic DLL. Below is the function of that particular DLL:
The sLotID is the parameter that I need to pass in and for the file_name and serr is the parameters passing back from the DLL.
CString _Class1::LotData(BSTR* sLotID, BSTR* file_name, BSTR* serr)
{
CString result;
static BYTE parms[] =
VTS_PBSTR VTS_PBSTR VTS_PBSTR;
InvokeHelper(0x60030008, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms,sLotID, file_name, serr);
return result;
}
In my code, this is what I do:
_Class1 ServerClass;
CString StringReceived = "123456";
BSTR sLotID = StringReceived.AllocSysString();
ProdType=ServerClass.LotData(&sLotID, &file_name, &serr);
Note: The function totally cannot receive the sLotID that I pass in, Please help....
ks tang
AT ENGINEERING
|
|
|
|
|
Dear all,
I run my program using F5 (which will stops in certain line when an error found), and it stops at file CHKSTK.ASM in this highlighted line:
probepages:<br />
sub ecx,_PAGESIZE_ ; yes, move down a page<br />
sub eax,_PAGESIZE_ ; adjust request and...<br />
<br />
<span style="background-color: yellow">test dword ptr [ecx],eax ; ...probe it</span><br />
<br />
cmp eax,_PAGESIZE_ ; more than one page requested?<br />
jae short probepages ; no
I wonder what kind of error that cause this?
Thanks in advance
|
|
|
|
|
The code you posted is not enough to find out what is wrong. What, e.g., is the value ecx gets initialized with?
Don't try it, just do it!
|
|
|
|
|
the ecx value is 206832, and the eax value is 15741120
I don't understand what does the ecx and the eax mean and how it gets initialized.
However, before the debug window bring me to CHKSTK.ASM, the error dialog box said 'Unhandled exception... ..Stack Overflow'.
thanks
|
|
|
|
|
The error said stack overflow.
You are looking in the wrong place.
chkstk.asm is where the program actually ran out of stack memory, but your problem is a design issue.
When the error happens look at the call stack in the debugger to see what function(s) were called to produce the overflow.
You either:
1. Tried to allocate too much memory from the stack.
e.g.
void badfunc( void )
{
long badvar[128*1024];
...
}
or,
2. Got caught in a deep function call loop that ended with the same effect as 1.
e.g. for small values this is fine, for larger values it will blow the stack
long badrecurse( long R )
{
long r = 1; // alloc 4 bytes off stack - each iteration!
if( R > 1 ) r = badrecurse(R-1);
return(R * r);
}
...cmk
Save the whales - collect the whole set
|
|
|
|
|
First of all I have to say that this is my first MFC interface I've ever built for a program that works perfectly under DOS.
The problem is next ... The simulation uses loop that ends only on exit command (something like never-ending loop). Interface is perfect in point that it does what it has to do ... but the problem occurs about the commands ... When I start the program it starts with updateing the interface with the caculations but the commands are not accessible (in fact - they are, but the pressing on them causes the simulation to go to "Not reponding" - it looks like the overloading memory or something like that).
I hope that I decribed it well ... so please help ..
And keep in mind that I am beginner in this kind a programming, so please do not post too complicate solutions
|
|
|
|
|
acinosanduce wrote:
I hope that I decribed it well ... so please help ..
What exactly is it that you need help with?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I want to make commands (buttons) on the main window not going to not responding mode ...
More in detail ::
On the main window there are three buttons Start, Pause and Exit ...
On Start it starts the simulation (never-ending loop) and works perfectly in updating data on the window ... but in the same time I'm not able to click on the other buttons like Pause or Exit - because the program stucks (looks like memory overloading or something) ...
So the major question is :: Where did I make a mistake?? What sould I do or implement??
|
|
|
|
|
Your application currently only has one message pump, and it is busy doing whatever the Start button told it to do. You need to create a secondary thread to do this work, thus leaving the primary thread free to handle the UI stuff. See here and here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I will check it now ... thanx in advance if it will solve the problem
|
|
|
|