|
What about the extended ASCII table? the rage goes to 255 http://www.asciitable.com/[^] .
But I did the experience of changing the "218" to a number between the normal range.. and the warning disapeard.
So.. that means i shouldn't use the extended range?
"Failure is always an option."
|
|
|
|
|
Well char is a C/C++ integer data type whoose range is [-127,128] while the extended ASCII table is (roughlty) simply a standard about encoding characters using (8-bit ) numbers.
Anyway, I made a little test: you may use
cout << unsigned char(218);
to the purpose.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Great.. the warning does not appear anymore.
Thanks allot!!
"Failure is always an option."
|
|
|
|
|
You're welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Please consider the following fragment of code from the book Programming Windows 95 with MFC
by Jeff Prosise:
CMainWindow::CMainWindow()
{
CString strWndClass = AfxRegisterWndClass ( 0, myApp.LoadStanddadCursor ( IDC_ARROW ),
(HBRUSH)(COLOR_3DFACE + 1), myApp.LoadStandardIcon( IDI_APPLICATION ) );
I do not understand why is is COLOR_3DFACE + 1, instead of COLOR_3DFACE. Since COLOR_3DFACE represents an enumeration value, it seems to me, adding 1 to it is wrong. What am I missing?
Thanks
Bob
|
|
|
|
|
BobInNJ wrote: why is is COLOR_3DFACE + 1, instead of COLOR_3DFACE
Because the docs state that's the way it needs to be:
WNDCLASS.hbrBackground
Handle to the class background brush. This member
can be a handle to the physical brush to be used
for painting the background, or it can be a color
value. A color value must be one of the following
standard system colors (the value 1 must be added
to the chosen color).
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark's answer is the good one.
The following is just a guess on the motivation:
Possibly because it avoid the following conflict
(from Winuser.h )
#define COLOR_SCROLLBAR 0
(from MSDN on WNDCLASS.hbrBackground )
When this member is NULL, an application must paint its own background whenever it is requested to paint in its client area.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Sorry, I'm quite angry with this problem ...
I tried to code a system-wide keyboard hook and send recived keyboard messages within a DLL toward an EXE ...
Everything went fine but TranslateMessage() that fails to generate WM_CHAR ...
within DLL:
------------------
struct lParamMember
{
WORD RepeatCount : 16,
ScanCode : 8,
IsExtended : 1,
Reserved : 4,
IsALTDown : 1,
WasKeyDown : 1,
IsBeingReleased : 1;
};
LRESULT CALLBACK KeyboardProc(int iCode, WPARAM wParam, LPARAM lParam)
{
if(iCode<0)
return CallNextHookEx(hKybrdHook, iCode, wParam, lParam);
lParamMember* plParam = (lParamMember*)&lParam;
if(plParam->IsBeingReleased)PostThreadMessageW(g_dwThreadID, WM_KEYDOWN, wParam, lParam);
else PostThreadMessageW(g_dwThreadID, WM_KEYUP, wParam, lParam);
return CallNextHookEx(hKybrdHook, iCode, wParam, lParam);
}
withing EXE:
-------------------
MSG msg;
while(GetMessageW(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
if(msg.message == WM_CHAR || msg.message == WM_DEADCHAR || msg.message == WM_SYSCHAR ||
msg.message == WM_SYSDEADCHAR)
MessageBox(0, L"Success!", 0, 0);
}
----------------------------------------------------------------
|
|
|
|
|
Jusef Marzbany wrote: if(plParam->IsBeingReleased)PostThreadMessageW(g_dwThreadID, WM_KEYDOWN, wParam, lParam);
else PostThreadMessageW(g_dwThreadID, WM_KEYUP, wParam, lParam);
Are these switched? I thought releasing a key meant keyup, not keydown.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I did as you, but it still doesn't work ...
Now it looks like this:
-----------------------
if(plParam->IsBeingReleased)PostThreadMessageW(g_dwThreadID, WM_KEYUP, wParam, lParam);
else PostThreadMessageW(g_dwThreadID, WM_KEYDOWN, wParam, lParam);
Help me PLS
|
|
|
|
|
Disclaimer: I'm only trying to help find potential problems
with the info given. Don't assume I know the solution - I don't.
Emulating system messages is always problematic.
What's happening in the debugger?
To start with, are your WM_KEY* messages actually getting to
the EXE's message loop?
Next, maybe take a look (using the debugger) at the sequence of
messages involved with a real keystroke. You're going to need
to emulate that exactly for this to work.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, I've mentioned it before ...
I recieved WM_KEYUP as well as WM_KEYDOWN in my message loop and I'm sure about that ...
The only remaining problem is TranslateMessage( ) ...
One would say It doesn't understand above messages any more! Where's Bill Gates?
|
|
|
|
|
Jusef Marzbany wrote: The only remaining problem is TranslateMessage() ...
Have you checked the return value from TranslateMessage() ?
Jusef Marzbany wrote: Where's Bill Gates?
He doesn't work full time at MS anymore, so he's probably doing charity work or something
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Yes, I have, It returns 0 for me
|
|
|
|
|
What kind of output do you get doing something like this
in the EXE:
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
if (msg.message == WM_KEYDOWN || msg.message == WM_KEYUP)
{
if (msg.message == WM_KEYDOWN)
TRACE0("WM_KEYDOWN - ");
else
TRACE0("WM_KEYUP - ");
if (!TranslateMessage(&msg))
{
TRACE0("TranslateMessage() Failed!\n");
}
else
{
TRACE0("TranslateMessage() Succeeded!\n");
}
}
if(msg.message == WM_CHAR || msg.message == WM_DEADCHAR || msg.message == WM_SYSCHAR ||
msg.message == WM_SYSDEADCHAR)
{
TRACE0("WM_CHAR!\n");
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
See I press a key! according to your code (that's exactly what I did!), I got:
1- one WM_KEYDOWN notification
2- a message saying TranslateMessage() has failed
and then nothing more!
So:
1- where's WM_KEYUP?
2- Why TranslateMessage() has failed?
|
|
|
|
|
Why don't you try to go deeper with the debugger? For instance, whenever the TranslateMessage fails, check out the details of the MSG structure.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Jusef Marzbany wrote: 1- where's WM_KEYUP?
You stated:
"I recieved WM_KEYUP as well as WM_KEYDOWN in my
message loop and I'm sure about that ..."
So you weren't actually getting both the messages before?
As cPallini mentioned, you'll need to debug this.
You're trying to force messages that are system messages.
Unless you do it the exact way the system does, it's not
going to work. That's why I said it's problematic.
TranslateMessage could be failing because you're not emulating the
system messages properly.
Keyboard input was never meant for multiple targets on Windows.
Only the one window with keyboard focus should get the key messages.
You may want to try posting messages to a window instead of
a thread.
Tip: Don't use MessageBox in the message loop!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you, Great
Thank you masters!
|
|
|
|
|
Does PostThreadMessage() succeed? Is the g_dwThreadID identifier valid?
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Yes, It is ...
As I mentioned before, everything went fine and I recieved WM_KEYDOWN and WM_KEYUP ...
But TranslateMessage( ) fails ...
|
|
|
|
|
Apologies; in that case Mark's advice seems a good way to go.
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Hi all,
in my application i am using the GetRawInputDeviceInfo and included the winuser.h and windows.h but it is saying
GetRawInputDeviceInfo' : undeclared identifier
can anyone tell the reason for this issue?
Thanks in advance..
modified on Saturday, September 13, 2008 1:05 PM
|
|
|
|
|
Hi all,
inmy application i have used the message shwon in the following line :
ON_MESSAGE(WM_INPUT, OnInput)
I am getting the error "WM_INPUT' : undeclared identifier"
can anybody tell me wat this error is and how i need to solve this???
|
|
|
|
|
"Minimum operating systems Windows XP"
Do you have the appropriate symbols defined for OS version in your stdafx.h file? Make sure they are 0x0501 to ensure the xp specific symbols get defined during compilation. Make sure to do a "Rebuild Solution" or equivalent to prevent any false negatives.
|
|
|
|