|
Now I have a dual-monitor system. Is there any API function with which I can enable or disable the second monitor, but not by using control panel?
Thanks in advance!
Wang Huaizhi
|
|
|
|
|
Hi everyone,
My problem seems simple, but I don't know where to start. The problem is :
Having a process Id or Handle, how do you get the name of the process (whether the process is iexplore, netscape, or something else)?
Thanks for all your help
|
|
|
|
|
GetModuleFileName(processHandle,buffer,buffersize) (9x,NT)
or
GetModuleBaseName(processHandle,moduleHandle,buffer,buffersize) (NT4/5)
|
|
|
|
|
void CTestKeyDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
UpdateData(TRUE);
char lsChar;
lsChar = char(nChar);
if (lsChar == 83)
{
AfxMessageBox("This is SS!w");
}
else
{
MessageBox("This is not SS!");
}
UpdateData(FALSE);
}
Ok, this is the code i use to get a message box to tell me if the keyboard button was "S" or not.
It works fine, but only if the dialog is complety empty, no buttons nothing at all.
I cant get it to work, any one have a hint to what i have to do??
Thank you a million zillion times
|
|
|
|
|
in an empty dialog the dialog itself has focus as there are no controls ... appwizaed sets the focus to the first control after InitDialog() so KeyDn() at the dialog level gets the input ... when you have controls on the dialog they get the focus
the HookWindow() stuff should help or i'm sure there's a more 'correct' way out there
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Well i couldt find any info on the
HookWindow() in MSDN, any tips on how to use it.
The thing i need to do, is i need to get focus on the dialog, not the button's or text
is there a way i can get the message if the focus is on a Button??? Like it dosnt matter
if there is focus on the buttons or dialog??
Thank you again.
|
|
|
|
|
Try searching for HookWindow - I got eight matches, including two very useful articles, ( one of which is a Paul DeLascia one on palettes I refer to from time to time )
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Use PreTranslateMessage(). Like this:
in TestKeyDlg.h
class CTestKeyDlg : public CDialog {
....
bool PreTranslateMessage(MSG *pMsg);
....
};
in TestKeyDlg.cpp
bool CTestKeyDlg::PreTranslateMessage(MSG *pMsg) {
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 83)
MessageBox("That's S!");
return CDialog::PreTranslateMessage(pMsg);
}
With the best regards, Vitaly.
|
|
|
|
|
I get this error when i do the same as you do.
Error->(Sorry for the mess)
c:\documents and settings\administrator\my documents\c++\testkey\testkeydlg.h(16) : error C2555: 'CTestKeyDlg::PreTranslateMessage' : overriding virtual function differs from 'CDialog::PreTranslateMessage' only by return type or calling convention
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
TestKeyDlg.cpp
c:\documents and settings\administrator\my documents\c++\testkey\testkeydlg.h(16) : error C2555: 'CTestKeyDlg::PreTranslateMessage' : overriding virtual function differs from 'CDialog::PreTranslateMessage' only by return type or calling convention
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
C:\Documents and Settings\Administrator\My Documents\C++\TestKey\TestKeyDlg.cpp(128) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Generating Code...
Need a litle hint
|
|
|
|
|
I get this error when i do the same as you do.
Error->(Sorry for the mess)
c:\documents and settings\administrator\my documents\c++\testkey\testkeydlg.h(16) : error C2555: 'CTestKeyDlg::PreTranslateMessage' : overriding virtual function differs from 'CDialog::PreTranslateMessage' only by return type or calling convention
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
TestKeyDlg.cpp
c:\documents and settings\administrator\my documents\c++\testkey\testkeydlg.h(16) : error C2555: 'CTestKeyDlg::PreTranslateMessage' : overriding virtual function differs from 'CDialog::PreTranslateMessage' only by return type or calling convention
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
C:\Documents and Settings\Administrator\My Documents\C++\TestKey\TestKeyDlg.cpp(128) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Generating Code...
Need a litle hint
|
|
|
|
|
did u use class wizard to generate the correct handlers for the PreTranslateMessage() function?
otherwise you will in fact have different call sig / return value from the defined handler in the afxwin.h file
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Opss i was sleeping, i didnt get to much coffie in my cup
Thank you, and thank you all for helping me.
|
|
|
|
|
I would like to highlight any CWnd with a border like Spy++ does.
Now i just draw a rectangle but that overwrites any other window
that could be over the CWnd i would like to highlight. At it does
look very ugly afterwards.
But Spy++ manages to highlight windows without overwriting any
other windows that may cover. How does Spy++ do that?
|
|
|
|
|
SetCapture()
GetWindowFromPoint()
draw the line you want using a region to clip the drawing where other windows are on top
etc etc
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
IMHO Spy++ uses hooks. So it's dll is loaded in the that window's process. So it can implement it's own WM_NCPAINT handler and draw this lines as they drawn by that window itself.
GetWindowFromPoint() is only used to determine the window to do it with.
With the best regards, Vitaly.
|
|
|
|
|
And does anyone now how this can be done?
Any examples?
|
|
|
|
|
I have opened a comm port for non-overlapped I/O and set up a thread to watch for read events with WaitCommEvent. I have my main thread doing writes with WriteFile. Neither thread uses any windows.
The problem is that the WriteFile seems to be blocked by the WaitCommEvent in the background thread. This makes sense for file I/O but for serial comms the read and write operations should be completely independent and not block each other. I can overcome this by using overlapped I/O but it complicates things horribly.
Question: Does anyone know of a way to stop the comm Wait from blocking a non-overlapped serial write?
|
|
|
|
|
I'd like to mix two or more sound streams.
I don't want to use hardware mixer or DirectSound for two reasons.
i) I want to save the output to a file.
ii)I want absolut control of the timing.
(ex. mix 3463ms of source 1 with 3463ms of source 2)
Of course if you know a way to do both of the above by using DirectSound it whould be welcome.
What i tried is for each WORD of sound1 and sound2
to get differce, divide it by 2 add add it to the lowest value.
What i get was terrible.
A second though is to multiply the two WORDs and divide the result
with 65536 (or shift by 16bits). Although it sounds to be faster,
i thing it's gona be the same. am'i right?
And now comes the real hard stuff.
What i wanna do at the end is to mix 2 -or more- sounds, and
each sound having a weight,
like: sound1(60%) + sound2(31%) + sound3(9%)
any ideas?
Memory leaks is the price we pay
|
|
|
|
|
To mix several sounds with a specizific gain you have to scale every single sound by a factor and then simply add all sounds together.
this could be sa followed :
float gain1 = 0.6; // 60%
float gain2 = 0.31; // 31%
float gain3 = 0.09; // 9%
int mix; // your mixdown
mix = (int)(gain1*(float)sample1+gain2*(float)sample2 ....)
But BEWARE: If you add to much sounds you will surely get an overflow. So it is better to pre-scale all sounds with the same factor.
hope it helps
Greatings Mario ///
----------------------
www.klangwerker.de
mario@klangwerker.de
----------------------
|
|
|
|
|
Thanx a lot.
After making several changes i relised that values from streams in .wav files
are of type 'short' and not WORD (a.k.a. 'unsigned short').
In other words, values are between -32k to +32k and not 0 to 64k.
After reading them correctly, i turn them into positive by adding 32k,
mix them and turn the result into real by substructing 32k.
For mixing i use the way you just mention.
If i scale all gains,so that the sum of all gains is 1.00 ,
i don't have to worry about overflows.
I also heard about mixing using L2-node which is equal to:
sqrt(S1^2+S2^2+..+Sv^2)
But in this case you get overflow, and have to scale the
result with sqrt(2)=0.707
Also i don't know how to fit different gains in this formula (yet).
I will try the L2-node , and inform you about which one gives the
best result.
Memory leaks is the price we pay
|
|
|
|
|
I assume you are mixing 16 bit PCM files streams. If that's the case then you have two problems:
1. The sound is stored as 16 bit SIGNED walues not WORD (unsigned int) values. The amplitude is between –32768 and 32767. You reduce the amplitude by going towards 0.
2. The amplitude is not linear. If you halve the amplitude the sound will not be half as loud. It follows a logarithmic law and something to do with 20*Log(A) where A is the amplitude. (I don't know the theory real well...life is too short.) The library should be full of books which will help you.
Hope you get it working. I love playing around with audio but don't have the time.
------------------------------------------------------------------------------------
PS: I made time! The following is a very primitive C mixer I threw together. It works but probably has bugs. I used CoolEdit to capture raw PCM files. If you use WAV files then just strip the headers first to get to the PCM data. But you probably already know that. You can also use the API to get the data a lot neater.
#include "stdafx.h"
#include <stdio.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
FILE *f1;
FILE *f2;
FILE *f3;
size_t result1;
size_t result2;
short buffer1[ 0xFFFF ];
short buffer2[ 0xFFFF ];
short buffer3[ 0xFFFF ];
int i;
f1 = fopen( "sound1.pcm", "rb" );
f2 = fopen( "sound2.pcm", "rb" );
f3 = fopen( "sound3.pcm", "wb" );
do
{
result1 = fread( buffer1, sizeof( short ), 0xFFFF, f1 );
result2 = fread( buffer2, sizeof( short ), 0xFFFF, f2 );
for ( i = 0; i < 0xFFFF; i++ )
{
buffer3[ i ] = buffer1[ i ] / 2 + buffer2[ i ] / 2;
}
fwrite( buffer3, sizeof( short ), 0xFFFF, f3 );
} while ( !feof( f1 ));
fclose( f1 );
fclose( f2 );
fclose( f3 );
return 0;
}
|
|
|
|
|
I already found out that its 16 signed but i
didn't know that i have to use log for reducing the volume.
Acually i never come to that point of handling volume and
never thought about it. I assume this have to do with mixing to.
For ex. (Sound1*0.33+Sound2*0.66) will give me Sound2 and half the
volume of Sound1 ?
What i am up to is a mixer where you could create filters using JScript.
Something like:
function OnGetStereoPaningAt(TimePosition)
{
// sound allways on the middle
return 0.5;
}
function OnGetStereoPaningAt(TimePosition)
{
// from left to right every 1 sec
return ( (TimePosition%44100)/44100 );
}
function OnGetWaveAt(TimePosition)
{
// return layer5 with 3sec echo
value w1=Document.layer5.Wave.GetValueAt(TimePosition);
value w2=Document.layer5.Wave.GetValueAt(TimePosition-44100*3);
return Mix(w1,w2,1,0.3) ;
}
Of course nothing of that is implemented right now.
|
|
|
|
|
I added the following line to my existing code which uses DirectSound,
stremaing to DirectSound buffer etc..
hres=m_pDsBuffer->QueryInterface(IID_IDirectSoundNotify,(LPVOID*)&lpDsNotify);
Now, I get the following error from linker:
error LNK2001: unresolved external symbol _IID_IDirectSoundNotify
P.S.
I think that the problem has something to do with comments in objbase.h (line 375)
any suggestions, ideas......
Thnx!
|
|
|
|
|
Hi Guys!
I got a project and I need making about 15 Buttons Bitmapped!
(CBitmapButton derived class)
The bitmapping done but one problem:
- I need the bitmaps to be transparented with any selected color, the color that is actually the background of the whole bitmap if you know what I mean? ie. the RGB(255,0,255) is the back of a bitmap.
- I tried the region (RGN) stuff but has a problem with loading the rest of the images! (3 state images), it just blits the 1st in the sequnce.
In advacnce, I Thank you!
|
|
|
|
|
I believe MaskBlt allows you to blt images using colour keys. It is not supported by Windows 95, so I'm not sure ( I wrote my own so I had W95 support ). I don't believe there is any way to get the colour keying you want unless you build it yourself.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|