|
hi WebSitesNG,
thanks for your reply.
i need it, because if the user accidentially press a particular key too long, so that it repeats itself, then this will result an error.
cheers
|
|
|
|
|
Check the previous key state bit.
void CMyWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nFlags & (1 << 14))
{
return;
}
CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
}
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I am writing a MDI appkication but there are times when the user tries to open a new window and I want to prevent this (e.g. when there is a resource conflict).
I tried putting PostMessage(WM_CLOSE, 0, 0) in the OnCreate function but it doesn't work.
Any ideas?
Elaine
|
|
|
|
|
Returning -1 from the OnCreate method should abort the creation process and destroy the window.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
It works but puts up a dialogue box with an error.
Commenting out the CView::OnCreate call causes an exception.
|
|
|
|
|
I'm going to try overriding CWinApp::OnFileNew , that should do it.
Thanks for trying.
Elaine
|
|
|
|
|
Returning FALSE from CDocument::OnNewDocument() will also do it.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Also, returning FALSE from a PreCreateWindow() override will prevent the creation before the
associated HWND is created.
Mark
|
|
|
|
|
Unfortunately the causes an error dilaogue to appear.
I'm going to try overriding CWinApp::OnFileNew , that should do it.
Thanks for trying.
Elaine
|
|
|
|
|
I didn't know that. I'm going to have to look into that - if it's MDI-specific maybe(?)
Thanks!
Mark
|
|
|
|
|
It looks MDI specific but I suppose you could use OnFileOpen for SDI.
|
|
|
|
|
How to catch WM_CHAR ,WM_KEYDOWN in Dialog Base.
|
|
|
|
|
In MFC, by using The On*() handlers, or using PreTranslateMessage(...) from within the CDialog class. In straight C/C++, by adding the message identifiers to your message pump.
Many examples on this site catch those messages - if you do an article search for those messages, I am sure you will find matches.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
If you want to learn how to create Games with DirectX visit this portal: lightportal.co.nr
|
|
|
|
|
I've looked around but I think I'm looking for the wrong things because I instinctively feel there must be a very, very simple way for me to make a DateTimePicker control on a simple MFC dialog automatically update the current time (and maybe date in another control). I don't mind following an article if you point me there
|
|
|
|
|
ldsdbomber wrote: there must be a very, very simple way
You mean like you read the data from the source control and you write it to the target control? That is very simple.
led mike
|
|
|
|
|
what source control? I want it to display the current time, but I am getting confused about the formats. I have a DateTimePicker control, but have seen documentation for a DateTime control. I've seen where you can send a SetTime message with CTime, but the control I'm using has SetTimer not SetTime. I think I'm just getting mixed up. I've dropped a picker onto my dialog, set it to display in time format, I just want that to update every second with the real time.
|
|
|
|
|
ldsdbomber wrote: I just want that to update every second with the real time.
Get the current time using GetSystemTime(). That result is your source data. Then write that data to the DateTimePicker control.
led mike
|
|
|
|
|
I realise I'm not at your standard, but are you meaning to take the mickey by just repeating my question? Obviously if I'm asking how to update a datetimepicker control I would do it, so telling me to get the current time and update the control is not an answer.
There is no SetTime function for my control. Maybe this is why I am getting confused. I am expecting to see a SetTime function, but I only see SetDlgItemText. Perhaps I need to pass in a pointer to GetSystemTime, then use that somehow formatted to pass to set the control text, but that wasn't what I was expecting, I now see I also need a timer event
|
|
|
|
|
Are you working from a book or tutorial? If not you should be. You should aquire some basic knowledge before posting questions here. Trying to use a forum to get people to teach you basic programming constructs is not going to be productive.
led mike
|
|
|
|
|
Have you set up a timer by calling SetTimer(1000) ? In response to the WM_TIMER message, update the control with the current time.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
no I haven't done that, thanks, I will look into that.
|
|
|
|
|
Hi David,
I'm only used to knocking out dialog apps with the MFC app wizard so am just a bit unsure where to put the timer in, and whats the proper syntax (and where to put it) for a function that the timer calls etc.
any tips or links to external tutorials?
|
|
|
|
|
ldsdbomber wrote: ...am just a bit unsure where to put the timer in...
A common place to call SetTimer() is in the OnInitDialog() method.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yep, I thought as much, it was the function that settimer calls I was unsure if it was just a function you can slap anywhere, or does it need to be "tied in" somehow to the appwizard generated stuff with the message maps and stuff.
|
|
|
|