|
I have an MFC app and I'd like to get notified whenever a any of several possible child windows recv focus. I thought I could just override the main window's PreTranslateMessage() function and simply check the pMsg->message value and if it's a WM_SETFOCUS and the pMsg->hWnd is one of the windows I care about then react accordingly. However I never get ANY WM_SETFOCUS messages!
Am I misunderstanding how PreTranslateMessage is supposed to be used or is there an alternate approach? I'd prefer not to have to subclass each of the controls, but I will if I have to.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
AFAIK the WM_* messages are sent to the pMsg->hWnd window. If that window does not handle the message then it is sent to the parent of that window and on up the parent chain until one of the windows actually handles the message (returns TRUE), or the there are no more parent windows. So the only way the main window will get the WM_SETFOCUS message is if none of the child windows handle it, or they return false if they do.
See CWnd::WalkPretranslateTree() and AfxInternalPreTranslateMessage() in the MFC sources for more details (Set a breakpoint in your PreTranslateMessage() function and use the call stack)
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
the problem is not from the way u try to catch the message, but from the message u want to catch, WM_SETFOCUS cound't be caught, I tried to catch it in the simplest window's program. catch this message before TranslateMessage calls, but still, couldn't get it. somebody knows why?
life is like a box of chocolate,you never know what you r going to get.
|
|
|
|
|
Jim, did you get a solution for this without rewriting all your child controls?
You may find that setting up a WH_CALLWNDPROC hook is the easiest way to be notified when a window in your app recieves the WM_SETFOCUS message.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
No, in the end I just added the OnSetFocus() methods to the various controls. Wasn't that big of a deal, just annoying. But then that pretty much sums up MFC development, for me at least
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Hi
I have a windows based application and creates a icon on the system tray, i wanted to keep it active all the time ( i mean visible in the system tray). I know i can do this by going to taskbar properties-> customize notifications -> Always show, does any body know how to achieve this programmatically?
Thanks for help in advance
|
|
|
|
|
Whenever the thump of the HScroll goes to the end of the scroll bar in the CListCtrl, I will add the 20 records in the listctrl. It will be attain by inserting the record at the HScroll method, by calculating the thump value. Whether the thump is getting to the end, then only I will add the records. But I met the problem which is When I track the thump to the end of the HScroll, the mouse holding the Thump. At the time I need to release the mouse from the holding of thump. I have tried by posting the message of WM_LBUTTONUP by the
SendMessage(WM_LBUTTONUP);
function. Please help me..
~ Selva
|
|
|
|
|
If you need to release the mouse capture and stop scrolling, I think you can try this sequence:
SetCapture();
ReleaseCapture();
I hope it helps.
|
|
|
|
|
Hi Everyone.... i am trying to get this piece of code working over a WAN connection, when i use it on a LAN it works ok.. but when i use it on a wan i can create the connection etc, create and remove directories etc, but as soon as i try to use the openfile function it crashes, does anyone have any ideas why ??
oh, i have tried to use passive rather than Active mode, when i do this i cant use the FtpFindFile function ??
just wondered if anyone had any pointers....
this is the snippet of code..
<br />
CInternetSession oISession(AfxGetAppName());<br />
CFtpConnection* poFtpConnection;<br />
<br />
poFtpConnection = oISession.GetFtpConnection(csSite,"xxx","xxxxx",2001,FALSE);<br />
<br />
poFtpConnection->GetCurrentDirectory(csCurDir);<br />
<br />
poFtpConnection->CreateDirectory(csDir);<br />
poFtpConnection->SetCurrentDirectory(csCurDir + csDir);<br />
<br />
CInternetFile* pInternetFile = poFtpConnection->OpenFile(csFile, GENERIC_WRITE,FTP_TRANSFER_TYPE_BINARY);<br />
<br />
The bold part is where it is falling down...
Any help would be appreciated..
Thanks
Lee
|
|
|
|
|
oh, forgot to say, i am using port forwarding in the router and the ports been used for the ftp is 2001...2009 i need to do it like this because i am going to have multiple connections to the router... i have used smartFTP and it connnects fine using with the port forwarding....
Lee
|
|
|
|
|
Have you stepped into the OpenFile() method to narrow the problem down further?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes, it is falling over at the FtpOpenFile method..., the m_hConnection is a valid handle but the hFile that gets returned is NULL ??
|
|
|
|
|
racing57 wrote: it is falling over at the FtpOpenFile method...
When that function fails, what does GetLastError() return?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i have everything in a try catch block, so when it fails its caught and at that point the getlasterror function returns 0 ???? its just baffling me, because it works ok on a lan...
|
|
|
|
|
racing57 wrote: i have everything in a try catch block...
So what exception is thrown?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
well when i try and call GetErrorMessage i get nothing back, and GetLastError returns 0.... i just cant get my head round whats happening ??? help!!!!!
|
|
|
|
|
little update.... if i change the port to 21 then it works ok... but i need the port to be something different, ie 2001-2009 as there will be more than one client from the router.... anyone got any ideas as to what could be causing it ??
thanks in advance
Lee
|
|
|
|
|
racing57 wrote: ...when i try and call GetErrorMessage i get nothing back, and GetLastError returns 0...
GetLastError() will only work if it's called right after the function that fails. This is apparently not possible in your case as other functions have been called that have reset the value to 0. However, since you have a try /catch block, you know the exception that is being thrown.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
how, if i call the geterrormessage function not is returned ??
|
|
|
|
|
ahhhh, the error message i am getting is 12001 - No more Internet handles can be allocated.... what could be causing this ??
|
|
|
|
|
Hi Everyone, i am still having this problem over a wan... can anyone shed any light on it for me ?? i'm getting kinda desperate to get it sorted now...
Thanks in advance
Lee
|
|
|
|
|
Hi. I want to use text that is not english in the VC6 in some string. I have an English version of VC6 and WIndows XP. I can write in say Chinese or whatever in Word etc because I have the language option set in XP. But in VC, I can not write in anything but English. All other characters come out as ???. Any ideas on who I can do this or if there is anyway for VC6 to support entry of non English char in an English version.
THANKS in advance
|
|
|
|
|
I think you need to compile your software application as UNICODE enabled. Should work that way ...
|
|
|
|
|
(VC++ 6.0 MFC MDI application)
I'm attempting to add file in use functionality to a MFC MDI application for the life of a CDocument. By default, the CDocument appears to lock the file only during serialization then it releases the file. I need to provide functionality not unlike MS Word where it remains locked during editting.
Just for proof of concept, to just see it work, and later make it a little bit more robust, I was providing implementation for OnOpenDocument, OnSaveDocument, and OnCloseDocument with the original MFC code in them. I made whatever modifications needed to prevent CDocument::ReleaseFile from being called while the file was open and I put a member variable in the CDocument class m_pFile to use to assist in keeping that file locked and open. I'm checking the lpszPathName against GetPathName() to determine when to use the stored pointer versus cleaning it up/closing and getting a new file/pointer.
The files get locked as expected but file Open/Save-SaveAs doesn't modify the file (A temporary file gets created/destroyed during the attempt). Only a New/Save-SaveAs (with a unique name) puts the serialized data into the file. Any ideas or has anyone successfully did this in an MDI app without ripping too much out to do it?
|
|
|
|
|
I think you should try a different way. Define a member of CFile type inside your document class, and then override OnOpenDocument , OnSaveDocument , and OnCloseDocument functions. In these functions call the original ones, but also add your code for locking and unlocking the file using additional CFile member (or maybe with some other features).
I suppose the functions may look like this:
BOOL CMyDocument::OnOpenDocument(LPCTSTR lpszPathName)
{
if( ! CDocument::OnOpenDocument(lpszPathName)) return FALSE;
m_MyFile.Open(lpszPathName, CFile::shareExclusive);
return TRUE;
}
void CMyDocument::OnCloseDocument()
{
m_MyFile.Close();
CDocument::OnCloseDocument();
}
BOOL CMyDocument::OnSaveDocument(LPCTSTR lpszPathName)
{
m_MyFile.Close();
if( ! CDocument::OnSaveDocument(lpszPathName)) return FALSE;
m_MyFile.Open(lpszPathName, CFile::shareExclusive);
}
I hope it works.
|
|
|
|