|
Thanks for the Reply.
But without a messagebox, the code excecutes properly. When messageBox is inserted it is leading to infinite loop.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timermessages/wm_timer.asp
In the above link, they have mentioned a statement like below.
"The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue. "
So instead of Timers , can i use threads and loop the function?
I mean replacing the Timers with Threads.
Thanks.
Chetan.
Helping others satisfies you...
|
|
|
|
|
chetan210183 wrote: "The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue. "
Yeah.
chetan210183 wrote: So instead of Timers , can i use threads and loop the function?
I mean replacing the Timers with Threads.
Why not!
Nibu thomas
Software Developer
|
|
|
|
|
Thanks a lot.
Can u please suggest links where i can get sample programs on Threads replacing the Timers.
Please......
Chetan.
Helping others satisfies you...
|
|
|
|
|
chetan210183 wrote: Can u please suggest links where i can get sample programs on Threads replacing the Timers.
Please......
I don't know if this is what you are searching for. Here[^] is it. Well it has got some topics on which multithreading depends. Will make a good reading for you.
Nibu thomas
Software Developer
|
|
|
|
|
You wrote:
void CMyDlg::OnClickStart()
{
fp = fopen(file_name,"a");
if (NULL == fp)
{
MessageBox ("Error Writing File",NULL, MB_OK|MB_ICONSTOP);
KillTimer(m_nTimer);
}
m_nTimer = SetTimer(1, 100, NULL);
fprintf(fp,"%d\n",status);
}
for killing timer use
KillTimer(1);
i.e what ID you provided to set the timer
The Timer returns the timer id when hwnd parameter of the settimer is NULL
hope this is enough for you
Knock out "T" from CAN'T
You 'CAN' if you think you 'CAN'
|
|
|
|
|
A_Laxman wrote: for killing timer use
KillTimer(1);
i.e what ID you provided to set the timer
The Timer returns the timer id when hwnd parameter of the settimer is NULL
From MSDN:
Return value of SetTimer:
The timer identifier of the new timer if the function is successful. An application passes this value to the KillTimer member function to kill the timer. Nonzero if successful; otherwise 0.
Nibu thomas
Software Developer
|
|
|
|
|
You can mask the COM port, and wait for events happen in COM port and then only update the text box.
|
|
|
|
|
i want read and write email in lotus notes by VC
who can give me some advice?
thanks!
|
|
|
|
|
i use CreateToolhelp32Snapshot function to seach all the process id ,
but i can not use process id to look for the main frame hwnd!!
can anyone tell me how to find that
Thanks
hi
|
|
|
|
|
Use EnumWindows to enumerate all top level windows. For each window enumerated use the GetWindowThreadProcessId function to filter the windows to those belonging to the desired process.
Steve
|
|
|
|
|
There are a lot of hWnds in a top level window, such as Static, Button, EditBox etc. Using EnumWindow to look for hWnd wastes a lot of resources of system, and makes the system slowly.
Can anybody give me a good idea!! thanks.
hi
|
|
|
|
|
EnumWindows only enumerates top level windows. The procedure I outlined doesn't waste system resources - It's how it's done!
Steve
|
|
|
|
|
|
Here's an example that uses the technique:
------------------------------------------
// Win32App.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <assert.h>
#include <vector>
#include <algorithm>
#include <malloc.h>
typedef std::vector<HWND> HWNDS;
namespace
{
struct EnumInfo
{
DWORD dwProcessID;
HWNDS *pHWNDS;
};
BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
{
const EnumInfo *pInfo = reinterpret_cast<const EnumInfo *>(lParam);
DWORD dwProcessID;
GetWindowThreadProcessId(hWnd, &dwProcessID);
if ( dwProcessID == pInfo->dwProcessID )
{
pInfo->pHWNDS->push_back(hWnd);
}
return TRUE;
}
}
BOOL GetProcessTopLevelWindows( DWORD dwProcessId, HWNDS *pOut )
{
assert(pOut);
EnumInfo ei = {dwProcessId, pOut};
return EnumWindows(&EnumWindowsProc, reinterpret_cast<LPARAM>(&ei));
}
struct ShowWindowTitle
{
bool operator()(HWND hWnd) const
{
int Len = GetWindowTextLength(hWnd);
if ( Len>0 )
{
char *pText = reinterpret_cast<char*>(_alloca(Len+1));
GetWindowText(hWnd, pText, Len+1);
MessageBox(NULL, pText, "Window title", MB_OK);
return true;
}
return false;
}
};
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWNDS wins;
if ( GetProcessTopLevelWindows(2216, &wins) ) // PID HARDCODED!
{
std::for_each(wins.begin(), wins.end(), ShowWindowTitle());
}
return 0;
}
Steve
|
|
|
|
|
class AFX_EXT_CLASS ConDlg : public CDialog
{
// Construction
public:
ConDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(ConDlg)
enum { IDD = IDD_DIALOG1 };
CDTPicker m_DateP1;
CDTPicker m_DateP2;
CDTPicker m_TimeP1;
CDTPicker m_TimeP2;
CString m_TypePk;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ConDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
struct M_Cage my_cage;
CString m_String;
Confused:
why m_cage could be touch while another vaiables such as m_DateP1 and m_String could not?
Lee
-- modified at 23:58 Monday 3rd April, 2006
|
|
|
|
|
Because it is protected. The others are public.
|
|
|
|
|
you did not read his post ...
|
|
|
|
|
Hi,friends,When I debug a propram in VC6.0,the complier report the error:
'CJsqApp::delete' is ambiguous
CJsqApp is a mulinherence class.
Please help me,Thank you in advance.
|
|
|
|
|
there are multiple delete() in the class and compiler doesn't know which one should be used - u should defind one more delete() which matches parameters as u called.
A special image tool for Windows C++ programmers, don't miss it!
The world unique Software Label Maker is waiting for you and me ...
A nice hyper tool for optimizing your Microsoft html-help contents.
|
|
|
|
|
I export a class from a extention dll and define a instance in another project,but,I could not see it's memeber variable except a struct variable defined in dll,what cause this? also,when i define the class instance in .H,the complier takes error as "the instuction '****' memory'****',could not read",what's mean?
Lee
-- modified at 23:59 Monday 3rd April, 2006
|
|
|
|
|
Hi,
I am using the DSOFramer control in an MFC dialog to display an excel chart. I have figured out how to run it and start with an excel worksheet and chart that I can modify to look how I want. Now I need two more tabs added (one with a worksheet and one with a chart)...I am using the following and it gives me an error that the Add function failed.
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
_Workbook wb;
Worksheets wsSet;
_Worksheet ws;
LPDISPATCH lpDisp = m_FrameControl.GetActiveDocument();
wb.AttachDispatch(lpDisp);
wsSet = wb.GetWorksheets();
ws = wsSet.Add(covOptional,covOptional,covOptional,COleVariant("Excel.Sheet"));
Thanks in advance for your help!
Jen
|
|
|
|
|
I have a programming project for one of my classes, but I have no idea where to start. Any help would be TREMENDOUSLY appreciated!
Program description:
Design and implement a Visual C++ .NET program that creates a simple “spreadsheet”. Your spreadsheet will contain 5 rows by 5 columns of updateable cells. There will be a 6th row and column that will display the total of the respective row or column. When the program executes it will display the spreadsheet with zeros in all cells and all totals. The program will prompt the user to enter 1 to update the spreadsheet or 0 to quit. When the user enters 1 to update the spreadsheet the program should prompt the user to enter the row and column to update. The row will be an integer 1 thru 5 and the columns will be characters A/a thru E/e. (1a is the upper left cell) The program should continue to prompt for row and column until a valid input is received. Next the program will prompt the user for the new value to go into cell X (replace X with appropriate row/ column reference, see sample run). After the value is entered the program will reprint the updated sheet and once again prompt enter 1 to update 0 to quit.
Assumptions:
-Eight digits will be enough width for the cells (tab). Cell values will not exceed 9,999,999.
-The prompt for edit or quit will only be 1 or 0. No other values will be used.
-For your testing purposes, a sample data file (data.txt) will be posted to WebCT. You can open this file, copy the data, run your program and right click your mouse to paste it to your program window. Press enter and the program should process the data as shown in the sample run below.
-This project will be much easier if you use an array. Remember that the first index in an array is zero
|
|
|
|
|
|
My apologies, I should have been more specific. The project is to be done in win32.
|
|
|
|
|
A game to transform letters read from a file to a prime number. Do and enjoy it!
The goal of this is to construct a C++ program that will read all letters from a specified file and transform them to a prime number.
The tasks you have to perform are:
(A) Read letters in sequence from a specified file, which contains 1 sentence. Transform each letter to the corresponding ASCII value.
For example, if the file contains “What?” then
‘W’ corresponds to 87
‘h’ corresponds to 104
‘a’ corresponds to 97
‘t’ corresponds to 116
(B) Calculate and output r1=the sum of all obtained integers (e.g. r1=87+104+97+116=404)
(C) Calculate and output r2=the length of Syracuse sequence seeded by r1.
Let n be a positive integer and f(n) be the transformation that sends n to n/2 if n is even and sends n to 3n+1 if n is odd. Starting with a positive value u called the seed, the sequence of integers iteratively generated by f and u is called a Syracuse sequence.
For example, starting with the seed u = 1, the subsequent terms of the sequence are 4, 2, and 1. The length of the sequence (excluding the seed) is therefore 3.
For u = 4, the next terms are 2 and 1. The length is 2.
For u = 404, the next terms are 202, 101, 304, 152, 76, 38, 19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, and 1. The length is 27.
It is conjectured (this means that we do not have a proof of this fact, only strong evidences) that for any positive seed the sequence will always reach to 1. In fact, computations show that for any seed u less than or equal to 3*2^53, the corresponding sequence always reaches 1. The general case is unknown.
(D) Calculate and output r3=the largest prime factor of r2.
A prime factor of n is a factor of n which is a prime number. A prime number is any integer greater than 1 and only divisible by itself and 1 (e.g. 2, 3, 5, 7, 11, 13, 17 etc). For example, 3 is the largest prime factor of 27 and 7 is the largest prime factor of 49.
Here are some example
Example 1
Enter the name of the input file: in1.txt
963
49
7
Press CTR-C to Leave...
|
|
|
|
|