|
I have tried to search scientific way of handling retutn key on many
discussion boards and websites but no use.
I have dialog box with two edit boxes. One edit box accepts number.
When user enters number and hits enter (Carriage Return) key it
should display the corresponding data to entered record number
in another edit box.
Since it is single line edit box the enter key will be grabbed by dialog
box and I have no way to intercept enter.
Then I tried
This
In my Edit Control class I added following...
UINT CQSmartEditCtrl::OnGetDlgCode()
{
UINT code = CEdit::OnGetDlgCode();
code |= DLGC_WANTMESSAGE;
return code;
}// OnGetDlgCode
and
void CQSmartEditCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if(nChar == 13 ) // Return Key
{
AfxMessageBox("Need to Display Data");
}
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
But now I don't know how to handle displaying of Data because I need to send
notification to dialog that it is time to display record. How to achieve this.
Also, I have question is there any alternative way to get Return Key from within
edit box which is scientific way
Regards,
Vijay
vijay_khot@hotmail.com
|
|
|
|
|
In OnKeyDown handler call CWnd::GetParent and cast the result to proper type - pointer to your dialog class. Then call appropriate method (the one that displays data) using the pointer.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks Tomas...
It helped me. Now I have one more question
UINT CQSmartEditCtrl::OnGetDlgCode()
{
UINT code = CEdit::OnGetDlgCode();
code |= DLGC_WANTMESSAGE;
return code;
}// OnGetDlgCode
This function is making Edit Ctrl to intercept all messages
including TAB and ESC
How to skip these messages?
Bad judgement gives Good experience;
Good judgement comes with Bad experience
|
|
|
|
|
Win2000 DDK SP1 have two constant in ntddk.h:
- PULONG_PTR (in struct _KDPC for exemple)
- ULONG_PTR
These two constants are unknown and undefine
BUILD ERROR
D:\PROGRAM FILES\NTDDK\INC\DDK\ntddk.h(370) : error C2146: syntax error : missing ';' before identifier 'Lock'
D:\PROGRAM FILES\NTDDK\INC\DDK\ntddk.h(370) : error C2501: 'PULONG_PTR' : missing storage-class or type specifiers
D:\PROGRAM FILES\NTDDK\INC\DDK\ntddk.h(370) : error C2501: 'Lock' : missing storage-class or type specifiers
D:\PROGRAM FILES\NTDDK\INC\DDK\ntddk.h(824) : error C2146: syntax error : missing ';' before identifier 'KSPIN_LOCK'
D:\PROGRAM FILES\NTDDK\INC\DDK\ntddk.h(824) : fatal error C1004: unexpected end of file found
??
i use namespace to include ntddk.h. Help Please
i use visual C++ 6.0 and SP 2 on windows 2000 Pro
|
|
|
|
|
These types are defined in basetsd.h
PULONG_PTR, which is a pointer to a ULONG_PTR.
PULONG_PTR is a pointer that is itself 32 bits for 32-bit Windows and 64 bits for 64-bit Windows. It points to an unsigned integer, ULONG_PTR, that is 32 bits for 32-bit Windows and 64 bits for 64-bit Windows
My copy of this faile is from the platform sdk. so make sure it is part of your project's path.
#if !defined(_W64)
#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
#define _W64 __w64
#else
#define _W64
#endif
#endif
#if ( 501 < __midl )
typedef [public] __int3264 INT_PTR, *PINT_PTR;
typedef [public] unsigned __int3264 UINT_PTR, *PUINT_PTR;
typedef [public] __int3264 LONG_PTR, *PLONG_PTR;
typedef [public] unsigned __int3264 ULONG_PTR, *PULONG_PTR;
#else // midl64
#if defined(_WIN64)
typedef __int64 INT_PTR, *PINT_PTR;
typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
typedef __int64 LONG_PTR, *PLONG_PTR;
typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
#define __int3264 __int64
#else
typedef _W64 int INT_PTR, *PINT_PTR;
typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
typedef _W64 long LONG_PTR, *PLONG_PTR;
typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
#define __int3264 __int32
#endif
#endif // midl64
Hope that helps.
Regards
Alfadhly
<marquee>
It is Illogical to define an inventor by his invention
|
|
|
|
|
hey ... quicky question
in the docs it says one must call CWinApp::HideApplication() before calling CWinApp::CloseAllDocuments() but i don't cos i don't want the app to close ... it seems to work ok but does anyone know if there is some terrible screw up happening down in the depths that just hasn't showed itself yet by not calling CWinApp::HideApplication() first ??
answers / hints appreciated
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I don't think you're going to screw something without HideApplication - if many your app is MDI and many MDI child windows are open you'll see them closing one by one. Just remember that calling CloseAllDocuments will destroy all docs *without* saving modified content.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I don't kow how to make for including ntddk.h declared in ntdll.dll. I havn't the file ntddk.h in the path
\\VC98\include\*.*
How to make??
|
|
|
|
|
It's in the Windows NT DDK, according to MSDN.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Thanks for you little help but if i include ntddk.h i have three errors
d:\program files\ntddk\inc\ddk\ntddk.h(370) : error C2146: syntax error : missing ';' before identifier 'Lock'
d:\program files\ntddk\inc\ddk\ntddk.h(370) : error C2501: 'PULONG_PTR' : missing storage-class or type specifiers
d:\program files\ntddk\inc\ddk\ntddk.h(370) : error C2501: 'Lock' : missing storage-class or type specifiers
Do You know??
And i accept this License Agreement
|
|
|
|
|
Is there a tool or a macro that helps in creating a zipfile of your sourcecode. Often when I post a project to codeproject, there's always a file(s) missing I didn't think of. It would be easy when you create such a zipfile from within Visual Studio.
|
|
|
|
|
...a simple DevStudio add-in!
There's an MFC class somewhere on CP which handles Zip/UnZip, so it wouldn't be too hard to do, methinks.
The only trick would be identify which files to add, and which to leave out (whouldn't be too difficult).
If you want to learn how to write add-ins, this sounds like a good project
Andy Metcalfe - Sonardyne International Ltd (andy.metcalfe@lineone.net) http://www.resorg.co.uk
"I used to be a medieval re-enactor, but I'm (nearly) alright now..."
|
|
|
|
|
I know the MFC Zip/Unzip because I developed an ATL-based version from it : SAWZip. Do you know how to program a DevStudio Add-in?
|
|
|
|
|
I started one last week, and it's easy. I got it in a night so I have an add-in that creates a text file of bookmarks, with comments, brings them up in a dialog, and I can select them and jump to the file location. Not much, but it *will* be cool when it stores bug history in an ADO database and links to our bug tracker at work.
The point is that it is easy. I considered doing it myself when I originally saw your comment. Just spend an evening in the MSDN and look at some samples. If you get stuck, I'd be happy to collaborate on a CP article that does it ( it sounds like we have the required bits between us ).
|
|
|
|
|
Beaten to it again!
Add-Ins are easy, though there are (as ever) a few funnies to contend with (toolbars, grrr. )
Seriously, both sound like excellent ideas to me, and if there's any way I can assist, please feel free to ask.
Hopefully I'll be publishing my own VC add-in (The Resource ID Organiser Add-In for Visual C++ 5.0/6.0) on CP very soon.
Then...SourceSafe add-ins look challenging....
Andy Metcalfe - Sonardyne International Ltd (andy.metcalfe@lineone.net) http://www.resorg.co.uk
"I used to be a medieval re-enactor, but I'm (nearly) alright now..."
|
|
|
|
|
I need to program a simple 3 octave piano keyboard using MFC.
I may paint bitmap with keys and handle clicks, then use PtInRegion.
But I would rather use buttons.
Is there any easy way to form MFC CButton with region shape (SetWindowRgn).
Well, you may have better idea.
a/c
|
|
|
|
|
This may help. You will need your button controls to overlap, though. That shouldn't be a problem, since they won't paint over each other.
http://www.codeguru.com/buttonctrl/UniButton.shtml
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
hi.
how can i find the current status of a process or application. just like in task manager. either tell me the API function name or code through which i'll be able to find out what is the current status of application whethre its RUNNING or NOT RESPONDING. infact i want to know in my program whether application is running or not if its in NOT RESPONDING status then i have to kill it. so plz help me out
thanx.
|
|
|
|
|
i think i answered this one a whiles ago but here goes again...
the task manager (and the system) doesn't actually know if your app is running normally or hung unless it processes messages its message queue ... now if your app does a huge calc that effectively stops it responding for a while windows will assume its hung and tell you so in the tm ... that may be correct in most cases but it may be wrong
if the huge calc is safely spawned off into another thread and the ui thread is running normally things will be cool and the gang ... otherwise maybe not
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
hi lauren.
thanx alot for replying but stil haven't solved my problem. infact i have to find out how windows track this thing that message in the queue is not respondind. i mean there has to be some API function which tells window that rightnow application is in NOT RESPONDING mode. there has to be some code or way and i m very much interested in it. coz this not possible that windows come to know all by its self that certain application is not responding or its time allocated to its thread is over n the task assigned to it is neither over nor safely spawnwd off to other thread.
i m again asking u to please tell about that API function which which keeps track of such matters or send me code which i could embed in my code.
regards
Haroon
|
|
|
|
|
Actually lauren gave the same response I was going to. If a process is not responding to messages then it is by definition not responding. Windows would tell this by virtue of the fact that it tries to interact with each process, not because it calls on an API function to tell it what it already knows - that it is trying to interact with a child process and it is not replying. This can mean it is busy, or hung. So you need therefore to attempt to interact with the process in question and see if it replies. Is the process of your creation ? The easy way would then be with copydata.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
You could do a SendMessage (you'd need a window handle) in a separate thread, record the "ping" time, and have your checker app's main thread query the worker thread's ping time. If the time is undefined (eg: < 0) after a time "t", you could unsafely assume the target process is compute bound. I think Win9x/NT uses t == 20 seconds.
Hope this helps.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Looks like Norm and Andrew have provided a couple of excellent solutions to your problem. Imho, SendMessageTimeout() appears to be the way to go - it's a supported API call that essentially does what I suggested in my hack.
/ravi
|
|
|
|
|
Luaren
The official way according to Matt Pietrek is to get main window of handle of of the application concerned and then call:
where m_nTimeout is usally set around 5000ms
if (!SendMessageTimeout(hWnd,WM_NULL ,0,0,SMTO_ABORTIFHUNG ,m_nTimeout ,&dwResult ))
pTask->SetTaskStatus(TRUE);
else
pTask->SetTaskStatus(FALSE);
Regards
Norm
|
|
|
|
|
Look article http://www.codepile.com/tric2.shtml
|
|
|
|