|
I have made a dialog-based WTL application in VS.NET.
I'm trying to make one edit window act as a command prompt. I would therefore like to receive a notification in the parent dialog when the user presses carriage return in the edit control.
I have tried to use the example by Kristian Lippert in his article Subclassing controls in ATL dialogs using WTL[^] but with no luck. It seems that the sub-class does not receive the WM_KEYDOWN or WM_CHAR at all (does receive WM_CHAR when typing some text).
First I thought that I could just use the IDOK-notification and use the control ID or the control hWnd parameters of the notification. But they are "empty" no matter which control has the focus when CR is pressed.
Any help appreciated.
Below is my control-template:
#define EN_GOT_RETURN 0x1000<br />
<br />
template <class T><br />
class CEditEnterNotificationT : public CWindowImpl<CEditEnterNotificationT<T> , CEdit><br />
{<br />
public:<br />
BEGIN_MSG_MAP(CEditEnterNotificationT< T >)<br />
TRACEMSG("CEditEnterNotification");<br />
MESSAGE_HANDLER(WM_CHAR, OnChar)<br />
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)<br />
END_MSG_MAP()<br />
<br />
CEditEnterNotificationT(HWND hWnd = NULL){ }<br />
<br />
CEditEnterNotificationT< T >& operator=(HWND hWnd)<br />
{<br />
m_hWnd = hWnd;<br />
return *this;<br />
}<br />
<br />
LRESULT OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
switch (wParam)<br />
{<br />
case '\r':
ATLTRACE("WM_CHAR - CR\n");<br />
return 0;<br />
break;<br />
}<br />
return DefWindowProc(uMsg, wParam, lParam);<br />
}<br />
<br />
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
switch (wParam)<br />
{<br />
case VK_RETURN:<br />
ATLTRACE("WM_KEYDOWN - CR\n");<br />
::PostMessage (m_parent, WM_COMMAND, MAKELONG(EN_GOT_RETURN, this->m_dlgItem), LPARAM(this->m_hWnd));<br />
bHandled = TRUE;<br />
return FALSE;<br />
}<br />
return DefWindowProc(uMsg, wParam, lParam);<br />
}<br />
<br />
BOOL AttachToDlgItem(HWND parent, UINT dlgID)<br />
{<br />
m_dlgItem = dlgID;<br />
m_parent = parent;<br />
HWND hWnd = ::GetDlgItem(parent,dlgID);<br />
return SubclassWindow(hWnd);<br />
}<br />
private:<br />
UINT m_dlgItem;<br />
HWND m_parent;<br />
};<br />
<br />
typedef CEditEnterNotificationT<CWindow> CEditEnterNotification;<br />
|
|
|
|
|
your subclassed control should handle WM_GETDLGCODE to tell the parent dialog that it "DLGC_WANTALLKEYS"
|
|
|
|
|
Thanks alot. That did the trick.
I don't think it's mentioned in the book (Pezold).
Happy now
|
|
|
|
|
Make sure that Want Return is set in the dialog editor.
|
|
|
|
|
This is by far the weirdest bug I’ve ever encountered! We’ve used an ATL NT Service module (multithreaded) to synchronize the physical clocks of the nodes in our network with the (so called) master time server. The service runs fine for 49,7 days, but then sh*t happens. RPC pulls a heavy CPU load for a few seconds and right afterwards the servers seems to show some nasty unexpected behavior. The service runs 100% CPU until a new client connects and asks the masters time, then the service continues normally for a few minutes and restarts pulling 100% CPU load. The weirdness is that “if” we set the clients interval at 5 minutes it all seems to run fine. I’m aware of the 32 bit rollover.
Concluding: for some reason the service starts pulling 100% CPU on the main thread. This because we couldn’t see (after profiling) any weird behavior in our own code. Debugging the host process doesn’t reach any further then the message loop where we expect the weirdness to happen.
Got a clue?
|
|
|
|
|
My applciation requires generating various wizards (either stacked dialog boxes / property sheets if MFC) using ATL. I am new to ATL. Can any body tell me how to display dialog box in ATL and followed by stacked dialogs? Any samples would be greatly appreciated.
Thanks.
Help Ever, Hurt Never
|
|
|
|
|
|
I am tring to do a little WTL and am getting a undeclared identifier
for CFile. If I try to include afx.h then ATL complanes that I am
not allowed to include windows.h, but I am not using the windows.h
include. What do I need to do.
Thank You
Bo Hunter
|
|
|
|
|
WTL doesn't have a CFile class. If you want to use MFC and WTL together, start a new MFC project, add support for ATL in the wizard, then add the WTL headers manually to stdafx.h.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
Background:
I've finally feel comfortable with c++ programming and now i want to get into 2D Game Programming. I'm using the free Borland compiler from the Command Prompt for my studies and so that makes it even harder.
Problem:
Since I'm trying to learn, the best way is to study the code and learn from it, however, all the DirectDraw/DirectX examples are written in VC++.
Question:
Can I implement DirectX, create a GUI, and use ATL/WTL/STL libraries to create 2D games such as Tetris using this compiler?
Follow-up Challenge:
If someone is movated to do so, can I just see a "skeliton" window using Direct X and DirectDraw in a GUI window using ATL/WTL/STL?
Summary:
Also, If I don't know what I'm talking about feel free to call me an idiot but if you do, also please correct me.
When in doubt, shout it out because the worst that could happen is waking up with a headache and a hospital bill.
|
|
|
|
|
How can I manipulate BSTR typed string in ATL3COM?
Can I convert it to some manipulateable String type?
If yes in which?
Kindly guide me.
Kind Regards
Atif
Watch Your Thoughts for they will become your actions.
Watch Your Actions for they will become your habits.
Watch Your Habits for they will become your beliefs.
Watch Your Beliefs for they will determine your destiny.
|
|
|
|
|
You may want to use the following functions to convert from/to char*/BSTR:
_com_util::ConvertBSTRToString(BSTR pSrc)<br />
_com_util::ConvertStringToBSTR(const char *pSrc)
Hope this helps.
-Tareq
|
|
|
|
|
|
Hi all,
I have a question, if you have some solutions, please advice me.
How to download a file without common file download dialog
I heard some people that you should do it, you have to
develop IE plugin. I investigated, knew that I have to use ATL.
Please advice me, how to, sample program, API ...
Thank you in advance for your kindness.
Best Regards,
yu-yu
|
|
|
|
|
|
HI Mike,
I think this situation,
A client perform click on HTML.
Usually, user execute 2 actions.
1.one download file dialog display, and click button.
2.another file dialog display and set directory and file name,
and download it.
This precondition is to decide download directory and file name.
I would like to download without 2 actions.
is it possible to do it ?
Best Regards,
yu-yu
|
|
|
|
|
|
Hi Mike,
Yes, I think so.
But, I memorise some virus situation.
When we click HTML infected virus, it download client
not to notice user, but it cause IE's security hall.
When I develop plugin that have mouse click event control
functin using ATL, this problem is solved.
But I have not skill to develop it still.
Do you think about it ?
Best Regards,
yu-yu
|
|
|
|
|
Hi All,
I am in the process of developing an ATL/COM extension for an application in which I have embedded the Windows Media Player ocx COM Control into an ATLDialog object. How do I get control of this object so that I can change the video being displayed? I guess if it was a CDialog I could use the appwizard to map the control to member variable. How do I do this for an ATL Dialog?
Do I get the handle and then ......
You help would be greatly appreciated
cheers
Bryce
|
|
|
|
|
Hi ,
U can use GetDlgItem(IDC_MEDIACONTROL1) , this will return u the handle of the media control window
now create a CWnd object attach this media control handle .
HWND hwn=GetDlgItem(IDC_MEDIACONTROL1)
CWnd * wnd=new CWnd();l
wnd->Attach(hwn);
then call wnd->GetControlUnknown()..this will return u the IUnknown Pointer.
Using this pointer query for other media control interfaces..and enjoy coding
byee..hope this solves ur problem
'
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
Hi Abhishek,
Thankyou for your help.
I have done what you said above, but need a little more guidance. When you say at the end "Using this pointer query for other media control interfaces..and enjoy coding"... what is the other media control interfaces? What interfaces/objects should I be aiming to query too...?
I want to be able to do something like....
HWND hwn=GetDlgItem(IDC_MEDIACONTROL1)
CWnd * wnd=new CWnd();
wnd->Attach(hwn);
IUnknownPtr pUnknown;
pUnknown = GetControlUnknown();
//.......
//Query interface to some type of MediaPlayer object
IMediaPlayerPtr pMyPretendMediaPlayerObject; //any ideas on the correct interface?
pMyPretendMediaPlayerObject->Open("The path to the file I want");
pMyPretendMediaPlayerObject->Play();
//.......
Does the logic for this seem ok.... or could you point me to somewhere I could read up on this.
thanks for your help
cheers
Bryce
|
|
|
|
|
Hi once again, sorry for not making myself so clear..
actually i mean
using that IUnknown Pointer
like
IUnknown *unk=wnd->GetControlUnknown();
Query for other interfaces like this
IMediaPlayer *mediaplayer
unk->QueryInterface(IID_IMediaPlayer,(void **)&mediaplayer);
in the same way all other interfaces that Windows Media Control Supports ..u can see supported interface in VB Object Browser(by addding Control in a VB and browse that object .using utility object browser).
So ...tell me if it worked..and i am making myself clear!!
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
Hi Abhishek,
Yep looking at the VB object browser was a good idea.
I have foudn one reason why it was not possible working.... I forgot to import the ocx object definition for the MediaPlayer (msdxm.ocx).
However, when I define the IMediaPlayer the compiler doesn't have a clue about what to do.
C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : error C2065: 'IMediaPlayer' : undeclared identifier
C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : error C2065: 'mediaplayer' : undeclared identifier
C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : warning C4552: '*' : operator has no effect; expected operator with side-effect
I getting pretty frustrated why it seems so complex to something that should be simple.
I am relatively new to ATL MFC etc.... but this should be a walk in the park.
thanks for your help
cheers
Bryce
|
|
|
|
|
|
Hi Michael,
Thanks for the pointer to your articles! nice to read the background info on why certain things have to be done.
The WTL example that you posted was with a com server (.exe). Does having my extension with activex control change many things if it is in a DLL?
Cheers
Bryce
|
|
|
|