|
I don't still master CALLBACK function,
such as its working theory and coding rule and so on
Can somebody tell me?
Thank you in advance!
|
|
|
|
|
As far as I know there's nothing much different in syntax.
just use the CALLBACK specifier.
The difference come in the code that's inside the function.
A callback is called from some outside source (usually windows itself) on the occurence of some event. Callback functions are 're-entrant'. So if that event occurs twice while your function is still processing windows will still call the function for execution (instead of waiting the first call to finish it's job).
This means that you have to make sure that your callback routine can handle such a situation.
Setting / resetting values of variables can cause a lot of confusion here.
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
Thank you again
It will cost much time to solve this problem if one error happens here.
|
|
|
|
|
Actually I've never read any formal documentation on CALLBACK function, don't even know if there's anything good around.
I just tried using the different callbacks with the WINAPI enum functions... and making mistakes!
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
|
|
I trying to create an MFC app which is capable of opening and creating multiple types of documents. I have two document templates created in the main app class using the CMultiDocTemplate class. Everything appears to work, except when I try to open a document (Rich Text in this case) that was saved (which is supported by the app) the document appears to be empty. Any ideas as to what might need to be done to make this work? Thanks.
neacetp
|
|
|
|
|
Come ON, someone out there must know this...
How can you send a char that's not on the keyboard using SendInput?
To type '¯', for example, you hold alt and type 0175 on the num pad.
So I guessed this, but it doesn't work
int i;
INPUT input[10];
ZeroMemory(input, sizeof(input));
for (i = 0; i < 10; i++)
input[i].type = INPUT_KEYBOARD;
input[0].ki.wVk = 18;
input[1].ki.wVk = input[2].ki.wVk = 0x60;
input[3].ki.wVk = input[4].ki.wVk = 0x61;
input[5].ki.wVk = input[6].ki.wVk = 0x67;
input[7].ki.wVk = input[8].ki.wVk = 0x65;
input[9].ki.wVk = 18;
input[2].ki.dwFlags = input[4].ki.dwFlags = input[6].ki.dwFlags =
input[8].ki.dwFlags = input[9].ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(10, input, sizeof(INPUT));
using a keyboard logger, i can see that it does exactly what I want, ie press alt, type 0175, release alt, but it doesn't send '¯' to the active app
Any ideas?
Any method to simulate the typing of ¯ to the active app will be fine - not necessarily SendInput(), that's just what i have used do far.
thanks in advance
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Friendly advice: Yelling at the board will not increase the chances of getting a response.
Partial response: Use VK_MENU for the Alt key.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--=
NO CARRIER
|
|
|
|
|
Michael Dunn wrote:
Friendly advice: Yelling at the board will not increase the chances of getting a response.
but it will increase it's chance of getting seen - this forum's so popular that in 1 day a post drifts back to the third page - it's quite likely that a lot of regulars who might know the answer to my problem never saw the post because it had disappeared before they got here.
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Did you try WM_CHAR already or it didn't work? Just like: ::SendMessage(hwnd, WM_CHAR, (WPARAM)175, (LPARAM)0); or something like that...
|
|
|
|
|
it didn't work, but I've had an idea...
it would probably work if i sent the WM_CHAR to the text box rather than the window
is it possible to get the hwnd of the control with the focus on a different window? There's probably an API call for it, but what is it?
I don't know the control ID or anything like that - i'm sending to a 3rd-party chat app
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
::ChildWindowFromPoint
put your mouse cursor over the child window, collect the x,y, then get the handle with that API.
HWND = ((CWnd*)ChildWindowFromPoint( POINT point ))->m_hWnd;
I hope it works out for you.
|
|
|
|
|
weird...
that works with notepad, but not with the chat program i'm writing this for.
besides, i don't want to have to hold the mouse cursor over the input box whenever I want to send something.
surely there's an API call to get the active child?
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Receiving a message is one thing, and displaying contents in an editbox is another. Not every thing is displayable, probably your receiver-window is not able to display that kind of characters----notepad can maybe, but that doesn't mean your editbox can too.
But of course you need to first make sure that your receiver-window really has received the aforementioned message(WM_CHAR), so override its PreTranslateMessage and see...
|
|
|
|
|
it's able to display it when i type it in (via alt+numpad)
i'm sending the message to an IRC client - i don't exactly want to crack it and override its PreTranslateMessate.
I'm giving up on writing this in C. I'm porting the whole thing to VB - it's SendKeys function does wnat I want.
The only reason I didn't write it in VB to begin with is because i couldn't get EnumWindows to work properly, but i've figured it out now.
Thanks anyway for your suggestions.
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, lParam As Long) As Long
Function EnumChildProc(ByVal hwnd As Long, lParam As Long) As Long
' DO SOMETHING WITH HWND HERE
End Function
Call EnumChildWindows(parentWnd, AddressOf EnumChildProc, 1)
Phlip,
I hope this VB code sample I typed will help you. It hurts to write this, but you could do the exact same thing in VC++, as a matter of fact doing it in VB is a bizzare abstraction of the real C++ API.
Saying you have to port it to visual basic doesn't make much sense to me although I'm sure you have your reasons.
|
|
|
|
|
What I'm trying to make is an automatic typer thingy for chat programs - just click a button and it types a bunch of stuff for you.
I could write the typing bit easily in VB - there's a function called "SendKeys" which does exactly that. But I didn't know of the AddressOf operator at that stage, so I though I'd have to use C++ to use EnumWindows because you have to pass a function pointer to it.
I then figured out how to use SendInput and made a function that turned a string into an array of INPUTs that would type that string (complete with things like '{' -> {SHIFT DOWN}'['{SHIFT UP}) but I ran into trouble if i wanted to include characters that weren't directly typable on the keyboard.
But now I've learned the AddressOf operator in VB so I have no problems programming it there.
If I know how to do it in VB, but don't in C, why bother trying to do it in C?
I would have preferred to do it in C, for obvious reasons (VB is, well, VB after all, for crissake), but the right tool for the right project and all that...
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Hi,
I need to be able to get the window name of a MDI window when it is created. I tried adding the following code to CProjectNameDoc::OnNewDocument() :
<br />
CProjectNameDoc::OnNewDocument()<br />
{<br />
if (!CDocument::OnNewDocument()) return FALSE;<br />
<br />
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();<br />
<br />
HWND hWnd;<br />
TCHAR szWndTitle[256];<br />
<br />
hWnd = ::GetWindow(pMainFrame->m_hWndMDIClient, GW_CHILD);<br />
<br />
::GetWindowText(hWnd,szWndTitle,<br />
sizeof(szWndTitle)/sizeof(szWndTitle[0]));<br />
<br />
AfxMessageBox(szWndTitle);<br />
}<br />
This however does not work correctly. The name displayed when I create a new window is the name of the window before.
The reason for this (as far as I can tell) is that OnNewDocument() is called before the window is created, so the name of the currently selected one is returned.
Any ideas how to fix this?
Thanks,
Mike
I also need to get a pointer to this window. I tried:
((CMainFrame *)AfxGetMainWnd())->GetActiveFrame()
But this seems to have the same time problem as before. I get a pointer to the window before the one being created ...
There are 10 people in the world
Those who understand binary and those who dont
|
|
|
|
|
BOOL CProjectNameDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument()) return FALSE;
AfxMessageBox(GetTitle( ));
return TRUE;
}
Good thing I have nothing to do all day
|
|
|
|
|
If i build a VxD using the Win98 DDK will it work in Win XP???
Kuniva
--------------------------------------------
|
|
|
|
|
AFAIK Windows XP does not use VXD drivers. So likely not.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
lol, err ok stupid question
anyways, how can I access low level stuff on windows XP then?
and ergh... this means, if i had driver code for Win98 i'll have to rewrite everything for Win XP?... that sucks..
Kuniva
--------------------------------------------
|
|
|
|
|
and err there's a WinXP DDK, whats that all about then???
and what does AFAIK mean????
Kuniva
--------------------------------------------
|
|
|
|
|