|
Thank You, could you possibly give me idea where to do that at / how the PreTranslateMesssage function works, It looks like it only take a MSG *msg parameter, im not sure how to use it.....
i guess i should try overriding the pretranslatemessage from the app class eh... hehe, sorry im slow sometimes
todo....
:: insert inpirational text here ::
|
|
|
|
|
BOOL CMySampleWnd::PreTranslateAppMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN ||
pMsg->message == WM_SYSKEYDOWN ||
pMsg->message == WM_LBUTTONDOWN ||
pMsg->message == WM_RBUTTONDOWN ||
pMsg->message == WM_MBUTTONDOWN ||
pMsg->message == WM_NCLBUTTONDOWN ||
pMsg->message == WM_NCRBUTTONDOWN ||
pMsg->message == WM_NCMBUTTONDOWN)
{
return FALSE;
}
return TRUE;
}
Enjoy it and good programing.
Carlos Antollini.
Pi Five[^]Creator
Sonork ID 100.10529 cantollini
|
|
|
|
|
1. If you want to control Ctrl+Alt+Del you should create a GINA.DLL or try to find out one.
2. If you want to avoid all the strange keystrokes like Windows keys and so on... you must create a "keyboard system wide hook". This can handle all the keys you want to having your app. the focus or not.
3. If you want to handle normal keys you can do it as the other answer says, but it will control only the keys selected in your application when your application have the focus.
4. if you want to get the keyboard controlled since the beggining you should call the hook from a windows service in order to get it loaded before the user have logged on...
My advice:
1. system service
2. System wide hook (note that it must be placed in a DLL)
3. manipulate (start,stop...) the service from your app.
hope this helps...
|
|
|
|
|
cool, i should keep focus, because i made the dialog full screen, and stays on top, so i think i can use the pretranslate message thing... just gotta figure out now that i got an override for that function from my app class, how to code it to only allow my alphanumerics...
thanks for all the help tho , glad to learn so much at once
todo....
:: insert inpirational text here ::
|
|
|
|
|
you are right joan murt, this wont work for me.
BOOL CMatrixApp::PreTranslateMessage(MSG* pMsg)
{
return 0;
//return CWinApp::PreTranslateMessage(pMsg);
}
this kills the ESC, but does not stop system keyboard escapes like ctrl-alt-delete , and alt-f4. is there a way to filter them out too in pretranslate message, or must i make as you said, a system wide hook to do that?
todo....
:: insert inpirational text here ::
|
|
|
|
|
i dont have to really worry about the system rebooting actually the customers will only have access to the app thru a keyboard and mouse.. they cant reboot the box.
is there somehow just in my one app to listen to all keyboard input system wide and stop ctrl-alt delete and the altf4 etc?? id really like to do it all from one app without using windows services , etc. it doesnt have to be complicated, just functional....
todo....
:: insert inpirational text here ::
|
|
|
|
|
I have overriden WM_TIMER of CMainFrm class.,and use SetTimer function.I'm not sure about one thing.Does WM_TIMER called for every its period even if there is no focus on main window and other application are focused?In the tests that I've done there were no problem and it is called but I want to be sure it is called ALWAYS after SetTimer function.Does anoybody have any experience?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
The WM_TIMER message is the lowest priority message handled by windows, and as such, there is no absolute guarantee that the message will always be handled. In a typical application that is usually idle, this won't be a problem, but in a heavily multi-threaded or especailly busy app, you stand a good chance of missing a WM_TIMER message every once in a while. This isn't necessarily a bad thing because WM_TIMER messages are happen quite frequently.
If it's absolutely essential that your timer messages get through, use a separate thread for a timer, and have it send messages back to the main window when a timer "tick" occurs.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
Thanks John for your reply.
John Simmons / outlaw programmer wrote:
If it's absolutely essential that your timer messages get through, use a separate thread for a timer, and have it send messages back to the main window when a timer "tick" occurs.
Does this means I use my SetTimer function in a new thread?(Start timer in new thread)
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
No, the whole purpose of setting up a separate thread is to eliminate the need for the WM_TIMER message completely. This means you have to implement your own timer code. There is timer code on CodeProject.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
Thanks.I got the point.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
In a file I see:
BEGIN_MESSAGE_MAP(CPaletteStatusBar, CStatusBar)
ON_WM_CREATE()
ON_WM_SIZE()
END_MESSAGE_MAP()
What does ON_WM_CREATE() mean? WHat is VC doing by writing this line of code?
Appreciate your help,
ns
|
|
|
|
|
ON_WM_CREATE() basically ties the WM_CREATE message to a member function of the CPaletteStatusBar called OnCreate. So whenever the WM_CREATE message is sent to the window tied to an instance of the CPaletteStatusBar class, OnCreate is called with the proper paremeter.
Having said that, here's what I typically do when I need to find the answer to a question such as yours:
1. Look it up on MSDN to see if that can answer my question.
2. If MSDN is not enough, I search for it in the actual MFC code. In other words, I do a Find in Files of ON_WM_CREATE and tell it to search in the folder where the MFC source code is installed (ie, C:\Program Files\Microsoft Visual Studio\VC98\mfc).
3. If I still don't understand, I try to find someone around me that knows the answer.
4. If that still doesn't work, I come to CodeProject and ask.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thanks. I havent programmed in a while and am feeling extremely overwhelmed. SO I am not functioning at my best. Sorry to bother you. YOur ideas are the first in this round that I'l take to heart....
Appreciate your help,
ns
|
|
|
|
|
Just one thing though: (hope I am not being a pain...)
THe search in the MFC folder gave me a zillion cpp files and I didnt know which one might be the relevant one and couldnt really go through each one. How does one decide?
I couldnt figure out even after seeing MSDN when WM_CREATE Is issued: It says
The WM_CREATE message is sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function.
SO if I dont have a call to CreateWindow I dont see this message? So when I call Create, this messgae isnt issued?
Appreciate your help,
ns
|
|
|
|
|
WM_CREATE is sent to the window by Windows (not MFC) as the first message after the window is created by the operating system.
WM_CREATE message is usually used by applications to perform window initializations after it has been created.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
ns wrote:
SO if I dont have a call to CreateWindow I dont see this message? So when I call Create, this messgae isnt issued?
Every window that is created in your application will call CreateWindow or CreateWindowEx and WM_CREATE will be sent. MFC hides the details of this in many ways, but in the long run CreateWindowEx or CreateWindow will be called.
John
|
|
|
|
|
May I suggest , that you try to use F12 (go to definition), it is really helpful if you want to see where class/variable/macro/function defined and what it does.
|
|
|
|
|
I have to have a Create function to spawn my modeless dialog. Do I just write it in or do I make it trap the WM_CREATE message?
Appreciate your help,
ns
|
|
|
|
|
The code I'm looking at has:
BOOL CZoom::Create(UINT nID, CWnd *pWnd, int index)
{
m_imageMapIndex = index;
m_imagePtr = imageMap[index].GetImagePointer();
m_imageSize = imageMap[index].GetImageSize();
imageMap[index].IncrementPointerCount();
imageMap[index].pZoomSet.insert(this);
return CDialog::Create( nID,pWnd);
}
and
void CResizeSonarViewBoxView::OnCreateviewbox()
{
CImageDisplay* pdlg;
pdlg = new CImageDisplay();
if(pdlg != NULL)
{
BOOL ret = pdlg->Create(IDD_DIALOGIMAGEDISPLAY, this);
if(!ret)
AfxMessageBox("Error creating Dialog");
}
so I guess my question is that did they just go and add a Create() function by hand or did they get it through he classWizard by trapping WM_CREATE and modify it?
In yet another book I see that they dont add a Create function by hand, but just call it in the constructor like so:
Create(IDD,pPArent);
Where did this function come from? Its not in their code......
Can I infer that if I want my create() to do more stuff, I can modify it, but then I have to write my own Create()?
Again is Create() associated with WM_CREATE ?
Thanks
Appreciate your help,
ns
|
|
|
|
|
Create is just a member function of the CDialog class. It has nothing to do with the WM_CREATE message. It's just the one used to create the dialog box modelessly.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thank you..
But now I'm curious. WHats WM_CREATE all about? When is it sent out? BY whom? ANd who gets it and how to they respond when they get it?
Appreciate your help,
ns
|
|
|
|
|
Use MSDN to fully answer some of these questions, but I also suggest picking up a book about Windows programming.
Here's what I know:
Whenever a window is created, resized, clicked on, destroyed, whatever, Windows (the operating system) sends a corresponding message to the callback function tied to it (the window). WM_CREATE is the ID of the message sent to that function (by Windows) at the moment the window is being created. If the programmer needs to do something at that time, he checks for that message (inside the function) and does something. If he doesn't care about it, he doesn't do anything and the window continues being created.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Recommend any super duper good book?
Appreciate your help,
ns
|
|
|
|
|
I don't have anything off the top of my head. I've heard that Charles Petzold puts out great Windows programming books. You may search him out on the web.
Also, you may wanna do a Search on this forum, or the Lounge maybe to see what other people have recommended. I'm sure this question (what book do you recommend?) has been asked many times here before.
Good luck and don't worry, it will all make sense before you know.
Alvaro
All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
|
|
|
|