|
thathvamsi wrote: Which is the best...WM_TIMER or the multimedia timers ...or whichone?
Which ever you like! which ever you found easy!
anyway Timer Work like this
SetTimer(...)
OnTimer()
{
call function based on time!
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Re
|
|
|
|
|
I'm not going to check the details of your code. Rather, I'll treat it as pseudo code.
First, be careful with OnTimer() and On_rx() logic, which could be conflicting. If you use timer, you should check whether your received the feedback inside OnTimer(), not On_rx(). If you must use On_rx(), you can check how much time elapsed since last On_send() call without using timer. OnTimer() and On_rx() complicate things unnecessarily.
Second, the blocks {} you used in the segment are incorrect:
thathvamsi wrote: On_rx(wparam,lparam)
{
//checks for packet received
//if no packet received from serial device, then
{
//check for timer
//while(timer has elapsed)
OnTimer()
{
//resend the packet to MPU
post_message(WM_RESEND,null)
}
}
}
Best,
Jun
|
|
|
|
|
In single thread
LRESULT WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (uMsg)<br />
{<br />
case WM_SHOWWINDOW:<br />
SendMessage(hWnd, WM_ENABLE, FALSE, 0);<br />
break;<br />
}<br />
<br />
.......<br />
}
SPY++ watch message:
WM_SHOWWINDOW...
WM_ENABLE...
WM_ENABLE...(RETURN)
WM_SHOWWINDOW...(RETURN)
message WM_SHOWWINDOW not handled, but the window procedure can handle WM_ENABLE, why?
Thanks.
|
|
|
|
|
From your Spy++ trace, it looks like WM_SHOWWINDOW is sent to your window.
Deus caritas est
|
|
|
|
|
That's correct.
From MSDN:
The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.
I think you can use PostMessage if you want this scenario:
WM_SHOWWINDOW
WM_SHOWWINWOW (RETURN)
WM_ENABLE
WM_ENABLE (RETURN)
Not sure why it would make a difference, the window will be disabled. You can also use the API function EnableWindow(hWnd, FALSE) to disable the window.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I want to write a minigame like "pacman",I want to read some code about this,can somebody help me?thanks a lot.;P
|
|
|
|
|
boilerroom wrote:
I want to write a minigame like "pacman",I want to read some code about this,can somebody help me?thanks a lot
Where are you getting problem!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
ThatsAlok wrote: Where are you getting problem
Sounds like somewhere between firing up his IDE and typing void main() { }
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall.
Awasu 2.2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
Taka Muraoka wrote: Sounds like somewhere between firing up his IDE and typing void main() { }
Might be WinMain or CWinApp class Object as it talking about windows .....
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Actually ,I just like typing int main().Maby using C++ in a GNU way is better.You konw,It seems that you are a great joker.And thanks
|
|
|
|
|
somebody who knows how to explain this pseudocode more deppr??
typedef int semaphore;
semaphore mutex = 1; /*controls access to 'rc'*/
semaphore db = 1; /*controls access to the database*/
int rc = 0; /*# of processes reading or wanting to */
void reader(void)
{
while(TRUE){
down(&mutex); /*get exclusive access to 'rc'*/
rc = rc + 1; /*one reader more now*/
if (rc == 1) down(&db); /*if this is the first reader...*/
up(&upmutext); /*released exclusive access to 'rc'*/
read_data_base(); /*access the data*/
down(&mutex); /*get exclusive access to 'rc'*/
rc = rc-1; /*one reader fewer now*/
if (rc==0) up(&db); /*if this is the last reader...*/
use_data_read(); /*noncritical region*/
}
}
void writer(void)
{
while(TRUE){
think_up_data(); /*noncritical region*/
down(&db); /*get exclusive access*/
write_data_base(); /*update the data*/
up(&db); /release exclusive access*/
}
}
pls
|
|
|
|
|
where exactly are you facing problem!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
my problem is the explaination of the pseudocode for me is not enough. what i want is more further explaination that for my IQ i can understand. can you give me further explaination for this pseudocode.?
|
|
|
|
|
Dear All,
I have a compound file (IStorage) structure. This file has a sub storage that will contain MSWord,Excel files. My question is how to edit/open the MSWord files directly from the compound file. I tried to use Document IPersistStorage interface.
But I don't know how to pass/add it to Documents ( Collection ).
So It seems that the document was loaded but never showed up.
Does anybody have done this before ?
Thank's
|
|
|
|
|
hi all . could any one help me fix this compilation error. I am using visual studio 6.Thanks
error :
-------------------Configuration: FindUser - Win32 Debug--------------------<br />
Compiling...<br />
FindUser.cpp<br />
FindUserDlg.cpp<br />
C:\visualC\FindUser\FindUserDlg.cpp(15) : error C2653: 'FindUserDlg' : is not a class or namespace name<br />
Generating Code...<br />
Error executing cl.exe.<br />
<br />
FindUser.exe - 1 error(s), 0 warning(s)
pointing at :
int FindUserDlg::GetPosByNick(CString szNick) {
in FindUserDlg.cpp : implementation file
error pic:
[img]http://i5.photobucket.com/albums/y180/method007/error3.jpg[/img]
finduserdlg.h content
<br />
<br />
#if !defined(AFX_FINDUSERDLG_H__8EF5BE4C_79B2_4F61_B376_E2A019C98B9C__INCLUDED_)<br />
#define AFX_FINDUSERDLG_H__8EF5BE4C_79B2_4F61_B376_E2A019C98B9C__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
<br />
<br />
<br />
<br />
class CFindUserDlg : public CDialog<br />
{<br />
public:<br />
CFindUserDlg(CWnd* pParent = NULL);
<br />
enum { IDD = IDD_FINDUSER_DIALOG };<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
<br />
protected:<br />
HICON m_hIcon;<br />
<br />
virtual BOOL OnInitDialog();<br />
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);<br />
afx_msg void OnPaint();<br />
afx_msg HCURSOR OnQueryDragIcon();<br />
afx_msg void OnButton1();<br />
DECLARE_MESSAGE_MAP()<br />
<br />
public: <br />
int GetPosByNick(CString szNick); ======== placed it here<br />
<br />
};<br />
<br />
<br />
#endif // !defined(AFX_FINDUSERDLG_H__8EF5BE4C_79B2_4F61_B376_E2A019C98B9C__INCLUDED_)
-- modified at 16:31 Monday 10th July, 2006
|
|
|
|
|
You should use the DECLARE_MESSAGE_MAP() macro at the end of your class declaration; no more declaration/defintion after it.
Best,
Jun
|
|
|
|
|
I may be wrong, but shouldn't the implementation be :
<br />
int CFindUserDlg::GetPosByNick(CString szNick)<br />
{<br />
..<br />
} ?,
Not
int FindUserDlg::GetPosByNick(CString szNick)..
As shown in your pic.
I Dream of Absolute Zero
|
|
|
|
|
I realise this is a very advanced question!
I have a server application which I'm trying to add performance counters to, to allow the server's performance to be monitored using standard tools, such as the System Monitor ActiveX control (most users will know this as part of the Performance management console in Administrative Tools). There's a reasonable amount of documentation on actually creating your performance counters, and I'm using a chunk of code that came with my copy of 'Programming Server-Side Applications for Windows' by Jeff Richter and Jason Clark. I've already got a number of simple counters (those using PERF_COUNTER_COUNTER and PERF_COUNTER_RAWCOUNT) running.
My problem is that I've got a piece of data I want to expose and no idea how to define this counter. I'd like to be able to show the average percentage utilisation of a set of worker objects, defined as the average amount of time they were used in the sample period. The value shown should be ((current sample - last sample) / (number of objects)) / (current sample time - last sample time). Doing this allows me to simply add the duration of an operation to the counter. It doesn't look like this is possible, though, certainly with the standard counter types.
The actual server is written in VB6 so I'd like to avoid 64-bit counters and timers if at all possible! I'm writing the performance counter values using a C++ DLL which the VB6 code calls into.
I can divide the time elapsed by the number of objects myself, but this obviously loses accuracy, since it's an integer division.
Any ideas greatly appreciated.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Have you tried breaking the calculation up into seperate lines of code and using casts to correct the data types between each operation.
Darka [Xanya]
|
|
|
|
|
Well, in case anyone else finds this:
My solution is to use a counter of type PERF_100NSEC_TIMER, which is the type used by, for example, the Processor\% Idle Time counter. I'm still supplying the time in milliseconds but have extended my DLL to multiply up the value I pass in by 10000, to convert from 1ms to 100ns intervals. I'm dividing the value I pass by the number of objects, which leads to a degree of inaccuracy for objects used very infrequently but with a long execution time (showing 300% at one point using a 1s sample period) but since I'm more interested in the long-term average, this is acceptable.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Wat do you mean by its not working you can put a break point and see through which control path the flow is going .
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
thanks for your help it is now working.
how can i move items up and dowm in the list.
i am a beginner
|
|
|
|
|
Hello
I have designed a program that takes in a list of structs of type data (shown below). The program works fine. But I need a way of sorting the list by decreasing length of string Sequence. In other words, I need to determine the length of each Sequence and position each data so that the longest strings appear first.
So I am not comparing strings themselves, but lengths of strings. I know there is a sort function that is part of the <list> class, but I am not sure if I can use it in this situation.
Thanks in advance for anyone who can come to a solution.
HRW.
#include <string>
#include <list>
#include <iostream>
#include <fstream>
using namespace std;
struct data
{
string Length;
string Sequence;
string N_Terminal;
string C_Terminal;
};
list<data> g_DataList;
list<data>::iterator dataListIter;
-- modified at 11:29 Monday 10th July, 2006
|
|
|
|
|
Isn't the third parameter of sort() a (pointer to a) comparison routine?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Assuming that the length of Sequence is stored in Length, you can provide your own comparison function, which compares Length data between any two list items.
Best,
Jun
|
|
|
|