|
VW_Red_Jetta wrote:
So
do you explicitly write "precondition" and "postcondition"
in the comment?
Neither.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hello, everyone!
I know nothing abuot mmap. And are there some tutorials or simple sample codes about mmap? I just want to learn the basic usage of mmap.
regards,
George
|
|
|
|
|
Hi all,
I am attempting to hook the keyboard to allow it to behave as a mouse device. The application works fine on 2K and XP but not on 98 or ME. If the controlling application Window is active all works fine but if it isn't things go pear shaped. This would indicate to me that I am not get a system hook rather a thread one, but that seems improbable given it works on other platforms and the hook code resides in a dll.
Any ideas?
Here is the code I use to hook the event:
/**
* Installs the hook.
*/
KEYHOOK_API bool InstallKeyboardHook()
{
if(g_hKeyboardHook == NULL) {
g_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstance, NULL);
}
// Fail if the hook fails to install
if(g_hKeyboardHook == NULL) {
return false;
}
return true;
}
/**
* Removes the hook
*/
KEYHOOK_API void RemoveKeyboardHook()
{
while(!UnhookWindowsHookEx(g_hKeyboardHook)) {
Sleep(100);
}
g_hKeyboardHook = NULL;
}
/**
* Called by the hook when there is a keyboard event.
*/
KEYHOOK_API LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0) {
// Check to see if the action belongs to the space key, if so we trap it
if(wParam == VK_SPACE) {
// Only perform an action if the space key is being released
if((::GetAsyncKeyState(VK_SPACE) & 0x80000000) != 0x80000000) {
// Determine the controller and perform the appropriate action
if(GetController() == SI_SCANNER) {
SetClicked();
}
else if(GetController() == SI_MOUSE) {
SetState((GetState() + 1) % NUM_STATES);
}
}
// Trap this message
return 1;
}
}
return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
}
|
|
|
|
|
I have been trying for quite some time now to download the Platform SDK from the msdn website. The mickeysoft program that is supposed to handle the installation keeps crapping out with a "Server Error" message. I can't download the CAB files either because they are coming in corrupted. Is there another way to obtain the SDK?
Thank you,
Eric Sepich
|
|
|
|
|
|
Greetings,
I would like to write a generic CPhaseManagement object, but keep hitting a wall with it being tied to the specific app. The Phases would be something like: InitPhase, IntroPhase, MenuPhase, AppPhase, and ExitPhase with an enumerated type defined in a PhaseSettings.h file !
Each Phase of the App will have it's own specific Phase routines (StartPhase, ProcessPhase and ExitPhase). These of course will be App specific.
So I need to know how to make a pointer to a function so that the PhaseManager can call the relevant PhaseStart/exit etc.
Any pointers (haha) / comments appreciated.
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
int Foo1( WPARAM, LPARAM )
{
}
int Foo2( WPARAM, LPARAM )
{
}
int (*pFunc)( WPARAM, LPARAM );
if (some_condition)
pFunc = Foo1;
else if (some_other_condition)
pFunc = Foo2;
(*pFunc)(parameter_list);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
cast to pointer to Function hey !
Who would have thought!
(Obviously not me)
Much Appreciated
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
Does this mean that I have to create a pointer to a <function with a fixed set of params> ?
As opposed to a pointer to a function with any set of params.
Obviously when I call it, I will have to pass the right param types, but do I have to declare the pointer to have those param types ?
Or am I flogging a dead camel ?
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
hi,
does anyone know how to retirve information of a particular hardware device?
eg. USB devices(pc Cam)
thanks
|
|
|
|
|
You might look into GetDeviceCaps() , or the WMI functions.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
GetDeviceCaps() a CDC function to get hardware information
|
|
|
|
|
Doesn't sound quite right, does it? Forget I mentioned it!
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I want to call some code after my dialog has been displayed on the screen. This means I cannot do it in OnInitDialog(). How can I do it?
Thank you.
|
|
|
|
|
More explanation: my dialog contains some data on startup. The user will then click the Update button and an icon is displayed on each line of data as each line is updated. I want the user to see this happen after the dialog appears but there is no message to process after the dialog is displayed. DoModal() just returns.
I think that I can create a modeless dialog instead but that is a lot of work compared to my modal one. Can I create my dialog modeless do my update and then convert to modal instead or must it remain modeless?
Is there undocumented feature which is a function that gets called after the dialog is displayed?
|
|
|
|
|
The most straightforward way is to simply post a user-defined message right before OnInitDialog() returns. This guarantees that the dialog box will be displayed and then the startup code will be executed.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thank you.
Can you tell me how I must do this?
|
|
|
|
|
static const UINT UDM_START_PROCESSING = ::RegisterWindowMessage(_T("UDM_START_PROCESSING"));
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
ON_REGISTERED_MESSAGE(UDM_START_PROCESSING, OnStartProcessing)
END_MESSAGE_MAP()
BOOL CMyDialog::OnInitDialog( void )
{
CDialog::OnInitDialog();
PostMessage(UDM_START_PROCESSING);
return TRUE;
}
LRESULT CMyDialog::OnStartProcessing( WPARAM, LPARAM )
{
return (0);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
In your OnInitDialog() , just before you return you can show the window and it's descendants. Then you can call your Update button handler, as though the user had clicked it.
...
CDialog::OnInitDialog();
SendMessageToDescendants(WM_SHOWWINDOW, (WPARAM)TRUE);
SendMessageToDescendants(WM_ENABLE , (WPARAM)TRUE);
OnUpdate();
return TRUE;
"The folly of man is that he dreams of what he can never achieve rather than dream of what he can."
"If you think education is expensive, try ignorance."
|
|
|
|
|
Anonymous wrote:
I want to call some code after my dialog has been displayed on the screen
There may be other ways, but I would probably do this by calling a thread in your OnInitDialog function. The thread would first sleep for however long you want it to, then update your display before returning. Good luck!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
I would use a timer.
something like this:
BOOL CDlgXXX::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(TIMER_ID, 50, NULL)
return TRUE;
}
void CDlgXXX::OnTimer(UINT nIDEvent)
{
if (TIMER_ID == nIDEvent)
{
KillTimer(TIMER_ID);
return;
}
CDialog::OnTimer(nIDEvent);
}
“Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002
|
|
|
|
|
Greetings All,
I have a CBitmap object and wish to derive a CTiledBitmap from it ?
What do I have to consider:
Do i have to use virtual Constructor/Destructor ?
Can I just have CBitmap as a member of CTiledBitmap ?
Any advice of how-to for derived classes ?
Cheers
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
An useful question when considering whether you should model your new class as derived from some base class is the following:
A CTiledBitmap is a CBitmap ?
Or put another way:
If I change all occurrences of CBitmap with CTiledBitmap in a preexisting program, will the program still work?
I guess the answer in your particular case is no. Please note that the interface of CBitmap is not virtual, so the class is not designed with derivation in mind. Probably, a better design is to derive your CTiledBitmap from CGdiObject and have CBitmap as a private member.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks
The CBitmap is a class of mine: should probably call it CMyBitmap ?
it has it's own constructor, loader and draw function.
So A CMyTiledBitmap is a CMyBitmap with some extra members (for the tiling info).
So, If I change all occurrences of CMyBitmap with CMyTiledBitmap in a preexisting program, the program will still work, but will have greater resource overhead.
So Why do I make the CMyBitmap constructor virtual ?
Cheers
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
Hi, I'm having trouble plotting different series in the same mschart, how can I do this if each plot has a differente number of points??
Thanks!
Julihc
|
|
|
|