|
Thanks to all of you. That worked.
|
|
|
|
|
some times MFC drives me so nuts that i use SDK procs.
CPoint cpPoint;
GetCursorPos(&cpPoint);
|
|
|
|
|
I'm trying to set a waitable timer from a CTime object. So I'm doing converstion from CTime to SYSTEMTIME then to a FILETIME and finally to a LARGE_INTEGER structure so I can pass it to SetWaitableTimer.
This compiles and runs, however my timer fires immediately every time. It's completely ignoring the time to fire on. Am I making these converstions wrong or just completely flubbing the whole thing up? I'm lost, any help would be very appreciated!!
CTime m_tNextRun(Schedule.GetNextRunTime());
SYSTEMTIME m_st_DueTime;
m_tNextRun.GetAsSystemTime(m_st_DueTime);
FILETIME m_ft_DueTime;
::SystemTimeToFileTime(&m_st_DueTime, &m_ft_DueTime);
LARGE_INTEGER m_lg_DueTime;
m_lg_DueTime.LowPart = m_ft_DueTime.dwLowDateTime;
m_lg_DueTime.HighPart = m_ft_DueTime.dwHighDateTime;
if(!::SetWaitableTimer(handles[command_timer], &m_lg_DueTime,0, NULL, NULL, 0)) {
DEBUG_LOG("CSleeperThread::run(): set waitable timer failed.");
}
::WaitForMultipleObjects(2, handles, FALSE, INFINITE);
Mike Ellertson
|
|
|
|
|
I don't see anything wrong with it. I assume you've already called CreateWaitableTimer ?
What's the return value of WaitForMultipleObjects ?
|
|
|
|
|
The return value of WaitForMultipleObjects is the index of the timer(which is what it should be).
If you look at SetWaitableTimer on MSDN the second parameter specifies the alarm date for the timer. Only thing, it's a LONG_INTEGER structure that your supposed to set using the FILETIME format.
I'm pretty sure I'm setting up this format wrong. Does anyone have a good conversion routine from a CTime object to a LONG_INTEGER used by SetWaitableTimer ? Or have any advice on setting this FILETIME format?
|
|
|
|
|
Hello,
About your article with the CSleeperThread's class and the functions :
static VOID CALLBACK TimerProc_Wrapper
VOID CALLBACK TimerProc
void ThreadMain();
void WakeUp();
How do you use those functions in the main in order to suspend the thread for 10s for example?
Thanks
Clément, french student
|
|
|
|
|
Hello,
I'm trying to *Send* a message to a Dialog Bar window early on in the initialization of an app and I believe I'm crashing because the Dialog Bar has not been created yet. How can I test to ensure it's been created and can accept & process such messages? I try to get a safe Handle (or call GetActiveWindow()), but that's valid all the time. If I change the SendMessage to a PostMessage, everything works, but I do need a SendMessage for some execution timing later in the app. Any suggestions/help?
thanks! JennyP
<code>
........
CDiagGlobalSched *gl_sched = &(((CMainFrame *)AfxGetApp()->m_pMainWnd)->m_SchedDlgBar1);
if (ForceUpdate) {
if (gl_sched->GetActiveWindow() != NULL) {
gl_sched->SendMessage(WM_COMMAND, ID_UPDATE_SCHED_BAR);
}
return TRUE;
}
</code>
|
|
|
|
|
say i have a struct like this:
<br />
<br />
typedef struct {<br />
char* text1;<br />
char* text2;<br />
...<br />
char* text25;<br />
}MYS,*PMYS;<br />
how can i access the struct like this?
<br />
PMYS pS=SomehowGetPtrToStruct();<br />
for (int i=0; i < MYS_TEXTCOUNT; i++)<br />
{<br />
char* text=pS[i];<br />
dosomething(text);<br />
}<br />
i dont want to get the items like this:
char* text=pS->text2;<br />
i also tried to do stuff like: char* text=pS+(sizeof(char*)*i); but i cant get it to work
|
|
|
|
|
If you want to use the array syntax, use an array (or a std::vector ). You could overload the [] operator for your struct if you want to obfuscate your code.
|
|
|
|
|
i dont need to use the array syntax, i just need to access the members of the struct without using the names
|
|
|
|
|
|
Message Closed
modified 20-Feb-22 19:24pm.
|
|
|
|
|
[Anders] wrote:
yeah but I tought there was some fancy way of doing it with a ptr like this char* text=pS+(sizeof(char*)*i);
No, because all you're doing is adding sizeof(char) * i to the pointer value of pS, which would be a really messed up way of accessing an array of your MYS struct. If you really want to do stuff like that, you have to learn exactly what + does in the context of a pointer.
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
if you really want to be nasty, you have to recast the pS pointer as a char**.
char** p = reinterpret_cast<char**>(pS) Now p[0] points to text1, p[1] to text2, etc.
However, this may be totally nonportable. If this is to work, you have to be sure that text1 is aligned with the beginning of the struct. Also, if sizeof(char*) is not the same size as the member alignment "distance", you will run into trouble.
May I suggest a totally different structure? How about using std::vector<std::string> or are you not in control of the layout of this structure and associated functions? Messing with raw pointers like that is highly error prone and will most likely give rise to late debugging session...
--
Seraphim Shock. Gold for your ears.
|
|
|
|
|
i think i have gotten it to work now, thanx (and yes i needed something nasty)
|
|
|
|
|
Overload the [] operator?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
[Anders] wrote:
i dont want to get the items like this:char* text=pS->text2;
There's bound to be a reason why you don't want to use this syntax. Any other way would be hard to read and maintain, and probably wouldn't be portable.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
hello, I'm looking for math libs for calculations with very big integer numbers(more than 64 bits) and high-precision floating-points(let's say numbers with 1,000 or more digits after the comma).
some links would be nice....
thx
Don't try it, just do it!
|
|
|
|
|
Hello,
I was writing a little application and I wanted to save some informations in a CSV format file. I expected to use ODBC to interface my file. I wrote some INSERT and SELECT statements and it worked fine. But when I wanted to use the UPDATE, I got an error message saying that "my command had a bad format" ... They could have said "ODBC doesn't support UPDATE or DELETE" !!!!
Because, after having searched a while what could be wrong in my format , I came on the web and found a note on microsoft site saying that ODBC doesn't support UPDATE or DELETE ...
Nevertheless, is there really no way to make it work?
Should I write some code that will delete the line from the file and use an INSERT after ?
Is there any way to retrieve the path I set in ODBC to access my file ?
Thanks in advance for help
DD
|
|
|
|
|
Qadddd wrote:
Because, after having searched a while what could be wrong in my format , I came on the web and found a note on microsoft site saying that ODBC doesn't support UPDATE or DELETE ...
You must've interpreted it wrong because I use Update() and Delete() all the time with ODBC. It works fine.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hello,
I was talking of this limitation only for ODBC used to access CSV files (and maybe others)!
But fortunately, it works fine with MySQL and SQL Server (for those I already used) and probably Oracle and a lot of more DB's, else it would have a very reduced interest to use ODBC.
Because if we do SELECT to extract our data and INSERT to add them, we are obliged to UPDATE and also DELETE them ...
Look at http://support.microsoft.com/?kbid=281759
Nevertheless, I have 2 remarks for Microsoft :
1) I find to easy to say "We don't support UPDATE nor DELETE for ODBC on CSV file"
2) I would have prefered a clear message as "This SQL statement is nor supported by this ODBC driver" instead of "Bad request format" ! The 1st msg indicates clearly that it works (not) as designed, while the 2nd msg can mean that you are stupid and don't how to write a SQL UPDATE statement ...
I am lucky, my files will become soon a table under MySQL and, as they are not so big, I have been writing some dirty code to rapidly do the UDDATE.
Regards,
DD
|
|
|
|
|
Qadddd wrote:
I am lucky, my files will become soon a table under MySQL and, as they are not so big, I have been writing some dirty code to rapidly do the UDDATE.
You're on your way then. I was going to suggest importing the file into an Access table, making the modifications, then exporting the data back to a CSV file. It would have taken a few more seconds, but would have solved the problem.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Anyone who's tried using MFC's CHtmlView in VC7 has problably noticed that implementing "OnEraseBkgnd" and simply returning "TRUE" doesn't fix the "flicker" problem, as it did in the past, - (and still does with "normal" CView derived views):
<br />
BOOL CMyHtmlView::OnEraseBkgnd(CDC* pDC)<br />
{<br />
return TRUE;<br />
}<br />
You may have also noticed that your derived CHtmlView class doesn't recieve WM_ERASEBKGND messages, which is why implementing OnEraseBkgnd doesn't work.
After a few hours of trying more complicated solutions, I seem to have found a simple fix for the problem. CHtmlView implements PreCreateWindow like this:
<br />
BOOL CHtmlView::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
cs.style |= WS_CLIPCHILDREN;<br />
return CFormView::PreCreateWindow(cs);<br />
}<br />
To fix the flicker problem, I provided my own implementation of PreCreateWindow, changing one line of code:
<br />
BOOL CMyHtmlView::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
cs.style &= ~WS_CLIPCHILDREN;<br />
return CFormView::PreCreateWindow(cs);<br />
}<br />
After making sure the WS_CLIPCHILDREN bit wasn't set, my derived CHtmlView object started receiving WM_ERASEBKGND messages. Now, returning "TRUE" from OnEraseBkgnd works as expected in the first place.
Hope this helps someone besides me....
|
|
|
|
|
--------------------------------------
ANALOG DEVICES
AD1812js SOUNDPORT 9617 BA1226.1-1.2
MODEL AA1812
MADE IN CHINA
FCC ID: LX9UN-1812
--------------------------------------
I very wanna get the above sound card drivers for Windows 2000.
Where to get it???
Please help me!
Thank you in advance!
Rap off for you,for me,for our human.
|
|
|
|
|
Usally drivers are found at the soundcard makers website,
I Touched Osama Bin Ladens Bushy Beard
|
|
|
|