|
Hello.
At the first time, I made a dialog with OnKeyDown function and there was no control on the dialog.
My OnKeyDown function worked well. I pressed a key(spacebar) and OnKeyDown function was called.
Next, I made some CButton controls on the dialog. And I soon noticed something wrong, OnKeyDown had no effect.
I found the reason. One of the button controls had focus automatically, and when I pressed spacebar that button was clicked.
(If there was no control on the dialog, that action would call OnKeyDown function.)
So I added the code "AfxGetApp()->m_pMainWnd->SetFocus();" in OnInitDialog, yet that seems ineffective.
I want to make the dialog grab 'keydown' focus like the first time, not the button control.
I need ideas and advice.
Thank you for reading this.
May the sky bring you a full measure of health and prosperity.
|
|
|
|
|
If you read the documentation of CDialog::OnInitDialog[^], you find this:
Return Value
Specifies whether the application has set the input focus to one of the controls in the dialog box. If OnInitDialog returns nonzero, Windows sets the input focus to the first control in the dialog box. The application can return 0 only if it has explicitly set the input focus to one of the controls in the dialog box.
So return FALSE from OnInitDialog. Does that help?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I tried and the button control seemed losing its 'focus', but when I pressed spacebar, the button was still clicked.
(The problem is that my action(pressing the key) didn't call the OnKeyDown function because of the buttons.
Once I removed the buttons for test, the program worked well. Yet I have to add buttons.)
Anyway, thanks for your answer. If you have any ideas, please let me know.
May the sky bring you a full measure of health and prosperity.
|
|
|
|
|
I'm not sure but you could try catching the key press in the PreTranslateMessage[^] method of the CDialog...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
|
Yourwelcome. Try returning TRUE from PreTranslateMessage after you called your OnKeyDown handler, this should stop the button from handling the keyhit too and get pressed. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
hi,get the key message use PreTranslateMessage() function.
you can try..
|
|
|
|
|
plz tell how to convert this statement in vb.net into c#
For Each node As XmlNode In xmlNl
ddlctry.Items.Add(node.LastChild.InnerText)
Next
|
|
|
|
|
foreach (XmlNode node in xmlNl)
{
ddlctry.Items.Add(node.LastChild.InnerText);
}
|
|
|
|
|
??? C# here
Why do you want to propaganda c# here!?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
|
If it was so urgent, then why not use the correct forum instead of the C++ forum ?
|
|
|
|
|
OK: so I badly need a new laptop, can you deliver it to me, plz plz urgentz?
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]
|
|
|
|
|
Just go to:
free.laptop.cpalliniz.urgentz.com[^] !
I thought you'd have known that one...
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Hey man, do you know:"mai rubare in casa del ladro?"
OT: I supposed you were angry with me, since you never replied my emails.
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]
|
|
|
|
|
CPallini wrote: Hey man, do you know:"mai rubare in casa del ladro?"
Isn't Ladro pottery from the Netherlands? Put's a new spin on the name!
Google: never steal in the house of the thief
(I did get "house of" for myself though..., and though
Nicely put phrase!
CPallini wrote: OT: I supposed you were angry with me, since you never replied my emails.
Erm, no embarassed. I got called away for work, and let those 10minuter-s time out, so I never saw the email. CP's email facility is still, erm, less than optimal.
Real address: imcclarke @ moc.oohay (I trust you to decrypt the post @ bit)
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Iain Clarke wrote: I trust you to decrypt the post @ bit
After all, I'm MVP (anyway, like you, I guess it was for my Lounge posts ).
BTW: good THHB's activity!
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]
|
|
|
|
|
|
What is the type of xmlNl ?
It is very difficult to help you because we don't know anything about the types of your variables.
Edit: oops, I didn't see that it was for C#...
modified on Wednesday, March 18, 2009 3:49 AM
|
|
|
|
|
Hi,
I have three horizontal sliders on my dialog box, i am calling OnHScroll Event from my appplication, whenever i have clicked on any of the 3 sliders the OnHScroll event is getting firing. I am not able to identify which slider i have clicked on..
I am using below code snippet for getting the slider position.
CSliderCtrl* slider = (CSliderCtrl*)pScrollBar;
int slider_pos = slider->GetPos();
now i want to know which slider iam moving..
Can any one tell me how to get that ....
Any immediate help will be appriciated....
Thanks in advance...............
|
|
|
|
|
Hi,
u can get the CWnd pointer to a slider via
int iCtrlD= pScrollBar->GetDlgCtrlID();
CWnd* sliderWnd = GetDlgItem(iCtrlD);
Thanks,
Spk
|
|
|
|
|
Hi All,
How to use CALLBACK functions in SetWaitableTimer?..I have tried a lot but not executing the function given as the argument to it ..any idea??
Regards,
SPK
|
|
|
|
|
If you provided some code, we could maybe help you fix your issue.
|
|
|
|
|
yes.. i am attaching the code here..
//In the Dialog class of my application
m_DsnTimer.SetTimer(100, &TimerProc, (LPVOID)this);
//here TimerProc is a callback function defined in the dlg class
int WINAPI TimerProc(LPVOID lpArgToCompletionRoutine)
{
CTimerApplicationDlg* obj = (CTimerApplicationDlg*)lpArgToCompletionRoutine;
AfxMessageBox(_T("In TimerProc"));
return false;
}
here m_DsnTimer is the tmer class
//In SetTimer Function i am doing like this
BOOL bReturn = FALSE;
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = -uiElapse;
PTIMERAPCROUTINE pcbTimerProc;
pcbTimerProc = (PTIMERAPCROUTINE)cbTimerProc;
if (NULL != m_hTimer)
{
bReturn = SetWaitableTimer(m_hTimer, &liDueTime,
1,
pcbTimerProc,
lpParam,
FALSE);
}
Regards,
Spk
|
|
|
|
|
Your thread needs to be in an alertable state to execute the waitable timer completion routine. This page[^] and this page[^] may be of use/interest.
To illustrate - the code below executes the timer completion routine as expected. Change the TRUE to FALSE in the SleepEx call and it won't, as the thread's no longer in an alertable state.
#include <windows.h>
#include <iostream>
bool timerFired = false;
VOID CALLBACK completion(LPVOID lpArgToCompletionRoutine,
DWORD dwTimerLowValue,
DWORD dwTimerHighValue)
{
std::cout << "In completion routine\n";
}
int main(int, char**)
{
if (HANDLE hTimer = CreateWaitableTimer(0, TRUE, 0))
{
__int64 due = -1000000LL;
SetWaitableTimer(hTimer, (LARGE_INTEGER*)&due, 0, &completion, 0, TRUE);
::SleepEx(5000, TRUE);
::CloseHandle(hTimer);
}
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|