|
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
|
|
|
|
|
nemoo wrote:
...without using phone-books.
How else would you do this without looking at the RAS phone book? Once the connection has been established, the number connected to is no longer relevant, thus the TCP/IP layer does not know, or need to know, about it. Call RasEnumConnections() to get the active connections (presumably you have only one), then call RasGetEntryProperties() to get the phone number used.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I've used CreateProcess to start .exe from inside apps before, and they've worked fine. However, I created a service application which starts at boot-up. It cannot seem to use the exact same functions I've used before. Why is this?? Thank you.
|
|
|
|
|
Hard to know for sure but it could be related to the account the service is running in verses the how the process (application) you are starting is installed. For example, if the service is running under the local system account and the application is trying to get values from the HKEY_CURRENT_USER registry keys that is going to break.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
The application that the service is trying to start is one of my own creation. It's a simple console app which does not use any reg keys. Just as a test I called CreateProcess with the notepad.exe inside the service app. Nothing...
|
|
|
|
|
When you say 'boot' do you mean before any user is logged in, while the blue/black screen is up? You might have failure because there is no desktop yet?
I am not so sure that you can launch an 'interactive' application at boot time.
Do you get any meaningul error value from GetLastError?
Your service might need to use CreateProcessAsUser to really get this to work right, if it is going to work at all.
|
|
|
|
|
It may be that the process *is* being created, but you can't see it. A service has it's own desktop, so notepad will be running on that (invisible) desktop. I suggest you use Task Manager to see if the process is running (it will show up in process list in Task Manager even when running on a different desktop).
|
|
|
|
|
The program will probably start, but the service does not run in the same desktop context as you do, so you need to allow it to show stuff on your desktop...
Go to the services settings and check "allow service to interact with desktop"
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application[^]
My Photos[^]
New developersite: RealDevs.Net
|
|
|
|
|
suppose that u a writting a software to give grading to three different types of student certificate,diplom and degree students,all students will be required to sit for exams which wil be graded as follows:
1-39: F
40-59: D
59-69: C
70-79: B
80-100: A
In addition to that, the Diploma students will be required to attend the 'lab tes' session that awards them 'P'(PASS), 'F'(Fail)or 'X'(ABSENT). The Degree students, on the other hand, need to undergo an 'Industrial Training' that requires the employers to give 'G'(GOOD), 'A'(AVERAGE) or 'P'(POOR).
This program is expedted to be used by the Exam Department that eners student Names and their IC numbers besides the above details. This program should also be able to highlight the highest mark, lowest mark and failure rates for each program. Once the data have been recorded, they shall be stored as a data file for future reference.
Provide a solution to the above requirments using classes, an Object Oriented approach and C++ language.
|
|
|
|
|
Here we go again! Another homework
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I charge $150/hour for a minimum of 4 hours.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
>> I charge $150/hour for a minimum of 4 hours.
Will you wear a dress and take it doggy style?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|