|
Thanx Kilo!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
According to my experience, I would like to override OnCancel() function to handle the key event. It makes your program a little easier to use and fewer codes also.
|
|
|
|
|
Does that actually work...? can you just return false in OnCancel to prevent escape from doing it's thing...?
In anycase...it's pretty hard to beat:
if(pMsg->message==WM_KEYDOWN){
if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE) return TRUE;
}
Thats easy enough for me.
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Misunderstanding, friend! I means that I will let the user press esc to quit after I release every resources in OnCancel() function. I donnot want to forbid this feature. I was not talking about coding but a solution. And Thanks your code also.
|
|
|
|
|
The way I do this is by overriding OnCancel() such as:
void CMyDlg::OnCancel() {
GetAsyncKeyState(VK_ESCAPE);
if (!GetAsyncKeyState(VK_ESCAPE)) {
CDialog::OnCancel();
}
}
|
|
|
|
|
Happy birthday HockeyDude!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Thank you kindly.
To be honest I totally forgot about that...
I guess I should go ask friends/family for gifts now?
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I create Folder, but then i draggin class in - class is copy
How move class to folder????
|
|
|
|
|
Drag with right mouse button - this will open popup menu with Copy and Move options when you drop.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
May be I must for each Toolbar button create Menu Item?
|
|
|
|
|
I want write a Thread to read and receive data from LPT port. Could someone help me?
|
|
|
|
|
I want to add a item to the right-click popup menu wherever the edit-lick control, which can belong to any program instance.
I thought there are two ways maybe, one is change the registry, like some "shell extending" articles in codeproject; two is hooking.
But I never touch those two domain before. Can you give me some suggestions? I've got the base info of hooking, but have no good info or source-code of mouse hooking. I have no info of registry.
Thanks ahead!
with Best Regards,
Kamp Huang
|
|
|
|
|
You can do that with local superclassing.
Subclassing is where you replace the windowproc of a window or control after it is created.
Local Superclassing is where you register a new class in your process that has the same name as one of the controls that have already been defined. When windows attempts to create a new control that has been superclasses, it will look in the local class definitions before it looks in the global definitions.
Here is an example of the code that you can add to make it so that every time that you hit a key in the edit box, a beep will sound. You can make the changes to do what you need to do.
WNDPROC lpfnEditClassProc = NULL;
LRESULT CALLBACK LocalEdit_WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
if (msg == WM_CHAR ) {
MessageBeep(-1);
}
return CallWindowProc(lpfnEditClassProc, hwnd, msg, wParam, lParam);
}
BOOL CreateLocalEditClass()
{
WNDCLASS wc;
if ( lpfnEditClassProc == NULL ) {
GetClassInfo(NULL, "Edit", &wc);
lpfnEditClassProc = (WNDPROC) wc.lpfnWndProc;
wc.lpfnWndProc = LocalEdit_WndProc;
wc.lpszClassName = "Edit";
wc.hInstance = _hInstance;
if (!RegisterClass(&wc))
return FALSE;
return TRUE;
}
}
void DeleteLocalEditClass()
{
if ( lpfnEditClassProc != NULL ) {
UnregisterClass("Edit", _hInstance);
lpfnEditClassProc = NULL;
}
}
If you need to change every edit control in windows to do what you want, you can look into global superclassing, but this is generally not a good idea.
|
|
|
|
|
Oh! New idea! I never thought of that before! But I really need to detect every edit-like controls to get the user selected text. I found that there are some many edit-like control with various class-name. Can I superclassing without specified a class-name? I wondered that. Hooking maybe the best way to do the tast. Thanks anyway!
|
|
|
|
|
Hi guys
I want to write a code which register a program in windows, which start up at log on. I mean target program should start up at the time of log on. and also a way to delete this registered program.
How can i do it?
regs
rohit
|
|
|
|
|
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
There is two ways of learning. Diving in. And slowly learning the basics. "The best way?" oc cource learning all the basics is the best way, but ive created the 3rd way of learning, that is: Diving in while you are slowly learning.
In this case... I was wondering how do you make a window "The kind of window that MFC would make" I dont expect a complete tutorial thread response, maybe a link and a couple basic first steps "to get me in the right area"
Personaly i am getting dang tierd of the dos screen "not giving up, just need somthing to work on, in order for i can learn somthing new and exciting "
Thanks all!
~SilverShalkin
ps... I got the right forum this time. "i kindof forget where i am half the time " RPG means Role Playing Game. Thats for those who read my last thread
This forum SUCKS! the forum you want to go to is... www.codeproject.com... Oops wrong forum
|
|
|
|
|
If you have VC, then use a wizard to create either a Win32 application to see how it's done the old way ( and the way that MFC wraps for you ), or a new MFC application to see how MFC does it. I'd recommend starting with an MFC dialog based application, it's the simplest. New dialogs are added by creating them in the resource editor, double clicking on the dialog and following the prompts to create a class. Then you need simply create an instance of the class and call DoModal on it. It will return IDOK or IDCANCEL if you want to test for what your user did with it and any data not stored in controls will be there for you after it closes.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
SilverShalkin wrote:
I was wondering how do you make a window "The kind of window that MFC would make"
Take a look at CWnd::CreateEx
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
Nish [BusterBoy] wrote:
Take a look at CWnd::CreateEx
i looked up CWnd and it said that CWnd is the basis of all window functions, so aplying the ::CreatEx... That creats the window? How do i use this in my code?
Thanks!
~SilverWing
ps... Are there any tutorials any one know of? or any books to look into?
Thanks
Entrapped deep in nothingness
The cold swirl as touch to ice
Dark cavity, abyss, hollowness
A dim glow would seem suffice
Far to reach, away from me
Look about, my sorrow plea
Touch to love and warmth to feel
A pull a tug to laminate and heal
Pools of life that glimmer me
Desire of full in richest thee
Love in full, and warmth impart
Darkness fills and thralls my heart
Entrapped deep in nothingness
Dark Cavity, abyss, hollowness…
Dustin Tigner
|
|
|
|
|
The best book to you is <inside visual="" c++=""> ms press
i am realfly8)
|
|
|
|
|
sorry but the title of the book is "inside visual c++"
i am realfly8)
|
|
|
|
|
Seriously, you need first to set up linking and including MFC, you'll be much better off taking my advice and letting the wizard give you a project in which all that is done for you.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Read this article:-
http://www.codeproject.com/useritems/mfcprogflow.asp
where I explain a simple MFC program [no wizard]
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
I think you're approaching the problem from the wrong angle. MFC is a framework, not just a library. This means that usually it creates main window for you. Your program supplies parts of code used to fill in the holes. So "The kind of window that MFC would make" is a frame window or dialog window, depending on type of application.
When I was learning MFC, I've found that skeleton applications generated by AppWizard were the best place to start. Also, you may find SCRIBBLE tutorial useful - no kidding here, it really shows most important MFC concepts.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|