|
The other way to handle this is in PreTranslateMessage()
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN && GetFocus() == GetDlgItem(ID_OF_CONTROL))
{
// handle it here!
}
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
I have added some additional code, which seems to work now. But I still find it a bit ugly to perform the check in the application class. But that's ugly windows
Would be nice if someone could add feedback, if this code is correct or not, e.g. the
CWinApp::PreTranslateMessage(pMsg); part.
Thanks for your help!
BOOL CMyApp::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN))
{
HWND hFocus = GetFocus();
CFrameWnd* pFrmWnd = dynamic_cast<cframewnd*>(GetMainWnd()); if (pFrmWnd == NULL)
{
ASSERT(FALSE);
}
CWnd* pTarget = pFrmWnd->GetActiveView()->GetDlgItem(IDC_EDIT_X);
// We should test, if an active view exists, if we are not sure...
HWND hTarget = NULL;
if (pTarget != NULL)
{
hTarget = pTarget->GetSafeHwnd();
}
if (hFocus == hTarget)
{
// Do what you want
}
return 1;
}
else
{
return CWinApp::PreTranslateMessage(pMsg);
}
}
|
|
|
|
|
I would have overridden PreTranslateMessage() in your edit control, and just sent a message to the parent:
BOOL CMyEdit::PreTranslateMessage(MSG *pMsg)
{
if((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN))
{
CWnd *pParent = GetParent();
if(pParent != NULL)
pParent->SendMessage(WM_KEYDOWN, VK_RETURN, pMsg->lParam);
}
else
return CEdit::PreTranslateMessage(pMsg);
}
And then just handle WM_KEYDOWN like normal in the parent and check for Enter being pressed. If you need to handle it in your main frame window, then use AfxGetMainWnd() instead of GetParent() .
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thank you for the hint, I will try it.
|
|
|
|
|
I want to prevent a window from being minimized(currently it minimizes itself as soon as it is no longer the foreground window), I think I need to write a hook, but I don't know what message I need to capture... can some one please give some detailed solution? Thanks a lot.
|
|
|
|
|
What about to create that window without minimize button ?
And remove minimize command from it's system menu ?
rrrado
|
|
|
|
|
The target window was not created by me, it's a third party progrram, I just hate it when it keeps minimizing itself so...
|
|
|
|
|
I'm handling WM_CONTEXTMENU message in dialog, invoked by keyboard. It contains two List controls. How to find which one (if any) is activated ?
I tried to get HWND of active window by ::GetActiveWindow()
and comnpare it to HWNDs of list controls get by ::GetDlgItem().
But they are never equal, even if some of the List controls is focused.
Any idea how to do this ?
Thanks
rrrado
|
|
|
|
|
Have you tried GetFocus() ?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Yes, the same result. But I've solved that,
i'm handling listctrls' NM_SETFOCUS and NM_KILLFOCUS and i remember which was focused last
But another mystery for me is, why NM_RETURN from list control is never sent
I look at messages in Spy++, it's always only finding default dialog item and invoking that.
rrrado
|
|
|
|
|
Hi,
Does naybody know how to get the call stack programaticly in a function
Thanks
Ceri
|
|
|
|
|
MFC has a function named AfxDumpStack() or something like that. There are several articles here on CP for crash handling and dumping the stack. Also see John Robbins's BugSlayer articles on MSDN.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hi,
Thanks for the reply.
This is no good to me for 2 reasons.
1.
I am not using MFC
2.
If i where then i dont want to output it, i need to actaully do something with the stack frames.
I have managed it now by using __asm blocks and using the esp pointer.
Not sure i you can help with this question.
Do you know how to get the module name or HMODULE that is mapped for a particualt section of memory. e.g.
A module is loaded at address 0x01000000. There is a function in that module at address 0x01000123. How can I determine which module that 0x01000123 is inside
Many Thanks
Ceri
|
|
|
|
|
|
See :
http://www.codeproject.com/tips/stackdumper.asp?target=stack
Hope that this helps
|
|
|
|
|
I had to use an application that use a National Instrument Data Acquisition card (a PCI card). When using the application the blue screen appears. The informations in the blue screen are
..................
IRQ_LESS_OR EQUAL (or something like this....)
............ NiDAQ32.??? (I don't remeber exatly)
....
I have to investigate about this problem. Here are some questions:
1) Can I say that the problem is not in the application but in driver/driver configuration?
2) What can I do with the blue screen information?
3) Can I call the National Instrument staff and send them the clue screen information / the Windows dump file?
4) What can I do by myself?
Thank you.
|
|
|
|
|
If your are using Windows NT/2000/XP then problem is probably the driver. Most likely an access violation in the driver caused the system to crash. In Windows 2000/XP you can find a dumpfile in the c:\winnt\minidump directory.
There are 2 reasons that the driver might have crashed:
1. You passed some invalid pointer or whatever that caused an access violation in the driver.
2. The driver is bad. I have worked will some of the NI drivers/dll's in the past and this would not surprise me.
|
|
|
|
|
Thanks.
How can I explore the dump file (I mean which tools I have to use)? Can I symply find there the parameters I passed to the driver?
Thank You.
|
|
|
|
|
You can download the "Debugging Tools for Windows" package from the MS site. IN this package there are some tools (like dbgwin) to view the dump files.
But I personally haven't been able to get any meaningfull info from the dump files.
|
|
|
|
|
See if any of these articles are of help:
http://www.winnetmag.com/Articles/Index.cfm?ArticleID=502&pg=2
http://www.winntmag.com/Articles/Index.cfm?ArticleID=301&pg=3
http://www.windowsitlibrary.com/Content/169/01/29.html
|
|
|
|
|
Hi,
You can use google.com to make a search with the information that you have onto your blue screen. Most of the time, you will find a web page that explain approximatively where the problem is.
bye
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Hi All,
Hi How can Achieve the below proposed..
I need to highlight a check button (MFC CButton) when the control gains focus (by keyboard navigation)... The highlight should be similar to the highlight effect of MouseOver.....
Any Help would be appreciated..
Thanks.
Henrik
|
|
|
|
|
Which MouseOver effect do you mean? What should happen if the button gets the focus?
|
|
|
|
|
Hi,
In a Hello World MFC Application create a CheckBox Button (with no caption and no caption space) on the main dialog form...
When i move the mouse over the control here it gets an orange (inner) highlight - so you can see that the button is in focus..
This does not happen when you tab into the control by keyboard...
run the application and watch how the checkbox looks different when you move the mouse over it - then try to tab into the checkbox - and you can see that no change occurs...
I owuld like the same effect to be applied to the control when the user tabs into the control as if the user moved the mouse over the controll..
I'm sorry I cant be more specific... I'm kindof a newbie with Visual Studio / MFC...
/Henrik
|
|
|
|
|
Um, Seems to be an XP feature - Saw my code on win2k today - and there there is no mouseover effect.......
Well ... then my problem is not really important anymore as the solution would only work for Xp users......
/Henrik
|
|
|
|