|
Lookup va_start, va_arg and va_end in MSDN
int average( int first, ... )
{
int count = 0, sum = 0, i = first;
va_list marker;
va_start( marker, first ); /* Initialize variable arguments. */
while( i != -1 )
{
sum += i;
count++;
i = va_arg( marker, int);
}
va_end( marker ); /* Reset variable arguments. */
return( sum ? (sum / count) : 0 );
}
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
hdaly wrote:
So, can I pass just the array, and work out the number of elements inside the function??
Not when using a plain array. Because you can't pass a whole array to a function, just a pointer to the first element, the way you have it now is the correct way. The alternative is to use an STL vector or other container that knows its size.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
Hi,
I need an idea to lock a MFC-Application after a specific time when no
user action happens.
The problem is:
The application has some internal messages like WM_TIMER, and some listctls get messages to display new text.
When the time is up the application has to lock itself and it appears a
login dialog.
|
|
|
|
|
Idefix wrote:
The problem is:
The application has some internal messages like WM_TIMER
Is this a problem?
You can have many timers. Each of them has an identifier.
I think that this should work:
void CMainFrame::OnStartTimer()
{
m_nTimer1 = SetTimer(1, 2000, 0);
m_nTimer2 = SetTimer(2, 2000, 0);
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
switch(nIDEvent)
{
case 1:
break;
case 2:
break;
}
CMDIFrameWnd::OnTimer(nIDEvent);
}
Let me know if it helped.
modified on Monday, November 29, 2010 6:12 AM
|
|
|
|
|
Yes of course, the app can have many timer but how can I recognise
when the user has made no actions for e.g. 5 min. ?
At first I thought to use the OnIdle function but the internal WM_TIMER message
annul the idle state.
Another Problem is that the app is a client programm and get a lot of IP packets form the server and displays the data in controls. This are not user actions!
|
|
|
|
|
You can use GetLastInputInfo on Win2k to give you the time of the last "input" event - and compare that to the current time and then lock the app if the time out has gone
If you wanna run on 9x I think your into hook land - look up WH_FOREGROUNDIDLE - you might find this http://www.microsoft.com/msj/0200/c/c0200.aspx and this http://msdn.microsoft.com/msdnmag/issues/0500/c/default.aspx useful which do what you want.
|
|
|
|
|
I'd simply poll keyboard and mouse inputs in the message queue.
~RaGE();
|
|
|
|
|
One way would be to get the screen saver timeout value at the start of your application. Then set this value to whatever idle time you are interested in. Once that idle time has been reached, Windows will broadcast a SC_SCREENSAVE message. When your application ends, restore the screen saver timeout value to what it was.
Another idea that comes to mind would be to call SetWindowsHookEx() . As far as which type of hook to use, I don't know. Several of them look like they might work, but ultimately it'd probably be only one of them.
Classier ways may exist, but having never done this, I'm not familiar with them.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Many thanks for your suggestions.
I realized the application lock to filter out
the messages WM_KEYDOWN, WM_SETCURSOR, WM_MOUSEMOVE ...
I use the WindowProc from CMainframe and PreTranslateMessage from the
Application to keep the user event in mind.
I set a timer to pull the last user event and divided the time of timer by 10.
When the timer the peeks the noted user event it puts them back. After 10 times without user events the applcations will be locked.
It goes well and is not so complicate.
I get another problem with messageboxes. When a messagebox appears there are no window messages In addition I have to handle a opened messagebox.
At the moment I'm thinking about this problem.
Thanks
|
|
|
|
|
I'm so stupid.
Why I haven't tried GetLastInputInfo at first? (don't answer me)
That works very simple and it is what I wanted.
Thanks
|
|
|
|
|
Hi,
I have at CListBox in a dialog box but I'm not able to capture mouse click (ex. LButtonUp() ) ?
Context-menu works fine on the mouse right click.
Can anybody help me ?
|
|
|
|
|
If the List box does not provide a way handle a message - WM_LBUTTONUP message in your case, you will have to use subclassing (write your own message procedure) for this control.
See the articles on subclassing here at CP, or at msdn.microsoft.com...
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Have MFC subclass it for you with a DDX_Control statment, if its based on a resource:
1. Derive a class from CListBox
2. Double click on the list box in the resource editor with CTRL held down
3. Select control
4. Select your new derived list box class
5. Give it a name
Then use class wizard to add a handler to your LB for WM_LBUTTONUP to your new LB
|
|
|
|
|
hi!
I have complete my app using mscomm32.ocx,then it runs ok on my machine (os:win2k) which installed vc studio 6.0.But it can't run on the other machine (os:win2k) without intalling vc studio 6.0.
especially I register this ocx in the other machine.
why?
thanks!
|
|
|
|
|
How can load bitmap into the dialog base......
|
|
|
|
|
Can any one tell me where can i get the latest SDK if i want to use this interface
IHTMLWindow4
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
I guess this must be in the platform sdk in webdevelopment section.
I Touched Osama Bin Ladens Bushy Beard
|
|
|
|
|
Hi. Is everybody know how resolve NetBIOS name for some IP ?
PS Don't tell me about gethostbyaddr() . Need resolve NetBIOS rather than DNS.
Thanks
---Ranger---
|
|
|
|
|
i tried gethostbyname and it first querries a DNS server, if failed it scans for netbios!
don't use slogans like this again please!
---Ranger--- wrote:
PS Don't tell me about gethostbyaddr() . Need resolve NetBIOS rather than DNS.
Don't try it, just do it!
|
|
|
|
|
1. gehostbyaddr() too slowly for LAN (resolving timeout is too big)
2. Name rsolved by gethostaddr can be both DNS or NetBIOS.
I need ONLY NetBIOS names
---Ranger---
|
|
|
|
|
Does someone knows how the buffers of an AVI file are written in the file ?
I already search the Microsoft and google sites and I just can't find, maybe for incompetence. If some one knows or knows were can I find this information I will be greatfull. Thanks
|
|
|
|
|
>Does someone knows how the buffers of an AVI file are written in the file ?
please make clear , what do u mean by buffers of an AVI file are written in a file
r u trying to read an AVI file , writing its data in some other file.
or if u mean how to write AVI file?
if the case is later the there is a library available Vfw32.lib.
using AVI function of this libray you can create ur own AVI file by writing
AUDIO/VIDEO data in it.
like
0 AVIFileInit // for initializing AVI library
1 AVIFileOpen // for creating AVI File
2 AVIStreamCreate / for creating Audio/ video stream
3 AVIStreamWrite //for writing audio video data
5 AVIFileClose // for closing ur file
4 AVIFileExit / un initializing the library
Abhishek Srivastava
Software Engineer (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
I have tryed this functions, but I had a problem that is, I am trying to add one audio stream and one or more video streams, when I join one audio with one video this vfw functions works fine, when I try to join one audio with two videos the videos became scramble, it interleaves the video frames
Can you help me with that ?
|
|
|
|
|
I need to display a long block of scrollable text in a dialog. I tried using a read-only CEdit but it doesn't seem to allow more than ~65000 characters. Is there a way to increase the amount of text a CEdit can display? Or is there a different, more appropriate solution?
|
|
|
|
|
A CRichEdit can handle almost any amount of text.
Just remember to call AfxInitRichEdit before trying to display the dialog.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|