|
MessageBox creates a window which has its own WndProc but it does not keep your previous WndProc to be called otherways the underlaying would never be repainted ...
|
|
|
|
|
OK, but what happens exactly? I mean, the main thread isn't waiting for MessageBox returning a value? If it is an asynchronous call, how is iAnswer set, at the end?
(When MessageBox is called for MsgBox B the value of iAnswer is still IDCANCEL ).
BTW Thanks for your reply.
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
|
|
|
|
|
The main thread (it is not a thread by the way ) will create a modal loop something like that:
// While the user has not pressed OK or Cancel or clicked one of the button
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
So the system never stops running... while you wait for the answer messages are still read from the "OS" and sent to the relevant windows. am I making sense?
|
|
|
|
|
BadJerry wrote: The main thread (it is not a thread by the way )
I think it is.
BadJerry wrote: So the system never stops running... while you wait for the answer messages are still read from the "OS" and sent to the relevant windows. am I making sense?
Yes.
Hence (roughly speaking) the main thread looses its quantum while waiting for iAnswer and possibly regains it to handle the next WM_TIMER message?
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
|
|
|
|
|
OK yes there is a main thread but there is no secondary thread... it just feels that way.
If you look at the WinMain, you will see that there is message loop. When you create a modal dialog, you simply create another message loop . The same function can therefore be called twice but it's more like recursion than multithreading...
I hope this helps!
|
|
|
|
|
I got it, thanks.
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
|
|
|
|
|
i created a dll....that uses the function..
headerfile
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
DLLIMPORT LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
#endif /* _DLL_H_ */
cpp file
/* Replace "dll.h" with the name of your header */
#include "key.h"
#include <windows.h>
DLLIMPORT LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
//some code here.....
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
MessageBox( NULL,"Test working","cool",MB_OK | MB_ICONINFORMATION);
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
when im compiling this dll with Dev-C++ compiler..im getting error....
my compiler log is:
Compiler: Default compiler
Building Makefile: "D:\devcpp project\keylogger\testlogger\sysproc\Makefile.win"
Executing make...
make.exe -f "D:\devcpp project\keylogger\testlogger\sysproc\Makefile.win" all
g++.exe -c dllmain.cpp -o dllmain.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -DBUILDING_DLL=1
In file included from dllmain.cpp:2:
key.h:10: error: `LRESULT' does not name a type
make.exe: *** [dllmain.o] Error 1
Execution terminated
can someone please help me what im doing wrong...what im able to understand is that it is not able to get the declaration for LRESULT......
how to correc that.....
thanx in advance...dudes
|
|
|
|
|
You need to post the code from key.h as that's where the error is, probably on line 9 or 10. The chances are that key.h is being included before windows.h and the compiler therfore has no definition for LRESULT. LRESULT doesn't just magicallly exist it is defined by a typedef somewhere within the include tree of windows.h
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
You guys rock...amazing....i didn't even notice that key.h is included before windows.h.....i understand the concept very well...but its just that i forget to notice that...thanx...."MR. C++ GURU"...
|
|
|
|
|
Member 4449040 wrote: key.h:10: error: `LRESULT' does not name a type
Have you omitted a #include ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i push the print screen key and the screen captures. then i run the executable file of the program i made. the program will be in such a fashion that it will get the captured screen from the memory and saves it on the hard drive. like u do from mspaint.
plz help me
|
|
|
|
|
|
|
when pressing the "print-screen" key, the OS will copy a bitmap of the screen on the CLIPBOARD in a bitmap format (probably CF_BITMAP).
your job, if you accept it, is to get the data back from the clipboard, create an image format (whatever it is) and
save it back on the disk in the format you want (easier is bmp).
There must be tooooonnnsss of examples of that on the web, just use google.
|
|
|
|
|
|
Umair Hakeem Zuberi wrote: how to get the image from clipboard in c
A link has already been provided to you. Why have you failed to read it?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Umair Hakeem Zuberi wrote: i cant get the contents, i m looking for, there
or it may be that because i have never use the site i dont understand how to look into it
Did you read up on OpenClipboard()?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Umair Hakeem Zuberi wrote: i want to know it through turbo c
Then I suggest you find a TurboC board.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Umair Hakeem Zuberi wrote: so i was wasting my time here?????????
Only you can answer that. That's a gamble that YOU took by asking on a predominately Microsoft site.
Umair Hakeem Zuberi wrote: i asked in my first post that i want coding in turbo c or u didn't read it????????
Maybe you should re-read it. Your first post contained no such requirement.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Umair Hakeem Zuberi wrote: its UR problem that u cant understand simple english
Mmm... What you are writing is simple english? Damm, I must have been away when the english teacher explained the words "coz", "u", "ur" and other from previous posts.
By the way...
Umair Hakeem Zuberi wrote: i push the print screen key and the screen captures. then i run the executable file of the program i made. the program will be in such a fashion that it will get the captured screen from the memory and saves it on the hard drive. like u do from mspaint.
plz help me
Where is it said that you are using plain C?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Stop with the text speak. Read the forum guidelines.
|
|
|
|