|
MFC Grid Control Exception in Release Build Only!
Can anyone help me with this? I get an unhandled exception error on the NM_CLICK message handling (function OnGridClick I created in my view) in the Release build, that works fine in the debug build!
All of my methods are executed properly but after they've returned there's an unhandled exception that I cannot seem to trace.
Can anyone help?!
|
|
|
|
|
We need more information. Show your code for the NM_CLICK message handler and tell us what the exception is.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Here's the mapping of the message to the function in my view.
IDC_CUSTOM1 is obviously the MFC Grid Control.
I don't think the fact that this is a recordview rather than a standard
view makes a difference, but let me know if you think it makes a difference.
BEGIN_MESSAGE_MAP(CMyView, CRecordView)
ON_NOTIFY(NM_CLICK, IDC_CUSTOM1, OnGridClick)
ON_NOTIFY(NM_DBLCLK,IDC_CUSTOM1, OnGridDblClick)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()
I added this public function to the gridctrl class (in gridctrl.h) to enable my view
to retrieve which cell was clicked
CCellID GetLeftClickDownCell()const {return m_LeftClickDownCell;}
Here's the actual message handler:
void CMyView::OnGridClick()
{
int r = m_grid.GetLeftClickDownCell().row; //MY FUNCTION CALL
int c = m_grid.GetLeftClickDownCell().col;
if (!c && r)
HandleDblClickColZero(r,true);
return;
}
HandleDblClickColZero does a bunch of stuff with the data from that grid cell - or does nothing at all - it doesn't matter which - It gets fully executed, OnGridclick is fully executed AND THEN the following error comes up (regardless of whether HandleDblClickColZero even gets called by the if statement):
Unhandled exception in MyProgram.exe 0xC0000005:Access Violation
All I can do is tie the access violation to the grid control, but how or why I am at a loss for!
<-j->
|
|
|
|
|
jarbus wrote:
ON_NOTIFY(NM_CLICK, IDC_CUSTOM1, OnGridClick)
jarbus wrote:
void CMyView::OnGridClick()
jarbus wrote:
OnGridclick is fully executed AND THEN the following error comes up
jarbus wrote:
Unhandled exception in MyProgram.exe 0xC0000005:Access Violation
As I suspected, your instruction pointer is getting messed up when your OnGridClick() message handler returns. What you have to do is add the proper parameters that are expected to be there when you handle a WM_NOTIFY message.
void CMyView::OnGridClick(NMHDR *, LRESULT *) It has to do with the way the IP and parameters are pushed onto the stack when the function starts, and then popped off the stack when the function ends. If you do not declare the proper parameters you end up with a mismatch and the IP gets screwed as a result.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
jarbus wrote:
I added this public function to the gridctrl class (in gridctrl.h) to enable my view
to retrieve which cell was clicked
CCellID GetLeftClickDownCell()const {return m_LeftClickDownCell;}
The row and column of the cell clicked is passed in the NM_GRIDVIEW struct that is passed to you OnGidClick() function as the NMHDR struct.
void CMyView::OnGridClick(NMHDR *pNMHDR, LRESULT *)
{
NM_GRIDVIEW *pNM_GRIDVIEW = (NM_GRIDVIEW *)pNMHDR;
int r = pNM_GRIDVIEW->iRow;
int c = pNM_GRIDVIEW->iColumn;
...
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I have made a dll using Microsoft Visual Studio 6, Win32 Platform. I want to import the dll in Delphi but I have problem in returning arrays and passing arrays as parameters.
For example
_declspec (dllexport) void ret(double* arr)
{
arr[0] = 1;
arr[1] = 2;
}
When I import this function in Delphi and pass an array as a parameter its values do not change.
Thank you!
modified 9-Mar-17 17:23pm.
|
|
|
|
|
shouldn't the code be:
_declspec (dllexport) void ret(double** arr)
{
*arr[0] = 1;
*arr[1] = 2;
}
????
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
No, his code should work as is. Strange that it is not.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I'm stuck, I have a base class String, derived class Pstring, and trying to develop another derived class Pstring2. Pstring2 needs a function called left. Main will call the function by Text2.left(Text1,N) // Text2 is assigned the leftmost N characters from Text1. I'm having a hard time understanding how to connect Pstring2 to Pstring and String base class. Left member function of Pstring2 will carve out the left most 10 characters assigned to an object. The code I have so far is noted below. Can you give me some help?
#include <iostream>
using namespace std;
#include <cstring> //for strcpy(), etc.
#include <conio.h> //For getch()
////////////////////////////////////////////////////////////////
class String //user-defined string type
{
protected:
enum { SZ = 80 }; //size of all String objects
char str[SZ]; //holds a C-string
public:
String() //no-arg constructor
{ str[0] = '\0'; }
String( char s[] ) //1-arg constructor
{ strcpy(str,s); } //convert C-string to String
void display() //display the String
{ cout << str; }
operator char*()
{ return str;}
};
class Pstring : public String
{
public:
Pstring(char s[]): String(s)
{ if(strlen(s)>(SZ-1)){
strncpy(str,s,79);
str[79] = '\0';
}
else
String(s);
}
};
//class Pstring2 : public Pstring
//{
// public:
// Pstring2() : Pstring
//};
////////////////////////////////////////////////////////////////
int main()
{
cout << "THIS SENTENCE IS SHORTER THAN SZ:" << endl;
Pstring2 s1 = "Never read the instructions.";
s1.display();
cout << endl <<"THIS SENTENCE IS LONGER THAN SZ:" << endl;
Pstring2 s2 = "I would have to say that the greatest single achievement "
"of the American medica";
s2.display();
cout << endl <<"THIS SENTENCE DEMONSTRATES THE LEFT, MID AND RIGHT FUNCTIONS:" << endl;
Pstring2 s3 = "A long time ago in a galaxy far, far away.";
s3.display();
getch();
return 0;
}
Thanks!
|
|
|
|
|
No need to reply. I've been working on it feverishly the last 2 hours and finally got it to work!! Oh what a feeling!!
Thanks!
|
|
|
|
|
hello ,
I am writing an application that gets a password and a user name from the user I need to send these information to a web site to check wheter these information is correct or not then the web site should respond to my application with the result.
How can I send these information to the web site and how can I get the result from it.
|
|
|
|
|
You could post an encrypted version of the username and password (or at least just MD5 the password) in a query sent to the website, and parse the response.
This[^] article can help you implement the client side portion of the task. You'll obviously need server side support also.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I need a function, which gives me the handle to an active Window. I currently use the FindWindow function, but it also returns handles to already destroyed windows (which come from the same application that ran before and was closed). I found the IsWindow function and currently use it in combination with FindWindow, which looks like the following:
private int GetExistingWindow(string cl, string name)
{
int hWnd;
while(true)
{
if((hWnd = WM.FindWindow(cl, name)) == 0)
StartProcess();
if(WM.IsWindow(hWnd))
break;
}
return hWnd;
}
questions:
1) Can I do it that way (means returns a second call of FindWindow another handle than the first one or do I always get the same)
2) Is there a better method (single function, etc.)
Thanks
BTW: The code is written in C#(functions are well implemented), but due to the fact that it is a Win32 API question I decided to post it here.
|
|
|
|
|
well the proplem is that in win32 you can not get a valid handle to a window in another application this is some type of protection that windows do to protect applications from affecting each other
|
|
|
|
|
I'm not sure what you are referring to but FindWindow() does exactly what you indicate is not possible - it returns a handle to a top-level window given either the window's name or class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
what code i can use to connect all visual c++ programs i created?
calling visual c++ program to another visual c++ program using a button.
thank you!
|
|
|
|
|
TO EXECUTE A PROGRAM use ShellExecute(...) read more in msdn .
keep smilling.....b'coz smile is the shortest distance between people....
|
|
|
|
|
Hi,
I am building an dll. in the dlll app i declared some variables. while accessing the variables the assertion of access denied. while on constructor of the app there is no problem for variables after that unable to access the variables. so currently i declare the variables outside of the class(global) there is no problem in this case. Any one help to me.
Thanks in Advance.
Have A Nice Day!
Murali.M
|
|
|
|
|
use at the declaration of the class
__declspec (dllexport)
and make sure the variables are public or private with get/set methods!
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I tried to optimize some mathematical calculation by adding assembler code using
SSE, but i have some problem:
I got two dimensional array of floats, and i don't know how to reserve memory for
it, I tried next way :
__declspec(align(16)) float** m_FirstArray = (float**)
_aligned_malloc(ARRAY_SIZE*sizeof(float),16);
for(int i = 0;i
|
|
|
|
|
First off, I would like to thank you for taking the time to see this problem. I'm sort of a n00b when it comes to using COM objects, and unfortunately the way I'm learning has a really steep learning curve. Basically, I am trying to create a program that writes to Word, and I'm having a bit of a problem passing objects to the COM objects that I instantiate - specifically the Range and Section objects. So let me order my questions:
1) How do I correctly create a new Range object so I can add it to a Section object?
2) How do I add the Range object to the Section? (According to the VBA documentation, the Sections collection object has an Add method that takes a Range object as its first argument [MFC specifies it as a VARIANT parameter type] and placement as a second argument).
Basically this is the way I see it, but I don't know how to do it:
1) Create new Range object.
2) Set information in Range object.
3) Add new Section using Sections.Add(new_range_obj, placement)
If anybody has any code that I can look at in an existing solution that interfaces with Word that would be awesome. I usually learn better by looking at code and seeing what it does anyways. Thanx!
|
|
|
|
|
Hi folks,
Where i can find the diference between C++ and VC++?.
Please send me link or material.
|
|
|
|
|
The main difference between regular C++ and Visual C++ is just that Visual C++ works a lot with Microsoft's frameworks, specifically .NET (if its Visual C++.NET) and MFC. You can still write standard C++ applications in VC++ with/without the Microsoft frameworks, however getting the Microsoft frameworks to work with other IDEs is difficult, yet possible if you really know how to do it. Microsoft does not release it's MFC framework, so in order to use it you would have to get VC++. In terms of IDE, its a matter of preference, otherwise its purely what you can and can not do between C++ and VC++. Just remember, everything you do in VC++ you could do in standard C++, but it would just take longer because you don't have all the pre-defined objects for Windows development that Microsoft provides as part of VC++.
Hope that helps.
|
|
|
|
|
C++ is a programming language, Visual C++ is a compiler/IDE for the C++ programming language.
|
|
|
|
|
The thing is that C++ is the language, and VC++ is just the environment that you can program in C++. It is like writing English text in Notepad- the language is English, but you write it in Notepad. But you can also write it in Word, WordPad? and so on... so, VC++ is the program(IDE to be more certain), and C++ is the language.
I hope you got it!
keep smilling.....b'coz smile is the shortest distance between people....
|
|
|
|