|
Yes, of course. That's how controls work. The problem is that your view cannot have focus by itself. The easiest way to do this would be to handle the onclick event of the view and deactivate the edit control.
|
|
|
|
|
I have been looking at how I would do this and keep on finding the same code - that you would derive from CEDit and override WM_CHAR messages, and check for VK_ESCAPE, however take a look at this code:
void CEditExtended::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
MessageBox("Character message thrown!");
switch( nChar )
{
case VK_ESCAPE :
{
MessageBox("Escape");
break;
}
case VK_RETURN :
{
MessageBox("Return!");
break;
}
default :
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
break;
}
}
CEdit::OnChar(UINT nChar,UINT nRepCnt,UINT nFlags);
}
Pressing the escape key simply isnt throwing these messages, why would this be?? Any idea how I can do this? (i know everything else is it set up right because if i press another key then this function gets called so its nothing like that)
any help very much appreciated!
thanks
|
|
|
|
|
Hi Anon,
I think you might find that your App (which I suspect is a wizard generated Dialog App) is actually generating a WM_CLOSE or WM_CANCEL. The easiest way to fix your problem is to put a check in you OnClose method.
It should look something like :
if (GetKeyState() & VK_ESCAPE = VK_ESCAPE)
return;
CDialog::OnCancel();
Let us know if you getting it working & how.
Julien.
|
|
|
|
|
Opps
Try this :
BOOL CYourDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
//////////////////////////////////////////////////////////////
// Prevent Enter and ESC from closing the control.
//////////////////////////////////////////////////////////////
if (wParam == IDOK)
return FALSE;
if (wParam == IDCANCEL)
return FALSE;
return CDialog::OnCommand(wParam, lParam);
}
J
|
|
|
|
|
One way to catch the escape key is to overide PreTranslateMessage and before calling the base class PreTranslateMessage, look for a message w/msg = WM_KEYDOWN and wParam = VK_ESCAPE. Then, I usually translate the message into a MYMSG_CUSTOM_ESCAPE message and post that message back to me and return without calling the base class. See sample below.
BOOL CMyWnd::PreTranslateMessage(MSG* pMsg)
{
BOOL bCallBaseClass = TRUE;
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)
{
PostMessage(MYMSG_CUSTOM_ESCAPE);
bCallBaseClass = FALSE;
}
if (bCallBaseClass)
BOOL CWnd::PreTranslateMessage(pMsg);
return TRUE;
}
LRESULT CMyWnd::OnMyCustomEscape(WPARAM wParam, LPARAM lParam)
{
// TO SOMETHING
return 0;
}
|
|
|
|
|
My "this" pointer in my DLL is getting f*ck up,.. I don't know why.
I have create a small 72K zipped test application and dll that shows
this problem.
download it here.
www.marino.dk/misc/dlltest01.zip
run the application, and click on the 'help' menu and then the 'testme2'
menu item. Here you should get an example of a "this" pointer being destroyed.
Plz somebody help me,
Peter Marino ( IO Interactive )
www.marino.dk
|
|
|
|
|
I don't understand what your objective is but I won't beat you about that.
You are making a comparison of g_lpThis to an uninitialized this pointer in the CDeleteMeDLLApp::Start2 method.
Your DLL is being loaded and initialized during the first call to LoadLibrary but this does not mean that you have an instance of the CDeleteMeDLLApp class on which you may make method calls. You are getting a raw pointer to the CDeleteMeDLLApp::Start2 method export and basically callin into very dangerous territory.
Please explain more about what you are trying to do and I think we can all help you better.
Cliff
|
|
|
|
|
ok,... it sounds like I have completly misunderstood how the a dll should work. The Start2 test is comparing the g_lpThis pointer to the actual this pointer,... which isn't the same,.. why isn't it the same, that is my question.
Ok, I got an answer at Codeguru,... it's because my Start2 is seen from the App as a "C" call and not a "C++" object call CDeleteMeDLLApp::Start2. This explains it. Which in turn also gives you the correct answer when you tell me that I don't have an instance of the CDeleteMeDllApp,.. well there is an instance, I just don't have it in my App program.
thx a lot. now I can sleep
Peter Marino
www.marino.dk
|
|
|
|
|
The "This" pointer in a member function of a class is actually an 'invisible' first parameter passed to the function by the compiler. For example, when you write the function :
void CDeleteMeDLLApp::Start2( unsigned long dwDummy1, unsigned long dwDummy2 )
The compiler actually generates this as if it was :
void CDeleteMeDLLApp::Start2(CDeleteMsDllApp* this, unsigned long dwDummy1, unsigned long dwDummy2 )
The problem here is that inside the DLL you are saying that "start2" is a class member function (and therefore has this 'invisible' first parameter called "this"). However, in the App you are telling the compiler it is a normal 'C/C++' function (and therfore it does not have a "this"). When the compiler generated the call to "Start2" is does not add the "this" bexcause it is not aware that "Start2" is a class member (and even if it was aware, the compiler does not now the address of the class instance 'theApp' at this point - only the DLL knows that. So the compilter cannot pass the address even if it knew it should)
To correct this you must resolve this inconsistent view of the function - either make it a member in both places, or a non member in both places. You have 3 choices :
(a) Use non-member functions in the dll, rather than class members;
(b) Make the member functions 'static', so they do not have a 'this' pointer;
(c) export the class from the DLL, rather than the individual member functions. When I do this, I often export a function that returns a pointer to the class, like this :
In the Dll :
CDeleteMeApp* declspec( dellexport) getClass() { return &theApp; }
In the app :
typedef CDeleteMeDll* (CALLBACK* GETCLASS)();
GETCLASS getClass;
HLIB lib = LoadLibrary("deleteMeDll");
getClass = (GETCLASS)GetProcAddress("getClass");
CDeleteMeDLL* theClass = getClass();
theClass->Start(pWnd);
theClass->Start2(1, 2);
You need to rework you interface between the DLL and the App - either make it 'c-style', and export 'normal' functions (you can of course make these exported functions into 'wrapper' functions that simply call the appropriate class member function !), or make it 'C++ style', and export the class, not the member functions. Either way, the bottom line is to avoid exporting class member functions!!
The root of this is that DLLs were invented before C++ was in widespread use, and therefore the DLL architecture has no knowledge of the concept of 'class' - DLLs were designed to hold code (functions) and data as separate elements, not classes (a hybrid mix of code and data). Microsoft has addressed this with the 'declspec (dllexport)' extension to C++ which basically allows you to export an entire class (the compiler will do the necessary work to map from C++ back onto the DLL-style function/data model).
|
|
|
|
|
Hello
Does anybody knows how can I catch Input and Output Internet traffic ?
Regards
|
|
|
|
|
Read more about it at ... and let me know what you think!
I think that spamming message boards is a very poor way to get people to buy your software, but maybe that's just me. Go to http://www.codeproject.com/info/advertise.asp if you want to advertise here.
--Mike--
http://home.inreach.com/mdunn/
"Holding the away team at bay with a non-functioning phaser was an act of unmitigated gall. I admire gall."
-- Lt. Cmdr. Worf
|
|
|
|
|
Is it possible to define a customized syntax highlighting in Visual Studio ? I want some keywords to be green, and some to be red. Thanks for the answers.
|
|
|
|
|
If you mean custom words then I'm not sure if that is possible but if you wish to recolorize the currently supported syntaxses (sp) you can go into Tools->Options and you change the colorization there.
Hope that helps.
Sean Cody (NullStream)
"As long as you want to live,
everywhere will become heaven.
Afterall, you are still alive."
- End Of Evanglion
|
|
|
|
|
Thanks for the answer, actually it's possible to add new keywords that will be highlighted in blue. What I want is define several set of keywords and a different color for each set. I also want to define a new comment delimiter (a semi-colon)
|
|
|
|
|
A semicolon as comment delimiter? Well happy coding, it migth work with something like Foo(); but what about for (int i = 0; i < 10; i++) ?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Actually I would like to highlight syntax for assembly language. In asm, ; is a comment delimiter.
|
|
|
|
|
|
Visual Assist
See you http://www.wholetomato.com/
This is very good tool for VC++
Libor Matejka
|
|
|
|
|
I have created an install program for a VC++ program which installs the necessary DLL's, Database, and executable. When I ran the install on my machine, (which happens to my development box) the install ran great and the program functioned normally. However I installed it on another machine where the install ran great but when you do an open database in the program, it crashes.
My first question is, this machine does have access installed, which means it has the access driver, but are there additional things that need to happen to that database in order for it to load? This machine does not have VC++ installed nor does it have the ODBC icon in the control panel.
My second question is about computers without the access drivers. How can use my install program to install that as well? I guess more specifically, what in the name of the actual driver and where is it suppost to go? (my first guess on location is Windows/System but I'm just making sure)
Thanks for the help!!
Chris
"Why are we hiding from the police, Daddy?"
"We use VI, son. They use Emacs."
|
|
|
|
|
You need to install MDAC (Microsoft Data Access Components), which you can download from http://www.microsoft.com/data/
I don't know what installer you use, but Installshield have support for installing MDAC silently on the endusers machine...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I found the MDAC module. Downloaded it, and am waiting from other guy to see if it was a success. (confident it will be) so now I looking into having Installshield automatically install MDAC, but I can't seem to find in the help file how Install shield might get this done.
Thanks for the insight.
Chris
"Why are we hiding from the police, Daddy?"
"We use VI, son. They use Emacs."
|
|
|
|
|
What version of InstallShield are you using?
In "InstallShield Professional for Windows Installer" MDAC is avaliable as a merge module, it's also possible to use their Express version, I just don't remember how, but I can find out.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Install shield for VC++. Comes with the disk. It's not the Professional Edition.
Looks like some of my money is going "Buh-bye!"
Chris
"Why are we hiding from the police, Daddy?"
"We use VI, son. They use Emacs."
|
|
|
|
|
Well, I have never tried it with that version. If you download the MDAC SDK, there is a way to install MDAC silent, they talk about it in the readme...
You just need to execute mdac_typ.exe, with the right parameters, from your installer...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
This is a standard C++ question rather than Visual C++ specific.
I'm trying to figure out how to make new types of streams (aka not stdio or file io related) and I'm not sure where to start. A few of the vague articles I read stated I must subclass a streambuf but the member functions are not well named nor well documented.
Essentially I'm trying to build a clean portable IPC library (well portable in that the interface is portable ) and the cleanest way I can think of is using customized streams (socket-stream,memory-stream,pipe-stream,memory-mapped-file-stream etc).
Can anyone point me in the right direction or to a suitable article or set of articles? I know there is a book or two out there but the only one suitable is a bit beyond a broke student's resources. I would appricate any assistance in any form.
Sean Cody (NullStream)
"As long as you want to live,
everywhere will become heaven.
Afterall, you are still alive."
- End Of Evanglion
|
|
|
|