|
Can you give me some implementation example?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Sorry, no I cannot; I found the MSDN link to the area you need to investigate, but I have no personal experience of this. If you read through the documentation you will find lots of sample code.
|
|
|
|
|
Thanks
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Hi,
Think I have got my hair in a mess,
say I have a function that accepts a base class ptr,
and I want to call a function on a class type that derives from the base class type. Is it possible to just
do a dynamic / static cast on it?
something like
<br />
void func(base* ptr)<br />
{<br />
derived * derivedptr = dynamic_cast<derived*>(ptr);<br />
<br />
derivedptr->derivedfunction();<br />
}<br />
Thanks for any information.
modified on Thursday, November 26, 2009 8:30 AM
|
|
|
|
|
The best way to do something like that is to declare the function as virtual in the base class and let the child class override this method. That's the basic principle of polymorphism.
|
|
|
|
|
Like Cedric Moonen said, you should use virtual functions.
But if you want to do what you're doing, you have to check the return of dynamic_cast for NULL.
|
|
|
|
|
hi
i want to play two sound file same time and want to listen the sound of these file
on separtly on left and right speaker,means sound of one file should play on left
speaker and second file should play on right speaker
|
|
|
|
|
|
Thanks for giving reply
I have no idea to handle this problem.
I need sample code if is possiable.i think direct sound is the solution
but not having correct API.
|
|
|
|
|
You can download the Direct X SDK from Microsoft, as well as a lot of useful information about it from here.
It's fairly easy to use, and comes with plenty of sample code to get you started.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
|
If you want to do this programmatically, it's fairly straightforward as well.
The actual method will depend on which audio API you're using. e.g. in DirectSound there's a "SetPan" method which can pan a buffer between left and right. So just load and play the two sounds, and set one to fully left pan, and the other to fully right.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Hi,
I'm using a Rich Text Edit control that reads in from a file at run time.
I would like to include the file as a resource of the project without having to install the file to a location where the user can tamper with it.
Is it possible, and if so, how can I achieve this?
I must add that I am using Visual C++ .Net (version 2003)
TIA
Tony
|
|
|
|
|
Yes, it is possible, just add this to your .rc file:
IDR_MYOWNRESOURCE_ID MYOWNRESOURCE_TYPE DISCARDABLE "res\\MyFile.rtf"
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
It is possible, yes, but you have to code it, afaik by defaults there's no pre-maid way to do it.
You have to use FindResource, LoadResource, LockResource, CRichEditCtrl::StreamIn in to read the file up from memory.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
As a follow up to this I have successfully managed to load the file as a resource, which is brilliant so thanks for the help.
One problem I am experiencing though is that I want to extract different sections of the file dependant on conditions, and I'm finding that if the document is saved from Micorsoft Word 2003 the string doesnt seem to be able search the file content, but using Wordpad all is OK.
I have just typecast the LPVOID I receive from LockResource to a CString
<pre>
CString csMess = (LPCTSTR)lpResLock;
</pre>
As I say this is OK if the file is saved from WordPad.
Any Suggestions?
Tony
|
|
|
|
|
i create a edit control whose parent window is in another process, i hook the parent window callback functin, just like this:
SetWindowsHookEx(WM_CALLWNDPROC, MyCallbackFunc, hDllMOdule, idProcss)
but i can't receive WM_CTLCOLOREDIT in my callback function, why?
i'll cry, who can help me? thank you very much
|
|
|
|
|
Is your edit control read-only or disabled?
From MSDN:
Read-only or disabled edit controls do not send the WM_CTLCOLOREDIT message; instead, they send the WM_CTLCOLORSTATIC message.
Greetings
Covean
|
|
|
|
|
no, it can gain input
My code like this:
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
PCWPSTRUCT pWps = (PCWPSTRUCT)lParam;
if (pWps->hWnd == hookWnd)
{
switch (pWps->message)
{
case WM_CTLCOLOREDIT:
{
some operation! // never receive this message
}
break;
}
}
}
|
|
|
|
|
Do I understand you right? Somehow you got the hWnd of an external app, after that you created an
edit control from your app and attached it to the parent hWnd from the external app?
If so, then this might be the problem (from MSDN):
The WM_CTLCOLOREDIT message is never sent between threads, it is only sent within the same thread.
This is just an assumption and maybe someone else could approve or disprove this.
Greetings
Covean
|
|
|
|
|
yes, you are correct! i'll cry, how can i do, it can't communicate between process, but i need this character
|
|
|
|
|
Here is some code I used with a low-level key hook to attach my thread input to the ones of the other
process. I used it in combination with ToUnicodeEx to get the displayed char. But I don't think this will solve your problem but I would give it a try.
Attach:
DWORD dwThreadWindow = GetWindowThreadProcessId(pVirtualLLKeyBoard->GetMessageWnd(), NULL);
DWORD dwThreadForeWin = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
BOOL bAttach = FALSE;
BOOL bAttached = FALSE;
if(dwThreadWindow != dwThreadForeWin)
{
if(dwThreadForeWin != 0)
bAttach = TRUE;
}
if(bAttach)
bAttached = AttachThreadInput(dwThreadForeWin, dwThreadWindow, TRUE);
"pVirtualLLKeyBoard->GetMessageWnd()" is the window of my app.
Detach:
if((bAttach)&&(bAttached))
AttachThreadInput(dwThreadForeWin, dwThreadWindow, FALSE);
After you got the hWnd from the other process, I would try to attach your thread to the window owning thread of the external application. On exit just detach it.
Greetings
Covean
|
|
|
|
|
|
Does it really work?
Greetings
Covean
|
|
|
|