|
Probably a stupid question, but I can't seem to get his to work. I have an array of 20 DWORD values, each DWORD represents a 20 pixel line in a bitmap. How can I convert this array into a bitmap handle (HBITMAP)?
I have tried calling CreateDIBSection() then copy the array data over to the retrieved void pointer, but I am unable to display the image. All I see is a black square which tells me the bitmap has not been created correctly.
|
|
|
|
|
Are you setting up the BITMAPINFO structure correctly for the format of your pixels?
Mark
|
|
|
|
|
Yeah. It was my own stupid fault, I had the byte order the wrong way around. 3 hours of debugging just to find that!
|
|
|
|
|
waldermort wrote: 3 hours of debugging just to find that!
Fun Fun! Glad you found it!
Mark
|
|
|
|
|
Q1
As we know that in a windows application whenever a key is pressed, a message is sent to the active window. We are developing a DOS based application and want to detect whenever a key is pressed from keyboard. How can we do so?
Q2
We are writing a DOS based application in which we have to display the system date and time. Write down the code for doing so.
|
|
|
|
|
Q1 kbhit
Q2 #include <time.h>
Good luck with your homework
|
|
|
|
|
|
I think you asked these questions and you get answers.
|
|
|
|
|
I want to hook the WM_MOUSEWHEEL msg in globel and identify whether it is scroll in or scroll out by 'zDelta', but the 'zDelta'(below) always seem to be zero. Can any one help me.
Thanks!
extern "C" _declspec(dllexport) LRESULT WINAPI MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if(nCode < 0)
return CallNextHookEx(g_hHook,nCode,wParam,lParam);
if(nCode == HC_ACTION)
{
switch(wParam)
{
case WM_MOUSEWHEEL:
short zDelta = (short)HIWORD(wParam);
break;
...........
default:
return CallNextHookEx(g_hHook,nCode,wParam,lParam);
}
}
}
|
|
|
|
|
Michael ZY wrote: extern "C" _declspec(dllexport) LRESULT WINAPI MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
I'm not sure why zdelta would be zero all the time.
Is "extern "C" the same linkage as __stdcall?
The hook func needs to be __stdcall.
try
extern _declspec(dllexport) LRESULT CALLBACK WINAPI MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
Mark
|
|
|
|
|
Thanks for reply, but still not Work.
i hooked other mouse msg like WM_LBUTTONDOWN are all fine.
Is that use the WH_MOUSE can not identify wheel scroll direction (need WH_MOUSE_LL?)
what i use now is:
g_hHook=SetWindowsHookEx(WH_MOUSE,MouseProc,g_hInstance,0);
|
|
|
|
|
I see it.
short zDelta = (short)HIWORD(wParam);
won't work. wParam is WM_MOUSEWHEEL, not the wheel delta
extern "C" _declspec(dllexport) LRESULT WINAPI MouseProc(int nCode,WPARAM wParam,LPARAM lParam){
if(nCode < 0)
return CallNextHookEx(g_hHook,nCode,wParam,lParam);
if(nCode == HC_ACTION)
{
switch(wParam)
{
case WM_MOUSEWHEEL:
short zDelta = (short)HIWORD(wParam);
break;
default:
return CallNextHookEx(g_hHook,nCode,wParam,lParam);
}
}
return CallNextHookEx(g_hHook,nCode,wParam,lParam);
}
I can't find how to get the wheel delta in a hook proc LOL I'll let you know when/if I do!
Mark
|
|
|
|
|
|
Got it!
Thanks a lot Mark!
Use the code like this:
case WM_MOUSEWHEEL:
{
typedef struct
{
MOUSEHOOKSTRUCT MOUSEHOOKSTRUCT;
DWORD mouseData;
}MOUSEHOOKSTRUCTEX,*PMOUSEHOOKSTRUCTEX;
MOUSEHOOKSTRUCTEX *MHSEX;
MHSEX=(MOUSEHOOKSTRUCTEX*)lParam;
if(MHSEX->mouseData==(WHEEL_DELTA<<16))
AfxMessageBox("up");
if(MHSEX->mouseData==(-WHEEL_DELTA<<16))
AfxMessageBox("down");
}
break;
|
|
|
|
|
I need to catch every keyboard event before operation system ( windows xp ) does.
What i mean is in case user click on key 'enter' ( or every other key ) my application need to check if the key is 'X' key - and in any case this key event need to continue as key event to the operation system.
I'm sure there is some win32 API function to do it - but i don't remember it.
Someone can help me ?
Thanks.
|
|
|
|
|
Yanshof wrote: I need to catch every keyboard event before operation system ( windows xp ) does.
Yanshof wrote: I'm sure there is some win32 API function to do it - but i don't remember it.
Do you see a contradiction between those 2 sentences??
|
|
|
|
|
Sorry ... but i don't see any contradiction.
I need some way to catch keyboard event - something like keyboard logger.
I did not found something useful in Google until now.
Thanks for any help.
|
|
|
|
|
Hi! Will this [^]help?
--------------------------------------------------------------------
If you need a hammer get C and shut up. If you need a nail gun get C++ and shut up. If you don't need *those* things (and good design should tell you) then by all means get a factory, factory, factory.
--code-frog@codeproject
|
|
|
|
|
Why do not use the Hook in the code and beside this - why thay use in this example DLL ?
|
|
|
|
|
Hi All,
I need to use the class wincrypt.h with some of my application that i writing.
I try to compile the application but all the object and function of this class is are not recognize by my compiler.
I even try to get demo application from here :
http://www.codeproject.com/cpp/cryptest.asp[^]
but my compiler repeat the message "undeclared identifier".
Some one can help me ?
Thanks.
|
|
|
|
|
What is the error you are getting?
|
|
|
|
|
Unidentified of the function and variables of this library.
cryptest\md5capi.cpp(47) : error C2065: 'HCRYPTPROV' : undeclared identifier
cryptest\md5capi.cpp(47) : error C2146: syntax error : missing ';' before identifier 'hCryptProv'
cryptest\md5capi.cpp(47) : error C2065: 'hCryptProv' : undeclared identifier
cryptest\md5capi.cpp(48) : error C2065: 'HCRYPTHASH' : undeclared identifier
cryptest\md5capi.cpp(48) : error C2146: syntax error : missing ';' before identifier 'hHash'
cryptest\md5capi.cpp(48) : error C2065: 'hHash' : undeclared identifier
cryptest\md5capi.cpp(55) : error C2065: 'CryptAcquireContext' : undeclared identifier
cryptest\md5capi.cpp(56) : error C2065: 'PROV_RSA_FULL' : undeclared identifier
cryptest\md5capi.cpp(56) : error C2065: 'CRYPT_VERIFYCONTEXT' : undeclared identifier
cryptest\md5capi.cpp(56) : error C2065: 'CRYPT_MACHINE_KEYSET' : undeclared identifier
cryptest\md5capi.cpp(59) : error C2065: 'CryptCreateHash' : undeclared identifier
cryptest\md5capi.cpp(60) : error C2065: 'CALG_MD5' : undeclared identifier
cryptest\md5capi.cpp(63) : error C2065: 'CryptHashData' : undeclared identifier
cryptest\md5capi.cpp(66) : error C2065: 'CryptGetHashParam' : undeclared identifier
cryptest\md5capi.cpp(66) : error C2065: 'HP_HASHVAL' : undeclared identifier
cryptest\md5capi.cpp(89) : error C2065: 'CryptDestroyHash' : undeclared identifier
cryptest\md5capi.cpp(90) : error C2065: 'CryptReleaseContext' : undeclared identifier
|
|
|
|
|
Looks like you have forgot to include a header file in your project. Search the header files for the definition of HCRYPTPROV, than add the #include statement to the top of your md5capi.cpp file.
|
|
|
|
|
I did not forgat include this file.
This is the first thing that i check - and its not it.
|
|
|
|
|
Did you include Wincrypt.h?
|
|
|
|