|
HockeyDude wrote:
I need to perform special operations on WM_PAINT, WM_LBUTTONUP etc before they're mapped to OnPaint()
WM_ERASEBKGND
HockeyDude wrote:
How would I use hooks in MFC
I don't know if it helps you but there is a article about
keyboards hook.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
|
Of course....Nish...your a genius...man if that'll let me do what I need done...wow...what a relief...only...will give me the handle to window the control is for, like SDK?
This is where one of the problems comes in..?
I wonder if theres a function for getting the MSG structure of the current message...i'm pretty sure that has the HWND...
in anycase...PreTranslateMessage sounds like a solid plan.
Cheers and thanx u kindly!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
Thanx Mike, but what I really need is the message AND the window handle that sent the message...so if the MSG structure's hwnd field is not NULL then i'm in business.
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
And of course, the window handle that sent the message isn't included..it's the handle that the message is for...oh well...I think i figured it out.
Thanx again!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
One of books says this field is usually NULL...which would totally suck...
I would ideally like to get the hwnd from the control that "sent" the message, but it appears this is not possible with the incoming MSG, it (if anything) gives me the hwnd to the window(control) whose WndProc should handle the message. I'm really only interested in intercepting messages from two windows. The parent and child...with the parent processing all the messages. So long as I know the parent's window hwnd i could do something like this:
CParentWnd::PreTransLateMessage(MSG)
{
if(this->m_hWnd == MSG.hwnd)
AfxMessageBox("Message from parent");
else
AfxMessageBox("Message from child");
}
If this doesn't work I have more trick up my sleeve which hopefully does.
What do you think Nish...does the above sound solid for acheiving the task at hand..? Is there a better way of doing it...???
Thanx man!
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hello Hockey
If you actually want to figure out which control the message came from,the MSG structure has a pt member. This might be useful if you want to try and locate the exact control that send the message.
But seriously if you want to catch messages before they are handled, at the control level, you must actually start thinking of sub-classing the controls.
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
As Nish have answered the message-interception thing (I guess he literally sits at his PC every waking hour (and most hours when he should be sleeping ) I thought I'd give it a go at the "what's OnCmdMsg all about".
OnCmdMsg gets called through two different paths: either from OnCommand or from MFC in response to a UI update. OnCommand handles only WM_COMMAND messages (not WM_PAINT or WM_LBUTTONDOWN - I'm a little unsure about WM_NOTIFY messages as they used to be WM_COMMAND messages in win16). OnCommand will quite early on call OnCmdMsg in order to do the message map lookup and dispatching.
But OnCmdMsg is also called when MFC needs info in order to update the UI. When you select a menu from the menu bar MFC will call OnCmdMsg in order to get this info. OnCmdMsg will look for an ON_COMMAND_UPDATE_UI entry in the message map and call it if present. In the ON_COMMAND_UPDATE_UI handler you can enable or disable the menu item. If no ON_COMMAND_UPDATE_UI handler is present OnCmdMsg will look for a ON_COMMAND handler for the command and if present it will enable the menu item.
Anyway, WM_COMMAND (and WM_NOTIFY?) is the only message that non-UI-window classes can handle (i.e. classes derived from CCmdTarget such as CWinApp and CDocument). But of course, UI-window classes (CView, CMainFrame etc) can handle both "ordinary" WM_xxx messages and WM_COMMAND messages.
Hope this clarifies the purpose of OnCmdMsg.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
|
Andy Metcalfe wrote:
The best explanation I've seen of what OnCmdMsg() actually does was in Paul DiLascia's article "Meandering Through the Maze of MFC Message and Command Routing" in the July 1995 edition of MSJ
Thanks for the Link Andy. But on that page I found a slight typo :-
BOOL CMyView::OnCmdMsg(...)
{
if (CMyView::OnCmdMsg(...))
return TRUE;
return m_wndGizmo.OnCmdMsg(...);
}
This must be a typo, right?
Else it will endlessly call itself!
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
Nish [BusterBoy] wrote:
This must be a typo, right?
Else it will endlessly call itself!
Well spotted Nish - you're dead right.
Presumably the call would be to CView::OnCmdMsg() , which would route the message through CMyView 's message map, and - if it wasn't handled there - on to the corresponding document.
Andy Metcalfe - Sonardyne International Ltd
Trouble with resource IDs? Try the Resource ID Organiser Add-In for Visual C++
"I would be careful in separating your wierdness, a good quirky weirdness, from the disturbed wierdness of people who take pleasure from PVC sheep with fruit repositories."
- Paul Watson
|
|
|
|
|
Steen Krogsgaard wrote:
To claim that computer games influence children is rediculous
'ridiculous' is spelt wrong. I do not know whether this is as intended. If not, you might want to correct it.
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
Nish [BusterBoy] wrote:
'ridiculous' is spelt wrong. I do not know whether this is as intended. If not, you might want to correct it.
Jesus Nish...I thought you lived in India...not to say indians can't speak English or anything, but you seem to know English really really well...like maybe you don't live in India...maybe you really do live in Canada somewhere...and your just hiding....
Just jokes...India was part of the British Empire for some time wasn't it...? Kinda like Hong Kong...Canada, Aussie you name it...God damn the queen...nevermind bless her...so greedy!!!(spelling)
Ciao!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
Jesus Nish...I thought you lived in India...
I've had a Jesuit education [which explains why my english is sorta good]; and I kinda love the english language a little more than the average Indian does I guess. Anyway in general educated Indians do speak the language pretty well, though the pronounciation might be quite awkward for foreigners to follow
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
Oops! When is Chris going to put a spell checker on CP (just kidding). Thanks Nish.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi All,
I try to install a service with specified account as following:
where "testuser" is a valid account (with no password)
in my NT workstation
CreateService() always return error ERROR_INVALID_SERVICE_ACCOUNT
"The account name is invalid or does not exist."
When I change lpszAccount to "HELLO\\testuser" where "HELLO" is my
machine name, error code ERROR_INVALID_PARAMETER will return
"The parameter is incorrect."
LPCTSTR lpszAccount = "testuser"; // "HELLO\\testuser"
LPCTSTR lpszPasswd = "";
SC_HANDLE schService = CreateService(
schSCManager,
"MyService",
"MyService",
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
"d:\\myservice\\myservice.exe",
NULL,
NULL,
NULL,
lpszAccount,
lpszPasswd);
What's wrong with the above code? Please help me out on this.
Thank you very much in advance!
Regards,
Chris Wang
email: hewang@hotmail.com
|
|
|
|
|
Chris Wang wrote:
LPCTSTR lpszAccount = "testuser";
Th username is specified wrong. It should be specified as domain-name\username or .\username to use the default domain.
Try using this instead
LPCTSTR lpsqAccount =".\testuser";
You might also want to read my article on services.
http://www.codeproject.com/system/serviceskeleton.asp
Thanks
Nish
My most recent CP article :-
A newbie's elementary guide to spawning processes
www.busterboy.org
|
|
|
|
|
Thanks for your message. But if lpszAccount is specified as ".\testuser", there is still invalid account error message. Backslash("\") should be expressed with double backslash("\\").
Chris
|
|
|
|
|
|
Yes, it's Ok now. I forgot one thing. If dwServiceType is specified as SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS instead of SERVICE_WIN32_OWN_PROCESS, it still can not work. Is it possible to set service type as above?
Chris
|
|
|
|
|
|
Does the user account have "log on as a service" rights?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Under XP I can use the nice anti-aliased folder icon in my list control by doing something like this to the imagelist...
<br />
HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 4);<br />
HICON ico = LoadIcon(GetModuleHandle("shell32.dll"), MAKEINTRESOURCE(4));<br />
int x = ImageList_AddIcon(hImageList, ico);<br />
... and using this in my list control is fine. When I use this image list in my tree control the image appears fine at first, but when the mouse is moved over an item, the scary black border begins to appear. In fact, the more times the mouse is moved over the image the blacker we get.
note: This is most noticeable with TVS_TRACKSELECT, it can sometimes be seen without.
This happens with CTreeCtrl and with a plain api WC_TREEVIEW window. Any ideas what's happening here? Explorer doesn't suffer, nor does SysTreeView32.
Thanks in advance,
--
Simon Steele
Programmers Notepad - www.pnotepad.org
|
|
|
|