|
You already have the solution to your problem - add in the WPARAM & LPARAM parameters.
But you want to know why it worked in debug, and not in release mode?
Do a search in the MFC code directorys for ON_MESSAGE, and you can see the definition of the macro. You can see that MFC is calling casting your function to a format that includes the two parameters.
In release mode, calling a function with parameters will put those parameters on the stack. Your function does not use them, so it does not pull them off the stack. I got "stack corruption" errors when I had this same fault (a long time ago now!)
In debug mode, my theory there is plenty of padded memory about, or the calling conventions do not use the stack. Either way - when it worked in debug mode, you were just lucky.
(Or unlucky - I'd prefer to fix the problem as soon as possible!)
My experience was with VC++ 6 - I think later versions of MFC do things a little differently, without casts in the ON_xxxxx message maps, so it's harder to have this fault.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Thank Iain,
Now i have my answer.
Thank you for sharing your nice exp. with us.
|
|
|
|
|
How to make two check boxes mutually exclusive?
Thanks in advance,
Anandi VC
|
|
|
|
|
You will have to handle it in code.
In the check box click handler, check or uncheck the other.
Or you should consider using radio buttons.
«_Superman_»
|
|
|
|
|
Thank you.I am handling it in code.
Anandi VC
|
|
|
|
|
Unless you have a REEEEEEEEEEEALLY good reason to make these checkboxes, your customers will thank you for making them radio buttons. The standard window controls look different for a reason - to give the user different expectations about how they work.
And if your work is not about keeping users of the software happy [and therefore giving you money to buy food], why are you doing this?
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Anandi.VC wrote: How to make two check boxes mutually exclusive?
Is that why Radio buttons where invented for??
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Tell them they are radio buttons.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Radio buttons can handle "one and only one" functionality.
But mutually exclusive check boxes can handle "zero or one" functionality which is not possible with radio buttons. Microsoft also uses mutually exclusive check boxes in their products.
«_Superman_»
|
|
|
|
|
«_Superman_» wrote: But mutually exclusive check boxes can handle "zero or one" functionality which is not possible with radio buttons.
Uh, yeah, it is. You add another radio button, label it "none of the above", and give it the same meaning in your program that the somewhat-less-than-obvious fewer than the maximum number of checkable checkboxes are checked state would have had, should you have been mad enough to actually implement such an atrocity.
Now you have a finite number of states, all of which are explicitly named, and all of which can be selected with a single click. Radio buttons - learn to love 'em.
|
|
|
|
|
Okay.
In VC++ 6.0, take a look at the properties dialog of a button.
You will see 2 check boxes for Icon and Bitmap .
So if this is an atrocity, how better would it be to do it in that space with radio buttons?
«_Superman_»
|
|
|
|
|
Space constraints? Combo box!
|
|
|
|
|
Hi All,
I have created ATL DLL with function Add(int var1, ibt var2), also registered dll using regsrv32 command, and I created another MFC project so plz tell me how to use this function of DLL in MFc project.? which files to include in new project?
|
|
|
|
|
#import the dll and then follow the steps underneatch
CoInitialize(NULL);
HRESULT hr = S_OK;
IITestObj* pTest = NULL;
hr = CoCreateInstance(__uuidof(ITestObj),NULL,CLSCTX_ALL,__uuidof(IITestObj),(void**)&pTest);
if(SUCCEEDED(hr))
{
pTest ->Add(5,10);
}
else
{
MessageBox("Failed to get the component",NULL,MB_OK);
CoUninitialize();
}
CoUninitialize ();
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
What is IITestObj* pTest = NULL; in your case?
In mine case , IITestobj is class, but compiler is giving error undeclared identifier,
I have imported DLL at start.
|
|
|
|
|
it is an interface pointer. ITestObj is the Atl Simple Object that I added using the class wizard.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi below code may help you,
#import "../MathOperations.dll" named_guids
using namespace MathOperationsLib;
Create instance for dll
HRESULT hresult;
CoInitialize(NULL);
IOperationsPtr ptr;
hresult=CoCreateInstance(MathOperationsLib::CLSID_Operations,NULL,CLSCTX_INPROC_SERVER,MathOperationsLib::IID_IOperations,(LPVOID *) &ptr);
if(FAILED(hresult))
{
MessageBox(L"Creation Failed",0,0);
return;
}
LONG Z;
ptr->AddNumbers(4,6,&Z);
CoUninitialize();
|
|
|
|
|
Hi,
I have a application that we installing on user's m/c in Admin credentials. But whenever user logs in as a normal user (without Admin credentials) we are trying to update the patch, which will replace some components (exe,dll) in "Program Files" directory. Since user doesn't have Admin credentials he will not be able to do so.
I woould like to know is there any way by which normal user will be able to update these patches, which will not require any Admin credentails.
Thanks
SNI
|
|
|
|
|
You can use remote tools like windows SMS, or remoteexec to push your dlls across the network.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
I have this code as part of my DllRegisterServer() method:
TCHAR szPath[MAX_PATH];
GetModuleFileName ( g_hinstThisDll, szPath, MAX_PATH );
TCHAR * pdest = _tcsrchr(szPath, _T('\\'));
TCHAR szTemp[MAX_PATH];
_tcsncpy(szTemp, szPath, (size_t) (pdest + 1));
_tcscpy(szPath, szTemp);
_tcscat(szPath, "My.tlb");
When I try to use RegSvr32.exe to register the DLL, I get a message that Windows DEP (Data Execution Protection) has stopped the execution of RegSvr32.exe.
I replaced the above code segment with a constant assignment (snippit follows) and RegSvr32.exe completed successfully:
TCHAR szPath[] = _T("C:\\SomePath\\My.tlb");
I copied the problem code into the main() of a console application and outputted the result, which yielded the intended string. (The console application wasn't under Windows DEP.)
From what little I know of DEP, this code must be doing something with protected memory in order to trip it.
I don't usually use this style of string manipulation - I generally use CString's or .NET's String class. Can anyone see what I'm doing wrong here?
Any help would be greatly appreciated.
MZR
|
|
|
|
|
Your code has a bug.
Mike the Red wrote: _tcsncpy(szTemp, szPath, (size_t) (pdest + 1));
What do you expect here as the count parameter?
It is taking the value as an address plus 1.
This is going to be a very big value.
Another example of why typecasting must be avoided.
I wonder how it worked in a console application.
I tried it in a console application and it gave me the DEP error.
«_Superman_»
|
|
|
|
|
Thanks for the quick response, Superman!
That code you quoted (_tcsncpy(szTemp, szPath, (size_t) (pdest + 1)); ) was copied from the MS help file's example code for _tcsrchr . To be honest, I copied it without careful examination.
What I was expecting for the the count parameter was the index of the last \ in the file path.
GetModuleFileName returns the full path to the .DLL, say "c:\some path\This.DLL". I'm trying to extract the path and change the filename to the type lib's name, for instance "c:\some path\My.tlb".
Now that I re-read the helpfile on _tcsrchr , "Returns a pointer to the last occurrence of c in string, or NULL if c is not found", I actually have no idea how I would make use of this function.
At this point, I would probably manually iterate through the filepath string to find the index of the last \, then pull a substring and concatenate the type lib's filename. Is there a more efficient way to do this with the built-in string manipulation routines?
Thanks again for your help!
MZR
|
|
|
|
|
You must use _tsplitpath .
In the dir parameter you will get the path minus the filename.
Now you can concatenate the .tlb filename using _tcsncat_s .
«_Superman_»
|
|
|
|
|
I am currently writing an application using C++ and MFC. In this application I would like to be able to convert a string stored in an object of type CString to a C++ int. This string represents a signed integer. It seems to me that there should be a member function of the class CString to do this, but I have been unable to find such a member.
Thanks
Bob
|
|
|
|
|
I don't think CString should have a member function to do conversion to int.
CString is meant for dealing with strings.
You can convert using _wtoi like so.
CString cs = L"25";
int i = ::_wtoi(cs);
«_Superman_»
|
|
|
|