|
void Class2::Draw(Image *a_pImage)
{
// add extra code for Class2 draw
Class1::Draw(a_pImage);
// add extra code for Class2 draw
}
modified on Friday, February 15, 2008 12:15 AM
|
|
|
|
|
Huh? That easy? I was expecting an extremely long message explaining how to delicately trick C++ into doing what I wanted... Thanks , Rajkumar!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Lord Kixdemp wrote: Huh? That easy?
"One of the difficulties people have with object-oriented design is that it's too simple to get from the beginning to the end. A mind trained to look for complex solutions is often stumped by this simplicity at first" - Bruce Eckel.
|
|
|
|
|
nice quote
|
|
|
|
|
Lord Kixdemp wrote: virtual void Draw(Image *a_pImage);
Class2::Draw() is virtual by default. The virtual keyword is unnecessary.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
I have three applications; A, B and C. A always stays in foreground and has focus. B an C run in background. B receives messages from A via socket. I need B to send Shift/Ctrl/Alt + key to C based on A's messages. I've tried CKeystrokeEngine, and it works some times but not all the time. Is there anything I can do to CKeystrokeEngine and change it's behavior so that it works all the time?
|
|
|
|
|
I just had a look into the CKeystrokeEngine class, it seems it depends on the keybd_event API and depends on the SetForegroundWindow and it is not sure that the window will be the active window to receive the keyboard event as CWindowEngine::FocusWindow() always return true without checking the return value of SetForegroundWindow API. if my assumption is correct B and C no longer be said as background app as it is brought to foreground every time a keystroke is to be send
As the A, B, C all r ur application and ur already communicating using sockets, i would suggest that u use ur own protocol in the same connection and interpret the key strokes, it doesnot require the window to be active foreground window.
|
|
|
|
|
I can't change A or C. B is the only app I am writing and have control over.
|
|
|
|
|
Have you tried PostMessage() with the WM_KEYDOWN message?
|
|
|
|
|
Sh*t/Alt/Ctrl keys can't be sent using postmessage.
|
|
|
|
|
njhy wrote: sh*t/Alt/Ctrl keys can't be sent using postmessage.
Wrong. Those keys can be sent by using PostMessage()
::PostMessage(myHwnd, WM_KEYDOWN, VK_SHIFT, 0);
::PostMessage(myHwnd, WM_KEYUP, VK_SHIFT, 0);
This code will send a shift key press and release event to the window with the handle myHwnd . And similarly you could send just any key press event, even multiple (simultaneous) key press events.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Try it your self. It does not work.
::PosMessage(myWnd, WM_KEYDOWN, VK_F13, 0); // VK_13 is SHIFT + F1
::PosMessage(myWnd, WM_KEYUP, VK_F13, 0);
or
::PosMessage(myWnd, WM_KEYDOWN, VK_SHIFT, 0);
::PosMessage(myWnd, WM_KEYDOWN, VK_F1, 0);
::PosMessage(myWnd, WM_KEYUP, VK_F1, 0);
::PosMessage(myWnd, WM_KEYUP, VK_SHIFT, 0);
|
|
|
|
|
Hmm... I've got it working by executing my code from within a DLL (a hook, to be precise). Neither do I have dev tools on this machine, so I can't test something right now.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I tried in a hook DLL, but did not work either. Can you post your codes here?
|
|
|
|
|
I'll be happy to share code with you if that would help you. I'll write to you when I am on my Dev machine.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
what about a combination of keybd_event(Shift/Ctrl/Alt) and PostMessage(key).
|
|
|
|
|
Hi everybody,
- I want to scan a list of parallel port of my PC in my app.
- and I want to set parallel port to ECP mode in BIOS from my app.
I use VC++ 6.0, Win2k.
How to do that ?
Best Regards,
Quang,
|
|
|
|
|
Hi,
The OS's from Win2000 to greater versions will not allow to access the ports directly. you may need to use a third party component to do it. i think in net u can find free libraries.
|
|
|
|
|
quangpk wrote: - I want to scan a list of parallel port of my PC in my app.
Have you tried the Win32_ParallelPort WMI class?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
- I write a DLL with funtions inport/outport, use CreateFile,OpenSCManager,OpenService,StartService,....
- I copy my App with my DLL file to some PC. some of them work ok and some other didn'n work.
Why ?
|
|
|
|
|
quangpk wrote: Why ?
I have no clue. What have you discovered using the debugger? Have you narrowed the problem down to just one or two statements? Are you checking return values from functions?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi, I copy file hwinterface.sys to folder .../window/system32/drivers/
(I use win NT2K) my App work.
|
|
|
|
|
quangpk wrote: my App work.
Great.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi
I want to disable pasting on an edit control
i have created a subclass control for CEdit and am using the following bit of code to disable pasting
which works in the way it stops the user being able to paste into the edit control
but it is disabling the v character as well so they are unable to type that in
Can anyone advise on a solution, so that it disables paste but the user can still use the v char
thanks
Simon
BOOL CCPEditControl::PreTranslateMessage(MSG* pMsg)
{
switch( pMsg->message )
{
case WM_KEYDOWN:
{
switch( pMsg->wParam )
{
case 0x56:
{
if( GetKeyState(VK_CONTROL) )
return true;
}
break;
}
}
break;
case WM_RBUTTONDOWN:
{
return true;
}
break;
}
return CEdit::PreTranslateMessage(pMsg);
}
|
|
|
|
|
si_69 wrote: Can anyone advise on a solution
No, and if there was one you certainly would not find it in the documentation[^]
led mike
|
|
|
|