|
Sounds like recursive calls.
Kuphryn
|
|
|
|
|
But how is it recursive on the dialog box when all I am doing is checking the first check box? I can see it being recursive in that everytime I call CheckRadioButton() to check the first button it calls OnCheckBox1() again. I still don't understand why it would recursively call the dialog box as well. Help please. Thanks!
|
|
|
|
|
Are you calling UpdateData in the right place\correctly?
Sounds like the associated member variable is not being kept up-to date as you are expecting.
You may already know this, but its a possiblilty all the same!!
|
|
|
|
|
I inserted UpdateData() at the beginning of both OnCheckBox1() and OnCheckBox2() and UpdateData(FALSE) at the end of each but it still doesn't work. It just doesn't like CheckRadioButton(button1, button2, button3) in OnCheckBox1(). That's what causes it to be recursive. Any ideas? Thanks.
|
|
|
|
|
Hi,
I want to minimize all windows before I start my dialog. Is there any command I can use or I should run the ShowDesktop.scf file? I know the file contains Windows Explorer Command as the following:
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop
Thank you in advance,
5iveboy
|
|
|
|
|
|
Dear all,
I want to execute a separate program from my dialog using a button. I have used WinExec, ShellExecute and CreateProcess and get the same problem. The button works fine as long as I build and run my program from Visual C++. But when I run the program independently by double-clicking its exec file from its folder and try the button, it does not work and the other application does not start. This happens on any operating system I tried. Here is the code:
HINSTANCE HINSCursorsd = ShellExecute (NULL,"open","../TestExeNew.exe",NULL,NULL,SW_SHOWNORMAL);
Your help is most greatly appreciated.
Thanks,
|
|
|
|
|
HINSTANCE HINSCursorsd = ShellExecute (NULL,"open","../TestExeNew.exe",NULL,NULL,SW_SHOWNORMAL);
The path is probably not the same
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Original message:
I have read the codeproject article about Finding crash information using the MAP file, which was helpful, but I'm stuck.
I have a very complex program full of dialog boxes that are derived from a class that is derived from CDialog. Inside these dialogs are a bunch of edit boxes of type CTableFieldEdit, which is derived from CEdit.
The program works beautifully in debug mode, but crashes in release mode some time between when I create the dialog item and when I call DoModal()
From what I've been able to determine, the crash happens in MFC42.dll, but it crashes in two different places, depending on which dialog I'm calling. Some of the dialogs crash at the address for GetStyle and some of them crash after the address for ScrollWindowEx, according to the map file.
I have already turned off all optimizations.
I'm stuck. What might I be doing wrong?
I can post some or all of the code if it will help.
I can even post the entire project if you like, but you won't be able to run the program as it connects to a database.
Thanks!
Update:
The problem seems to be related to how I handle message maps in my derived dialog classes, but I don't know how to fix it or why it works correctly in Debug mode, but not Release mode.
Here's what's happening:
My Dialog boxes are derived from CFormHelperDlg, which is a class I made to reduce code redundancy.
CFormHelperDlg is derived from CDialog.
There are certain messages I want to handle in CFormHelperDlg rather than in the class for each given dialog (since all the code is redundant), so I set up my message maps as such:
In CJailDialog (which is derived from CFormHelperDlg):
BEGIN_MESSAGE_MAP(CJailDialog, CFormHelperDlg)
//{{AFX_MSG_MAP(CJailDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
In CFormHelperDlg (which is derived from CDialog):
BEGIN_MESSAGE_MAP(CFormHelperDlg, CDialog)
//{{AFX_MSG_MAP(CFormHelperDlg)
ON_BN_CLICKED(IDC_BUTTON_JAN, OnButtonJan)
ON_BN_CLICKED(IDC_BUTTON_FEB, OnButtonFeb)
ON_BN_CLICKED(IDC_BUTTON_MAR, OnButtonMar)
ON_BN_CLICKED(IDC_BUTTON_APR, OnButtonApr)
ON_BN_CLICKED(IDC_BUTTON_MAY, OnButtonMay)
ON_BN_CLICKED(IDC_BUTTON_JUN, OnButtonJun)
ON_BN_CLICKED(IDC_BUTTON_JUL, OnButtonJul)
ON_BN_CLICKED(IDC_BUTTON_AUG, OnButtonAug)
ON_BN_CLICKED(IDC_BUTTON_SEP, OnButtonSep)
ON_BN_CLICKED(IDC_BUTTON_OCT, OnButtonOct)
ON_BN_CLICKED(IDC_BUTTON_NOV, OnButtonNov)
ON_BN_CLICKED(IDC_BUTTON_DEC, OnButtonDec)
ON_BN_CLICKED(IDC_MANAGER_SIGNOFF, OnManagerSignoff)
ON_MESSAGE(WM_INITDIALOG, OnInitDialog)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
...each of those buttons exists on all the dialog boxes derived from CFormHelperDlg, so I'd rather just keep the message map there.
I've been using this all along because it worked fine in Debug mode.
I discovered the error was the message map by changing CJailDialog's message map to:
BEGIN_MESSAGE_MAP(CJailDialog, CDialog)
//{{AFX_MSG_MAP(CJailDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
And suddenly there was no crashing.
Of course, it also didn't respond to the buttons anymore
What do I need to do in order to make this work in release mode the way it works in debug mode?
|
|
|
|
|
Can you not add debug info to your appplication in release mode? This will allow you do run the software and get a call stack of where the crash occurs. From there you can backtrack to your most recent code that ran and hopefully find the problem.
If you vote me down, my score will only get lower
|
|
|
|
|
Call stack looks like this:
CWnd::GetStyle(const CWnd * const 0x0012f758 {CJailDialog hWnd=0x002d0b20}) line 195 + 1 byte
_AfxHandleActivate(CWnd * 0x0012f758 {CJailDialog hWnd=0x002d0b20}, unsigned int 1, CWnd * 0x00323fc0 {CMainFrame hWnd=0x003f011c}) line 145 + 11 bytes
MFC42! 5f401be9()
CWnd::WindowProc(CWnd * const 0x0012f758 {CJailDialog hWnd=0x002d0b20}, unsigned int 6, unsigned int 1, long 4129052) line 1596 + 27 bytes
AfxCallWndProc(CWnd * 0x0012f758 {CJailDialog hWnd=0x002d0b20}, HWND__ * 0x00000000, unsigned int 6, unsigned int 1, long 4129052) line 218
AfxWndProc(HWND__ * 0x002d0b20, unsigned int 6, unsigned int 1, long 4129052) line 377 + 16 bytes
AfxWndProcBase(HWND__ * 0x002d0b20, unsigned int 6, unsigned int 1, long 4129052) line 220 + 21 bytes
USER32! 77d43a50()
USER32! 77d43b1f()
USER32! 77d444f5()
USER32! 77d44525()
NTDLL! 77f75da3()
58000080()
I don't know about you, but that doesn't seem very helpful to me...
|
|
|
|
|
|
Alas, I had already read this article, to no avail.
|
|
|
|
|
what is function signature of your OnInitDialog member, if it is anything other than
LRESULT OnInitDialog(WPARAM wParam, LPARAM lParam)
the application is bound to crash in release mode.
Remember, OnInitDialog function is provided as a virtual function in CDialog already, and if you want to handle the WM_INITDIALOG message yourself, you need to at least name it differently, the way you are doing it, you are probably declaing it as
virtual BOOL OnInitDialog();
/yawar
I have no signature
|
|
|
|
|
I think I need to provide a little explanation of my response too, look at the expansion of ON_MESSAGE macro in AFXMSG_.H file
#define ON_MESSAGE(message, memberFxn) \<br />
{ message, 0, 0, 0, AfxSig_lwl, \<br />
(AFX_PMSG)(AFX_PMSGW)(LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM))&memberFxn },
Anything you put in ON_MESSAGE macro has to have this declaration, the compiler generates the code and assumes that your function will have a return type of LRESULT and will take two parameters, WPARAM and LPARAM. If you declare return type different or make parameters different, you will end up corrupting the stack and hence the crash in release mode.
answer to question that why this won't crash in debug mode is simple, the debug executable has a lot of guard bytes before and after function calls, those bytes get corrupted but stack does not. Probably if the target function signature would be too big (20+ parameters) it will crash in debug too.
Let me know if this was the reason. I have gone in too much detail without even knowing if your bug really was because of bad function signature.
Ciao,
/yawar
|
|
|
|
|
You, sir, are a life saver.
I assumed that:
a) Since Visual Studio generated the message handler for me, it must be right (ha!)
and
b) Since CFormHelperDlg calls CDialog::OnInitDialog(), it would be ok
My understanding of how all this stuff works starts to get pretty cloudy when it comes to areas like this.
Thanks again for the help.
|
|
|
|
|
glad to have helped.. have fun
/yawar
|
|
|
|
|
This problem looks similar to mine. Unfortunately, I don't understand this answer. When I change the 'signature' of my own OnInitDialog function to match your suggestion, it doesn't get called, even in DEBUG.
Any more enlightenment to offer?
dahill
|
|
|
|
|
Hello,
I need to disable the start button.
Is there anyone hat an help me.
I need to do it from a MFC App.
|
|
|
|
|
Try:
GetDlgItem(IDC_YOUR_START_BUTTON)->EnableWindow(FALSE);
|
|
|
|
|
|
Hello,
Just a thought
How can I take the icon from one exe and put it on my exe
programaticly of course
Or should I say can I?
I mean I know about the FindResource function but you have to give it the name of the icon
as the second parameter the name of that particular resource.
So how can I get an exe's icon and how can I then load an icon into my exe and set it as my
exes ico.
icons icons icons
|
|
|
|
|
Can you use ExtractIcon() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello,
I am gleening some code that I found that uses OLE for Drag&Drop across multiple CListCtrls. The main problem is that I am very new to Visual C++ and need some help with LVITEM structures.
In my .h file I have
typedef struct {
LVITEM lvi;
char szLabel[256];
CString sFrom;
CString smsg_num;
} ListInfo;
And am trying to get multiple column data from a CListCtrl to drag&drop.
In my .cpp file I have:
...
void CDDListCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
...
// Create global memory for sharing dragdrop data, we allocate
// space for 2 int and nItem ListInfo structures
HGLOBAL hgData = GlobalAlloc(GPTR,m_nItem*sizeof(ListInfo)+2*sizeof(int));
ASSERT(hgData!=NULL);
char* p = (char*) GlobalLock(hgData);
ASSERT(p!=NULL);
// Place control type in first 2 bytes
*(int *) (p) = CT_LIST;
// Place number of list items in next 2 bytes
*(int *) (p+sizeof(int)) = m_nItem;
// Then the nItem ListInfo structures will start at:
ListInfo* lpData = (ListInfo*) (p + 2*sizeof(int));
CString DebugStr;
// Here is where we read all selected items into array. - Murrah
int jItem = -1;
int i = 0;
while ((jItem = GetNextItem(jItem,LVNI_ALL | LVNI_SELECTED)) > -1)
{
ASSERT(i>=0 && i <m_nItem);
ZeroMemory(&lpData[i], sizeof(ListInfo));
lpData[i].lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
lpData[i].lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
lpData[i].lvi.pszText = (char*) &(lpData[i].szLabel);
lpData[i].lvi.iItem = jItem;
lpData[i].lvi.cchTextMax = 255;
// GetItemText works here, now to figure out how to get it into lpData[i];
//DebugStr.Format(_T("%s"),GetItemText(jItem, 2));
//AfxMessageBox(DebugStr);
// pDragList->GetItem (lvi.plvi);
// lvi.sFrom = pDragList->GetItemText(lvi.plvi->iItem, 1);
// lvi.smsg_num = pDragList->GetItemText(lvi.plvi->iItem, 2);
BOOL bSuccess = GetItem(&(lpData[i].lvi));
ASSERT(bSuccess);
// lpData[i].sFrom = GetItemText(jItem, 1);
m_pSaveIndItem[i] = jItem;
i++;
}
...
I gleened this code from another application that I found (except I added the two CStrings in the ListInfo structure), and it works fine for a single column CListCtrl, but I can't figure out how to get my other column data into lpData[i].
GetItemText(jItem, 1) and GetItemText(jItem, 2) both return the correct data for the subitems, but I just can't figure out how to get it into lpData[i].
Also, once I do get the data into lpData[i], how do I get it back out when I finalize the drop?
Thanks,
Murrah Boswell
|
|
|
|
|
Can someone please tell me how can I find out the number to which my computer is connected when using a dial-up connection, without using phone-books. I want to monitor a dial-up connection that I haven't initialized in my program so I have to find out its handle first
Thanks
|
|
|
|
|